@wcag-checkr/ci 1.0.0-rc.356 → 1.0.0-rc.357
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ErrorBoundary-CIvHp9mt.js → ErrorBoundary-DnusfUkN.js} +7 -7
- package/dist/assets/{copy-ai-fixer-prompt-CKzZ3eDP.js → copy-ai-fixer-prompt-DxPDhVVS.js} +2 -2
- package/dist/assets/{devtools-panel-D5vKbEZ0.js → devtools-panel-Bkm14O-E.js} +1 -1
- package/dist/assets/{parallel-tab-flow-BWy6rZQY.js → parallel-tab-flow-CGASYHfy.js} +1 -1
- package/dist/assets/{scheduled-audit-runner-WGkZQWGB.js → scheduled-audit-runner-DB_DvRPY.js} +93 -93
- package/dist/assets/{service-worker.ts-CGQ5RUha.js → service-worker.ts-N2GtmT2p.js} +2 -2
- package/dist/assets/{side-panel-deupnjOo.js → side-panel-CwHXNEWf.js} +3 -3
- package/dist/assets/{site-report-renderer-D2duZR-v.js → site-report-renderer-CtsQnMT1.js} +1 -1
- package/dist/devtools/panel.html +3 -3
- package/dist/manifest.json +2 -2
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/side-panel.html +4 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scheduled-audit-runner-
|
|
2
|
-
var an=Object.defineProperty;var nn=(t,s,a)=>s in t?an(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var gs=(t,s,a)=>nn(t,typeof s!="symbol"?s+"":s,a);import{R as Qe,i as he,r as m,j as e,M as Ge,C as Mt,A as Et}from"./styles-DsUDu0nn.js";import{e as Qt,o as rn,p as on,q as fs,t as Yt,u as me,v as ia,w as _e,S as Fe,g as Ye,b as ln,c as cn,x as Re,y as De,z as Jt,A as oa,B as dn,C as Xt,D as fe,E as un,F as pn,G as hn,H as mn,k as xn,I as gn,h as fn,i as Zt,J as bn,K as vn,N as yn,L as Pt,M as la,O as Gt,P as wn,Q as jn,f as Xe,R as gt,T as Nn,U as kn,V as bs,X as Sn,Y as An,Z as Cn,_ as In,$ as En,a0 as Rn,a1 as Tn,a2 as $n,a3 as Ln,a4 as Un,a5 as _n,a6 as Dn,a7 as On,a8 as Fn,a9 as ca,aa as Mn,ab as vs,ac as ys,ad as Rt,ae as Pn,af as ws,ag as Gn,ah as Vn,ai as Wn,m as Bn,n as Hn}from"./scheduled-audit-runner-WGkZQWGB.js";import{_ as Ae}from"./preload-helper-D7HrI6pR.js";import{o as be,a as X,f as Ne,s as H,c as da,h as ve,r as Te,j as ua,T as Kn}from"./crash-reporter-7_6X-wSd.js";import{g as pa,f as Nt,t as at,r as zn,B as Me,e as es,h as qn,o as Ue,i as ha,j as kt,k as Qn}from"./ai-usage-log-CrsaOPBE.js";import{g as Yn,a as ma}from"./diff-NSOR-wHP.js";import{s as Jn,t as Xn}from"./design-system-audit-DpxJrxnb.js";const js=t=>{let s;const a=new Set,n=(p,c)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=c??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(g=>g(s,h))}},r=()=>s,i={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,i);return i},Zn=t=>t?js(t):js,er=t=>t;function tr(t,s=er){const a=Qe.useSyncExternalStore(t.subscribe,Qe.useCallback(()=>s(t.getState()),[t,s]),Qe.useCallback(()=>s(t.getInitialState()),[t,s]));return Qe.useDebugValue(a),a}const Ns=t=>{const s=Zn(t),a=n=>tr(s,n);return Object.assign(a,s),a},sr=t=>t?Ns(t):Ns,b=sr(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",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,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),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}),Qt(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}})})),ft="sidePanel:lastAudit";function ar(){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((d,p)=>d+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")),rr({results:s.results,delta:s.delta,componentId:s.componentId}),nr(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",()=>{bt()})),t.push(be("LICENSE_CHANGED_EVENT",()=>{xa()})),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 Ae(async()=>{const{loadSiteCrawlPerUrlResults:i}=await import("./scheduled-audit-runner-WGkZQWGB.js").then(d=>d.aU);return{loadSiteCrawlPerUrlResults:i}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:r}=await Ae(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-WGkZQWGB.js").then(d=>d.aW);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 d=await r(i.url);l(i.url,d)}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 nr(t,s,a){var n,r;if(t.length!==0)try{const o=await pa();if(!o.enabled)return;const l=b.getState().tier;if(Yt(l)||!Ne(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],p=b.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const u=await X({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:p});if(typeof u.content!="string"||u.content.length<200)continue;const h=Nt(c,a??null);at(u.content,h),i&&await zn({url:i,exportedAt:new Date().toISOString(),format:c,filename:h}),d.push(h)}catch(u){console.warn(`[auto-export] format ${c} failed:`,u)}d.length>0&&he.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function rr(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[ft]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function ir(){const s=(await chrome.storage.local.get(ft))[ft];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function or(){await chrome.storage.local.remove(ft)}async function St(){b.getState().clearResults(),await or()}async function bt(){const t=await X({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function xa(t){const s=await X({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ga()}async function ga(){const{fetchMessages:t}=await Ae(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>br);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 lr(){async function t(){const s=await rn();if(!s||on(s)==="expired"){fs(null);return}fs(s.config)}await t(),chrome.storage.onChanged.addListener((s,a)=>{a!=="local"||!("rubricConfigCache"in s)||t()})}async function cr(){const s=(await X({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;b.getState().setUserMode(a)}function dr(){return chrome.runtime.connect({name:"audit-keepalive"})}let vt=null;async function ur(){if(vt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(vt=t.id)}catch{}}function ts(){if(vt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:vt}).catch(()=>{})}function je(t){ts(),b.getState().setSiteCrawlReport(null),Qt(null).catch(()=>{}),H(t)}function pr(t){ts(),b.getState().setSiteCrawlReport(null),Qt(null).catch(()=>{}),H(t)}const Vt="dismissedFindings";function At(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function Ze(t){return`reading-order::${t}`}function et(t){return`tab-order::${t}`}function ss(t){return`violation::${t}`}async function Ct(){try{const t=await chrome.storage.local.get(Vt),s=t==null?void 0:t[Vt];if(s&&typeof s=="object")return s}catch{}return{}}async function as(t){await chrome.storage.local.set({[Vt]:t})}async function ns(t){return(await Ct())[At(t)]??{}}async function rs(t,s,a,n){const r=await Ct(),o=At(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await as(r)}async function tt(t,s){if(s.length===0)return;const a=await Ct(),n=At(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 as(a)}async function is(t,s){const a=await Ct(),n=At(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await as(a))}const cd=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:rs,addDismissals:tt,dismissalKeyForReadingOrder:Ze,dismissalKeyForTabOrder:et,dismissalKeyForViolation:ss,getDismissalsForUrl:ns,removeDismissal:is},Symbol.toStringTag,{value:"Module"}));function hr({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[o,l]=m.useState(!0),[i,d]=m.useState(""),[p,c]=m.useState(!1),[u,h]=m.useState(null);async function g(f){var y;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const N=await X({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});N.success?(h({ok:!0,msg:`Sent (ref: ${N.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((y=N.error)==null?void 0:y.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=>d(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)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function ks({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 yt=da("messages-client"),mr="https://api.wcagcheckr.com",fa="wcagcheckr",xr=1e4;function gr(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ba(t,s){const a=await Yn();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":gr()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${mr}${t}`,{...s,headers:n,signal:AbortSignal.timeout(xr)})}async function fr(t){try{const s=await ba(`/v1/products/${fa}/messages`,{userMode:t??null});return s.ok?await s.json():(yt.warn("fetchMessages http",s.status),null)}catch(s){return yt.warn("fetchMessages failed",s),null}}async function Pe(t,s){try{const a=await ba(`/v1/products/${fa}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(yt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return yt.warn("ackMessage failed",a),!1}}const br=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Pe,fetchMessages:fr},Symbol.toStringTag,{value:"Module"})),vr=["http:","https:"];function yr(t){try{const s=new URL(t);return vr.includes(s.protocol)}catch{return!1}}function Ss(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),d=t.slice(o+2,l);yr(d)?s.push(e.jsx("a",{href:d,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 va({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],o=0;function l(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Ss(d)},`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((d,p)=>e.jsx("li",{children:Ss(d)},p))},`u-${o++}`)),n=[])}for(const d of s){const p=d.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 wr={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},jr={critical:"bg-rose-50 border-rose-200"};function ya(){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 d(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),Pe(g.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await Pe(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),Pe(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(Nr,{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(kr,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function Nr({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 kr({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:()=>{ga()},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 ${wr[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(va,{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 wa(){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 Pe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Pe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${jr.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(va,{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 Sr=[{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 ja(){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"}),H({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:Sr.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 Ar=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function Cr(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ir(){var p,c;const t=b(u=>u.view),s=b(u=>u.setView);b(u=>u.setUserMode);const a=b(u=>u.results),n=b(u=>u.status),[r,o]=m.useState(!1),l=((p=a[0])==null?void 0:p.pageUrl)??((c=a[0])==null?void 0:c.scope),i=Cr(l),d=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(ja,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ya,{}),e.jsx(ks,{onClick:()=>void H({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(ks,{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]})]})}),d&&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 St(),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(Er,{view:t,setView:s}),e.jsx(Ge,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(hr,{onClose:()=>o(!1)})})]})}function Er({view:t,setView:s}){const a=m.useRef([]),n=b(i=>i.results),r=Ar.filter(i=>!i.hideWhenIdle||n.length>0);function o(i){var c;const d=(i+r.length)%r.length,p=r[d];p&&(s(p.slug),(c=a.current[d])==null||c.focus())}function l(i,d){switch(i.key){case"ArrowRight":i.preventDefault(),o(d+1);break;case"ArrowLeft":i.preventDefault(),o(d-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,d)=>{const p=t===i.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":p,tabIndex:p?0:-1,onClick:()=>s(i.slug),onKeyDown:c=>l(c,d),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 Rr({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(Mt,{open:a,onClose:()=>n(!1)})]})}const Tr="https://wcagcheckr.com/upgrade";function $r(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(null),[d,p]=m.useState(Me),[c,u]=m.useState(Me[0].id),[h,g]=m.useState("none"),[f,y]=m.useState(null),N=b(D=>D.status),$=b(D=>D.tier),R=b(D=>D.results.length>0),I=N==="running";m.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"matrixPresets"}),X({type:"SETTINGS_GET",key:"activePresetId"})]).then(([D,V])=>{const z=Array.isArray(D.data)?D.data:null;p(z&&z.length>0?z:Me),typeof V.data=="string"&&u(V.data)})},[]);function k(D){const V=d.find(z=>z.id===D);V&&(u(D),H({type:"SETTINGS_SET",key:"activePresetId",value:D}),H({type:"SETTINGS_SET",key:"stateMatrix",value:V.matrix}))}const S=Ne($,"storybookAutoIterate");m.useEffect(()=>{const D=be("ELEMENT_PICKED_EVENT",(z,T)=>{n(!1);const re=T.frameId;B(re),o({selector:z.selector,frameId:re,speech:z.speech})}),V=be("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{D(),V()}},[]);async function x(){const D=await me();D&&(n(!0),await ve(D,{type:"PICKER_ACTIVATE_REQUEST",tabId:D}))}function C(){r&&(B(r.frameId),je({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function w(){if(!S){i("storybook:auto-iterate");return}B(),je({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function v(){B(),je({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function E(){B(),je({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function _(){B(),je({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),b.getState().startNewScan()}function M(){B(),je({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function q(){B(),je({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function O(){H({type:"CANCEL_AUDIT"})}async function B(D){b.getState().setPinned(null);const V=await me();if(V)try{await ve(V,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:V},D)}catch{}}async function L(D){y(null);const V=await me();if(!V){y("No audited tab; open a page first.");return}if(D==="none"){const T=await X({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:V});T.ok||y(T.error??"Failed to clear throttle."),g("none");return}const z=await X({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:V,profile:D});if(!z.ok){y(z.error??"Failed to apply throttle.");return}g(D)}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:D=>s(D.target.value),disabled:I||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)",S?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:D=>k(D.target.value),disabled:I||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(D=>e.jsx("option",{value:D.id,children:D.name},D.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:D=>void L(D.target.value),disabled:I||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(Ur,{picking:a,picked:r,isRunning:I,onPick:x,onRun:C,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:E,disabled:I,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:I?"Auditing…":"Scan page"}),e.jsx("button",{onClick:_,disabled:I||!R,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:R?"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:I?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:M,disabled:I,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:I?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:q,disabled:I,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:I?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:v,disabled:I,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:I?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:w,disabled:I,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:I?"Auditing…":"Audit all stories"}),I&&e.jsx("button",{onClick:O,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!I&&R&&e.jsx("button",{type:"button",onClick:()=>void St(),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&&!I&&e.jsx(_r,{selector:r.selector,onRepick:x,onClear:()=>o(null)})]}),e.jsx(Ge,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(Rr,{feature:l??"",upgradeUrl:Tr})})]})}function Lr({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 Ur({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(Lr,{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 _r({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 Dr={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Or={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Fr(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),d=b(f=>f.results),p=b(f=>f.tier),c=d.flatMap(f=>f.violations);if(!Ne(p,"visualizers"))return null;async function u(f){const y=await me();y&&(i(f),f==="off"?await ve(y,{type:"VISION_SIMULATOR_CLEAR",tabId:y}).catch(()=>{}):await ve(y,{type:"VISION_SIMULATOR_APPLY",tabId:y,mode:f}).catch(()=>{}))}async function h(f){const y=await me();if(y){if(t&&await ve(y,{type:Dr[t],tabId:y}).catch(()=>{}),t===f){s(null);return}await ve(y,{type:Or[f],tabId:y}).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 y=await Te(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:c});n(!0),o(`Previewing ${y.visualFixCount} visual fix${y.visualFixCount===1?"":"es"} + ${y.annotationCount} annotation${y.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(We,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>h("outline")}),e.jsx(We,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>h("tab-order")}),e.jsx(We,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>h("reading-order")}),e.jsx(We,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>h("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(We,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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 u(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 We({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Se({feature:t,label:s,children:a}){const n=b(r=>r.tier);return Ne(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 Mr(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 Pr(){const t=b(d=>d.status),s=b(d=>d.progress),a=b(d=>d.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":Mr(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(As,{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(As,{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 As({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 Cs(t){if(!t)return"";try{return new URL(t).host}catch{return t}}function Gr({onView:t,viewingRun:s,crawlOnly:a}){var d,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 · ${Cs(n.startUrl)} · ${n.pagesAudited} page${n.pagesAudited===1?"":"s"} · grade ${n.siteGrade}`;else if(!a&&r.length>0){const c=((d=r[0])==null?void 0:d.pageUrl)??((p=r[0])==null?void 0:p.scope),u=r.reduce((h,g)=>h+g.violations.length,0);i=`Last audit · ${Cs(c)} · ${u} finding${u===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 Vr(){const t=new Set;for(const s of Fe)for(const a of s.axeRules)t.add(a);return t}function Na(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 Wr(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 Br(t,s,a={}){const n=Vr(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=ia(o),i={critical:0,serious:0,moderate:0,minor:0};for(const c of l)i[c.impact]++;const d=new Set(l.map(c=>_e(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const u=_e(c.ruleId,c.selector);d.has(u)||(d.add(u),i.serious++)}return{total:i.critical+i.serious+i.moderate+i.minor,counts:i,representatives:l}}function Is(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(ln).map(cn).filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function os(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?Is(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return Ye(s).then(d=>{i||(a(s,d),r(Is(d,t)))}),()=>{i=!0}},[s,t,a]),n}const Hr=[{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 Kr(){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(zr,{results:t,status:s,setView:a}),e.jsx(qr,{setView:a})]})}function zr({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(y=>y.violations),r=ia(n),o=((g=t[0])==null?void 0:g.pageUrl)??((f=t[0])==null?void 0:f.scope)??"audited page",l=t.length,i=os(t),d=b(y=>y.acknowledgedKeys),p=b(y=>y.dismissedKeys),c=Na(n,i,d,p),u=3,h=c>0&&c<=u?r.slice(0,u):[];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(y=>{var R;const N=((R=y.target)==null?void 0:R.selector)??"(no selector)",$=N.length>50?N.slice(0,47)+"…":N;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:`${y.description??y.ruleId} — ${N}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${y.impact==="critical"?"bg-rose-200 text-rose-900":y.impact==="serious"?"bg-orange-200 text-orange-900":y.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:y.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:y.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:$})]})},`${y.ruleId}::${N}`)})})]})}function qr({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:Hr.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 nt="aiConfig";function ls(){const[t,s]=m.useState(!1);return m.useEffect(()=>{function a(r){s(!!(r&&r.enabled&&r.apiKey))}chrome.storage.local.get(nt).then(r=>a(r[nt])).catch(()=>s(!1));const n=(r,o)=>{var l;o!=="local"||!(nt in r)||a((l=r[nt])==null?void 0:l.newValue)};return chrome.storage.onChanged.addListener(n),()=>chrome.storage.onChanged.removeListener(n)},[]),t}const Qr={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Yr={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 Jr({violations:t,componentId:s,hideOverallHeader:a=!1}){var ee,U,Z,Q,ie,le,de,xe;const[n,r]=m.useState([]),[o,l]=m.useState({}),[i,d]=m.useState([]),[p,c]=m.useState([]),[u,h]=m.useState(new Set),[g,f]=m.useState(null),[y,N]=m.useState({}),[$,R]=m.useState(new Set),[I,k]=m.useState(null),S=b(G=>G.status),x=b(G=>G.progress),C=b(G=>G.freshThisSession),w=b(G=>G.results),v=(ee=w[0])==null?void 0:ee.startedAt,E=((U=w[0])==null?void 0:U.pageUrl)??((Z=w[0])==null?void 0:Z.scope)??null;m.useEffect(()=>{if(!s){r([]),l({});return}let G=!1;return chrome.storage.local.get("igtRuns").then(te=>{if(G)return;const ne=((te==null?void 0:te.igtRuns)??{})[s]??{};r(Object.values(ne))}),Promise.all([Re(s),De([s])]).then(([te,ge])=>{if(G)return;const ne=new Set(ge.map(J=>J.criterionId)),Y={},ye=[];for(const J of te){const ce=ne.has(J.criterionId)?"pass":J.verdict;J.criterionId==="2.4.3"?Y.focusOrder=ce:J.criterionId==="2.1.2"?Y.keyboardTrap=ce:J.criterionId==="2.4.7"?Y.focusVisible=ce:J.criterionId==="1.3.2"?Y.readingOrder=ce:J.criterionId==="1.4.11"&&(Y.nonTextContrast=ce),ye.push({criterionId:J.criterionId,ruleId:`ai-walkthrough-${J.criterionId}`,pageUrl:J.pageUrl,verdict:ce,reasoning:ne.has(J.criterionId)?`Human verified: ${J.reasoning}`:J.reasoning})}l(Y),d(ye)}),()=>{G=!0}},[s]),m.useEffect(()=>{if(!E){c([]);return}let G=!1;return Ye(E).then(te=>{G||c(te)}),()=>{G=!0}},[E,w]);const _=os(w);if(S==="running")return e.jsx(ni,{current:x==null?void 0:x.current,total:x==null?void 0:x.total});const M=Jt({violations:t,auditRan:w.length>0,manualRuns:n,workflows:fe,heuristicCounts:{tabOrder:((ie=(Q=w[0])==null?void 0:Q.tabOrderIssues)==null?void 0:ie.length)??0,readingOrder:((de=(le=w[0])==null?void 0:le.readingOrderIssues)==null?void 0:de.length)??0},interactiveAuditVerdicts:o,aiResolvedFails:_.map(G=>({ruleId:G.ruleId,impact:"serious",selector:G.selector}))}),q=b(G=>G.acknowledgedKeys),B=new Set(w.map(G=>G.pageUrl??G.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",L=w.length>0?oa(w,{runs:n,workflows:fe},"2.1","AA",q,p,i,B):void 0,D=w.length>0?dn(Xt({audits:w,igtRuns:n,workflows:fe,acknowledgedMatchKeys:q,incompleteResolutions:p,interactiveAuditResults:i,auditScope:B}),fe):void 0,V=M.overallLetter,T=(L?L.failingCriteria.length+L.inconclusiveCriteria.length+L.untestedCriteria.length:0)===0&&!!L;async function re(G){var ye;if(!E||!((ye=L==null?void 0:L.inconclusiveReasons)!=null&&ye[G]))return;const ge=L.inconclusiveReasons[G].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(ge.length===0)return;h(J=>new Set(J).add(G)),f(null);const ne=[];let Y=0;try{for(const ce of ge){const ke=await H({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ce.ruleOrStepId,pageUrl:ce.pageUrl??E,wcagCriterion:G,elements:ce.elements??[],targetLevel:"AA"});if(ke!=null&&ke.unavailableReason){f(ke.unavailableReason);break}ke!=null&&ke.resolutions&&(ne.push(...ke.resolutions),Y+=ke.totalCostUsd??0)}if(E){const ce=await Ye(E);c(ce)}const J={total:ne.length,pass:ne.filter(ce=>ce.verdict==="pass").length,fail:ne.filter(ce=>ce.verdict==="fail").length,uncertain:ne.filter(ce=>ce.verdict==="uncertain").length,costUsd:Y,resolutions:ne};N(ce=>({...ce,[G]:J}))}finally{h(J=>{const ce=new Set(J);return ce.delete(G),ce})}}function oe(G){R(te=>{const ge=new Set(te);return ge.has(G)?ge.delete(G):ge.add(G),ge})}const j=((xe=w[0])==null?void 0:xe.startedAt)??null,A=s&&j?`${s}::${j}`:null;m.useEffect(()=>{if(!A||!L||I===A||S!=="complete")return;const G=L.inconclusiveCriteria.filter(te=>{var ne;return(((ne=L.inconclusiveReasons)==null?void 0:ne[te])??[]).some(Y=>Y.source==="axe-incomplete"&&Y.elements&&Y.elements.length>0)});if(G.length===0){k(A);return}k(A),(async()=>{for(const te of G)try{await re(te)}catch{}})()},[A,L,S]);async function F(G){var ke,xs;if(!E)return;const te=((ke=L==null?void 0:L.inconclusiveReasons)==null?void 0:ke[G])??[],ge=((xs=L==null?void 0:L.failingReasons)==null?void 0:xs[G])??[],ne=[],Y=new Set;for(const ue of te){if(ue.source!=="axe-incomplete"||!ue.elements)continue;const Ce=ue.pageUrl??E;for(const Ie of ue.elements){const Ve=`${Ce}::${ue.ruleOrStepId}::${Ie.selector}`;Y.has(Ve)||(Y.add(Ve),ne.push({ruleId:ue.ruleOrStepId,pageUrl:Ce,selector:Ie.selector}))}}for(const ue of ge){if(ue.source!=="ai"||!ue.selector)continue;const Ce=ue.ruleOrStepId.startsWith("ai-resolved::")?ue.ruleOrStepId.slice(13):ue.ruleOrStepId,Ie=ue.pageUrl??E,Ve=`${Ie}::${Ce}::${ue.selector}`;Y.has(Ve)||(Y.add(Ve),ne.push({ruleId:Ce,pageUrl:Ie,selector:ue.selector}))}if(ne.length===0)return;const ye=new Date().toISOString(),J=[];for(const ue of ne){const Ce=p.find(Ie=>Ie.pageUrl===ue.pageUrl&&Ie.ruleId===ue.ruleId&&Ie.selector===ue.selector);Ce&&Ce.verdict==="pass"&&Ce.reasoning.startsWith("Marked as visually verified")||J.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(J.length===0)return;await un(J);const ce=await Ye(E);c(ce),N(ue=>({...ue,[G]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const W=(()=>{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,ge=L.untestedCriteria.length,ne=[];if(te>0){const ye=L.failingCriteria.slice(0,4).join(", ")+(te>4?`, +${te-4}`:"");ne.push(`${te} ${te===1?"criterion":"criteria"} failing (${ye})`)}if(G>0){const ye=L.inconclusiveCriteria.slice(0,4).join(", ")+(G>4?`, +${G-4}`:"");ne.push(`${G} inconclusive (${ye})`)}if(ge>0){const ye=L.untestedCriteria.slice(0,4).join(", ")+(ge>4?`, +${ge-4}`:"");ne.push(`${ge} untested (${ye})`)}const Y=te>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":ge>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:`${ne.join(" · ")}. ${Y}`}})();let K=0;for(const G of fe){const te=n.find(ne=>ne.workflowId===G.id);if(!te)continue;G.steps.every(ne=>{const Y=te.steps[ne.id];return(Y==null?void 0:Y.status)==="pass"||(Y==null?void 0:Y.status)==="fail"||(Y==null?void 0:Y.status)==="skip"||(Y==null?void 0:Y.status)==="not-applicable"})&&K++}const pe=new Set;for(const G of t)q.has(G.matchKey)||pe.add(`${G.ruleId}::${G.target.selector}`);for(const G of _)G.verdict==="fail"&&pe.add(`${G.ruleId}::${G.selector}`);const ae=pe.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!C&&v&&e.jsx(ri,{scannedAt:v}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Qr[V]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:V})}),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 ",M.subGrades.length," verification areas below. Untested areas count as F until verified."]}),W&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${W.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:[W.kind==="conformant"?"✓ ":"✗ ",W.text]}),e.jsx("p",{className:"mt-0.5",children:W.detail})]})]})]}),a&&W&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${W.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:[W.kind==="conformant"?"✓ ":"✗ ",W.text]}),e.jsx("p",{className:"mt-0.5",children:W.detail})]}),M.isLawsuitRisk&&e.jsx(ei,{areas:M.warningAreas}),e.jsx(ti,{grades:M.subGrades,uncategorized:Br(t,p,{excludeAckedMatchKeys:q})}),L&&e.jsx(Xr,{coverage:L,onResolveWithAi:re,onMarkVisuallyVerified:F,resolving:u,resolveError:g,lastResolveResult:y,expandedResultFor:$,onToggleResultDetail:oe,violations:t}),D&&e.jsx(Zr,{layers:D}),e.jsx(ai,{violationsRemaining:ae,manualCompleted:K,manualTotal:fe.length}),K>0||w.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:K})," 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:`${K/fe.length*100}%`}})})]}):null]})}function Xr({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:d}){const p=b(I=>I.setView),c=b(I=>I.setFindingsLens),u=b(I=>I.setPendingAreaExpand);function h(I){const k=pn(I,d);p("report"),k?(c("per-area"),u(k)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,y]=m.useState(g>0&&g<=3),N=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),$=t.canClaimConformance,R=[];return t.failingCriteria.length>0&&R.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&R.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&R.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${$?"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 ${$?"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 (",N,"%)"]}),$&&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)."]}),!$&&(()=>{const I=[];t.failingCriteria.length>0&&I.push("failing"),t.inconclusiveCriteria.length>0&&I.push("inconclusive"),t.untestedCriteria.length>0&&I.push("untested");const k=I.length===0?"unresolved":I.length===1?I[0]:I.length===2?`${I[0]} or ${I[1]}`:`${I.slice(0,-1).join(", ")}, or ${I[I.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",k,"."]})})(),!$&&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."]}),!$&&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.length>0&&e.jsx("button",{type:"button",onClick:()=>y(I=>!I),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!$&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[R.map(I=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${I.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[I.kind==="untested"?"Untested":I.kind==="inconclusive"?"Inconclusive":"Failing"," (",I.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:I.ids.map(k=>{var M,q;const S=I.kind==="inconclusive"?(M=t.inconclusiveReasons)==null?void 0:M[k]:void 0,x=I.kind==="failing"?(q=t.failingReasons)==null?void 0:q[k]:void 0,C=S==null?void 0:S.some(O=>O.source==="axe-incomplete"&&O.elements&&O.elements.length>0),w=x==null?void 0:x.some(O=>O.source==="ai"),v=(n==null?void 0:n.has(k))??!1,E=o==null?void 0:o[k],_=(l==null?void 0:l.has(k))??!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(k),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 ${k}`,children:["· ",k]}),(I.kind==="inconclusive"&&C||I.kind==="failing"&&w)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[I.kind==="inconclusive"&&s&&k!=="1.4.3"&&k!=="1.4.6"&&e.jsx("button",{type:"button",disabled:v,onClick:()=>s(k),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:v?"Resolving…":E?"✨ Resolve again →":"✨ Resolve with AI →"}),I.kind==="inconclusive"&&(k==="1.4.3"||k==="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:v,onClick:()=>a(k),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:I.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&&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 ",E.total," ",E.total===1?"verdict":"verdicts",":",E.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",E.pass," pass"]}),E.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",E.fail," fail"]}),E.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",E.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",E.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(k),className:"ml-auto text-[10px] underline text-brand-700",children:_?"hide reasoning":"show reasoning"})]}),E.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",E.uncertain," ",E.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),E.pass===E.total&&E.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."]}),_&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:E.resolutions.map((O,B)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:O.verdict==="pass"?"text-emerald-700 font-semibold":O.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:O.verdict==="pass"?"✓":O.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:O.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:O.reasoning})]},B))})]}),x&&x.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:x.map((O,B)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[O.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),O.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," fail — "]}),O.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," fail — "]}),O.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:O.selector}),O.notes&&e.jsx("span",{className:"text-rose-700",children:O.notes})]},B))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((O,B)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[O.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," — "]}),O.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," skipped — "]}),O.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," — "]}),O.resolutionHint,O.elements&&O.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",O.elements.length===1?"element":`${O.elements.length} elements`,":"," ",O.elements.slice(0,3).map((L,D,V)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),D<V.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},D)),O.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",O.elements.length-3," more"]})]})]},B))}):I.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.)"})]},k)})})]},I.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 Es={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 Zr({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,d=l.failing.length,p=l.inconclusive.length,c=l.unevaluated.length,u=l.cleared,h=d>0||p>0,g=i>0&&!h&&c===0,f=g?"text-emerald-700":d>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":d>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:g?"✓":d>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:Es[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:i===0?"no coverage yet":`${u}/${i}`}),d>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:["· ",d," 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:Es[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 ei({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 ti({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 d=i.counts;return d.critical+d.serious+d.moderate+d.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 d=l(i),p="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=d?"cursor-pointer hover:bg-slate-100":"cursor-default",u=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Yr[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(si,{grade:i,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:d?e.jsx("button",{type:"button",onClick:()=>o(i.id),className:`${p} ${c}`,"aria-label":`Open ${i.label} violations`,children:u}):e.jsx("div",{className:p,children:u})},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 si({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const d=fe.find(p=>p.id===i);return(d==null?void 0:d.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?ka(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((d,p)=>e.jsxs("span",{children:[p>0&&" · ",e.jsxs("span",{className:d.cls,children:[d.n," ",d.label]})]},d.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 ai({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 d=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 ${d}`,"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 ni({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 ri({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 (",ka(s)," old). Re-scan to grade the current page state."]})]})}function ka(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 Sa(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Rs(t){if(!Sa())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-DB_DvRPY.js","assets/preload-helper-D7HrI6pR.js","assets/diff-NSOR-wHP.js","assets/crash-reporter-7_6X-wSd.js","assets/ai-usage-log-CrsaOPBE.js","assets/copy-ai-fixer-prompt-DxPDhVVS.js","assets/site-report-renderer-CtsQnMT1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var an=Object.defineProperty;var nn=(t,s,a)=>s in t?an(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var gs=(t,s,a)=>nn(t,typeof s!="symbol"?s+"":s,a);import{R as Qe,i as he,r as m,j as e,M as Ge,C as Mt,A as Et}from"./styles-DsUDu0nn.js";import{e as Qt,o as rn,p as on,q as fs,t as Yt,u as me,v as ia,w as _e,S as Fe,g as Ye,b as ln,c as cn,x as Re,y as De,z as Jt,A as oa,B as dn,C as Xt,D as fe,E as un,F as pn,G as hn,H as mn,k as xn,I as gn,h as fn,i as Zt,J as bn,K as vn,N as yn,L as Pt,M as la,O as Gt,P as wn,Q as jn,f as Xe,R as gt,T as Nn,U as kn,V as bs,X as Sn,Y as An,Z as Cn,_ as In,$ as En,a0 as Rn,a1 as Tn,a2 as $n,a3 as Ln,a4 as Un,a5 as _n,a6 as Dn,a7 as On,a8 as Fn,a9 as ca,aa as Mn,ab as vs,ac as ys,ad as Rt,ae as Pn,af as ws,ag as Gn,ah as Vn,ai as Wn,m as Bn,n as Hn}from"./scheduled-audit-runner-DB_DvRPY.js";import{_ as Ae}from"./preload-helper-D7HrI6pR.js";import{o as be,a as X,f as Ne,s as H,c as da,h as ve,r as Te,j as ua,T as Kn}from"./crash-reporter-7_6X-wSd.js";import{g as pa,f as Nt,t as at,r as zn,B as Me,e as es,h as qn,o as Ue,i as ha,j as kt,k as Qn}from"./ai-usage-log-CrsaOPBE.js";import{g as Yn,a as ma}from"./diff-NSOR-wHP.js";import{s as Jn,t as Xn}from"./design-system-audit-DpxJrxnb.js";const js=t=>{let s;const a=new Set,n=(p,c)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=c??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(g=>g(s,h))}},r=()=>s,i={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,i);return i},Zn=t=>t?js(t):js,er=t=>t;function tr(t,s=er){const a=Qe.useSyncExternalStore(t.subscribe,Qe.useCallback(()=>s(t.getState()),[t,s]),Qe.useCallback(()=>s(t.getInitialState()),[t,s]));return Qe.useDebugValue(a),a}const Ns=t=>{const s=Zn(t),a=n=>tr(s,n);return Object.assign(a,s),a},sr=t=>t?Ns(t):Ns,b=sr(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",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,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),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}),Qt(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}})})),ft="sidePanel:lastAudit";function ar(){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((d,p)=>d+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")),rr({results:s.results,delta:s.delta,componentId:s.componentId}),nr(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",()=>{bt()})),t.push(be("LICENSE_CHANGED_EVENT",()=>{xa()})),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 Ae(async()=>{const{loadSiteCrawlPerUrlResults:i}=await import("./scheduled-audit-runner-DB_DvRPY.js").then(d=>d.aU);return{loadSiteCrawlPerUrlResults:i}},__vite__mapDeps([0,1,2,3,4])),{getResolutionsForPage:r}=await Ae(async()=>{const{getResolutionsForPage:i}=await import("./scheduled-audit-runner-DB_DvRPY.js").then(d=>d.aW);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 d=await r(i.url);l(i.url,d)}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 nr(t,s,a){var n,r;if(t.length!==0)try{const o=await pa();if(!o.enabled)return;const l=b.getState().tier;if(Yt(l)||!Ne(l,"autoExportAuditReports"))return;const i=((n=t[0])==null?void 0:n.pageUrl)??((r=t[0])==null?void 0:r.scope)??"",d=[],p=b.getState().lastAuditWallClockMs??void 0;for(const c of o.formats)try{const u=await X({type:"EXPORT_REQUEST",format:c,results:t,delta:s??void 0,wallClockMs:p});if(typeof u.content!="string"||u.content.length<200)continue;const h=Nt(c,a??null);at(u.content,h),i&&await zn({url:i,exportedAt:new Date().toISOString(),format:c,filename:h}),d.push(h)}catch(u){console.warn(`[auto-export] format ${c} failed:`,u)}d.length>0&&he.polite(`Audit auto-exported ${d.length} file${d.length===1?"":"s"}.`)}catch(o){console.warn("[auto-export] failed:",o)}}async function rr(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[ft]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function ir(){const s=(await chrome.storage.local.get(ft))[ft];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function or(){await chrome.storage.local.remove(ft)}async function St(){b.getState().clearResults(),await or()}async function bt(){const t=await X({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function xa(t){const s=await X({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ga()}async function ga(){const{fetchMessages:t}=await Ae(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>br);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 lr(){async function t(){const s=await rn();if(!s||on(s)==="expired"){fs(null);return}fs(s.config)}await t(),chrome.storage.onChanged.addListener((s,a)=>{a!=="local"||!("rubricConfigCache"in s)||t()})}async function cr(){const s=(await X({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="power"||s==="dev"?s:null;b.getState().setUserMode(a)}function dr(){return chrome.runtime.connect({name:"audit-keepalive"})}let vt=null;async function ur(){if(vt===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(vt=t.id)}catch{}}function ts(){if(vt===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:vt}).catch(()=>{})}function je(t){ts(),b.getState().setSiteCrawlReport(null),Qt(null).catch(()=>{}),H(t)}function pr(t){ts(),b.getState().setSiteCrawlReport(null),Qt(null).catch(()=>{}),H(t)}const Vt="dismissedFindings";function At(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function Ze(t){return`reading-order::${t}`}function et(t){return`tab-order::${t}`}function ss(t){return`violation::${t}`}async function Ct(){try{const t=await chrome.storage.local.get(Vt),s=t==null?void 0:t[Vt];if(s&&typeof s=="object")return s}catch{}return{}}async function as(t){await chrome.storage.local.set({[Vt]:t})}async function ns(t){return(await Ct())[At(t)]??{}}async function rs(t,s,a,n){const r=await Ct(),o=At(t),l=r[o]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[o]=l,await as(r)}async function tt(t,s){if(s.length===0)return;const a=await Ct(),n=At(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 as(a)}async function is(t,s){const a=await Ct(),n=At(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await as(a))}const cd=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:rs,addDismissals:tt,dismissalKeyForReadingOrder:Ze,dismissalKeyForTabOrder:et,dismissalKeyForViolation:ss,getDismissalsForUrl:ns,removeDismissal:is},Symbol.toStringTag,{value:"Module"}));function hr({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[o,l]=m.useState(!0),[i,d]=m.useState(""),[p,c]=m.useState(!1),[u,h]=m.useState(null);async function g(f){var y;if(f.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const N=await X({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:o,replyEmail:i.trim()||void 0});N.success?(h({ok:!0,msg:`Sent (ref: ${N.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((y=N.error)==null?void 0:y.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=>d(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)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function ks({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 yt=da("messages-client"),mr="https://api.wcagcheckr.com",fa="wcagcheckr",xr=1e4;function gr(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ba(t,s){const a=await Yn();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":gr()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${mr}${t}`,{...s,headers:n,signal:AbortSignal.timeout(xr)})}async function fr(t){try{const s=await ba(`/v1/products/${fa}/messages`,{userMode:t??null});return s.ok?await s.json():(yt.warn("fetchMessages http",s.status),null)}catch(s){return yt.warn("fetchMessages failed",s),null}}async function Pe(t,s){try{const a=await ba(`/v1/products/${fa}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(yt.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return yt.warn("ackMessage failed",a),!1}}const br=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:Pe,fetchMessages:fr},Symbol.toStringTag,{value:"Module"})),vr=["http:","https:"];function yr(t){try{const s=new URL(t);return vr.includes(s.protocol)}catch{return!1}}function Ss(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),d=t.slice(o+2,l);yr(d)?s.push(e.jsx("a",{href:d,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 va({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],o=0;function l(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:Ss(d)},`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((d,p)=>e.jsx("li",{children:Ss(d)},p))},`u-${o++}`)),n=[])}for(const d of s){const p=d.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 wr={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},jr={critical:"bg-rose-50 border-rose-200"};function ya(){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 d(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),Pe(g.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await Pe(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),Pe(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(Nr,{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(kr,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function Nr({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 kr({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:()=>{ga()},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 ${wr[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(va,{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 wa(){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 Pe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),Pe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${jr.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(va,{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 Sr=[{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 ja(){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"}),H({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:Sr.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 Ar=[{slug:"matrix",label:"Dashboard"},{slug:"report",label:"Findings",hideWhenIdle:!0}];function Cr(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ir(){var p,c;const t=b(u=>u.view),s=b(u=>u.setView);b(u=>u.setUserMode);const a=b(u=>u.results),n=b(u=>u.status),[r,o]=m.useState(!1),l=((p=a[0])==null?void 0:p.pageUrl)??((c=a[0])==null?void 0:c.scope),i=Cr(l),d=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(ja,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ya,{}),e.jsx(ks,{onClick:()=>void H({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(ks,{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]})]})}),d&&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 St(),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(Er,{view:t,setView:s}),e.jsx(Ge,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(hr,{onClose:()=>o(!1)})})]})}function Er({view:t,setView:s}){const a=m.useRef([]),n=b(i=>i.results),r=Ar.filter(i=>!i.hideWhenIdle||n.length>0);function o(i){var c;const d=(i+r.length)%r.length,p=r[d];p&&(s(p.slug),(c=a.current[d])==null||c.focus())}function l(i,d){switch(i.key){case"ArrowRight":i.preventDefault(),o(d+1);break;case"ArrowLeft":i.preventDefault(),o(d-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,d)=>{const p=t===i.slug;return e.jsx("button",{ref:c=>{a.current[d]=c},role:"tab","aria-selected":p,tabIndex:p?0:-1,onClick:()=>s(i.slug),onKeyDown:c=>l(c,d),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 Rr({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(Mt,{open:a,onClose:()=>n(!1)})]})}const Tr="https://wcagcheckr.com/upgrade";function $r(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState(null),[d,p]=m.useState(Me),[c,u]=m.useState(Me[0].id),[h,g]=m.useState("none"),[f,y]=m.useState(null),N=b(D=>D.status),$=b(D=>D.tier),R=b(D=>D.results.length>0),I=N==="running";m.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"matrixPresets"}),X({type:"SETTINGS_GET",key:"activePresetId"})]).then(([D,V])=>{const z=Array.isArray(D.data)?D.data:null;p(z&&z.length>0?z:Me),typeof V.data=="string"&&u(V.data)})},[]);function k(D){const V=d.find(z=>z.id===D);V&&(u(D),H({type:"SETTINGS_SET",key:"activePresetId",value:D}),H({type:"SETTINGS_SET",key:"stateMatrix",value:V.matrix}))}const S=Ne($,"storybookAutoIterate");m.useEffect(()=>{const D=be("ELEMENT_PICKED_EVENT",(z,T)=>{n(!1);const re=T.frameId;B(re),o({selector:z.selector,frameId:re,speech:z.speech})}),V=be("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{D(),V()}},[]);async function x(){const D=await me();D&&(n(!0),await ve(D,{type:"PICKER_ACTIVATE_REQUEST",tabId:D}))}function C(){r&&(B(r.frameId),je({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function w(){if(!S){i("storybook:auto-iterate");return}B(),je({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function v(){B(),je({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function E(){B(),je({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function _(){B(),je({type:"START_AUDIT",mode:"full-page",verifyFixesOnly:!0}),b.getState().startNewScan()}function M(){B(),je({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function q(){B(),je({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function O(){H({type:"CANCEL_AUDIT"})}async function B(D){b.getState().setPinned(null);const V=await me();if(V)try{await ve(V,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:V},D)}catch{}}async function L(D){y(null);const V=await me();if(!V){y("No audited tab; open a page first.");return}if(D==="none"){const T=await X({type:"PERF_THROTTLE_CLEAR_REQUEST",tabId:V});T.ok||y(T.error??"Failed to clear throttle."),g("none");return}const z=await X({type:"PERF_THROTTLE_APPLY_REQUEST",tabId:V,profile:D});if(!z.ok){y(z.error??"Failed to apply throttle.");return}g(D)}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:D=>s(D.target.value),disabled:I||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)",S?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:D=>k(D.target.value),disabled:I||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(D=>e.jsx("option",{value:D.id,children:D.name},D.id))}),e.jsxs("select",{"aria-label":"Performance throttle",value:h,onChange:D=>void L(D.target.value),disabled:I||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(Ur,{picking:a,picked:r,isRunning:I,onPick:x,onRun:C,onClearPick:()=>o(null)}):t==="full-page"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:E,disabled:I,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:I?"Auditing…":"Scan page"}),e.jsx("button",{onClick:_,disabled:I||!R,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:R?"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:I?"Auditing…":"Verify fixes (skip passed)"})]}):t==="quick-scan"?e.jsx("button",{onClick:M,disabled:I,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:I?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:q,disabled:I,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:I?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:v,disabled:I,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:I?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:w,disabled:I,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:I?"Auditing…":"Audit all stories"}),I&&e.jsx("button",{onClick:O,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!I&&R&&e.jsx("button",{type:"button",onClick:()=>void St(),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&&!I&&e.jsx(_r,{selector:r.selector,onRepick:x,onClear:()=>o(null)})]}),e.jsx(Ge,{open:l!==null,onClose:()=>i(null),title:"Upgrade to continue",children:e.jsx(Rr,{feature:l??"",upgradeUrl:Tr})})]})}function Lr({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 Ur({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(Lr,{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 _r({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 Dr={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Or={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Fr(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,o]=m.useState(null),[l,i]=m.useState("off"),d=b(f=>f.results),p=b(f=>f.tier),c=d.flatMap(f=>f.violations);if(!Ne(p,"visualizers"))return null;async function u(f){const y=await me();y&&(i(f),f==="off"?await ve(y,{type:"VISION_SIMULATOR_CLEAR",tabId:y}).catch(()=>{}):await ve(y,{type:"VISION_SIMULATOR_APPLY",tabId:y,mode:f}).catch(()=>{}))}async function h(f){const y=await me();if(y){if(t&&await ve(y,{type:Dr[t],tabId:y}).catch(()=>{}),t===f){s(null);return}await ve(y,{type:Or[f],tabId:y}).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 y=await Te(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:c});n(!0),o(`Previewing ${y.visualFixCount} visual fix${y.visualFixCount===1?"":"es"} + ${y.annotationCount} annotation${y.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(We,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>h("outline")}),e.jsx(We,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>h("tab-order")}),e.jsx(We,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>h("reading-order")}),e.jsx(We,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>h("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(We,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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 u(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 We({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Se({feature:t,label:s,children:a}){const n=b(r=>r.tier);return Ne(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 Mr(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 Pr(){const t=b(d=>d.status),s=b(d=>d.progress),a=b(d=>d.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":Mr(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(As,{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(As,{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 As({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 Cs(t){if(!t)return"";try{return new URL(t).host}catch{return t}}function Gr({onView:t,viewingRun:s,crawlOnly:a}){var d,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 · ${Cs(n.startUrl)} · ${n.pagesAudited} page${n.pagesAudited===1?"":"s"} · grade ${n.siteGrade}`;else if(!a&&r.length>0){const c=((d=r[0])==null?void 0:d.pageUrl)??((p=r[0])==null?void 0:p.scope),u=r.reduce((h,g)=>h+g.violations.length,0);i=`Last audit · ${Cs(c)} · ${u} finding${u===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 Vr(){const t=new Set;for(const s of Fe)for(const a of s.axeRules)t.add(a);return t}function Na(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 Wr(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 Br(t,s,a={}){const n=Vr(),o=(a.excludeAckedMatchKeys?t.filter(c=>!a.excludeAckedMatchKeys.has(c.matchKey)):t).filter(c=>!n.has(c.ruleId)),l=ia(o),i={critical:0,serious:0,moderate:0,minor:0};for(const c of l)i[c.impact]++;const d=new Set(l.map(c=>_e(c.ruleId,c.target.selector)));for(const c of s){if(c.verdict!=="fail"||n.has(c.ruleId))continue;const u=_e(c.ruleId,c.selector);d.has(u)||(d.add(u),i.serious++)}return{total:i.critical+i.serious+i.moderate+i.minor,counts:i,representatives:l}}function Is(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(ln).map(cn).filter(r=>r.verdict==="fail"&&a.has(`${r.ruleId}::${r.selector}`))}function os(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?Is(i,t):[]});return m.useEffect(()=>{if(!s){r([]);return}let i=!1;return Ye(s).then(d=>{i||(a(s,d),r(Is(d,t)))}),()=>{i=!0}},[s,t,a]),n}const Hr=[{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 Kr(){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(zr,{results:t,status:s,setView:a}),e.jsx(qr,{setView:a})]})}function zr({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(y=>y.violations),r=ia(n),o=((g=t[0])==null?void 0:g.pageUrl)??((f=t[0])==null?void 0:f.scope)??"audited page",l=t.length,i=os(t),d=b(y=>y.acknowledgedKeys),p=b(y=>y.dismissedKeys),c=Na(n,i,d,p),u=3,h=c>0&&c<=u?r.slice(0,u):[];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(y=>{var R;const N=((R=y.target)==null?void 0:R.selector)??"(no selector)",$=N.length>50?N.slice(0,47)+"…":N;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:`${y.description??y.ruleId} — ${N}`,children:[e.jsx("span",{className:`shrink-0 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded ${y.impact==="critical"?"bg-rose-200 text-rose-900":y.impact==="serious"?"bg-orange-200 text-orange-900":y.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:y.impact}),e.jsx("span",{className:"text-[11px] font-mono text-slate-900 shrink-0",children:y.ruleId}),e.jsx("code",{className:"text-[10px] text-slate-500 truncate",children:$})]})},`${y.ruleId}::${N}`)})})]})}function qr({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:Hr.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 nt="aiConfig";function ls(){const[t,s]=m.useState(!1);return m.useEffect(()=>{function a(r){s(!!(r&&r.enabled&&r.apiKey))}chrome.storage.local.get(nt).then(r=>a(r[nt])).catch(()=>s(!1));const n=(r,o)=>{var l;o!=="local"||!(nt in r)||a((l=r[nt])==null?void 0:l.newValue)};return chrome.storage.onChanged.addListener(n),()=>chrome.storage.onChanged.removeListener(n)},[]),t}const Qr={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Yr={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 Jr({violations:t,componentId:s,hideOverallHeader:a=!1}){var ee,U,Z,Q,ie,le,de,xe;const[n,r]=m.useState([]),[o,l]=m.useState({}),[i,d]=m.useState([]),[p,c]=m.useState([]),[u,h]=m.useState(new Set),[g,f]=m.useState(null),[y,N]=m.useState({}),[$,R]=m.useState(new Set),[I,k]=m.useState(null),S=b(G=>G.status),x=b(G=>G.progress),C=b(G=>G.freshThisSession),w=b(G=>G.results),v=(ee=w[0])==null?void 0:ee.startedAt,E=((U=w[0])==null?void 0:U.pageUrl)??((Z=w[0])==null?void 0:Z.scope)??null;m.useEffect(()=>{if(!s){r([]),l({});return}let G=!1;return chrome.storage.local.get("igtRuns").then(te=>{if(G)return;const ne=((te==null?void 0:te.igtRuns)??{})[s]??{};r(Object.values(ne))}),Promise.all([Re(s),De([s])]).then(([te,ge])=>{if(G)return;const ne=new Set(ge.map(J=>J.criterionId)),Y={},ye=[];for(const J of te){const ce=ne.has(J.criterionId)?"pass":J.verdict;J.criterionId==="2.4.3"?Y.focusOrder=ce:J.criterionId==="2.1.2"?Y.keyboardTrap=ce:J.criterionId==="2.4.7"?Y.focusVisible=ce:J.criterionId==="1.3.2"?Y.readingOrder=ce:J.criterionId==="1.4.11"&&(Y.nonTextContrast=ce),ye.push({criterionId:J.criterionId,ruleId:`ai-walkthrough-${J.criterionId}`,pageUrl:J.pageUrl,verdict:ce,reasoning:ne.has(J.criterionId)?`Human verified: ${J.reasoning}`:J.reasoning})}l(Y),d(ye)}),()=>{G=!0}},[s]),m.useEffect(()=>{if(!E){c([]);return}let G=!1;return Ye(E).then(te=>{G||c(te)}),()=>{G=!0}},[E,w]);const _=os(w);if(S==="running")return e.jsx(ni,{current:x==null?void 0:x.current,total:x==null?void 0:x.total});const M=Jt({violations:t,auditRan:w.length>0,manualRuns:n,workflows:fe,heuristicCounts:{tabOrder:((ie=(Q=w[0])==null?void 0:Q.tabOrderIssues)==null?void 0:ie.length)??0,readingOrder:((de=(le=w[0])==null?void 0:le.readingOrderIssues)==null?void 0:de.length)??0},interactiveAuditVerdicts:o,aiResolvedFails:_.map(G=>({ruleId:G.ruleId,impact:"serious",selector:G.selector}))}),q=b(G=>G.acknowledgedKeys),B=new Set(w.map(G=>G.pageUrl??G.scope??"").filter(Boolean)).size>1?"site-crawl":"single-page",L=w.length>0?oa(w,{runs:n,workflows:fe},"2.1","AA",q,p,i,B):void 0,D=w.length>0?dn(Xt({audits:w,igtRuns:n,workflows:fe,acknowledgedMatchKeys:q,incompleteResolutions:p,interactiveAuditResults:i,auditScope:B}),fe):void 0,V=M.overallLetter,T=(L?L.failingCriteria.length+L.inconclusiveCriteria.length+L.untestedCriteria.length:0)===0&&!!L;async function re(G){var ye;if(!E||!((ye=L==null?void 0:L.inconclusiveReasons)!=null&&ye[G]))return;const ge=L.inconclusiveReasons[G].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(ge.length===0)return;h(J=>new Set(J).add(G)),f(null);const ne=[];let Y=0;try{for(const ce of ge){const ke=await H({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:ce.ruleOrStepId,pageUrl:ce.pageUrl??E,wcagCriterion:G,elements:ce.elements??[],targetLevel:"AA"});if(ke!=null&&ke.unavailableReason){f(ke.unavailableReason);break}ke!=null&&ke.resolutions&&(ne.push(...ke.resolutions),Y+=ke.totalCostUsd??0)}if(E){const ce=await Ye(E);c(ce)}const J={total:ne.length,pass:ne.filter(ce=>ce.verdict==="pass").length,fail:ne.filter(ce=>ce.verdict==="fail").length,uncertain:ne.filter(ce=>ce.verdict==="uncertain").length,costUsd:Y,resolutions:ne};N(ce=>({...ce,[G]:J}))}finally{h(J=>{const ce=new Set(J);return ce.delete(G),ce})}}function oe(G){R(te=>{const ge=new Set(te);return ge.has(G)?ge.delete(G):ge.add(G),ge})}const j=((xe=w[0])==null?void 0:xe.startedAt)??null,A=s&&j?`${s}::${j}`:null;m.useEffect(()=>{if(!A||!L||I===A||S!=="complete")return;const G=L.inconclusiveCriteria.filter(te=>{var ne;return(((ne=L.inconclusiveReasons)==null?void 0:ne[te])??[]).some(Y=>Y.source==="axe-incomplete"&&Y.elements&&Y.elements.length>0)});if(G.length===0){k(A);return}k(A),(async()=>{for(const te of G)try{await re(te)}catch{}})()},[A,L,S]);async function F(G){var ke,xs;if(!E)return;const te=((ke=L==null?void 0:L.inconclusiveReasons)==null?void 0:ke[G])??[],ge=((xs=L==null?void 0:L.failingReasons)==null?void 0:xs[G])??[],ne=[],Y=new Set;for(const ue of te){if(ue.source!=="axe-incomplete"||!ue.elements)continue;const Ce=ue.pageUrl??E;for(const Ie of ue.elements){const Ve=`${Ce}::${ue.ruleOrStepId}::${Ie.selector}`;Y.has(Ve)||(Y.add(Ve),ne.push({ruleId:ue.ruleOrStepId,pageUrl:Ce,selector:Ie.selector}))}}for(const ue of ge){if(ue.source!=="ai"||!ue.selector)continue;const Ce=ue.ruleOrStepId.startsWith("ai-resolved::")?ue.ruleOrStepId.slice(13):ue.ruleOrStepId,Ie=ue.pageUrl??E,Ve=`${Ie}::${Ce}::${ue.selector}`;Y.has(Ve)||(Y.add(Ve),ne.push({ruleId:Ce,pageUrl:Ie,selector:ue.selector}))}if(ne.length===0)return;const ye=new Date().toISOString(),J=[];for(const ue of ne){const Ce=p.find(Ie=>Ie.pageUrl===ue.pageUrl&&Ie.ruleId===ue.ruleId&&Ie.selector===ue.selector);Ce&&Ce.verdict==="pass"&&Ce.reasoning.startsWith("Marked as visually verified")||J.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(J.length===0)return;await un(J);const ce=await Ye(E);c(ce),N(ue=>({...ue,[G]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const W=(()=>{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,ge=L.untestedCriteria.length,ne=[];if(te>0){const ye=L.failingCriteria.slice(0,4).join(", ")+(te>4?`, +${te-4}`:"");ne.push(`${te} ${te===1?"criterion":"criteria"} failing (${ye})`)}if(G>0){const ye=L.inconclusiveCriteria.slice(0,4).join(", ")+(G>4?`, +${G-4}`:"");ne.push(`${G} inconclusive (${ye})`)}if(ge>0){const ye=L.untestedCriteria.slice(0,4).join(", ")+(ge>4?`, +${ge-4}`:"");ne.push(`${ge} untested (${ye})`)}const Y=te>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":ge>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:`${ne.join(" · ")}. ${Y}`}})();let K=0;for(const G of fe){const te=n.find(ne=>ne.workflowId===G.id);if(!te)continue;G.steps.every(ne=>{const Y=te.steps[ne.id];return(Y==null?void 0:Y.status)==="pass"||(Y==null?void 0:Y.status)==="fail"||(Y==null?void 0:Y.status)==="skip"||(Y==null?void 0:Y.status)==="not-applicable"})&&K++}const pe=new Set;for(const G of t)q.has(G.matchKey)||pe.add(`${G.ruleId}::${G.target.selector}`);for(const G of _)G.verdict==="fail"&&pe.add(`${G.ruleId}::${G.selector}`);const ae=pe.size;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!C&&v&&e.jsx(ri,{scannedAt:v}),!a&&e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Qr[V]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:V})}),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 ",M.subGrades.length," verification areas below. Untested areas count as F until verified."]}),W&&e.jsxs("div",{className:`text-[11px] leading-snug mt-1 rounded px-2 py-1 border ${W.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:[W.kind==="conformant"?"✓ ":"✗ ",W.text]}),e.jsx("p",{className:"mt-0.5",children:W.detail})]})]})]}),a&&W&&e.jsxs("div",{className:`text-[11px] leading-snug px-3 py-2 border-b ${W.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:[W.kind==="conformant"?"✓ ":"✗ ",W.text]}),e.jsx("p",{className:"mt-0.5",children:W.detail})]}),M.isLawsuitRisk&&e.jsx(ei,{areas:M.warningAreas}),e.jsx(ti,{grades:M.subGrades,uncategorized:Br(t,p,{excludeAckedMatchKeys:q})}),L&&e.jsx(Xr,{coverage:L,onResolveWithAi:re,onMarkVisuallyVerified:F,resolving:u,resolveError:g,lastResolveResult:y,expandedResultFor:$,onToggleResultDetail:oe,violations:t}),D&&e.jsx(Zr,{layers:D}),e.jsx(ai,{violationsRemaining:ae,manualCompleted:K,manualTotal:fe.length}),K>0||w.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:K})," 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:`${K/fe.length*100}%`}})})]}):null]})}function Xr({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:o,expandedResultFor:l,onToggleResultDetail:i,violations:d}){const p=b(I=>I.setView),c=b(I=>I.setFindingsLens),u=b(I=>I.setPendingAreaExpand);function h(I){const k=pn(I,d);p("report"),k?(c("per-area"),u(k)):c("violations")}const g=t.untestedCriteria.length+t.inconclusiveCriteria.length,[f,y]=m.useState(g>0&&g<=3),N=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),$=t.canClaimConformance,R=[];return t.failingCriteria.length>0&&R.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&R.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&R.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${$?"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 ${$?"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 (",N,"%)"]}),$&&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)."]}),!$&&(()=>{const I=[];t.failingCriteria.length>0&&I.push("failing"),t.inconclusiveCriteria.length>0&&I.push("inconclusive"),t.untestedCriteria.length>0&&I.push("untested");const k=I.length===0?"unresolved":I.length===1?I[0]:I.length===2?`${I[0]} or ${I[1]}`:`${I.slice(0,-1).join(", ")}, or ${I[I.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",k,"."]})})(),!$&&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."]}),!$&&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.length>0&&e.jsx("button",{type:"button",onClick:()=>y(I=>!I),className:"text-[11px] underline shrink-0 self-start",children:f?"hide":"show list"})]}),f&&!$&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[R.map(I=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${I.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[I.kind==="untested"?"Untested":I.kind==="inconclusive"?"Inconclusive":"Failing"," (",I.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:I.ids.map(k=>{var M,q;const S=I.kind==="inconclusive"?(M=t.inconclusiveReasons)==null?void 0:M[k]:void 0,x=I.kind==="failing"?(q=t.failingReasons)==null?void 0:q[k]:void 0,C=S==null?void 0:S.some(O=>O.source==="axe-incomplete"&&O.elements&&O.elements.length>0),w=x==null?void 0:x.some(O=>O.source==="ai"),v=(n==null?void 0:n.has(k))??!1,E=o==null?void 0:o[k],_=(l==null?void 0:l.has(k))??!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(k),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 ${k}`,children:["· ",k]}),(I.kind==="inconclusive"&&C||I.kind==="failing"&&w)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[I.kind==="inconclusive"&&s&&k!=="1.4.3"&&k!=="1.4.6"&&e.jsx("button",{type:"button",disabled:v,onClick:()=>s(k),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:v?"Resolving…":E?"✨ Resolve again →":"✨ Resolve with AI →"}),I.kind==="inconclusive"&&(k==="1.4.3"||k==="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:v,onClick:()=>a(k),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:I.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&&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 ",E.total," ",E.total===1?"verdict":"verdicts",":",E.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",E.pass," pass"]}),E.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",E.fail," fail"]}),E.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",E.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",E.costUsd.toFixed(4)]}),i&&e.jsx("button",{type:"button",onClick:()=>i(k),className:"ml-auto text-[10px] underline text-brand-700",children:_?"hide reasoning":"show reasoning"})]}),E.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",E.uncertain," ",E.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),E.pass===E.total&&E.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."]}),_&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:E.resolutions.map((O,B)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:O.verdict==="pass"?"text-emerald-700 font-semibold":O.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:O.verdict==="pass"?"✓":O.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:O.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:O.reasoning})]},B))})]}),x&&x.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:x.map((O,B)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[O.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),O.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," fail — "]}),O.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," fail — "]}),O.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:O.selector}),O.notes&&e.jsx("span",{className:"text-rose-700",children:O.notes})]},B))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((O,B)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[O.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," — "]}),O.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," skipped — "]}),O.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:O.ruleOrStepId})," — "]}),O.resolutionHint,O.elements&&O.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",O.elements.length===1?"element":`${O.elements.length} elements`,":"," ",O.elements.slice(0,3).map((L,D,V)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),D<V.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},D)),O.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",O.elements.length-3," more"]})]})]},B))}):I.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.)"})]},k)})})]},I.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 Es={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 Zr({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,d=l.failing.length,p=l.inconclusive.length,c=l.unevaluated.length,u=l.cleared,h=d>0||p>0,g=i>0&&!h&&c===0,f=g?"text-emerald-700":d>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":d>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:g?"✓":d>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:Es[o].label}),e.jsx("span",{className:`font-mono text-[10px] ${f}`,children:i===0?"no coverage yet":`${u}/${i}`}),d>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:["· ",d," 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:Es[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 ei({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 ti({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 d=i.counts;return d.critical+d.serious+d.moderate+d.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 d=l(i),p="flex items-center gap-2 text-[11px] w-full text-left rounded px-1 py-0.5 -mx-1",c=d?"cursor-pointer hover:bg-slate-100":"cursor-default",u=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Yr[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(si,{grade:i,onOpenGuided:()=>a("guided")})]});return e.jsx("li",{children:d?e.jsx("button",{type:"button",onClick:()=>o(i.id),className:`${p} ${c}`,"aria-label":`Open ${i.label} violations`,children:u}):e.jsx("div",{className:p,children:u})},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 si({grade:t,onOpenGuided:s}){const a=i=>{if(!i)return"";const d=fe.find(p=>p.id===i);return(d==null?void 0:d.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?ka(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((d,p)=>e.jsxs("span",{children:[p>0&&" · ",e.jsxs("span",{className:d.cls,children:[d.n," ",d.label]})]},d.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 ai({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 d=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 ${d}`,"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 ni({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 ri({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 (",ka(s)," old). Re-scan to grade the current page state."]})]})}function ka(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 Sa(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Rs(t){if(!Sa())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; }
|
|
@@ -7,7 +7,7 @@ var an=Object.defineProperty;var nn=(t,s,a)=>s in t?an(t,s,{enumerable:!0,config
|
|
|
7
7
|
} catch (err) { return false; }
|
|
8
8
|
})()`;s.inspectedWindow.eval(r,(o,l)=>{a(l?!1:o===!0)})})}const Ts=.022,ii=1.414,Tt=2.4,oi=.2126729,li=.7151522,ci=.072175,di=.56,ui=.57,pi=.62,hi=.65,$s=1.14,Ls=.1,mi=.027,xi=.027,gi=5e-4;function Us(t,s,a){const n=t/255,r=s/255,o=a/255;return oi*Math.pow(n,Tt)+li*Math.pow(r,Tt)+ci*Math.pow(o,Tt)}function _s(t){return t<0?0:t<Ts?t+Math.pow(Ts-t,ii):t}function fi(t,s){const a=_s(Us(t[0],t[1],t[2])),n=_s(Us(s[0],s[1],s[2]));if(Math.abs(n-a)<gi)return 0;let r=0;return n>a?(r=(Math.pow(n,di)-Math.pow(a,ui))*$s,r<Ls?0:(r-mi)*100):(r=(Math.pow(n,hi)-Math.pow(a,pi))*$s,r>-Ls?0:(r+xi)*100)}function Ds(t){const s=t.trim().replace(/^#/,"");if(s.length===3){const a=parseInt(s[0]+s[0],16),n=parseInt(s[1]+s[1],16),r=parseInt(s[2]+s[2],16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}if(s.length===6){const a=parseInt(s.slice(0,2),16),n=parseInt(s.slice(2,4),16),r=parseInt(s.slice(4,6),16);return Number.isFinite(a)&&Number.isFinite(n)&&Number.isFinite(r)?[a,n,r]:null}return null}function bi(t,s,a=75){const n=Ds(t),r=Ds(s);if(!n||!r)return null;const o=fi(n,r);return{lc:o,passes:Math.abs(o)>=a,threshold:a}}const Be={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function vi(t){return/^wcag\d/.test(t.wcagCriterion)?[Be["ada-iii"],Be[508],Be.eaa,Be["en-301-549"],Be.aoda]:[]}const yi={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function st({violation:t,alreadyAcknowledged:s}){const a=b(x=>x.pinnedMatchKey),n=b(x=>x.pinnedFound),r=b(x=>x.setPinned),o=b(x=>{var C;return(C=x.results[0])==null?void 0:C.frameId}),l=b(x=>{var C;return(C=x.results[0])==null?void 0:C.scope}),i=b(x=>x.results),d=b(x=>x.acknowledgedKeys.has(t.matchKey)),p=b(x=>x.markAcknowledged),c=b(x=>x.markUnacknowledged),u=s||d,h=ss(t.matchKey),g=b(x=>x.dismissedKeys.has(h)),f=b(x=>x.markDismissed),y=b(x=>x.markUndismissed),N=a===t.matchKey,$=N&&!n;async function R(x){try{return(await Te(x,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:x,selector:t.target.selector},o)).found}catch{return!0}}async function I(){const x=await me();if(!x)return;if(N){r(null);try{await ve(x,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:x},o)}catch{}return}const C=await R(x);r(t.matchKey,C)}function k(x){x.stopPropagation(),t.currentState.breakpoint.width<=640&&ts(),(async()=>{const C=await me();if(!C)return;try{await X({type:"STATE_DRIVE_REQUEST",tabId:C,state:t.currentState,scope:l,frameId:o})}catch{}const w=await R(C);r(t.matchKey,w)})()}async function S(x){x.stopPropagation();const C=await me();if(!C)return;try{await X({type:"STATE_DRIVE_REQUEST",tabId:C,state:Ai(),scope:l,frameId:o})}catch{H({type:"STATE_RESET_REQUEST",tabId:C})}const w=await R(C);r(t.matchKey,w)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:I,"aria-pressed":N,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
9
9
|
${N?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${yi[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(Ci,{violation:t}),e.jsx(Ri,{violation:t}),e.jsx(Ei,{violation:t}),e.jsx(Ii,{text:t.target.failureSummary}),e.jsx(Ti,{ruleId:t.ruleId}),N&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",wi(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:k,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),k(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),S(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),Sa()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:x=>{x.preventDefault(),x.stopPropagation(),Rs(t.target.selector)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),Rs(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),$&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs",children:[t.needsReview&&(u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Verified OK"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(t.matchKey),Ni(t,i)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),p(t.matchKey),ji(t,i)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"The rule was right to flag this — I verified the content is fine. Surfaces in the AI fix prompt's 'Previously verified by human' section.",className:"px-2 py-0.5 border border-emerald-300 bg-emerald-50 text-emerald-800 rounded hover:bg-emerald-100 cursor-pointer",children:"✓ Verified OK"})),g?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700 font-semibold",children:"✗ Dismissed"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),y(h),Si(t,i)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Undo"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),f(h),ki(t,i,h)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"The rule itself is wrong about this page — false positive. Suppresses this finding from future audits on this URL + filters it from the AI fix prompt.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"✗ Not a real issue"})]}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function wi(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function ji(t,s){await xn({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await It(t.componentId,s)}async function Ni(t,s){await mn(t.componentId,t.matchKey),await It(t.componentId,s)}async function ki(t,s,a){var l,i;const n=((l=s[0])==null?void 0:l.pageUrl)??((i=s[0])==null?void 0:i.scope)??"";if(!n)return;const r=(t.target.outerHTML??t.target.selector).slice(0,200),o=`Marked "not a real issue" via Findings UI (${t.ruleId} on ${t.target.selector})`;await rs(n,a,o,r),await It(t.componentId,s)}async function Si(t,s){var n,r;const a=((n=s[0])==null?void 0:n.pageUrl)??((r=s[0])==null?void 0:r.scope)??"";a&&(await is(a,ss(t.matchKey)),await It(t.componentId,s))}async function It(t,s){const a=s.flatMap(n=>n.violations);try{const n=await X({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function Ai(){const t=es.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Aa(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),o=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(o==null?void 0:o[1])??"#ffffff"}}function Ci({violation:t}){const s=Aa(t);if(!s)return null;const a=s.ratio>=s.required,n=bi(s.fg,s.bg,75),r=(n==null?void 0:n.passes)??!1;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] flex-wrap",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]}),n&&e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border ${r?"border-emerald-300 bg-emerald-50 text-emerald-800":"border-amber-300 bg-amber-50 text-amber-800"}`,title:"APCA Lc — the contrast algorithm WCAG 3 is built around. Signed: positive = dark text on light, negative = light on dark. |Lc| ≥ 75 typically required for body text.","data-testid":"apca-lc",children:["APCA Lc ",n.lc.toFixed(1)]})]})}function Ii({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function Ei({violation:t}){const s=vi(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function Ri({violation:t}){const s=Aa(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let o=!1;return hn(t.matchKey).then(l=>{l&&!o&&n({kind:"ready",suggestion:l})}),()=>{o=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const o=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await X({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:o}]}),i=l.results.find(d=>d.matchKey===t.matchKey);i?(await gn(i),n({kind:"ready",suggestion:i})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(o){n({kind:"empty",reason:o instanceof Error?o.message:String(o)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((o,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:o.background,color:o.foreground},title:`fg ${o.foreground} on bg ${o.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:o.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:o.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[o.contrast.toFixed(2)," : 1"]})]}),o.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:o.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Ti({ruleId:t}){const s=fn(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}function cs({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l,ack:i}){const[d,p]=m.useState(!1),[c,u]=m.useState(""),[h,g]=m.useState(!1),[f,y]=m.useState(null),[N,$]=m.useState(!1),[R,I]=m.useState(!1),k=ls(),S=o.verdict,x=S==="pass"?"bg-emerald-200 text-emerald-900":S==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900";async function C(){g(!0),y(null);try{if(!c.trim()){y("Note is required — explain how you manually verified this."),g(!1);return}if(S==="pass"){y("This walkthrough already passed — no acknowledgement needed."),g(!1);return}await Zt({componentId:t,criterionId:a,pageUrl:s,note:c.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:S}),l()}catch(v){y(v instanceof Error?v.message:String(v))}finally{g(!1)}}async function w(){var v;I(!0),y(null);try{const _=(v=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:v.id;if(!_){y("No active tab — open the audited page first."),I(!1);return}const q=await H({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:_,componentId:t,pageUrl:s});q.ok||y(q.error??"Re-run failed."),l()}catch(E){y(E instanceof Error?E.message:String(E))}finally{I(!1)}}return i?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"shrink-0 font-mono text-[10px] font-bold rounded px-1.5 py-0.5 uppercase bg-emerald-500 text-white",children:"✓ verified"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-xs font-medium text-emerald-900",children:[e.jsx("span",{className:"font-mono text-[11px] text-emerald-700 mr-1.5",children:a}),n??"Walkthrough"," — human verified"]}),e.jsxs("p",{className:"text-[11px] text-emerald-800 mt-0.5 leading-snug",children:[e.jsx("strong",{children:"Note:"})," ",i.note]}),e.jsxs("p",{className:"text-[10px] text-emerald-700 mt-0.5",children:["Recorded ",new Date(i.acknowledgedAt).toLocaleString(),". Original AI verdict: ",S,"."]})]})]})}):e.jsxs("div",{className:"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 ${x}`,children:S}),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??`Walkthrough verdict: ${S}`]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-0.5 leading-snug",children:S==="fail"?"AI walkthrough flagged a failure here. Fix the page and re-run, or verify manually and acknowledge.":S==="uncertain"?"AI walkthrough couldn't decide. Fix the underlying ambiguity, or verify manually and acknowledge.":"AI walkthrough passed — no action needed."})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>$(v=>!v),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:N?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void w(),disabled:R||!k,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:k?"Re-run AI walkthrough after fixing the page (uses the active tab)":"AI walkthroughs need an Anthropic API key. Open Settings → AI to add one.",children:R?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{p(v=>!v),y(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"})]}),N&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded p-2",children:[r&&e.jsxs(e.Fragment,{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})]}),d&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",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:c,onChange:v=>u(v.target.value),placeholder:"e.g., Verified live page via curl + screenshot — 2px white borders visible on both inputs against dark card.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),f&&e.jsx("p",{className:"text-[10px] text-rose-700",children:f}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void C(),disabled:h,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:h?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{p(!1),u(""),y(null)},disabled:h,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"})]})]}),f&&!d&&e.jsx("p",{className:"text-[10px] text-rose-700",children:f})]})}function $i(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ca(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Li(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Ca(n),o=s.get(r);o?o.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Os={critical:0,serious:1,moderate:2,minor:3},Ui={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 _i({results:t,interactiveVerdicts:s,aiResolvedFails:a}){var k;const n=t.length,r=t.flatMap(S=>S.violations),o=Li(t);o.sort((S,x)=>{const C=Os[S.representative.impact]??99,w=Os[x.representative.impact]??99;return C!==w?C-w:x.states.length-S.states.length});const l=Jt({violations:r,auditRan:!0,manualRuns:[],workflows:fe,heuristicCounts:{},interactiveAuditVerdicts:s}),i=new Map;for(const S of Fe)i.set(S.id,[]);const d=[];for(const S of o){let x=!1;for(const C of Fe)if(C.axeRules.includes(S.representative.ruleId)){i.get(C.id).push(S),x=!0;break}x||d.push(S)}const p=new Map;for(const S of Fe)p.set(S.id,[]);const c=[];for(const S of a??[]){let x=!1;for(const C of Fe)if(C.axeRules.includes(S.ruleId)){p.get(C.id).push(S),x=!0;break}x||c.push(S)}const u=((k=t[0])==null?void 0:k.componentId)??null,[h,g]=m.useState([]),[f,y]=m.useState({}),[N,$]=m.useState(0);m.useEffect(()=>{let S=!1;return(async()=>{if(!u){g([]),y({});return}const[x,C]=await Promise.all([Re(u),De([u])]);if(S)return;g(x);const w={};for(const v of C)w[v.criterionId]=v;y(w)})(),()=>{S=!0}},[u,N]);const R=new Map;for(const S of Fe)R.set(S.id,[]);const I={"2.4.3":"tab-order","2.1.2":"keyboard","2.4.7":"keyboard","1.3.2":"reading-order","1.4.11":"contrast","2.5.3":"aria"};for(const S of h){if(S.verdict==="pass")continue;const x=I[S.criterionId];if(!x)continue;const C=R.get(x);C&&C.push({record:S,ack:f[S.criterionId]??null})}return e.jsxs("div",{className:"space-y-1.5",children:[l.subGrades.map(S=>e.jsx(Fs,{subGrade:S,groups:i.get(S.id)??[],totalStates:n,aiFails:p.get(S.id)??[],walkthroughIssues:R.get(S.id)??[],componentId:u,onWalkthroughChanged:()=>$(x=>x+1)},S.id)),(d.length>0||c.length>0)&&e.jsx(Fs,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:d,totalStates:n,aiFails:c,walkthroughIssues:[],componentId:u,onWalkthroughChanged:()=>$(S=>S+1)})]})}function Fs({subGrade:t,groups:s,totalStates:a,aiFails:n,walkthroughIssues:r,componentId:o,onWalkthroughChanged:l}){const[i,d]=m.useState(!1),p=b(x=>x.pendingAreaExpand),c=b(x=>x.setPendingAreaExpand);m.useEffect(()=>{p===t.id&&(d(!0),c(null),requestAnimationFrame(()=>{const x=document.querySelector(`[data-area-card="${t.id}"]`);x==null||x.scrollIntoView({behavior:"smooth",block:"start"})}))},[p,t.id,c]);const[u,h]=m.useState("idle"),[g,f]=m.useState(null),[y,N]=m.useState(0),$=s.length>0||n.length>0||r.length>0,R=Ui[t.letter],I=s.filter(x=>x.representative.ruleId==="color-contrast"||x.representative.ruleId==="color-contrast-enhanced"),k=I.length>=2;async function S(x){x.stopPropagation(),h("loading"),f(null);try{const C=I.map(v=>{const E=v.representative.target.outerHTML,_=v.representative.target.failureSummary,M=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(_),q=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(_);if(!M||!q)return null;const O=v.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:v.representative.matchKey,foreground:M[1],background:q[1],fontSize:16,fontWeight:400,targetLevel:O,_html:E}}).filter(v=>v!==null);if(C.length===0){h("error"),f("Could not parse fg/bg colors from the violation failure summaries.");return}const w=await X({type:"AI_COLOR_SUGGEST_REQUEST",inputs:C.map(({_html:v,...E})=>E)});if(w.unavailableReason&&w.results.length===0){h("error"),f(w.unavailableReason);return}await bn(w.results),h("done"),N(v=>v+1),i||d(!0)}catch(C){h("error"),f(C instanceof Error?C.message:String(C))}}return e.jsxs("div",{"data-area-card":t.id,className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>d(x=>!x),"aria-expanded":i,disabled:!$,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold font-display ${R}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:$?(()=>{const x=s.length+n.length+r.length,C=[];return s.length>0&&C.push(`${s.length} axe`),n.length>0&&C.push(`${n.length} AI-resolved`),r.length>0&&C.push(`${r.length} walkthrough`),`${x} ${x===1?"issue":"issues"} to fix (${C.join(" + ")})`})():"No issues found"})]}),k&&e.jsx("span",{role:"button",tabIndex:0,onClick:x=>void S(x),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),S(x))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${I.length} contrast issues at once`,children:u==="loading"?"Asking AI…":u==="done"?`✓ Suggested for all ${I.length}`:`✨ Suggest for all ${I.length}`}),$&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0 font-mono","aria-hidden":"true",children:i?"−":"+"})]}),u==="error"&&g&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:g}),i&&$&&e.jsxs("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:[s.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(st,{violation:x.representative}),e.jsx(Di,{states:x.states,totalStates:a})]},`${Ca(x.representative)}::${y}`)),n.length>0&&e.jsxs(e.Fragment,{children:[s.length>0&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI-resolved fails (",n.length,")"]}),n.map(x=>e.jsx(Oi,{fail:x},`${x.ruleId}::${x.selector}`))]}),r.length>0&&e.jsxs(e.Fragment,{children:[(s.length>0||n.length>0)&&e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 pt-2 px-1",children:["AI walkthrough findings (",r.length,")"]}),r.map(x=>e.jsx("div",{className:"border border-slate-200 rounded bg-white p-2",children:e.jsx(cs,{componentId:o??"",pageUrl:x.record.pageUrl,criterionId:x.record.criterionId,record:x.record,ack:x.ack,onChanged:l})},x.record.criterionId))]})]})]})}function Di({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map($i))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",o=a.join(`
|
|
10
|
-
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:o,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function Oi({fail:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(!1);async function o(){a(!0);try{const{saveResolutions:l}=await Ae(async()=>{const{saveResolutions:i}=await import("./scheduled-audit-runner-
|
|
10
|
+
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:o,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}function Oi({fail:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(!1);async function o(){a(!0);try{const{saveResolutions:l}=await Ae(async()=>{const{saveResolutions:i}=await import("./scheduled-audit-runner-DB_DvRPY.js").then(d=>d.aW);return{saveResolutions:i}},__vite__mapDeps([0,1,2,3,4]));await l([{...t,verdict:"pass",reasoning:`[Human override — visually verified by user] ${t.reasoning}`,resolvedAt:new Date().toISOString()}]),r(!0)}finally{a(!1)}}return e.jsxs("div",{className:`border rounded-md bg-white p-2 text-[11px] ${n?"border-emerald-200 bg-emerald-50":"border-rose-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[10px] text-rose-700",children:t.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold ${n?"bg-emerald-100 text-emerald-800":"bg-rose-100 text-rose-900"}`,children:n?"✓ Resolved":"AI verdict: FAIL"})]}),e.jsx("p",{className:"font-mono text-[10px] text-slate-700 mb-1 break-all",children:t.selector}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug mb-2",children:t.reasoning}),!n&&e.jsx("button",{type:"button",onClick:()=>void o(),disabled:s,className:"px-2 py-1 text-[11px] font-medium bg-white border border-emerald-300 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Override the AI's fail determination — your human visual judgment is the highest authority per WCAG-EM. Use when you've verified the contrast / labeling is actually fine.",children:"✓ Mark as resolved (override AI)"})]})}const Ms="igtRuns";async function Fi(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Ms))[Ms];return s&&typeof s=="object"?s:{}}async function Mi(t,s){var l,i;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,o=(await Fi())[t];if(o)for(const d of fe){const p=o[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((i=(l=p.steps)==null?void 0:l[c.id])==null?void 0:i.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const g=a.tabOrderIssues??[];if(g.length===0)continue;await tt(n,g.map(f=>({key:et(f.selector),reason:h,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const g=a.readingOrderIssues??[];if(g.length===0)continue;await tt(n,g.map(f=>({key:Ze(f.selector),reason:h,snippet:`${f.selector} — ${f.textSnippet||"(no text)"}`})))}}}}const Pi=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),Gi=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function Vi(t){return Pi.has(t.ruleId)}function Wi(t){return Gi.has(t.ruleId)}function Bi(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ia(){var M,q,O,B;const t=b(L=>L.results),s=b(L=>L.delta),a=b(L=>L.componentId),n=((M=t[0])==null?void 0:M.pageUrl)??((q=t[0])==null?void 0:q.scope)??"",[r,o]=m.useState({}),[l,i]=m.useState(!1),[d,p]=m.useState(!1);m.useEffect(()=>{if(!a){i(!1),p(!1);return}let L=!1;return(async()=>{const D=await Re(a);if(L)return;const V=D.some(T=>T.criterionId==="2.1.2"&&T.verdict==="pass"),z=D.some(T=>T.criterionId==="1.3.2");i(V),p(z)})(),()=>{L=!0}},[a]);const[c,u]=m.useState(0);m.useEffect(()=>{if(!n)return;let L=!1;return(async()=>{if(a&&t.length>0)try{await Mi(a,t)}catch{}if(L)return;const D=await ns(n);L||o(D)})(),()=>{L=!0}},[n,c,a,t]);async function h(L,D){if(!n)return;const V=window.prompt(`Why is this finding a false positive?
|
|
11
11
|
|
|
12
12
|
(Recorded with the dismissal so future you remembers the reasoning.)`,"");V!==null&&(await rs(n,L,V||"(no reason given)",D),u(z=>z+1))}async function g(L){n&&(await is(n,L),u(D=>D+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const f=t.reduce((L,D)=>{var V;return L+(((V=D.announcements)==null?void 0:V.length)??0)},0),y=t.reduce((L,D)=>{var V;return L+(((V=D.focusEvents)==null?void 0:V.length)??0)},0),N=t.reduce((L,D)=>{var V;return L+(((V=D.focusEvents)==null?void 0:V.filter(z=>z.isFocusReset).length)??0)},0),$=Ps(t,Vi),R=Ps(t,Wi),I=$.length,k=R.length,S=d?[]:((O=t[0])==null?void 0:O.readingOrderIssues)??[],x=l?[]:((B=t[0])==null?void 0:B.tabOrderIssues)??[],C=S.filter(L=>!(Ze(L.selector)in r)),w=S.filter(L=>Ze(L.selector)in r),v=x.filter(L=>!(et(L.selector)in r)),E=x.filter(L=>et(L.selector)in r);if(f===0&&y===0&&I===0&&k===0&&C.length===0&&v.length===0&&w.length===0&&E.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const _=w.length+E.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[I," structural · ",k," form ·"," ",v.length," tab-order ·"," ",C.length," reading-order ·"," ",f," ",f===1?"announcement":"announcements"," ·"," ",y," focus ",y===1?"event":"events",N>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",N," focus reset",N===1?"":"s"]}),_>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",_," dismissed"]})]}),v.length>0&&e.jsx(zi,{issues:v,onDismiss:h}),C.length>0&&e.jsx(qi,{issues:C,onDismiss:h}),_>0&&e.jsx(Qi,{dismissedReadingOrder:w,dismissedTabOrder:E,dismissals:r,onRestore:g}),I>0&&e.jsx(Gs,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:$}),k>0&&e.jsx(Gs,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:R}),e.jsx(Hi,{delta:s}),t.map((L,D)=>{const V=L.announcements??[],z=L.focusEvents??[];return V.length===0&&z.length===0?null:e.jsx(Ki,{state:L.state,announcements:V,focusEvents:z},D)})]})}function Hi({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,o)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},o))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,o)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},o))})]})]})}function Ps(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const o=_e(r.ruleId,r.target.selector),l=a.get(o);l?l.states.push(r.currentState):a.set(o,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const o={critical:0,serious:1,moderate:2,minor:3};return(o[n.violation.impact]??99)-(o[r.violation.impact]??99)})}function Gs({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function Ki({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Bi(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function zi({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,o)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},o)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function qi({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Qi({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,o]=m.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>o(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(i=>{const d=`tab-order::${i.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:i.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(i=>{const d=`reading-order::${i.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:i.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Yi={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Ji({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const o=r.impact,l=r.description,i=s.length;return i===1?e.jsx(st,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Yi[o]}`,children:o}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",i]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(st,{violation:d},p))})]})}function Xi(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Zi={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Ea({open:t,onClose:s,format:a,content:n,filename:r}){const o=qn(new Blob([n]).size);function l(){at(n,r),s()}function i(){Ue(n),s()}return e.jsxs(Ge,{open:t,onClose:s,title:Zi[a],description:`Generated bundle — ${o}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:i,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Vs=7800;function eo(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===u);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(`
|
|
13
13
|
`),d=new URLSearchParams({title:o,body:i});let p=`${n}/issues/new?${d.toString()}`;return p.length>Vs&&(p=p.slice(0,Vs)),{url:p,title:o,body:i}}const Ws=7800;function to(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===u);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(`Rule: ${c.ruleId} (${c.impact})`),l.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),l.push(`Description: ${c.description}`),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: ${c.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const i=l.join(`
|
|
@@ -15,7 +15,7 @@ var an=Object.defineProperty;var nn=(t,s,a)=>s in t?an(t,s,{enumerable:!0,config
|
|
|
15
15
|
`),p=new URLSearchParams({"[Title]":l,"[Description]":d});let c=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return c.length>Bs&&(c=c.slice(0,Bs)),{url:c,title:l,description:d}}const Hs=7800;function ao(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=r.find(f=>`${f.ruleId}::${f.target.selector}`===u);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
|
`),d=new URLSearchParams({"issue[title]":o,"issue[description]":i});let p=`${n}/-/issues/new?${d.toString()}`;return p.length>Hs&&(p=p.slice(0,Hs)),{url:p,title:o,description:i}}const Ks=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],no=["wcag-component-auditor","wcag-forensic-log"];async function ro(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Ks);s=Object.keys(n).length,await chrome.storage.local.remove(Ks)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of no)try{await io(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 io(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 Wt="accessibilityStatementInputs:v1";async function oo(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(Wt))[Wt];return s&&typeof s=="object"?s:null}async function lo(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[Wt]:t})}function Ra({open:t,onClose:s,results:a,siteCrawlSource:n}){const[r,o]=m.useState("eaa"),[l,i]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState("partial"),[h,g]=m.useState(""),[f,y]=m.useState(""),[N,$]=m.useState(""),[R,I]=m.useState(""),[k,S]=m.useState("English"),[x,C]=m.useState("wcagcheckr (self-evaluation)"),[w,v]=m.useState("2.1"),[E,_]=m.useState("AA"),[M,q]=m.useState(!1),[O,B]=m.useState(null),L=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var re,oe,j,A;const T=await oo();if(T&&(T.framing&&o(T.framing),T.organizationName&&i(T.organizationName),T.siteUrl&&p(T.siteUrl),T.conformanceStatus&&u(T.conformanceStatus),(re=T.contact)!=null&&re.email&&g(T.contact.email),(oe=T.contact)!=null&&oe.phone&&y(T.contact.phone),(j=T.contact)!=null&&j.formUrl&&$(T.contact.formUrl),T.countryCode&&I(T.countryCode),T.language&&S(T.language),T.auditedBy&&C(T.auditedBy),T.wcagVersion&&v(T.wcagVersion),T.wcagLevel&&_(T.wcagLevel)),!(T!=null&&T.siteUrl)&&((A=a[0])!=null&&A.pageUrl))try{const F=new URL(a[0].pageUrl);p(`${F.protocol}//${F.host}/`)}catch{}T!=null&&T.conformanceStatus||u(vn(a)),setTimeout(()=>{var F;return(F=L.current)==null?void 0:F.focus()},50)})()},[t,a]),!t)return null;function D(){var j;const T=new Date().toISOString().slice(0,10),re=(j=a[0])!=null&&j.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):T,oe={};return h.trim()&&(oe.email=h.trim()),f.trim()&&(oe.phone=f.trim()),N.trim()&&(oe.formUrl=N.trim()),{framing:r,organizationName:l.trim(),siteUrl:d.trim(),conformanceStatus:c,preparedAt:T,evaluatedAt:re,contact:oe,countryCode:R||null,language:k.trim()||"English",auditedBy:x.trim()||"wcagcheckr (self-evaluation)",wcagVersion:w,wcagLevel:E}}function V(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 z(T){var j;B(null);const re=D(),oe=V(re);if(oe){B(oe);return}q(!0);try{await lo(re);const A=await X({type:"EXPORT_REQUEST",format:T==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:n?[]:a,siteCrawlSource:n||void 0,statementInputs:re}),F=(A==null?void 0:A.content)??"";if(!F||F.startsWith("# Accessibility statement — error")){B(F||"Export failed — no response.");return}try{await navigator.clipboard.writeText(F)}catch{}const W=new Blob([F],{type:T==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),K=URL.createObjectURL(W);typeof chrome<"u"&&((j=chrome.tabs)!=null&&j.create)?await chrome.tabs.create({url:K,active:!0}).catch(()=>{window.open(K,"_blank","noopener,noreferrer")}):window.open(K,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(K),6e4),s()}catch(A){B(A instanceof Error?A.message:String(A))}finally{q(!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:d,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=>u(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:w,onChange:T=>v(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:E,onChange:T=>_(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=>y(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:N,onChange:T=>$(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:R,onChange:T=>I(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(yn).map(([T,re])=>e.jsxs("option",{value:T,children:[T," — ",re.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:k,onChange:T=>S(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=>C(T.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),O&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:O})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void z("markdown"),disabled:M,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:M?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void z("html"),disabled:M,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:M?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:M,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 Ta(){const t=b(A=>A.delta),s=b(A=>A.componentId),a=b(A=>A.results),n=b(A=>A.tier),r=b(A=>A.baselineList),o=b(A=>A.siteCrawlReport),[l,i]=m.useState(""),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[f,y]=m.useState(!1),[N,$]=m.useState(!1),[R,I]=m.useState(null),[k,S]=m.useState(null),[x,C]=m.useState(!1),[w,v]=m.useState(!1),[E,_]=m.useState(null),[M,q]=m.useState(!1);m.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"githubRepoUrl"}),X({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),X({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),X({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([A,F,W,K])=>{i(typeof A.data=="string"?A.data:""),p(typeof F.data=="string"?F.data:""),u(typeof W.data=="string"?W.data:""),g(typeof K.data=="string"?K.data:"")})},[]),m.useEffect(()=>be("BADGE_CLICKED_EVENT",F=>{const W=`viol-row-${F.violationId}`,K=document.getElementById(W);K&&(K.scrollIntoView({behavior:"smooth",block:"center"}),K.classList.add("ring-2","ring-rose-500"),setTimeout(()=>K.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const A=await me();A&&(w&&await ve(A,{type:"BADGES_HIDE_REQUEST",tabId:A}).catch(()=>{}),M&&await ve(A,{type:"HEATMAP_HIDE_REQUEST",tabId:A}).catch(()=>{}))})()},[]);async function O(){const A=await me();if(!A){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(w){await ve(A,{type:"BADGES_HIDE_REQUEST",tabId:A}).catch(()=>{}),v(!1),_(null);return}const F={critical:4,serious:3,moderate:2,minor:1},W=new Map;for(const ee of a)for(const U of ee.violations)W.has(U.matchKey)||W.set(U.matchKey,U);const pe=Array.from(W.values()).sort((ee,U)=>F[U.impact]-F[ee.impact]).map((ee,U)=>({id:ee.matchKey,index:U+1,selector:ee.target.selector,impact:ee.impact,ruleId:ee.ruleId,wcagCriterion:ee.wcagCriterion}));if(pe.length===0){he.polite("No violations to badge.");return}const ae=await Te(A,{type:"BADGES_SHOW_REQUEST",tabId:A,violations:pe}).catch(()=>null);ae&&(v(!0),_({rendered:ae.rendered,requested:ae.requested,clustered:ae.clustered}),he.polite(`${ae.rendered} violation badges shown on the page.`))}async function B(){const A=await me();if(!A){he.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(M){await ve(A,{type:"HEATMAP_HIDE_REQUEST",tabId:A}).catch(()=>{}),q(!1);return}const F=new Map;for(const pe of a)for(const ae of pe.violations)F.has(ae.matchKey)||F.set(ae.matchKey,ae);const W=Array.from(F.values()).map(pe=>({selector:pe.target.selector,impact:pe.impact}));if(W.length===0){he.polite("No violations to heatmap.");return}const K=await Te(A,{type:"HEATMAP_SHOW_REQUEST",tabId:A,violations:W}).catch(()=>null);K&&(q(!0),he.polite(`Heatmap shown with ${K.rendered} violation blobs.`))}const L=Ne(n,"exportJson"),D=Ne(n,"issueTrackers"),V=ua(n).maxBaselines,z=r.some(A=>A.componentId===s),T=z||r.length<V;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 re(){if(!s||a.length===0)return;const A=a.flatMap(U=>U.violations),F=a.flatMap(U=>U.announcements??[]),W=a.flatMap(U=>U.focusEvents??[]),K=a[0],ae=(await X({type:"SETTINGS_GET",key:"stateMatrix"})).data??es;await H({type:"BASELINE_SET",componentId:s,violations:A,announcements:F,focusEvents:W,snapshotMeta:{url:window.location.href,axeVersion:K.axeVersion,matrixConfig:ae,capturedAt:new Date().toISOString()}});const ee=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:A,announcements:F,focusEvents:W,currentMatrix:ae});b.getState().setDelta(ee.delta),he.polite(`Baseline saved for ${s}.`)}async function oe(){if(!s||!z||!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 H({type:"BASELINE_DELETE",componentId:s});const F=a.flatMap(ee=>ee.violations),W=a.flatMap(ee=>ee.announcements??[]),K=a.flatMap(ee=>ee.focusEvents??[]),pe=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:F,announcements:W,focusEvents:K});b.getState().setDelta(pe.delta);const ae=await X({type:"BASELINE_LIST"});b.getState().setBaselineList(ae.items),he.polite(`Baseline cleared for ${s}.`)}async function j(A,F=!1){if(a.length===0)return;if(A==="ai-prompt"){const{copyAiFixerPrompt:le}=await Ae(async()=>{const{copyAiFixerPrompt:de}=await import("./copy-ai-fixer-prompt-CKzZ3eDP.js");return{copyAiFixerPrompt:de}},__vite__mapDeps([5,1,3]));await le({results:a,componentId:s,delta:F?void 0:t,siteCrawlReport:o});return}let W;if((A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet")&&s){const le=await chrome.storage.local.get("igtRuns"),xe=((le==null?void 0:le.igtRuns)??{})[s]??{};W=Object.values(xe)}const ae=await X({type:"EXPORT_REQUEST",format:A,results:a,delta:F?void 0:t??void 0,manualRuns:W,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet"){const le=Nt(A,s);await ha()?at(ae.content,le):S({open:!0,format:A,content:ae.content,filename:le});return}if(A==="html-print"||A==="vpat"||A==="methodology-doc"||A==="conformance-crosswalk"||A==="executive-report"){Ue(ae.content);return}const ee=A==="json"?"application/json":A==="sarif"?"application/sarif+json":A==="ticket-bundle"?"text/markdown":"application/xml",U=A==="junit"?"xml":A==="ticket-bundle"?"md":A,Z=new Blob([ae.content],{type:ee}),Q=URL.createObjectURL(Z),ie=document.createElement("a");ie.href=Q,ie.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${U}`,ie.click(),URL.revokeObjectURL(Q)}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:re,disabled:!T,title:T?void 0:`Free tier limits you to ${V} 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"}),z&&e.jsx("button",{onClick:oe,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:()=>y(!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 O(),"aria-pressed":w,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:w?"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:w?"Hide badges":"Show badges 🎯"}),w&&E&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[E.rendered," of ",E.requested," rendered",E.clustered>0?` · ${E.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void B(),"aria-pressed":M,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:M?"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:M?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(xo,{disabled:!L,onExport:j,onAccessibilityStatement:()=>C(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!T&&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 A=$t(t.new),F=$t(t.persistent),W=$t(t.fixed),K=[...A.review,...F.review];return e.jsxs(e.Fragment,{children:[e.jsx(He,{title:"New",violations:A.findings,count:A.findings.length,accent:"red",actions:[...D&&l&&A.findings.length>0?[{label:"File GitHub issue",onClick:()=>uo(l,s,A.findings)}]:[],...D&&d&&A.findings.length>0?[{label:"File Jira issue",onClick:()=>po(d,s,A.findings)}]:[],...D&&c&&A.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>ho(c,s,A.findings)}]:[],...D&&h&&A.findings.length>0?[{label:"File GitLab issue",onClick:()=>mo(h,s,A.findings)}]:[]]}),e.jsx(He,{title:"Persistent",violations:F.findings,count:F.findings.length,accent:"slate"}),e.jsx(He,{title:"Fixed",violations:W.findings,count:t.fixedCount,accent:"green"}),K.length>0&&e.jsx(He,{title:"Needs review (does not affect grade)",violations:K,count:K.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(He,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),k&&e.jsx(Ea,{open:k.open,onClose:()=>S(null),format:k.format,content:k.content,filename:k.filename}),e.jsx(Ra,{open:x,onClose:()=>C(!1),results:a}),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"})]})]}),R&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",R.chromeStorageKeysCleared," chrome.storage key",R.chromeStorageKeysCleared===1?"":"s"," + ",R.indexedDbsCleared.length," database",R.indexedDbsCleared.length===1?"":"s",".",R.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",R.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:R?e.jsx("button",{type:"button",onClick:()=>{y(!1),I(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:()=>y(!1),disabled:N,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()=>{$(!0);try{const A=await ro();I(A),await St(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(A){I({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[A instanceof Error?A.message:String(A)]})}finally{$(!1)}},disabled:N,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:N?"Resetting…":"Reset everything"})]})})]})})]})}const co={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 He({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 ${co[n]} ${o?"cursor-pointer select-none":""}`,onClick:o?()=>i(d=>!d):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(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),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((d,p)=>e.jsx(st,{violation:d,alreadyAcknowledged:!0},p)):Xi(s).map(d=>e.jsx(Ji,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function uo(t,s,a){if(a.length===0)return;const{url:n}=eo(t,s,a);kt(n)}function po(t,s,a){if(a.length===0)return;const{url:n}=to(t,s,a);kt(n)}function ho(t,s,a){if(a.length===0)return;const{url:n}=so(t,s,a);kt(n)}function mo(t,s,a){if(a.length===0)return;const{url:n}=ao(t,s,a);kt(n)}function xo({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,o]=m.useState(!1),[l,i]=m.useState(!1);function d(p){o(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>o(p=>!p),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>o(!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:l,onChange:p=>i(p.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(we,{onClick:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(we,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(we,{onClick:()=>d("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:()=>d("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:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(we,{onClick:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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,{onClick:()=>{o(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function we({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const go="2024-07-25",fo="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.",$a=[{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($a.flatMap(t=>t.wcag2Criteria));function bo(t,s){return $a.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 vo={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function La(){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 u=c.axeRulesEvaluated;if(u){for(const h of u.passed)r.add(h.wcagCriterion);for(const h of u.inapplicable)r.add(h.wcagCriterion);for(const h of u.incomplete)r.add(h.wcagCriterion)}}const o=bo(n,r),l=new Map;for(const c of o){const u=l.get(c.outcome.category)??[];u.push(c),l.set(c.outcome.category,u)}const i=o.filter(c=>c.status==="clean").length,d=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:go}),"."," ",fo]})]}),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:[d," 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 u=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:[vo[c]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.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(yo,{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 yo({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 wo=[{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"}],jo={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 No(){const t=b(u=>u.results),s=b(u=>u.componentId),a=b(u=>u.findingsLens),n=b(u=>u.setFindingsLens),r=b(u=>u.setView),o=b(u=>u.status),[l,i]=m.useState({});m.useEffect(()=>{if(!s)return;let u=!1;return(async()=>{const h=await Re(s),g=await De([s]);if(u)return;const f=new Set(g.map(N=>N.criterionId)),y={};for(const N of h){const $=f.has(N.criterionId)?"pass":N.verdict;N.criterionId==="2.4.3"?y.focusOrder=$:N.criterionId==="2.1.2"?y.keyboardTrap=$:N.criterionId==="2.4.7"?y.focusVisible=$:N.criterionId==="1.3.2"?y.readingOrder=$:N.criterionId==="1.4.11"&&(y.nonTextContrast=$)}i(y)})(),()=>{u=!0}},[s]);const d=os(t),[p,c]=m.useState([]);return m.useEffect(()=>{if(!s){c([]);return}let u=!1;return chrome.storage.local.get("igtRuns").then(h=>{if(u)return;const f=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(zs,{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(zs,{setView:r}),e.jsx(So,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(ko,{results:t}),e.jsx(Ao,{lens:a,setLens:n}),e.jsx(Co,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function zs({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 ko({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 d(){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:()=>d(),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 So({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var f,y,N,$;const r=t.flatMap(R=>R.violations),o=b(R=>R.lastAuditWallClockMs),l=b(R=>R.acknowledgedKeys),i=b(R=>R.dismissedKeys),p=Jt({violations:r,auditRan:!0,manualRuns:a,workflows:fe,heuristicCounts:{tabOrder:((y=(f=t[0])==null?void 0:f.tabOrderIssues)==null?void 0:y.length)??0,readingOrder:(($=(N=t[0])==null?void 0:N.readingOrderIssues)==null?void 0:$.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(R=>({ruleId:R.ruleId,impact:"serious",selector:R.selector}))}).overallLetter,c=Na(r,n,l,i),u=Wr(r,n,l,i),h=t.length,g=o??t.reduce((R,I)=>R+I.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 ${jo[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-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&&u.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",u.length," WCAG criterion",u.length===1?"":"a"," (",u.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 Ao({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:wo.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 Co({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(Io,{componentId:a,results:s}),e.jsx($o,{componentId:a}),e.jsx(Jr,{violations:s.flatMap(i=>i.violations),componentId:a,hideOverallHeader:!0}),e.jsx(Oo,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(Lo,{})]}):t==="per-area"?e.jsx(_i,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(_o,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ia,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ta,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(La,{})}):null}const wt={critical:0,serious:1,moderate:2,minor:3};function Bt(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Io({componentId:t,results:s}){var f,y;const a=b(N=>N.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,d]=m.useState(0);m.useEffect(()=>{let N=!1;return(async()=>{if(!t){r({}),l({});return}const $=await Re(t);if(N)return;const R={};for(const S of $)R[S.criterionId]=S;r(R);const I=await De([t]);if(N)return;const k={};for(const S of I)k[`${S.criterionId}::${S.pageUrl}`]=S;l(k)})(),()=>{N=!0}},[t,i]);const p=((f=s[0])==null?void 0:f.pageUrl)??((y=s[0])==null?void 0:y.scope)??"",c=ht.map(N=>({crit:N,record:n[N.id]??null})).filter(({record:N})=>N&&(N.verdict==="fail"||N.verdict==="uncertain")).filter(({crit:N})=>!o[`${N.id}::${p}`]),u=new Set,h=[];for(const N of s)for(const $ of N.violations){if($.needsReview)continue;const R=_e($.ruleId,$.target.selector);u.has(R)||(u.add(R),h.push($))}h.sort((N,$)=>(wt[N.impact]??99)-(wt[$.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:N,record:$})=>e.jsx(Eo,{componentId:t??"",pageUrl:p,criterionId:N.id,label:N.label,blurb:N.blurb,record:$,onChanged:()=>d(R=>R+1)},`wt::${N.id}`)),h.map(N=>e.jsx(Ro,{violation:N,onOpen:()=>a("violations")},`axe::${Bt(N)}`))]})]})}function Eo({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l}){const[i,d]=m.useState(!1),[p,c]=m.useState(""),[u,h]=m.useState(!1),[g,f]=m.useState(null),[y,N]=m.useState(!1),[$,R]=m.useState(!1),I=ls(),k=o.verdict,S=k==="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 Zt({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:k}),l()}catch(w){f(w instanceof Error?w.message:String(w))}finally{h(!1)}}async function C(){var w;R(!0),f(null);try{const E=(w=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:w.id;if(!E){f("No active tab — open the audited page first."),R(!1);return}const M=await H({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:E,componentId:t,pageUrl:s});M.ok||f(M.error??"Re-run failed."),l()}catch(v){f(v instanceof Error?v.message:String(v))}finally{R(!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 ${S}`,children:k}),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:k==="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:()=>N(w=>!w),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:y?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:$||!I,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:I?"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:$?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(w=>!w),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"})]}),y&&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:w=>c(w.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:u,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:u?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{d(!1),c(""),f(null)},disabled:u,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 Ro({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 ht=[{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)."}],To={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function $o({componentId:t}){const[s,a]=m.useState({}),[n,r]=m.useState({});m.useEffect(()=>{let u=!1;return(async()=>{if(!t){a({}),r({});return}const[h,g]=await Promise.all([Re(t),De([t])]);if(u)return;const f={};for(const N of h)f[N.criterionId]=N;a(f);const y={};for(const N of g)y[N.criterionId]=N;r(y)})(),()=>{u=!0}},[t]);const o={};for(const[u,h]of Object.entries(s))o[u]=n[u]?"pass":h.verdict;const l=Object.values(o).length,i=Object.values(o).filter(u=>u==="pass").length,d=Object.values(o).filter(u=>u==="fail").length,p=Object.values(o).filter(u=>u==="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 ${ht.length} criteria pending human verification`:`${l}/${ht.length} · ${i} pass · ${d} 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:ht.map(u=>{const h=s[u.id],g=n[u.id],f=h==null?void 0:h.verdict,y=g?"pass":f,N=h?Pt(h.reasoning):!1,$=h?la(h.reasoning):!1,R=h?Gt(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":y?To[y]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${f})`:y?`AI verdict: ${y}${R?` (cascade ${R})`:""}`:"AI did not produce a verdict on this criterion",children:g?"✓ verified":y||"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:u.id}),u.label,$&&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:u.blurb}),N&&!$&&!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,"."]})]})]})]},u.id)})})]})}function Lo(){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 Uo({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 De([t]).then(d=>{if(i)return;const p={};for(const c of d)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(cs,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(d=>d+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function _o({results:t}){const s=b(i=>i.dismissedKeys),a=b(i=>i.componentId),n=new Set,r=[];for(const i of t)for(const d of i.violations){if(s.has(`violation::${d.matchKey}`))continue;const p=Bt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((i,d)=>{const p=wt[i.impact]??99,c=wt[d.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Re(a).then(d=>{i||l(d.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(Uo,{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(st,{violation:i},Bt(i)))]})}const Do={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function Oo({pageUrl:t}){const s=b(p=>p.tier),a=Yt(s),n=Ne(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await pa();if(p||o(c),t){const u=await Qn(t);p||i(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?Do[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:d})]}),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 Ht="igtRuns";async function Fo(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 tt(r,l.map(i=>({key:et(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 tt(r,l.map(i=>({key:Ze(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const Mo={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"}},Po={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"}},Go={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function qs(t,s){const a=await me();if(!a)return;const n=s?Mo[t]:Po[t];try{await ve(a,n)}catch{}}async function Vo(){const s=(await chrome.storage.local.get(Ht))[Ht];return s&&typeof s=="object"?s:{}}async function Qs(t){await chrome.storage.local.set({[Ht]:t})}function Wo(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 Bo(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{Vo().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,u,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)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),Qs(g),h.status==="pass"){const y=fe.find($=>$.id===c),N=y==null?void 0:y.steps.find($=>$.id===u);N!=null&&N.autoDismissActivity&&Fo(N.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[c];const h={...a,[t]:u};n(h),Qs(h)}const p=fe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(Ho,{workflow:p,run:c,results:s,onAnswer:(u,h)=>i(p.id,u,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 u=l[c.id],h=u?wn(u,c):null,g=u?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}),u&&e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function Ho({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const o=m.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=Wo(p,a);return d},[t,a]);function l(){for(const d of t.steps){const p=o[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const i=t.steps.filter(d=>{var p;return((p=o[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),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((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=o[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void qs(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Go[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void qs(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(rt,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(rt,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(rt,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(rt,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:u=>n(d.id,{status:c.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const Ko={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 rt({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?Ko[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const mt="savedFlows";async function zo(){const t=await chrome.storage.local.get(mt);return Array.isArray(t[mt])?t[mt]:[]}async function Ys(t){await chrome.storage.local.set({[mt]:t})}function qo(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{zo().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 u=await Te(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){o("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){o("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},f=[g,...t];s(f),await Ys(f),o(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(u){o(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await me();if(u){o(`Replaying "${c.name}"…`);try{const h=await Te(u,{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 u=t.filter(h=>h.id!==c);s(u),await Ys(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick: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:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Qo(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(d=>d.split("-").map(Yo).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function Yo(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Jo(){const t=b(i=>i.baselineList),s=b(i=>i.tier),a=Kn[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{bt().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 H({type:"BASELINE_DELETE",componentId:i}),await bt()}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 d=Qo(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:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[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 Xo={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 ${Xo[t]}`,children:a})}const xt="wcagcheckr";function se(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Je(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 Zo(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function el(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 tl(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 sl(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 al(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 (${se(t.receipt.tsaName)}) — anchored ${se(Je(t.receipt.anchoredAt))}</td></tr>
|
|
18
|
+
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await H({type:"BASELINE_DELETE",componentId:s});const F=a.flatMap(ee=>ee.violations),W=a.flatMap(ee=>ee.announcements??[]),K=a.flatMap(ee=>ee.focusEvents??[]),pe=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:F,announcements:W,focusEvents:K});b.getState().setDelta(pe.delta);const ae=await X({type:"BASELINE_LIST"});b.getState().setBaselineList(ae.items),he.polite(`Baseline cleared for ${s}.`)}async function j(A,F=!1){if(a.length===0)return;if(A==="ai-prompt"){const{copyAiFixerPrompt:le}=await Ae(async()=>{const{copyAiFixerPrompt:de}=await import("./copy-ai-fixer-prompt-DxPDhVVS.js");return{copyAiFixerPrompt:de}},__vite__mapDeps([5,1,3]));await le({results:a,componentId:s,delta:F?void 0:t,siteCrawlReport:o});return}let W;if((A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet")&&s){const le=await chrome.storage.local.get("igtRuns"),xe=((le==null?void 0:le.igtRuns)??{})[s]??{};W=Object.values(xe)}const ae=await X({type:"EXPORT_REQUEST",format:A,results:a,delta:F?void 0:t??void 0,manualRuns:W,dismissedKeys:void 0,incompleteResolutions:void 0,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(A==="defense-bundle"||A==="evidence-bundle"||A==="deposition-packet"){const le=Nt(A,s);await ha()?at(ae.content,le):S({open:!0,format:A,content:ae.content,filename:le});return}if(A==="html-print"||A==="vpat"||A==="methodology-doc"||A==="conformance-crosswalk"||A==="executive-report"){Ue(ae.content);return}const ee=A==="json"?"application/json":A==="sarif"?"application/sarif+json":A==="ticket-bundle"?"text/markdown":"application/xml",U=A==="junit"?"xml":A==="ticket-bundle"?"md":A,Z=new Blob([ae.content],{type:ee}),Q=URL.createObjectURL(Z),ie=document.createElement("a");ie.href=Q,ie.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${U}`,ie.click(),URL.revokeObjectURL(Q)}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:re,disabled:!T,title:T?void 0:`Free tier limits you to ${V} 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"}),z&&e.jsx("button",{onClick:oe,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:()=>y(!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 O(),"aria-pressed":w,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:w?"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:w?"Hide badges":"Show badges 🎯"}),w&&E&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[E.rendered," of ",E.requested," rendered",E.clustered>0?` · ${E.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void B(),"aria-pressed":M,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:M?"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:M?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(xo,{disabled:!L,onExport:j,onAccessibilityStatement:()=>C(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!T&&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 A=$t(t.new),F=$t(t.persistent),W=$t(t.fixed),K=[...A.review,...F.review];return e.jsxs(e.Fragment,{children:[e.jsx(He,{title:"New",violations:A.findings,count:A.findings.length,accent:"red",actions:[...D&&l&&A.findings.length>0?[{label:"File GitHub issue",onClick:()=>uo(l,s,A.findings)}]:[],...D&&d&&A.findings.length>0?[{label:"File Jira issue",onClick:()=>po(d,s,A.findings)}]:[],...D&&c&&A.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>ho(c,s,A.findings)}]:[],...D&&h&&A.findings.length>0?[{label:"File GitLab issue",onClick:()=>mo(h,s,A.findings)}]:[]]}),e.jsx(He,{title:"Persistent",violations:F.findings,count:F.findings.length,accent:"slate"}),e.jsx(He,{title:"Fixed",violations:W.findings,count:t.fixedCount,accent:"green"}),K.length>0&&e.jsx(He,{title:"Needs review (does not affect grade)",violations:K,count:K.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(He,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),k&&e.jsx(Ea,{open:k.open,onClose:()=>S(null),format:k.format,content:k.content,filename:k.filename}),e.jsx(Ra,{open:x,onClose:()=>C(!1),results:a}),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"})]})]}),R&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",R.chromeStorageKeysCleared," chrome.storage key",R.chromeStorageKeysCleared===1?"":"s"," + ",R.indexedDbsCleared.length," database",R.indexedDbsCleared.length===1?"":"s",".",R.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",R.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:R?e.jsx("button",{type:"button",onClick:()=>{y(!1),I(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:()=>y(!1),disabled:N,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()=>{$(!0);try{const A=await ro();I(A),await St(),he.polite("Audit data reset. Ready for a fresh scan.")}catch(A){I({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[A instanceof Error?A.message:String(A)]})}finally{$(!1)}},disabled:N,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:N?"Resetting…":"Reset everything"})]})})]})})]})}const co={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 He({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 ${co[n]} ${o?"cursor-pointer select-none":""}`,onClick:o?()=>i(d=>!d):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(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),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((d,p)=>e.jsx(st,{violation:d,alreadyAcknowledged:!0},p)):Xi(s).map(d=>e.jsx(Ji,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function uo(t,s,a){if(a.length===0)return;const{url:n}=eo(t,s,a);kt(n)}function po(t,s,a){if(a.length===0)return;const{url:n}=to(t,s,a);kt(n)}function ho(t,s,a){if(a.length===0)return;const{url:n}=so(t,s,a);kt(n)}function mo(t,s,a){if(a.length===0)return;const{url:n}=ao(t,s,a);kt(n)}function xo({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,o]=m.useState(!1),[l,i]=m.useState(!1);function d(p){o(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>o(p=>!p),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>o(!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:l,onChange:p=>i(p.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(we,{onClick:()=>d("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(we,{onClick:()=>d("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(we,{onClick:()=>d("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:()=>d("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:()=>d("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(we,{onClick:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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:()=>d("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,{onClick:()=>{o(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function we({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const go="2024-07-25",fo="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.",$a=[{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($a.flatMap(t=>t.wcag2Criteria));function bo(t,s){return $a.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 vo={perceive:"Perceive",operate:"Operate",understand:"Understand",robust:"Robust"};function La(){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 u=c.axeRulesEvaluated;if(u){for(const h of u.passed)r.add(h.wcagCriterion);for(const h of u.inapplicable)r.add(h.wcagCriterion);for(const h of u.incomplete)r.add(h.wcagCriterion)}}const o=bo(n,r),l=new Map;for(const c of o){const u=l.get(c.outcome.category)??[];u.push(c),l.set(c.outcome.category,u)}const i=o.filter(c=>c.status==="clean").length,d=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:go}),"."," ",fo]})]}),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:[d," 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 u=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:[vo[c]," · ",u.length]}),e.jsx("ul",{className:"divide-y divide-slate-100",children:u.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(yo,{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 yo({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 wo=[{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"}],jo={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 No(){const t=b(u=>u.results),s=b(u=>u.componentId),a=b(u=>u.findingsLens),n=b(u=>u.setFindingsLens),r=b(u=>u.setView),o=b(u=>u.status),[l,i]=m.useState({});m.useEffect(()=>{if(!s)return;let u=!1;return(async()=>{const h=await Re(s),g=await De([s]);if(u)return;const f=new Set(g.map(N=>N.criterionId)),y={};for(const N of h){const $=f.has(N.criterionId)?"pass":N.verdict;N.criterionId==="2.4.3"?y.focusOrder=$:N.criterionId==="2.1.2"?y.keyboardTrap=$:N.criterionId==="2.4.7"?y.focusVisible=$:N.criterionId==="1.3.2"?y.readingOrder=$:N.criterionId==="1.4.11"&&(y.nonTextContrast=$)}i(y)})(),()=>{u=!0}},[s]);const d=os(t),[p,c]=m.useState([]);return m.useEffect(()=>{if(!s){c([]);return}let u=!1;return chrome.storage.local.get("igtRuns").then(h=>{if(u)return;const f=((h==null?void 0:h.igtRuns)??{})[s]??{};c(Object.values(f))}),()=>{u=!0}},[s]),t.length===0?e.jsxs("div",{className:"p-4",children:[e.jsx(zs,{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(zs,{setView:r}),e.jsx(So,{results:t,interactiveVerdicts:l,manualRuns:p,aiResolvedFails:d}),e.jsx(ko,{results:t}),e.jsx(Ao,{lens:a,setLens:n}),e.jsx(Co,{lens:a,results:t,componentId:s,interactiveVerdicts:l,aiResolvedFails:d})]})}function zs({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 ko({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 d(){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:()=>d(),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 So({results:t,interactiveVerdicts:s,manualRuns:a,aiResolvedFails:n}){var f,y,N,$;const r=t.flatMap(R=>R.violations),o=b(R=>R.lastAuditWallClockMs),l=b(R=>R.acknowledgedKeys),i=b(R=>R.dismissedKeys),p=Jt({violations:r,auditRan:!0,manualRuns:a,workflows:fe,heuristicCounts:{tabOrder:((y=(f=t[0])==null?void 0:f.tabOrderIssues)==null?void 0:y.length)??0,readingOrder:(($=(N=t[0])==null?void 0:N.readingOrderIssues)==null?void 0:$.length)??0},interactiveAuditVerdicts:s,aiResolvedFails:n.map(R=>({ruleId:R.ruleId,impact:"serious",selector:R.selector}))}).overallLetter,c=Na(r,n,l,i),u=Wr(r,n,l,i),h=t.length,g=o??t.reduce((R,I)=>R+I.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 ${jo[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-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&&u.length>0&&e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug mt-0.5",children:["across ",u.length," WCAG criterion",u.length===1?"":"a"," (",u.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 Ao({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:wo.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 Co({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(Io,{componentId:a,results:s}),e.jsx($o,{componentId:a}),e.jsx(Jr,{violations:s.flatMap(i=>i.violations),componentId:a,hideOverallHeader:!0}),e.jsx(Oo,{pageUrl:((o=s[0])==null?void 0:o.pageUrl)??((l=s[0])==null?void 0:l.scope)??""}),e.jsx(Lo,{})]}):t==="per-area"?e.jsx(_i,{results:s,interactiveVerdicts:n,aiResolvedFails:r}):t==="violations"?e.jsx(_o,{results:s}):t==="activity"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ia,{})}):t==="delta"?e.jsx("div",{className:"-mx-3",children:e.jsx(Ta,{})}):t==="wcag3"?e.jsx("div",{className:"-mx-3",children:e.jsx(La,{})}):null}const wt={critical:0,serious:1,moderate:2,minor:3};function Bt(t){return`${_e(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Io({componentId:t,results:s}){var f,y;const a=b(N=>N.setFindingsLens),[n,r]=m.useState({}),[o,l]=m.useState({}),[i,d]=m.useState(0);m.useEffect(()=>{let N=!1;return(async()=>{if(!t){r({}),l({});return}const $=await Re(t);if(N)return;const R={};for(const S of $)R[S.criterionId]=S;r(R);const I=await De([t]);if(N)return;const k={};for(const S of I)k[`${S.criterionId}::${S.pageUrl}`]=S;l(k)})(),()=>{N=!0}},[t,i]);const p=((f=s[0])==null?void 0:f.pageUrl)??((y=s[0])==null?void 0:y.scope)??"",c=ht.map(N=>({crit:N,record:n[N.id]??null})).filter(({record:N})=>N&&(N.verdict==="fail"||N.verdict==="uncertain")).filter(({crit:N})=>!o[`${N.id}::${p}`]),u=new Set,h=[];for(const N of s)for(const $ of N.violations){if($.needsReview)continue;const R=_e($.ruleId,$.target.selector);u.has(R)||(u.add(R),h.push($))}h.sort((N,$)=>(wt[N.impact]??99)-(wt[$.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:N,record:$})=>e.jsx(Eo,{componentId:t??"",pageUrl:p,criterionId:N.id,label:N.label,blurb:N.blurb,record:$,onChanged:()=>d(R=>R+1)},`wt::${N.id}`)),h.map(N=>e.jsx(Ro,{violation:N,onOpen:()=>a("violations")},`axe::${Bt(N)}`))]})]})}function Eo({componentId:t,pageUrl:s,criterionId:a,label:n,blurb:r,record:o,onChanged:l}){const[i,d]=m.useState(!1),[p,c]=m.useState(""),[u,h]=m.useState(!1),[g,f]=m.useState(null),[y,N]=m.useState(!1),[$,R]=m.useState(!1),I=ls(),k=o.verdict,S=k==="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 Zt({componentId:t,criterionId:a,pageUrl:s,note:p.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:k}),l()}catch(w){f(w instanceof Error?w.message:String(w))}finally{h(!1)}}async function C(){var w;R(!0),f(null);try{const E=(w=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:w.id;if(!E){f("No active tab — open the audited page first."),R(!1);return}const M=await H({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:a,tabId:E,componentId:t,pageUrl:s});M.ok||f(M.error??"Re-run failed."),l()}catch(v){f(v instanceof Error?v.message:String(v))}finally{R(!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 ${S}`,children:k}),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:k==="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:()=>N(w=>!w),className:"text-[10px] px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:y?"Hide AI reasoning":"Show AI reasoning"}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:$||!I,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:I?"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:$?"Re-running…":"Re-run after fix"}),e.jsx("button",{type:"button",onClick:()=>{d(w=>!w),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"})]}),y&&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:w=>c(w.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:u,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:u?"Saving…":"Confirm verification"}),e.jsx("button",{type:"button",onClick:()=>{d(!1),c(""),f(null)},disabled:u,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 Ro({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 ht=[{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)."}],To={pass:"bg-emerald-500 text-white",fail:"bg-rose-600 text-white",uncertain:"bg-amber-500 text-slate-900"};function $o({componentId:t}){const[s,a]=m.useState({}),[n,r]=m.useState({});m.useEffect(()=>{let u=!1;return(async()=>{if(!t){a({}),r({});return}const[h,g]=await Promise.all([Re(t),De([t])]);if(u)return;const f={};for(const N of h)f[N.criterionId]=N;a(f);const y={};for(const N of g)y[N.criterionId]=N;r(y)})(),()=>{u=!0}},[t]);const o={};for(const[u,h]of Object.entries(s))o[u]=n[u]?"pass":h.verdict;const l=Object.values(o).length,i=Object.values(o).filter(u=>u==="pass").length,d=Object.values(o).filter(u=>u==="fail").length,p=Object.values(o).filter(u=>u==="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 ${ht.length} criteria pending human verification`:`${l}/${ht.length} · ${i} pass · ${d} 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:ht.map(u=>{const h=s[u.id],g=n[u.id],f=h==null?void 0:h.verdict,y=g?"pass":f,N=h?Pt(h.reasoning):!1,$=h?la(h.reasoning):!1,R=h?Gt(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":y?To[y]:"bg-slate-200 text-slate-500"}`,title:g?`Human verified at ${new Date(g.acknowledgedAt).toLocaleString()} — note: "${g.note}". (AI verdict was: ${f})`:y?`AI verdict: ${y}${R?` (cascade ${R})`:""}`:"AI did not produce a verdict on this criterion",children:g?"✓ verified":y||"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:u.id}),u.label,$&&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:u.blurb}),N&&!$&&!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,"."]})]})]})]},u.id)})})]})}function Lo(){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 Uo({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 De([t]).then(d=>{if(i)return;const p={};for(const c of d)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(cs,{componentId:t??"",pageUrl:i.pageUrl,criterionId:i.criterionId,record:i,onChanged:()=>r(d=>d+1),ack:o[i.criterionId]??null})},i.criterionId))]})}function _o({results:t}){const s=b(i=>i.dismissedKeys),a=b(i=>i.componentId),n=new Set,r=[];for(const i of t)for(const d of i.violations){if(s.has(`violation::${d.matchKey}`))continue;const p=Bt(d);n.has(p)||(n.add(p),r.push(d))}r.sort((i,d)=>{const p=wt[i.impact]??99,c=wt[d.impact]??99;return p-c});const[o,l]=m.useState([]);return m.useEffect(()=>{if(!a){l([]);return}let i=!1;return Re(a).then(d=>{i||l(d.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(Uo,{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(st,{violation:i},Bt(i)))]})}const Do={"deposition-packet":"Deposition packet · court-grade","defense-bundle":"Defense bundle · locally anchored","html-print":"HTML print · printable","ai-prompt":"AI fix prompt · markdown"};function Oo({pageUrl:t}){const s=b(p=>p.tier),a=Yt(s),n=Ne(s,"autoExportAuditReports"),[r,o]=m.useState(null),[l,i]=m.useState(null);if(m.useEffect(()=>{let p=!1;return(async()=>{const c=await pa();if(p||o(c),t){const u=await Qn(t);p||i(u)}})(),()=>{p=!0}},[t]),a||!n||!r||!r.enabled)return null;const d=r.formats.length===1?Do[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:d})]}),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 Ht="igtRuns";async function Fo(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 tt(r,l.map(i=>({key:et(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 tt(r,l.map(i=>({key:Ze(i.selector),reason:o,snippet:`${i.selector} — ${i.textSnippet||"(no text)"}`})))}}const Mo={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"}},Po={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"}},Go={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function qs(t,s){const a=await me();if(!a)return;const n=s?Mo[t]:Po[t];try{await ve(a,n)}catch{}}async function Vo(){const s=(await chrome.storage.local.get(Ht))[Ht];return s&&typeof s=="object"?s:{}}async function Qs(t){await chrome.storage.local.set({[Ht]:t})}function Wo(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 Bo(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=m.useState({}),[r,o]=m.useState(null);if(m.useEffect(()=>{Vo().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,u,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)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),Qs(g),h.status==="pass"){const y=fe.find($=>$.id===c),N=y==null?void 0:y.steps.find($=>$.id===u);N!=null&&N.autoDismissActivity&&Fo(N.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[c];const h={...a,[t]:u};n(h),Qs(h)}const p=fe.find(c=>c.id===r);if(p){const c=l[p.id];return e.jsx(Ho,{workflow:p,run:c,results:s,onAnswer:(u,h)=>i(p.id,u,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 u=l[c.id],h=u?wn(u,c):null,g=u?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}),u&&e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function Ho({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const o=m.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=Wo(p,a);return d},[t,a]);function l(){for(const d of t.steps){const p=o[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const i=t.steps.filter(d=>{var p;return((p=o[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),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((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=o[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void qs(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Go[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void qs(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(rt,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(rt,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(rt,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(rt,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:u=>n(d.id,{status:c.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const Ko={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 rt({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?Ko[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const mt="savedFlows";async function zo(){const t=await chrome.storage.local.get(mt);return Array.isArray(t[mt])?t[mt]:[]}async function Ys(t){await chrome.storage.local.set({[mt]:t})}function qo(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,o]=m.useState(null);m.useEffect(()=>{zo().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 u=await Te(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){o("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){o("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},f=[g,...t];s(f),await Ys(f),o(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(u){o(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await me();if(u){o(`Replaying "${c.name}"…`);try{const h=await Te(u,{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 u=t.filter(h=>h.id!==c);s(u),await Ys(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick: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:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Qo(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(d=>d.split("-").map(Yo).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||o}}function Yo(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Jo(){const t=b(i=>i.baselineList),s=b(i=>i.tier),a=Kn[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,o]=m.useState(!1);if(m.useEffect(()=>{bt().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 H({type:"BASELINE_DELETE",componentId:i}),await bt()}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 d=Qo(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:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[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 Xo={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 ${Xo[t]}`,children:a})}const xt="wcagcheckr";function se(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Je(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 Zo(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function el(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 tl(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 sl(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 al(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 (${se(t.receipt.tsaName)}) — anchored ${se(Je(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>${se(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
20
20
|
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${se(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${se(xt)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
21
21
|
<article class="entry">
|
|
@@ -243,9 +243,9 @@ Future audits will treat every detected violation as new (no delta filtering). T
|
|
|
243
243
|
|
|
244
244
|
${K instanceof Error?K.message:String(K)}
|
|
245
245
|
|
|
246
|
-
Fix or clear the field and try again.`),null}return{include:j,exclude:A}}function V(j,A){return j<5?!0:window.confirm(A?`Verify-fixes mode: ${j} crawled pages, but walkthroughs that already passed or were human-acked will be skipped. Estimated wall-clock: ~${Math.ceil(j*2.5)} minutes (vs. ${j*5} for a full re-crawl). Proceed?`:`Each of the ${j} pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this to take roughly ${j*5} minutes. Proceed?`)}function z(j=!1){if(!f)return;const A=D();if(A){if(p&&!j){b.getState().setSiteCrawlError(null),b.getState().setCrawlDiscoveryStatus("discovering"),pr({type:"START_CRAWL_DISCOVERY",startUrl:f,maxPages:N,...A.include?{includeRegex:A.include}:{},...A.exclude?{excludeRegex:A.exclude}:{}});return}V(N,j)&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),je({type:"START_SITE_CRAWL",startUrl:f,maxPages:N,...A.include?{includeRegex:A.include}:{},...A.exclude?{excludeRegex:A.exclude}:{},...j?{verifyFixesOnly:!0}:{}}))}}function T(){const j=l.filter(A=>h.has(A));if(j.length===0){window.alert("Keep at least one page to audit.");return}V(j.length,!1)&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),b.getState().resetCrawlDiscovery(),je({type:"START_SITE_CRAWL",startUrl:f,urls:j}))}function re(){H({type:"CANCEL_CRAWL_DISCOVERY"}),b.getState().resetCrawlDiscovery()}function oe(){H({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),s!=="running"&&o==="idle"&&e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 space-y-1.5",children:[e.jsx("label",{htmlFor:"crawl-preset",className:"block text-[11px] font-semibold text-slate-700",children:"Audit depth (state-matrix preset)"}),e.jsx("select",{id:"crawl-preset",value:k,onChange:j=>x(j.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5",title:"Each crawled page runs this preset's state matrix. Full = pseudo-states × themes × directions × breakpoints (slowest, most thorough). Quick = single state (fastest). Set this once and every page in the crawl uses it.",children:R.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug",children:["Each crawled page runs the same single-page audit pipeline you see on the Dashboard. This selector overrides the persisted preset for BOTH surfaces. AI walkthroughs + disabled-rules list are still in ",e.jsx("strong",{children:"Settings → AI"})," and ",e.jsx("strong",{children:"Settings → State Matrix"}),"."]})]}),s!=="running"&&o==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:f,onChange:j=>y(j.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:N,onChange:j=>q(Math.min(200,Math.max(1,parseInt(j.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:C,onChange:j=>O(j.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:v,onChange:j=>B(j.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsxs("label",{className:"flex items-start gap-2 text-[11px] text-slate-700 bg-slate-50 border border-slate-200 rounded px-2.5 py-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:j=>L(j.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Remember these settings."})," Keep max pages + the include/exclude filters for next time (the audit-depth preset is always remembered)."]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-[11px] text-slate-700 bg-slate-50 border border-slate-200 rounded px-2.5 py-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:j=>u(j.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Review pages before auditing."})," First list every page that would be crawled, then let me remove any I don't want before the audit runs. Turn off to start auditing immediately (pages are discovered as it goes)."]})]}),e.jsx("button",{type:"button",onClick:()=>z(!1),disabled:!f,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:p?"Find pages to audit":"Start whole-site audit"}),(()=>{const j=n&&n.startUrl===f,A=!f||!j;return e.jsxs("button",{type:"button",onClick:()=>z(!0),disabled:A,className:"w-full text-sm px-4 py-2.5 border border-emerald-400 text-emerald-700 bg-white rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed font-medium",title:f?j?"Re-crawl after fixes/acks. Walkthroughs that previously passed or were human-acked are skipped per page — saves AI calls + wall-clock without changing axe coverage.":"Run a full crawl on this URL first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.":"Enter a start URL first.",children:["Verify fixes only (skip passed walkthroughs)",!j&&f&&e.jsx("span",{className:"block text-[10px] text-emerald-600 font-normal mt-0.5",children:"Run a full crawl first to enable this."})]})})()]}),o==="discovering"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Finding pages…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-1.5",children:[e.jsxs("p",{className:"text-xs",children:[e.jsx("strong",{children:i})," page",i===1?"":"s"," found so far"]}),d&&e.jsx("p",{className:"text-[11px] font-mono break-all text-slate-600",children:d}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:"Loading each page to read its links — no audit yet. You'll get to prune the list before anything is audited."})]}),e.jsx("button",{type:"button",onClick:re,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),o==="reviewing"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Review pages to audit"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Found ",e.jsx("strong",{children:l.length})," page",l.length===1?"":"s",". Uncheck any you don't want, then audit the rest. ",e.jsx("strong",{children:h.size})," selected."]}),l.length===0?e.jsx("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900",children:"No pages were discovered from this URL. Check the start URL and any include/exclude filters, then try again."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>g(new Set(l)),className:"text-[11px] text-brand-600 hover:underline",children:"Select all"}),e.jsx("span",{className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:()=>g(new Set),className:"text-[11px] text-brand-600 hover:underline",children:"Select none"})]}),e.jsx("ul",{className:"border border-slate-200 rounded max-h-72 overflow-y-auto divide-y divide-slate-100 bg-white",children:l.map(j=>e.jsx("li",{children:e.jsxs("label",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11px] cursor-pointer hover:bg-slate-50",children:[e.jsx("input",{type:"checkbox",checked:h.has(j),onChange:A=>{g(F=>{const W=new Set(F);return A.target.checked?W.add(j):W.delete(j),W})},className:"mt-0.5"}),e.jsx("span",{className:"font-mono break-all text-slate-700",children:j})]})},j))})]}),e.jsxs("button",{type:"button",onClick:T,disabled:h.size===0,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:["Audit ",h.size," page",h.size===1?"":"s"]}),e.jsx("button",{type:"button",onClick:re,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel — back to crawl settings"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:oe,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(cl,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function cl({report:t}){function s(){Ae(async()=>{const{renderSiteReportHtml:w}=await import("./site-report-renderer-D2duZR-v.js");return{renderSiteReportHtml:w}},__vite__mapDeps([6,0,1,2,3,4])).then(({renderSiteReportHtml:w})=>{const v=w(t);Ue(v)})}const[a,n]=m.useState(!1),[r,o]=m.useState({state:"idle"});async function l(){if(window.confirm(`Save the current crawl as the site baseline?
|
|
246
|
+
Fix or clear the field and try again.`),null}return{include:j,exclude:A}}function V(j,A){return j<5?!0:window.confirm(A?`Verify-fixes mode: ${j} crawled pages, but walkthroughs that already passed or were human-acked will be skipped. Estimated wall-clock: ~${Math.ceil(j*2.5)} minutes (vs. ${j*5} for a full re-crawl). Proceed?`:`Each of the ${j} pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this to take roughly ${j*5} minutes. Proceed?`)}function z(j=!1){if(!f)return;const A=D();if(A){if(p&&!j){b.getState().setSiteCrawlError(null),b.getState().setCrawlDiscoveryStatus("discovering"),pr({type:"START_CRAWL_DISCOVERY",startUrl:f,maxPages:N,...A.include?{includeRegex:A.include}:{},...A.exclude?{excludeRegex:A.exclude}:{}});return}V(N,j)&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),je({type:"START_SITE_CRAWL",startUrl:f,maxPages:N,...A.include?{includeRegex:A.include}:{},...A.exclude?{excludeRegex:A.exclude}:{},...j?{verifyFixesOnly:!0}:{}}))}}function T(){const j=l.filter(A=>h.has(A));if(j.length===0){window.alert("Keep at least one page to audit.");return}V(j.length,!1)&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),b.getState().resetCrawlDiscovery(),je({type:"START_SITE_CRAWL",startUrl:f,urls:j}))}function re(){H({type:"CANCEL_CRAWL_DISCOVERY"}),b.getState().resetCrawlDiscovery()}function oe(){H({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Heads-up if you're logged in."})," ","The crawler follows whatever links appear in the rendered page — so if you're authenticated to the target site, it will walk into the authenticated nav (admin pages, dashboards, account pages) and try to audit them. Some of those may 404 or behave unexpectedly without specific context. For a clean public-site crawl, log out first or run from an incognito window."]}),s!=="running"&&o==="idle"&&e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2.5 py-2 space-y-1.5",children:[e.jsx("label",{htmlFor:"crawl-preset",className:"block text-[11px] font-semibold text-slate-700",children:"Audit depth (state-matrix preset)"}),e.jsx("select",{id:"crawl-preset",value:k,onChange:j=>x(j.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5",title:"Each crawled page runs this preset's state matrix. Full = pseudo-states × themes × directions × breakpoints (slowest, most thorough). Quick = single state (fastest). Set this once and every page in the crawl uses it.",children:R.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug",children:["Each crawled page runs the same single-page audit pipeline you see on the Dashboard. This selector overrides the persisted preset for BOTH surfaces. AI walkthroughs + disabled-rules list are still in ",e.jsx("strong",{children:"Settings → AI"})," and ",e.jsx("strong",{children:"Settings → State Matrix"}),"."]})]}),s!=="running"&&o==="idle"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:f,onChange:j=>y(j.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:N,onChange:j=>q(Math.min(200,Math.max(1,parseInt(j.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your configured single-page pipeline — see Settings → State Matrix for what that means."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-include",className:"block text-[11px] text-slate-500 mb-1",children:"Include only URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-include",type:"text",value:C,onChange:j=>O(j.target.value),placeholder:"^https://example\\.com/products/",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsxs("p",{className:"text-[10px] text-slate-500 mt-1",children:["When set, only URLs matching this regex get crawled. Useful for scoping a crawl to one section, e.g. ",e.jsx("code",{children:"/blog/"}),"."]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-exclude",className:"block text-[11px] text-slate-500 mb-1",children:"Exclude URLs matching (regex, optional)"}),e.jsx("input",{id:"crawl-exclude",type:"text",value:v,onChange:j=>B(j.target.value),placeholder:"/admin|/dashboard|/account|/login",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"URLs matching this regex are skipped. Helpful when logged in to the target site — keep the crawl on the public surface."})]}),e.jsxs("label",{className:"flex items-start gap-2 text-[11px] text-slate-700 bg-slate-50 border border-slate-200 rounded px-2.5 py-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:j=>L(j.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Remember these settings."})," Keep max pages + the include/exclude filters for next time (the audit-depth preset is always remembered)."]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-[11px] text-slate-700 bg-slate-50 border border-slate-200 rounded px-2.5 py-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:j=>u(j.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Review pages before auditing."})," First list every page that would be crawled, then let me remove any I don't want before the audit runs. Turn off to start auditing immediately (pages are discovered as it goes)."]})]}),e.jsx("button",{type:"button",onClick:()=>z(!1),disabled:!f,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:p?"Find pages to audit":"Start whole-site audit"}),(()=>{const j=n&&n.startUrl===f,A=!f||!j;return e.jsxs("button",{type:"button",onClick:()=>z(!0),disabled:A,className:"w-full text-sm px-4 py-2.5 border border-emerald-400 text-emerald-700 bg-white rounded hover:bg-emerald-50 disabled:opacity-50 disabled:cursor-not-allowed font-medium",title:f?j?"Re-crawl after fixes/acks. Walkthroughs that previously passed or were human-acked are skipped per page — saves AI calls + wall-clock without changing axe coverage.":"Run a full crawl on this URL first. Verify-fixes mode reuses prior walkthrough verdicts + acks; without prior data there's nothing to skip.":"Enter a start URL first.",children:["Verify fixes only (skip passed walkthroughs)",!j&&f&&e.jsx("span",{className:"block text-[10px] text-emerald-600 font-normal mt-0.5",children:"Run a full crawl first to enable this."})]})})()]}),o==="discovering"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Finding pages…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-1.5",children:[e.jsxs("p",{className:"text-xs",children:[e.jsx("strong",{children:i})," page",i===1?"":"s"," found so far"]}),d&&e.jsx("p",{className:"text-[11px] font-mono break-all text-slate-600",children:d}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:"Loading each page to read its links — no audit yet. You'll get to prune the list before anything is audited."})]}),e.jsx("button",{type:"button",onClick:re,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),o==="reviewing"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Review pages to audit"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Found ",e.jsx("strong",{children:l.length})," page",l.length===1?"":"s",". Uncheck any you don't want, then audit the rest. ",e.jsx("strong",{children:h.size})," selected."]}),l.length===0?e.jsx("div",{className:"border border-amber-200 bg-amber-50 rounded px-2.5 py-2 text-[11px] text-amber-900",children:"No pages were discovered from this URL. Check the start URL and any include/exclude filters, then try again."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>g(new Set(l)),className:"text-[11px] text-brand-600 hover:underline",children:"Select all"}),e.jsx("span",{className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:()=>g(new Set),className:"text-[11px] text-brand-600 hover:underline",children:"Select none"})]}),e.jsx("ul",{className:"border border-slate-200 rounded max-h-72 overflow-y-auto divide-y divide-slate-100 bg-white",children:l.map(j=>e.jsx("li",{children:e.jsxs("label",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11px] cursor-pointer hover:bg-slate-50",children:[e.jsx("input",{type:"checkbox",checked:h.has(j),onChange:A=>{g(F=>{const W=new Set(F);return A.target.checked?W.add(j):W.delete(j),W})},className:"mt-0.5"}),e.jsx("span",{className:"font-mono break-all text-slate-700",children:j})]})},j))})]}),e.jsxs("button",{type:"button",onClick:T,disabled:h.size===0,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:["Audit ",h.size," page",h.size===1?"":"s"]}),e.jsx("button",{type:"button",onClick:re,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel — back to crawl settings"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:oe,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(cl,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function cl({report:t}){function s(){Ae(async()=>{const{renderSiteReportHtml:w}=await import("./site-report-renderer-CtsQnMT1.js");return{renderSiteReportHtml:w}},__vite__mapDeps([6,0,1,2,3,4])).then(({renderSiteReportHtml:w})=>{const v=w(t);Ue(v)})}const[a,n]=m.useState(!1),[r,o]=m.useState({state:"idle"});async function l(){if(window.confirm(`Save the current crawl as the site baseline?
|
|
247
247
|
|
|
248
|
-
Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){o({state:"running",current:0,total:t.pagesAudited});try{const E=(await X({type:"SETTINGS_GET",key:"stateMatrix"})).data??es,_=await Xe();if(!_||_.length===0){o({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let M=0,q=0;for(let O=0;O<_.length;O++){const B=_[O];if(o({state:"running",current:O,total:_.length}),B.error||B.results.length===0||!B.componentId){q++;continue}try{const L=B.results.flatMap(T=>T.violations),D=B.results.flatMap(T=>T.announcements??[]),V=B.results.flatMap(T=>T.focusEvents??[]),z=B.results[0];await H({type:"BASELINE_SET",componentId:B.componentId,violations:L,announcements:D,focusEvents:V,snapshotMeta:{url:B.url,axeVersion:z.axeVersion,matrixConfig:E,capturedAt:new Date().toISOString()}}),M++}catch(L){console.warn("[site-crawl-panel] BASELINE_SET failed for",B.url,L),q++}}try{const O=await X({type:"BASELINE_LIST"});b.getState().setBaselineList(O.items)}catch{}o({state:"done",saved:M,failed:q})}catch(v){o({state:"error",message:v instanceof Error?v.message:String(v)})}}}const[i,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[g,f]=m.useState(!1),y=b(w=>w.tier),N=Ne(y,"exportPreLitigationReport");async function $(){c(null);try{const w=await Xe();if(!w||w.length===0){c("No per-URL results found. Re-run the crawl.");return}if(!w.some(E=>{var _;return(((_=E.results)==null?void 0:_.length)??0)>0})){c("Crawled pages have no audit results to use.");return}h(!0)}catch(w){c(w instanceof Error?w.message:String(w))}}const[R,I]=m.useState({state:"idle"});async function k(){var q,O,B;const{createZip:w}=await Ae(async()=>{const{createZip:L}=await import("./zip-encoder-CtULHXx_.js");return{createZip:L}},[]),{renderSiteReportHtml:v}=await Ae(async()=>{const{renderSiteReportHtml:L}=await import("./site-report-renderer-
|
|
248
|
+
Each of the ${t.pagesAudited} crawled page${t.pagesAudited===1?"":"s"} will be saved as its own baseline. Future audits + re-crawls will show delta against these snapshots. Any existing baselines for these same components will be overwritten.`)){o({state:"running",current:0,total:t.pagesAudited});try{const E=(await X({type:"SETTINGS_GET",key:"stateMatrix"})).data??es,_=await Xe();if(!_||_.length===0){o({state:"error",message:"No per-URL results found in storage. Re-run the crawl."});return}let M=0,q=0;for(let O=0;O<_.length;O++){const B=_[O];if(o({state:"running",current:O,total:_.length}),B.error||B.results.length===0||!B.componentId){q++;continue}try{const L=B.results.flatMap(T=>T.violations),D=B.results.flatMap(T=>T.announcements??[]),V=B.results.flatMap(T=>T.focusEvents??[]),z=B.results[0];await H({type:"BASELINE_SET",componentId:B.componentId,violations:L,announcements:D,focusEvents:V,snapshotMeta:{url:B.url,axeVersion:z.axeVersion,matrixConfig:E,capturedAt:new Date().toISOString()}}),M++}catch(L){console.warn("[site-crawl-panel] BASELINE_SET failed for",B.url,L),q++}}try{const O=await X({type:"BASELINE_LIST"});b.getState().setBaselineList(O.items)}catch{}o({state:"done",saved:M,failed:q})}catch(v){o({state:"error",message:v instanceof Error?v.message:String(v)})}}}const[i,d]=m.useState(null),[p,c]=m.useState(null),[u,h]=m.useState(!1),[g,f]=m.useState(!1),y=b(w=>w.tier),N=Ne(y,"exportPreLitigationReport");async function $(){c(null);try{const w=await Xe();if(!w||w.length===0){c("No per-URL results found. Re-run the crawl.");return}if(!w.some(E=>{var _;return(((_=E.results)==null?void 0:_.length)??0)>0})){c("Crawled pages have no audit results to use.");return}h(!0)}catch(w){c(w instanceof Error?w.message:String(w))}}const[R,I]=m.useState({state:"idle"});async function k(){var q,O,B;const{createZip:w}=await Ae(async()=>{const{createZip:L}=await import("./zip-encoder-CtULHXx_.js");return{createZip:L}},[]),{renderSiteReportHtml:v}=await Ae(async()=>{const{renderSiteReportHtml:L}=await import("./site-report-renderer-CtsQnMT1.js");return{renderSiteReportHtml:L}},__vite__mapDeps([6,0,1,2,3,4])),E=[{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}],_=[],M=[];I({state:"running",current:"site-report.html",doneCount:0,totalCount:E.length+3});try{try{const j=v(t);M.push({name:"site-report.html",content:j})}catch{_.push("site-report.html")}I(j=>j.state==="running"?{...j,current:"ai-fix-prompt.md",doneCount:j.doneCount+1}:j);try{const j=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]});j!=null&&j.content&&j.content.length>50?M.push({name:"ai-fix-prompt.md",content:j.content}):_.push("ai-fix-prompt.md")}catch{_.push("ai-fix-prompt.md")}for(const{format:j,filename:A}of E){I(F=>F.state==="running"?{...F,current:A,doneCount:F.doneCount+1}:F);try{const F=await X({type:"EXPORT_REQUEST",format:j,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});F!=null&&F.content&&F.content.length>50?M.push({name:A,content:F.content}):_.push(A)}catch(F){console.warn(`[bulk-export] ${j} failed`,F),_.push(A)}}I(j=>j.state==="running"?{...j,current:"pre-litigation-report.html",doneCount:j.doneCount+1}:j);try{const j=await gt();if(j.length>0){const A=typeof chrome<"u"&&((B=(O=(q=chrome.runtime)==null?void 0:q.getManifest)==null?void 0:O.call(q))==null?void 0:B.version)||"1.0.0",{buildPreLitigationReportHtml:F}=await Ae(async()=>{const{buildPreLitigationReportHtml:K}=await Promise.resolve().then(()=>rl);return{buildPreLitigationReportHtml:K}},void 0),W=F({entries:j,extensionVersion:A});M.push({name:"pre-litigation-report.html",content:W})}else _.push("pre-litigation-report.html (no forensic entries yet)")}catch{_.push("pre-litigation-report.html")}const L=`wcagcheckr — Site-wide compliance bundle
|
|
249
249
|
========================================
|
|
250
250
|
|
|
251
251
|
Generated: ${new Date().toISOString()}
|
|
@@ -265,7 +265,7 @@ Contents:
|
|
|
265
265
|
`:"")+`Each HTML report opens directly in a browser. Use
|
|
266
266
|
Ctrl+P → Save as PDF in the report you want sealed for legal
|
|
267
267
|
or compliance submission.
|
|
268
|
-
`;if(M.unshift({name:"README.txt",content:L}),M.length===0){I({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const D=w(M),V=new Date().toISOString().slice(0,10),z=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",T=`wcagcheckr-site-bundle-${V}-${z}.zip`,re=URL.createObjectURL(D),oe=document.createElement("a");oe.href=re,oe.download=T,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),setTimeout(()=>URL.revokeObjectURL(re),3e4),I({state:"done",included:M.length,skipped:_})}catch(L){I({state:"error",message:L instanceof Error?L.message:String(L)})}}async function S(){var w,v,E;f(!0),c(null);try{const _=await gt();if(_.length===0){c("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const M=typeof chrome<"u"&&((E=(v=(w=chrome.runtime)==null?void 0:w.getManifest)==null?void 0:v.call(w))==null?void 0:E.version)||"1.0.0";await ds({entries:_,extensionVersion:M})}catch(_){c(_ instanceof Error?_.message:String(_))}finally{f(!1)}}async function x(w,v){d(w),c(null);try{const E=`site:${t.startUrl}`,_=await X({type:"EXPORT_REQUEST",format:w,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(_!=null&&_.content)||_.content.length<50){c(`Generation returned empty content for ${w}.`);return}if(v==="download"){const M=Nt(w,E);at(_.content,M)}else Ue(_.content)}catch(E){c(E instanceof Error?E.message:String(E))}finally{d(null)}}async function C(){n(!0);try{const w=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),v=(w==null?void 0:w.content)??"";if(!v){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(v)}catch{}Ue(v,"text/markdown;charset=utf-8")}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${il[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${ol[t.siteRisk]}`,children:jn[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited",(()=>{const w=t.totalUniqueViolations,v=t.totalWalkthroughFindings,E=t.totalNeedsReview,_=w+v,M=[];return w>0&&M.push(`${w} axe`),v>0&&M.push(`${v} AI walkthrough`),e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:_})," total finding",_===1?"":"s",M.length>0&&e.jsxs(e.Fragment,{children:[" (",M.join(" + "),")"]}),E>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:E})," need",E===1?"s":""," review"]})]})})(),t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),e.jsx("button",{type:"button",onClick:C,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:r.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:r.state==="running"?`Saving baselines… ${r.current+1}/${r.total}`:"📌 Set this crawl as the site baseline"}),r.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",r.saved," baseline",r.saved===1?"":"s",r.failed>0&&` · ${r.failed} failed (re-crawl those pages and retry)`]}),r.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",r.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),e.jsx("button",{type:"button",onClick:()=>void k(),disabled:R.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:R.state==="running"?`Generating ${R.current} (${R.doneCount}/${R.totalCount})…`:"📦 Download all reports as a zip"}),R.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",R.included," file",R.included===1?"":"s"," into the zip",R.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",R.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:R.skipped.map(w=>e.jsx("li",{className:"break-all",children:w},w))})]})]}),R.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",R.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Ee,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",busy:i==="defense-bundle",disabled:i!==null,onClick:()=>void x("defense-bundle","download")}),e.jsx(Ee,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",busy:i==="deposition-packet",disabled:i!==null,onClick:()=>void x("deposition-packet","download")}),e.jsx(Ee,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",busy:i==="evidence-bundle",disabled:i!==null,onClick:()=>void x("evidence-bundle","download")}),e.jsx(Ee,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",busy:i==="vpat",disabled:i!==null,onClick:()=>void x("vpat","open-in-tab")}),e.jsx(Ee,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",busy:i==="conformance-crosswalk",disabled:i!==null,onClick:()=>void x("conformance-crosswalk","open-in-tab")}),e.jsx(Ee,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",busy:i==="methodology-doc",disabled:i!==null,onClick:()=>void x("methodology-doc","open-in-tab")}),e.jsx(Ee,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",busy:i==="executive-report",disabled:i!==null,onClick:()=>void x("executive-report","open-in-tab")}),e.jsx(Ee,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:i!==null,onClick:()=>void $()}),N&&e.jsx(Ee,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:g,disabled:i!==null||g,onClick:()=>void S()})]}),p&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",p]})]}),e.jsx(Ra,{open:u,onClose:()=>h(!1),results:[],siteCrawlSource:!0}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(Lt,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(w=>w.isShared&&!w.needsReview),openPage:Ke}),e.jsx(Lt,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(w=>!w.isShared&&!w.needsReview),openPage:Ke}),t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((w,v)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[w.ruleId," · WCAG ",w.wcagCriterion," · ",w.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:w.description}),w.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:w.details}),w.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),w.pages.map(E=>e.jsxs("button",{type:"button",onClick:()=>void Ke(E.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",E.url]},E.url))]})]},v))})]}),e.jsx(Lt,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(w=>w.needsReview),openPage:Ke,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:[e.jsx("strong",{children:"Click any row"})," to expand it inline and see exactly what's wrong on that page — axe findings, AI walkthrough verdicts, and human acknowledgements with action buttons right there. Click the URL itself to open the audited page in a new tab."]}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:t.pages.map(w=>{const v=(t.findingGroups??[]).filter(E=>E.needsReview&&E.pages.some(_=>_.url===w.url)).length;return e.jsx(ul,{page:w,findingGroups:t.findingGroups??[],needsReviewCount:v,onOpenSinglePage:()=>void Ke(w.url)},w.url)})})]})]})}async function Ke(t){try{const s=await Xe(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await Ae(async()=>{const{getResolutionsForPage:o}=await import("./scheduled-audit-runner-WGkZQWGB.js").then(l=>l.aW);return{getResolutionsForPage:o}},__vite__mapDeps([0,1,2,3,4])),r=await n(t);b.getState().setResolutionsForUrl(t,r)}catch{}b.getState().setResults(a.results,a.delta,a.componentId),b.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}b.getState().setView("report"),b.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Ee({label:t,sub:s,busy:a,disabled:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function Lt({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const o=s==="needs-review",l=o?"text-amber-700":"text-slate-500",i=o?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=o?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${l}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((p,c)=>e.jsx(dl,{group:p,sectionKind:s,cardCls:i,labelCls:d,openPage:n},`${p.ruleId}::${p.representativeSelector}::${c}`))})]})}function dl({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const o=Nn(t.ruleId),i=o.whatsWrong&&o.whatsWrong!=="An accessibility rule failed on this page.",d=i?o.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,p=i?o.whyItMatters:null,c=i?o.howToFix:null,u=s==="needs-review",h=s==="shared-actionable",g=u?"review":t.impact,f=u?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${ll[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:f,children:g}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(p||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[p&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:p})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!i&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:u?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(y=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(y.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",y.url]})},y.url))})]}),u&&e.jsx("div",{className:"ml-7 mt-2 pt-2 border-t border-dashed border-slate-200",children:e.jsx(Da,{group:t})})]})}function Da({group:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(""),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(!1);async function u(){l(!0),d(null);try{if(!n.trim()){d("Note is required — explain your review judgment."),l(!1);return}const h=await Xe()??[],{acknowledgeFinding:g}=await Ae(async()=>{const{acknowledgeFinding:y}=await import("./scheduled-audit-runner-WGkZQWGB.js").then(N=>N.aV);return{acknowledgeFinding:y}},__vite__mapDeps([0,1,2,3,4]));let f=0;for(const y of t.pages){const N=h.find($=>$.url===y.url);if(N)for(const $ of N.results)for(const R of $.violations)R.ruleId===t.ruleId&&R.target.selector===y.selector&&(await g({componentId:N.componentId,matchKey:R.matchKey,ruleId:R.ruleId,note:n.trim()}),f++)}f===0?d("Could not find this finding in the persisted crawl data — re-run the crawl and try again."):(c(!0),a(!1))}catch(h){d(h instanceof Error?h.message:String(h))}finally{l(!1)}}return p?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2",children:e.jsxs("p",{className:"text-[11px] text-emerald-900",children:[e.jsx("strong",{children:"✓ Acknowledged."})," Re-run a crawl (or refresh the audit on the affected page) to see the finding drop out."]})}):s?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"Your review judgment (required, goes into the forensic record)"}),e.jsx("textarea",{value:n,onChange:h=>r(h.target.value),placeholder:"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:i}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:o?"Saving…":`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),e.jsx("button",{type:"button",onClick:()=>{a(!1),r(""),d(null)},disabled:o,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"})]})]}):e.jsx("button",{type:"button",onClick:()=>{a(!0),d(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",title:"Mark this needsReview finding as human-verified across all affected pages. The ack persists across crawls as long as the underlying content's matchKey is stable (which it is for ai-alt-uncertain unless the alt text or image structure changes).",children:"Mark verified manually"})}function ul({page:t,findingGroups:s,needsReviewCount:a,onOpenSinglePage:n}){const[r,o]=m.useState(!1),l=t.walkthroughFindings??[],i=t.walkthroughAcknowledgements??[],d=Math.max(0,t.uniqueViolations-l.length-i.length),p=s.filter(g=>g.needsReview&&g.pages.some(f=>f.url===t.url)),c=s.filter(g=>!g.needsReview&&g.pages.some(f=>f.url===t.url)).map(g=>{var f;return{ruleId:g.ruleId,impact:g.impact,description:g.axeDescription,wcagCriterion:g.wcagCriterion,selector:((f=g.pages.find(y=>y.url===t.url))==null?void 0:f.selector)??g.representativeSelector}}).sort((g,f)=>{const y={critical:0,serious:1,moderate:2,minor:3};return(y[g.impact]??99)-(y[f.impact]??99)}),u=c.length>0||l.length>0||i.length>0||p.length>0||!!t.error,h=t.grade==="A"?"text-emerald-700":t.grade==="B"?"text-lime-700":t.grade==="C"?"text-yellow-700":t.grade==="D"?"text-orange-700":"text-rose-700";return e.jsxs("div",{className:"border-b border-slate-100 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>o(g=>!g),disabled:!u,className:"w-full flex items-center gap-2 text-left px-2 py-1.5 hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white text-xs","aria-expanded":r,children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${h}`,children:t.grade}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"font-mono text-[11px] text-brand-700 hover:underline break-all flex-1",title:"Open this page in a new browser tab",children:t.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:"axe violations only",children:[d," axe"]}),e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${l.length>0?"text-rose-700":i.length>0?"text-emerald-700":"text-slate-400"}`,children:[l.length," walkthru",i.length>0?` (${i.length}✓)`:""]}),a>0&&e.jsxs("span",{className:"text-[10px] shrink-0 tabular-nums font-medium text-amber-700",title:`${a} item${a===1?"":"s"} flagged for human review`,children:[a," review"]}),u&&e.jsx("span",{className:"text-[10px] text-slate-400 shrink-0 font-mono","aria-hidden":"true",children:r?"−":"+"})]}),r&&u&&e.jsx(pl,{page:t,axeFindings:c,needsReviewGroups:p,onOpenSinglePage:n})]})}function pl({page:t,axeFindings:s,needsReviewGroups:a,onOpenSinglePage:n}){const r=`${t.url}::dom:html`,[o,l]=m.useState([]),[i,d]=m.useState({}),[p,c]=m.useState(0);return m.useEffect(()=>{let u=!1;return Promise.all([Re(r),De([r])]).then(([h,g])=>{if(u)return;l(h.filter(y=>y.verdict!=="pass"));const f={};for(const y of g)f[y.criterionId]=y;d(f)}),()=>{u=!0}},[r,p]),e.jsxs("div",{className:"bg-slate-50 px-2 py-2 space-y-2 text-[11px]",children:[t.error&&e.jsxs("p",{className:"text-rose-700",children:["⚠ ",t.error]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["Axe findings (",s.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:s.map((u,h)=>e.jsxs("li",{className:"bg-white border border-slate-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`font-mono text-[10px] font-bold uppercase px-1 rounded ${u.impact==="critical"?"bg-rose-200 text-rose-900":u.impact==="serious"?"bg-orange-200 text-orange-900":u.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:u.impact}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.description}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.selector})]},`${u.ruleId}::${u.selector}::${h}`))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["AI walkthrough findings (",o.length,")"]}),e.jsx("div",{className:"space-y-2",children:o.map(u=>e.jsx("div",{className:"bg-white border border-slate-200 rounded p-1.5",children:e.jsx(cs,{componentId:r,pageUrl:t.url,criterionId:u.criterionId,record:u,ack:i[u.criterionId]??null,onChanged:()=>c(h=>h+1)})},u.criterionId))})]}),Object.keys(i).length>0&&o.every(u=>i[u.criterionId])&&Object.keys(i).length>o.length&&e.jsx("p",{className:"text-[10px] text-emerald-700",children:"✓ All walkthroughs on this page either passed or are human-verified."}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-amber-700 mb-1",children:["Needs human review (",a.length,")"]}),e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"bg-white border border-amber-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] font-bold uppercase px-1 rounded bg-amber-200 text-amber-900",children:"review"}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.axeDescription}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.representativeSelector}),u.failureSummary&&e.jsxs("p",{className:"text-[10px] text-slate-600 mt-1 whitespace-pre-wrap",children:[u.failureSummary.slice(0,400),u.failureSummary.length>400?"…":""]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Da,{group:u})})]},`${u.ruleId}::${u.representativeSelector}`))})]}),e.jsx("div",{className:"pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-brand-600 hover:underline",children:"Open full single-page view (lenses, visualizers, guided checks) →"})})]})}const Ut="onboardingDismissed",_t=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function hl(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Ut).then(i=>{i[Ut]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ut]:!0}),s(!1),n(0)}const o=a===_t.length-1,l=_t[a];return e.jsxs(Ge,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",_t.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(i=>i-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),o?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(i=>i+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function ml(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function xl(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",o=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",i=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${o}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",i]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}const it="aiConfig",gl=[{key:"altText",label:"Alt-text descriptiveness"},{key:"headings",label:"Heading clarity vs section content"},{key:"sensory",label:'Sensory-language instructions ("click the green button")'},{key:"aria",label:"ARIA role semantic correctness"},{key:"imageOfText",label:"Image-of-text detection"},{key:"colorOnlyMeaning",label:"Color-only meaning"},{key:"genericLinkText",label:'Generic link text ("click here", "read more")'},{key:"wallOfText",label:"Wall-of-text / readability"},{key:"languageMismatch",label:"Declared-language mismatch"}];function Oa(){const t=b(c=>c.results),s=b(c=>c.aiFailure),[a,n]=m.useState("unknown"),[r,o]=m.useState(!1);m.useEffect(()=>{function c(h){if(!h){n("off-no-key");return}if(!h.enabled){n("off-by-user");return}if(!h.apiKey){n("off-no-key");return}n("on")}chrome.storage.local.get(it).then(h=>c(h[it])).catch(()=>n("off-no-key"));const u=(h,g)=>{var f;g!=="local"||!(it in h)||c((f=h[it])==null?void 0:f.newValue)};return chrome.storage.onChanged.addListener(u),()=>chrome.storage.onChanged.removeListener(u)},[]);const l=t.length;if(m.useEffect(()=>{o(!1)},[l]),t.length===0||a==="on"||a==="unknown"||r||s)return null;const i=a==="off-by-user",d=i?"AI augmentation is off — semantic-quality checks did not run.":"No AI API key — semantic-quality checks did not run.",p=i?"You disabled AI in Settings. Structural checks (axe-core, DOM analyzers, state matrix) ran normally. The checks below would have added semantic quality verdicts.":"Structural checks (axe-core, DOM analyzers, state matrix) ran normally. The semantic-quality checks below would have added human-like content judgment — they need an Anthropic API key (BYO) to run.";return e.jsx("div",{role:"status",className:"px-3 py-2 border-b border-sky-200 bg-sky-50 text-xs text-sky-900 flex flex-col gap-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:"ℹ"})," ",d]}),e.jsx("div",{className:"mt-0.5",children:p}),e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"cursor-pointer hover:underline",children:"What didn't run"}),e.jsx("ul",{className:"mt-1 pl-4 list-disc text-[11px] leading-snug",children:gl.map(c=>e.jsx("li",{children:c.label},c.key))})]}),e.jsx("div",{className:"mt-1.5 flex gap-2",children:e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:"text-[11px] px-2 py-0.5 rounded bg-sky-600 text-white hover:bg-sky-700",children:"Enable in Settings"})})]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"hover:opacity-70 leading-none text-sm","aria-label":"Dismiss AI-off notice for this audit",title:"Dismiss for this audit",children:"×"})]})})}function Js(){const[t,s]=m.useState(!1);return m.useEffect(()=>be("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(Ge,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function fl(){var o;const[t,s]=m.useState(null);if(m.useEffect(()=>{kn().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await bs(),b.getState().startNewScan(),t.mode==="storybook-all"?je({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&je({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await bs(),s(null)}const r=t.mode==="storybook-all"?`Story ${((o=t.completedStories)==null?void 0:o.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Dt="storybook:hintDismissed";function bl(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var i;if((await chrome.storage.local.get(Dt))[Dt])return;const l=await me();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((i=p.result)==null?void 0:i.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Dt]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function vl(){var o;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.status),n=(o=t[0])==null?void 0:o.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${yl(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function yl(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const o=Math.round(r/60);if(o<60)return`${o}m ago`;const l=Math.round(o/60);if(l<24)return`${l}h ago`;const i=Math.round(l/24);return i<7?`${i}d ago`:a.toLocaleDateString()}function wl(){const t=b(i=>i.results),s=b(i=>i.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let i=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(i)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{i=!0}},[s]),t.length===0)return null;const r=t.flatMap(i=>i.violations),o=Sn(r,a.length>0?{runs:a,workflows:fe}:void 0),l=o.manual!==void 0&&o.manual.workflowsCompleted===o.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}const Fa={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 is clean on every check that automated lawsuit-targeting tools run.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix to drop off the easy-target list.",high:"High risk. Multiple findings here are patterns demand-letter mills target.",critical:"Critical risk. Your site has many high-frequency patterns ADA-targeting firms scan for."},version:0};Fa.ruleIds;function jl(){var t;return((t=An())==null?void 0:t.lawfare)??Fa}function Ma(t,s=jl()){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 Pa={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Nl={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Pa]},kl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Pa]};function us(t){return t==="thorough"?kl:Nl}function Xs(t){const s=us(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ga(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,o]=m.useState(0),[l,i]=m.useState(!1),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[f,y]=m.useState(!1);if(m.useEffect(()=>{let x=!1;return s(null),n(null),gt().then(C=>{x||s(C)}).catch(C=>{x||n(C instanceof Error?C.message:String(C))}),()=>{x=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const N=t.length,$=t.filter(x=>x.receipt).length,R=b(x=>x.tier),I=Ne(R,"exportPreLitigationReport");async function k(){if(!(!t||t.length===0)){y(!0);try{await ds({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),i(!1)}finally{y(!1)}}}async function S(){if(!t||t.length===0)return;const x={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},C=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),w=URL.createObjectURL(C),v=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,E=document.createElement("a");E.href=w,E.download=v,E.click(),setTimeout(()=>URL.revokeObjectURL(w),1e3)}return N===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[N," ",N===1?"entry":"entries",$>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[$," RFC 3161-anchored"]})]}),$===0&&N>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[I&&e.jsx("button",{type:"button",onClick:()=>i(x=>!x),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void S(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>o(x=>x+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:x=>p(x.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:x=>u(x.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:h,onChange:x=>g(x.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:f||N===0,onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:f?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(x=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${x.grade==="A"?"bg-emerald-100 text-emerald-700":x.grade==="B"?"bg-lime-100 text-lime-700":x.grade==="C"?"bg-yellow-100 text-yellow-700":x.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:x.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:x.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${x.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:x.receipt?`Anchored to ${x.receipt.tsaName} at ${x.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:x.receipt?`RFC 3161 (${x.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:x.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:x.capturedAt}),(x.totals.critical>0||x.totals.serious>0)&&e.jsxs("span",{children:[x.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[x.totals.critical," crit"]}),x.totals.critical>0&&x.totals.serious>0&&" · ",x.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[x.totals.serious," sev"]})]}),e.jsxs("span",{children:[x.statesAudited," ",x.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:x.hash,children:[x.hash.slice(0,12),"…"]})]})]},`${x.componentId}::${x.capturedAt}`))})]})}function Sl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return gt().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,o=t[t.length-1],l=t.slice(0,3),i=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",o&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:o.capturedAt.slice(0,10)})]}),i>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[i," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(Ge,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(Ga,{})})})]})}function Al(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Cl={eyebrow:"You're on a trial",headline:"Full features unlocked while you evaluate.",body:"When your trial ends, a paid plan keeps RFC 3161 trusted-timestamp anchoring, AI fix suggestions, and audit-history evidence active for every scan."},Il={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},El={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Rl={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Va(){const t=b(u=>u.tier),s=b(u=>u.trialDaysRemaining),a=b(u=>u.seatsUsed),n=b(u=>u.seatsTotal),r=b(u=>u.planCode),o=b(u=>u.licenseDaysRemaining),l=b(u=>u.pastDue),[i,d]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=o,h=u!==null&&u<=7,g=u===null?"":u===0?"expires today":u===1?"1 day left":`${u} days left`;return e.jsxs("aside",{"aria-label":"License status",className:h?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:h?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),g&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",g]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Mt,{open:i,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?Rl:El,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,g=t==="team"&&a!==null&&n!==null&&a>n,f=t==="team"&&a!==null&&n!==null&&a===n,y=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:f?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${y.bg} border-b ${y.border} px-3 py-2 space-y-1 text-[11px] ${y.shadow}`,children:[e.jsxs("div",{className:y.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:y.subtitle,children:[" · ",h]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),g&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),f&&!g&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:y.link,children:"Manage license →"})})]})}const p=t==="trial"?Cl:Il,c=t==="trial"?Al(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Mt,{open:i,onClose:()=>d(!1)})]})}const Wa={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},Ba={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},jt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Tl={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},Zs={critical:0,serious:1,moderate:2,minor:3};function $l(){b(p=>p.setUserMode);const t=b(p=>p.status),s=b(p=>p.setStatus),a=b(p=>p.errorMessage),n=b(p=>p.setError),[r,o]=m.useState(!1),[l,i]=m.useState(!1),d=m.useRef(t);return m.useEffect(()=>{if(d.current==="running"&&t==="complete"){i(!0);const p=setTimeout(()=>i(!1),3500);return d.current=t,()=>clearTimeout(p)}d.current=t},[t]),m.useEffect(()=>{if(t!=="running")return;const p=setTimeout(()=>{b.getState().status==="running"&&(s("idle"),n("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[t,s,n]),e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(Va,{}),e.jsx(wa,{}),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(ja,{}),e.jsx(ya,{})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]})]}),t==="running"&&e.jsx(Ll,{}),e.jsx(Oa,{}),t==="failed"&&a&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:a}),e.jsx("button",{type:"button",onClick:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[r?e.jsx(_a,{onBack:()=>o(!1)}):e.jsx(_l,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Ul,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use, plus our extended DOM analyzers and AI walkthroughs covering all 50 WCAG 2.1 AA criteria."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function Ll(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 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 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void H({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function Ul(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function _l({onPickCrawl:t}){const s=b(h=>h.status),a=b(h=>h.results),n=b(h=>h.siteCrawlReport),[r,o]=m.useState("quick"),[l,i]=m.useState("all"),d=s==="running",p=a.flatMap(h=>h.violations),c=a.length>0;function u(){je({type:"START_AUDIT",mode:"full-page",matrixOverride:us(r)}),b.getState().startNewScan(),he.polite(`${r==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:u,disabled:d,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:d?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:d,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(Fl,{depth:r,onChange:o,disabled:d})]}),!c&&!d&&(n?e.jsx(Ol,{report:n,onView:t}):e.jsx(Dl,{})),c&&e.jsx(Ml,{violations:p,severityFilter:l,onSeverityFilterChange:i,scanDepth:r})]})}function Dl(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function Ol({report:t,onView:s}){const a=b(c=>c.tier),n=Ne(a,"lawfareRisk"),[r,o]=m.useState(null);m.useEffect(()=>{let c=!1;return Xe().then(u=>{c||o((u??[]).flatMap(h=>h.results.flatMap(g=>g.violations)))}),()=>{c=!0}},[t.startUrl,t.finishedAt]);let l=t.startUrl;try{l=new URL(t.startUrl).host}catch{}const i=`Whole-site crawl · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"} · ${l}`,d=e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline font-medium",children:"View full report →"});if(!n)return e.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:i}),e.jsxs("div",{className:"p-3 text-xs text-slate-600",children:["Whole-site crawl complete. ",d]})]});const p=r?Ma(r):null;return p?e.jsxs("div",{className:`border rounded-lg overflow-hidden ${Wa[p.tier]}`,children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:i}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ba[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}, whole site`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade · whole site"}),e.jsxs("p",{className:`text-base font-semibold ${jt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${jt[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged across ",t.pagesAudited," page",t.pagesAudited===1?"":"s",". ",d]}),p.flaggedRuleCount===0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:["No demand-letter-bait issues found site-wide. ",d]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners across the whole site. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade (open the full report or power/dev mode for that)."]})]})]})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:i}),e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Reading your last crawl…"})]})}function Fl({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:`${Xs("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:`${Xs("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})]})}function Ml({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var w;const r=b(v=>v.status),o=b(v=>v.results),l=b(v=>v.freshThisSession),i=b(v=>v.componentId),d=b(v=>v.tier),p=(w=o[0])==null?void 0:w.startedAt,u=Ne(d,"lawfareRisk")?Ma(t):null,h=r==="running",[g,f]=m.useState([]);m.useEffect(()=>{if(!i){f([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(E=>{if(v)return;const M=((E==null?void 0:E.igtRuns)??{})[i]??{};f(Object.values(M))}),()=>{v=!0}},[i]);const y=b(v=>v.acknowledgedKeys),N=o.length>0?oa(o,{runs:g,workflows:fe},"2.1","AA",y):void 0;function $(){je({type:"START_AUDIT",mode:"full-page",matrixOverride:us(n)}),b.getState().startNewScan(),he.polite("Re-scanning this page now.")}const R=s==="lawsuit-risk"?t.filter(v=>v.impact==="critical"||v.impact==="serious"):t,I=new Map;for(const v of R){const E=_e(v.ruleId,v.target.selector);I.has(E)||I.set(E,v)}const k=Array.from(I.values()),S=new Map;for(const v of k){const E=S.get(v.ruleId)??[];E.push(v),S.set(v.ruleId,E)}const x=Array.from(S.entries()).sort((v,E)=>(Zs[v[1][0].impact]??99)-(Zs[E[1][0].impact]??99)),C=t.filter(v=>v.impact==="critical"||v.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[p&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Hl,{iso:p})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void St(),disabled:h,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:$,disabled:h,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:h?"Scanning…":"↻ Scan again"})]})]}),h?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white 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",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):u?e.jsxs("div",{className:`border rounded-lg overflow-hidden ${Wa[u.tier]}`,children:[!l&&p&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ba[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${jt[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${jt[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 bg-slate-50",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Lawsuit-target risk grade isn’t available on your current plan"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Upgrade your plan to see the demand-letter exposure grade for this page."})]}),!h&&N&&!N.canClaimConformance&&e.jsx(Pl,{coverage:N}),!h&&N&&N.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",N.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(Bl,{}),e.jsx(Sl,{}),t.length>0&&e.jsx(Gl,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[x.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),x.map(([v,E])=>e.jsx(Vl,{ruleId:v,violations:E},v))]})]})}function Pl({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),H({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function Gl({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function Vl({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,o=Cn(t,r),l=s[0].impact,i=s[0],p=o.whatsWrong==="An accessibility rule failed on this page."&&i.description?i.description:o.whatsWrong,c=i.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Tl[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",o.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",o.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,g)=>e.jsx(Wl,{violation:h},g))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Wl({violation:t}){const s=b(o=>{var l;return(l=o.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(o){o.stopPropagation();const l=await me();if(l)try{const i=await Te(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(i.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const ot=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function Bl(){const t=b(c=>c.results),s=b(c=>c.componentId),[a,n]=m.useState(null),[r,o]=m.useState(!1),[l,i]=m.useState(null);async function d(c,u){if(t.length!==0){n(c);try{const h=await X({type:"EXPORT_REQUEST",format:c,results:t,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(c==="defense-bundle"||c==="evidence-bundle"){const g=Nt(c,s);await ha()?at(h.content,g):i({open:!0,format:c,content:h.content,filename:g})}else if(u)Ue(h.content);else{try{await navigator.clipboard.writeText(h.content),he.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const f=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
268
|
+
`;if(M.unshift({name:"README.txt",content:L}),M.length===0){I({state:"error",message:"No reports could be generated. Re-run the crawl and try again."});return}const D=w(M),V=new Date().toISOString().slice(0,10),z=t.startUrl.replace(/^https?:\/\//,"").replace(/[^a-z0-9]/gi,"-").replace(/-+/g,"-").slice(0,32).toLowerCase()||"crawl",T=`wcagcheckr-site-bundle-${V}-${z}.zip`,re=URL.createObjectURL(D),oe=document.createElement("a");oe.href=re,oe.download=T,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),setTimeout(()=>URL.revokeObjectURL(re),3e4),I({state:"done",included:M.length,skipped:_})}catch(L){I({state:"error",message:L instanceof Error?L.message:String(L)})}}async function S(){var w,v,E;f(!0),c(null);try{const _=await gt();if(_.length===0){c("No forensic-log entries yet. Generate a defense bundle or deposition packet first — those create the anchored entries the pre-litigation report documents.");return}const M=typeof chrome<"u"&&((E=(v=(w=chrome.runtime)==null?void 0:w.getManifest)==null?void 0:v.call(w))==null?void 0:E.version)||"1.0.0";await ds({entries:_,extensionVersion:M})}catch(_){c(_ instanceof Error?_.message:String(_))}finally{f(!1)}}async function x(w,v){d(w),c(null);try{const E=`site:${t.startUrl}`,_=await X({type:"EXPORT_REQUEST",format:w,results:[],siteCrawlSource:!0,wallClockMs:t.totalDurationMs});if(!(_!=null&&_.content)||_.content.length<50){c(`Generation returned empty content for ${w}.`);return}if(v==="download"){const M=Nt(w,E);at(_.content,M)}else Ue(_.content)}catch(E){c(E instanceof Error?E.message:String(E))}finally{d(null)}}async function C(){n(!0);try{const w=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),v=(w==null?void 0:w.content)??"";if(!v){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(v)}catch{}Ue(v,"text/markdown;charset=utf-8")}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${il[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${ol[t.siteRisk]}`,children:jn[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited",(()=>{const w=t.totalUniqueViolations,v=t.totalWalkthroughFindings,E=t.totalNeedsReview,_=w+v,M=[];return w>0&&M.push(`${w} axe`),v>0&&M.push(`${v} AI walkthrough`),e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:_})," total finding",_===1?"":"s",M.length>0&&e.jsxs(e.Fragment,{children:[" (",M.join(" + "),")"]}),E>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:E})," need",E===1?"s":""," review"]})]})})(),t.walkthroughAcknowledgements.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{className:"text-emerald-700",children:t.walkthroughAcknowledgements.length})," human-verified"]}),t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 font-medium",children:"📊 Open full site report (standalone HTML)"}),e.jsx("button",{type:"button",onClick:C,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:r.state==="running",className:"w-full text-sm px-4 py-2.5 border border-emerald-500 text-emerald-700 rounded hover:bg-emerald-50 disabled:opacity-50 font-medium",title:"Save each crawled page's current state as its baseline. Future audits + re-crawls show delta against this snapshot.",children:r.state==="running"?`Saving baselines… ${r.current+1}/${r.total}`:"📌 Set this crawl as the site baseline"}),r.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Saved ",r.saved," baseline",r.saved===1?"":"s",r.failed>0&&` · ${r.failed} failed (re-crawl those pages and retry)`]}),r.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",r.message]}),e.jsxs("div",{className:"border border-slate-200 rounded-lg p-3 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-700",children:"Site-wide compliance documents"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Generate the same legal / compliance / industry docs you can produce from a single-page audit — but covering the whole crawled site. Use these to respond to demand letters, file VPATs, or document remediation history."}),e.jsx("button",{type:"button",onClick:()=>void k(),disabled:R.state==="running",className:"w-full text-sm px-4 py-2.5 bg-slate-900 text-white rounded hover:bg-slate-800 disabled:opacity-50 font-medium",title:"Generate all compliance docs at once and download as a single .zip file",children:R.state==="running"?`Generating ${R.current} (${R.doneCount}/${R.totalCount})…`:"📦 Download all reports as a zip"}),R.state==="done"&&e.jsxs("div",{className:"text-[11px] text-emerald-800 bg-emerald-50 border border-emerald-200 rounded px-2.5 py-1.5",children:["✓ Bundled ",R.included," file",R.included===1?"":"s"," into the zip",R.skipped.length>0&&e.jsxs(e.Fragment,{children:[" ","· skipped ",R.skipped.length,":",e.jsx("ul",{className:"mt-0.5 ml-3 list-disc",children:R.skipped.map(w=>e.jsx("li",{className:"break-all",children:w},w))})]})]}),R.state==="error"&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",R.message]}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[e.jsx(Ee,{label:"⚖ Defense bundle",sub:"Forensic-anchored HTML evidence — download + Ctrl+P to seal as PDF",busy:i==="defense-bundle",disabled:i!==null,onClick:()=>void x("defense-bundle","download")}),e.jsx(Ee,{label:"📜 Deposition packet",sub:"Court-grade — cover sheet, chain of custody, sworn declaration template",busy:i==="deposition-packet",disabled:i!==null,onClick:()=>void x("deposition-packet","download")}),e.jsx(Ee,{label:"📂 Evidence bundle",sub:"Same shape as Defense — neutral 'evidence' framing",busy:i==="evidence-bundle",disabled:i!==null,onClick:()=>void x("evidence-bundle","download")}),e.jsx(Ee,{label:"📋 VPAT (Voluntary Product Accessibility Template)",sub:"Formal industry conformance template — opens in new tab",busy:i==="vpat",disabled:i!==null,onClick:()=>void x("vpat","open-in-tab")}),e.jsx(Ee,{label:"🔄 Conformance crosswalk",sub:"WCAG 2.1 AA criterion-by-criterion conformance table",busy:i==="conformance-crosswalk",disabled:i!==null,onClick:()=>void x("conformance-crosswalk","open-in-tab")}),e.jsx(Ee,{label:"🔬 Methodology doc",sub:"How this audit was conducted — defensibility documentation",busy:i==="methodology-doc",disabled:i!==null,onClick:()=>void x("methodology-doc","open-in-tab")}),e.jsx(Ee,{label:"📊 Executive report",sub:"Stakeholder summary — grade hero, top risks, next steps. Print-ready.",busy:i==="executive-report",disabled:i!==null,onClick:()=>void x("executive-report","open-in-tab")}),e.jsx(Ee,{label:"📃 Accessibility statement",sub:"Public WCAG conformance statement (HTML or Markdown) — opens a dialog for org info",busy:!1,disabled:i!==null,onClick:()=>void $()}),N&&e.jsx(Ee,{label:"📋 Pre-litigation report",sub:"Audit-history record across time — requires anchored entries (generate a defense bundle first)",busy:g,disabled:i!==null||g,onClick:()=>void S()})]}),p&&e.jsxs("div",{className:"text-[11px] text-rose-800 bg-rose-50 border border-rose-200 rounded px-2.5 py-1.5",children:["✗ ",p]})]}),e.jsx(Ra,{open:u,onClose:()=>h(!1),results:[],siteCrawlSource:!0}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"This report is your do-the-work list."})," ","Each finding below is grouped by whether it's likely a"," ",e.jsx("strong",{children:"shared resource"})," (a CSS rule, component, or layout that affects multiple pages — fix it once, helps everywhere) or ",e.jsx("strong",{children:"page-specific"})," (only that one URL). Click any affected URL to open that page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)."]}),e.jsx(Lt,{title:"Shared resources — fix once, helps multiple pages",sectionKind:"shared-actionable",groups:t.findingGroups.filter(w=>w.isShared&&!w.needsReview),openPage:Ke}),e.jsx(Lt,{title:"Page-specific — one-off; fix on that page",sectionKind:"local-actionable",groups:t.findingGroups.filter(w=>!w.isShared&&!w.needsReview),openPage:Ke}),t.consistencyFindings.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700 mb-2",children:["Site-wide patterns (",t.consistencyFindings.length,")"]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Inconsistencies the comparators only see across pages — navigation order divergence, identification mismatches, redundant entry. WCAG 3.2.3 / 3.2.4 / 3.2.6."}),e.jsx("ul",{className:"space-y-2",children:t.consistencyFindings.map((w,v)=>e.jsxs("li",{className:"border border-blue-200 rounded p-2.5 bg-blue-50 text-xs",children:[e.jsxs("p",{className:"font-mono text-[10px] text-blue-700",children:[w.ruleId," · WCAG ",w.wcagCriterion," · ",w.impact]}),e.jsx("p",{className:"text-sm text-blue-900 mt-1",children:w.description}),w.details&&e.jsx("p",{className:"text-[11px] text-blue-800 mt-1 whitespace-pre-wrap leading-snug",children:w.details}),w.pages.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-blue-700",children:"Pages compared:"}),w.pages.map(E=>e.jsxs("button",{type:"button",onClick:()=>void Ke(E.url),className:"block w-full text-left text-[11px] font-mono text-blue-800 hover:text-blue-900 hover:underline truncate",children:["→ ",E.url]},E.url))]})]},v))})]}),e.jsx(Lt,{title:"Needs human review",sectionKind:"needs-review",groups:t.findingGroups.filter(w=>w.needsReview),openPage:Ke,hint:"AI flagged these as possibly failing but couldn't decide — you need to look + judge. They don't count toward the severity total above."}),t.findingGroups.length===0&&t.consistencyFindings.length===0&&e.jsxs("div",{className:"border border-emerald-200 rounded p-3 bg-emerald-50 text-xs text-emerald-900",children:[e.jsxs("strong",{children:["✓ No findings across the ",t.pagesAudited," crawled page",t.pagesAudited===1?"":"s","."]})," Per-page audits all completed cleanly. Drill into any page below to see the full per-page Findings if you want to verify or run guided manual checks."]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:[e.jsx("strong",{children:"Click any row"})," to expand it inline and see exactly what's wrong on that page — axe findings, AI walkthrough verdicts, and human acknowledgements with action buttons right there. Click the URL itself to open the audited page in a new tab."]}),e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:t.pages.map(w=>{const v=(t.findingGroups??[]).filter(E=>E.needsReview&&E.pages.some(_=>_.url===w.url)).length;return e.jsx(ul,{page:w,findingGroups:t.findingGroups??[],needsReviewCount:v,onOpenSinglePage:()=>void Ke(w.url)},w.url)})})]})]})}async function Ke(t){try{const s=await Xe(),a=s==null?void 0:s.find(n=>n.url===t);if(!a||a.results.length===0||!a.componentId){console.warn("[site-crawl-panel] no cached crawl results for",t);return}try{const{getResolutionsForPage:n}=await Ae(async()=>{const{getResolutionsForPage:o}=await import("./scheduled-audit-runner-DB_DvRPY.js").then(l=>l.aW);return{getResolutionsForPage:o}},__vite__mapDeps([0,1,2,3,4])),r=await n(t);b.getState().setResolutionsForUrl(t,r)}catch{}b.getState().setResults(a.results,a.delta,a.componentId),b.getState().setCrawlNavContext({mode:"page",url:t});try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}b.getState().setView("report"),b.getState().setFindingsLens("overview")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}function Ee({label:t,sub:s,busy:a,disabled:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"w-full text-left px-3 py-2 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-medium text-slate-900",children:a?`Generating ${t.replace(/^[^a-zA-Z]+/,"")}…`:t}),e.jsx("div",{className:"text-[10px] text-slate-600 leading-snug mt-0.5",children:s})]})}function Lt({title:t,sectionKind:s,groups:a,openPage:n,hint:r}){if(a.length===0)return null;const o=s==="needs-review",l=o?"text-amber-700":"text-slate-500",i=o?"border-amber-200 bg-amber-50":"border-slate-200 bg-white",d=o?"bg-amber-200 text-amber-900":"";return e.jsxs("div",{children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wide mb-2 ${l}`,children:[t," (",a.length,")"]}),r&&e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:r}),e.jsx("ul",{className:"space-y-2",children:a.map((p,c)=>e.jsx(dl,{group:p,sectionKind:s,cardCls:i,labelCls:d,openPage:n},`${p.ruleId}::${p.representativeSelector}::${c}`))})]})}function dl({group:t,sectionKind:s,cardCls:a,labelCls:n,openPage:r}){const o=Nn(t.ruleId),i=o.whatsWrong&&o.whatsWrong!=="An accessibility rule failed on this page.",d=i?o.whatsWrong:t.axeDescription||`Rule "${t.ruleId}" was flagged — see axe-core docs for this rule.`,p=i?o.whyItMatters:null,c=i?o.howToFix:null,u=s==="needs-review",h=s==="shared-actionable",g=u?"review":t.impact,f=u?`${n} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`:`${ll[t.impact]} text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0`;return e.jsxs("li",{className:`border rounded p-2.5 text-xs ${a}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:f,children:g}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:d}),e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 mt-0.5 break-all",children:[t.ruleId,t.wcagCriterion&&` · WCAG ${t.wcagCriterion}`]}),e.jsxs("p",{className:"text-[11px] text-slate-600 mt-1",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Shared"})," — found on"," ",e.jsx("strong",{children:t.pages.length})," page",t.pages.length===1?"":"s",". Likely a shared component or CSS rule — fix once."]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Page-specific"})," — only on this one page."]}),t.totalOccurrences>t.pages.length&&e.jsxs(e.Fragment,{children:[" · ",t.totalOccurrences," matrix-state occurrences"]})]})]})]}),(p||c)&&e.jsxs("div",{className:"ml-7 mb-2 space-y-1.5",children:[p&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Why it matters"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:p})]}),c&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"How to fix"}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:c})]})]}),t.representativeSelector&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Where to find it"}),e.jsx("p",{className:"text-[11px] font-mono text-slate-700 break-all",children:t.representativeSelector}),t.representativeOuterHTML&&e.jsxs("p",{className:"text-[10px] font-mono text-slate-500 break-all mt-0.5 line-clamp-2",children:[t.representativeOuterHTML.slice(0,200),t.representativeOuterHTML.length>200?"…":""]})]}),t.failureSummary&&!i&&e.jsxs("div",{className:"ml-7 mb-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400",children:"Detail"}),e.jsxs("p",{className:"text-[11px] text-slate-700 leading-snug whitespace-pre-wrap",children:[t.failureSummary.slice(0,600),t.failureSummary.length>600?"…":""]})]}),e.jsxs("div",{className:"ml-7",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-400 mb-0.5",children:u?"Open to review":"Affected pages"}),e.jsx("ul",{className:"space-y-0.5",children:t.pages.map(y=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(y.url),className:"block w-full text-left text-[11px] font-mono text-brand-700 hover:text-brand-900 hover:underline truncate",title:"Open this page's full per-page Findings (acknowledge / fix-preview / guided checks / visualizers)",children:["→ ",y.url]})},y.url))})]}),u&&e.jsx("div",{className:"ml-7 mt-2 pt-2 border-t border-dashed border-slate-200",children:e.jsx(Da,{group:t})})]})}function Da({group:t}){const[s,a]=m.useState(!1),[n,r]=m.useState(""),[o,l]=m.useState(!1),[i,d]=m.useState(null),[p,c]=m.useState(!1);async function u(){l(!0),d(null);try{if(!n.trim()){d("Note is required — explain your review judgment."),l(!1);return}const h=await Xe()??[],{acknowledgeFinding:g}=await Ae(async()=>{const{acknowledgeFinding:y}=await import("./scheduled-audit-runner-DB_DvRPY.js").then(N=>N.aV);return{acknowledgeFinding:y}},__vite__mapDeps([0,1,2,3,4]));let f=0;for(const y of t.pages){const N=h.find($=>$.url===y.url);if(N)for(const $ of N.results)for(const R of $.violations)R.ruleId===t.ruleId&&R.target.selector===y.selector&&(await g({componentId:N.componentId,matchKey:R.matchKey,ruleId:R.ruleId,note:n.trim()}),f++)}f===0?d("Could not find this finding in the persisted crawl data — re-run the crawl and try again."):(c(!0),a(!1))}catch(h){d(h instanceof Error?h.message:String(h))}finally{l(!1)}}return p?e.jsx("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2",children:e.jsxs("p",{className:"text-[11px] text-emerald-900",children:[e.jsx("strong",{children:"✓ Acknowledged."})," Re-run a crawl (or refresh the audit on the affected page) to see the finding drop out."]})}):s?e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded p-2 space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold text-emerald-900 block",children:"Your review judgment (required, goes into the forensic record)"}),e.jsx("textarea",{value:n,onChange:h=>r(h.target.value),placeholder:"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.",className:"w-full text-[11px] px-2 py-1 border border-emerald-300 rounded resize-y min-h-[60px]",autoFocus:!0}),i&&e.jsx("p",{className:"text-[10px] text-rose-700",children:i}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 disabled:opacity-50 font-medium",children:o?"Saving…":`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),e.jsx("button",{type:"button",onClick:()=>{a(!1),r(""),d(null)},disabled:o,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"})]})]}):e.jsx("button",{type:"button",onClick:()=>{a(!0),d(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",title:"Mark this needsReview finding as human-verified across all affected pages. The ack persists across crawls as long as the underlying content's matchKey is stable (which it is for ai-alt-uncertain unless the alt text or image structure changes).",children:"Mark verified manually"})}function ul({page:t,findingGroups:s,needsReviewCount:a,onOpenSinglePage:n}){const[r,o]=m.useState(!1),l=t.walkthroughFindings??[],i=t.walkthroughAcknowledgements??[],d=Math.max(0,t.uniqueViolations-l.length-i.length),p=s.filter(g=>g.needsReview&&g.pages.some(f=>f.url===t.url)),c=s.filter(g=>!g.needsReview&&g.pages.some(f=>f.url===t.url)).map(g=>{var f;return{ruleId:g.ruleId,impact:g.impact,description:g.axeDescription,wcagCriterion:g.wcagCriterion,selector:((f=g.pages.find(y=>y.url===t.url))==null?void 0:f.selector)??g.representativeSelector}}).sort((g,f)=>{const y={critical:0,serious:1,moderate:2,minor:3};return(y[g.impact]??99)-(y[f.impact]??99)}),u=c.length>0||l.length>0||i.length>0||p.length>0||!!t.error,h=t.grade==="A"?"text-emerald-700":t.grade==="B"?"text-lime-700":t.grade==="C"?"text-yellow-700":t.grade==="D"?"text-orange-700":"text-rose-700";return e.jsxs("div",{className:"border-b border-slate-100 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>o(g=>!g),disabled:!u,className:"w-full flex items-center gap-2 text-left px-2 py-1.5 hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white text-xs","aria-expanded":r,children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${h}`,children:t.grade}),e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"font-mono text-[11px] text-brand-700 hover:underline break-all flex-1",title:"Open this page in a new browser tab",children:t.url}),e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0 tabular-nums",title:"axe violations only",children:[d," axe"]}),e.jsxs("span",{className:`text-[10px] shrink-0 tabular-nums font-medium ${l.length>0?"text-rose-700":i.length>0?"text-emerald-700":"text-slate-400"}`,children:[l.length," walkthru",i.length>0?` (${i.length}✓)`:""]}),a>0&&e.jsxs("span",{className:"text-[10px] shrink-0 tabular-nums font-medium text-amber-700",title:`${a} item${a===1?"":"s"} flagged for human review`,children:[a," review"]}),u&&e.jsx("span",{className:"text-[10px] text-slate-400 shrink-0 font-mono","aria-hidden":"true",children:r?"−":"+"})]}),r&&u&&e.jsx(pl,{page:t,axeFindings:c,needsReviewGroups:p,onOpenSinglePage:n})]})}function pl({page:t,axeFindings:s,needsReviewGroups:a,onOpenSinglePage:n}){const r=`${t.url}::dom:html`,[o,l]=m.useState([]),[i,d]=m.useState({}),[p,c]=m.useState(0);return m.useEffect(()=>{let u=!1;return Promise.all([Re(r),De([r])]).then(([h,g])=>{if(u)return;l(h.filter(y=>y.verdict!=="pass"));const f={};for(const y of g)f[y.criterionId]=y;d(f)}),()=>{u=!0}},[r,p]),e.jsxs("div",{className:"bg-slate-50 px-2 py-2 space-y-2 text-[11px]",children:[t.error&&e.jsxs("p",{className:"text-rose-700",children:["⚠ ",t.error]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["Axe findings (",s.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:s.map((u,h)=>e.jsxs("li",{className:"bg-white border border-slate-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`font-mono text-[10px] font-bold uppercase px-1 rounded ${u.impact==="critical"?"bg-rose-200 text-rose-900":u.impact==="serious"?"bg-orange-200 text-orange-900":u.impact==="moderate"?"bg-amber-200 text-amber-900":"bg-slate-200 text-slate-700"}`,children:u.impact}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.description}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.selector})]},`${u.ruleId}::${u.selector}::${h}`))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-slate-500 mb-1",children:["AI walkthrough findings (",o.length,")"]}),e.jsx("div",{className:"space-y-2",children:o.map(u=>e.jsx("div",{className:"bg-white border border-slate-200 rounded p-1.5",children:e.jsx(cs,{componentId:r,pageUrl:t.url,criterionId:u.criterionId,record:u,ack:i[u.criterionId]??null,onChanged:()=>c(h=>h+1)})},u.criterionId))})]}),Object.keys(i).length>0&&o.every(u=>i[u.criterionId])&&Object.keys(i).length>o.length&&e.jsx("p",{className:"text-[10px] text-emerald-700",children:"✓ All walkthroughs on this page either passed or are human-verified."}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-amber-700 mb-1",children:["Needs human review (",a.length,")"]}),e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"bg-white border border-amber-200 rounded p-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"font-mono text-[10px] font-bold uppercase px-1 rounded bg-amber-200 text-amber-900",children:"review"}),e.jsx("code",{className:"text-[10px] bg-slate-100 px-1 rounded",children:u.ruleId}),u.wcagCriterion&&e.jsx("span",{className:"text-[10px] text-slate-500",children:u.wcagCriterion})]}),e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:u.axeDescription}),e.jsx("code",{className:"block text-[10px] text-slate-500 break-all mt-0.5",children:u.representativeSelector}),u.failureSummary&&e.jsxs("p",{className:"text-[10px] text-slate-600 mt-1 whitespace-pre-wrap",children:[u.failureSummary.slice(0,400),u.failureSummary.length>400?"…":""]}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Da,{group:u})})]},`${u.ruleId}::${u.representativeSelector}`))})]}),e.jsx("div",{className:"pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-brand-600 hover:underline",children:"Open full single-page view (lenses, visualizers, guided checks) →"})})]})}const Ut="onboardingDismissed",_t=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function hl(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Ut).then(i=>{i[Ut]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ut]:!0}),s(!1),n(0)}const o=a===_t.length-1,l=_t[a];return e.jsxs(Ge,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",_t.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(i=>i-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),o?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(i=>i+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function ml(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function xl(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=m.useState(!1);if(!t)return null;const r=t.severity==="total",o=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",i=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${o}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",i]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}const it="aiConfig",gl=[{key:"altText",label:"Alt-text descriptiveness"},{key:"headings",label:"Heading clarity vs section content"},{key:"sensory",label:'Sensory-language instructions ("click the green button")'},{key:"aria",label:"ARIA role semantic correctness"},{key:"imageOfText",label:"Image-of-text detection"},{key:"colorOnlyMeaning",label:"Color-only meaning"},{key:"genericLinkText",label:'Generic link text ("click here", "read more")'},{key:"wallOfText",label:"Wall-of-text / readability"},{key:"languageMismatch",label:"Declared-language mismatch"}];function Oa(){const t=b(c=>c.results),s=b(c=>c.aiFailure),[a,n]=m.useState("unknown"),[r,o]=m.useState(!1);m.useEffect(()=>{function c(h){if(!h){n("off-no-key");return}if(!h.enabled){n("off-by-user");return}if(!h.apiKey){n("off-no-key");return}n("on")}chrome.storage.local.get(it).then(h=>c(h[it])).catch(()=>n("off-no-key"));const u=(h,g)=>{var f;g!=="local"||!(it in h)||c((f=h[it])==null?void 0:f.newValue)};return chrome.storage.onChanged.addListener(u),()=>chrome.storage.onChanged.removeListener(u)},[]);const l=t.length;if(m.useEffect(()=>{o(!1)},[l]),t.length===0||a==="on"||a==="unknown"||r||s)return null;const i=a==="off-by-user",d=i?"AI augmentation is off — semantic-quality checks did not run.":"No AI API key — semantic-quality checks did not run.",p=i?"You disabled AI in Settings. Structural checks (axe-core, DOM analyzers, state matrix) ran normally. The checks below would have added semantic quality verdicts.":"Structural checks (axe-core, DOM analyzers, state matrix) ran normally. The semantic-quality checks below would have added human-like content judgment — they need an Anthropic API key (BYO) to run.";return e.jsx("div",{role:"status",className:"px-3 py-2 border-b border-sky-200 bg-sky-50 text-xs text-sky-900 flex flex-col gap-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:"ℹ"})," ",d]}),e.jsx("div",{className:"mt-0.5",children:p}),e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"cursor-pointer hover:underline",children:"What didn't run"}),e.jsx("ul",{className:"mt-1 pl-4 list-disc text-[11px] leading-snug",children:gl.map(c=>e.jsx("li",{children:c.label},c.key))})]}),e.jsx("div",{className:"mt-1.5 flex gap-2",children:e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:"text-[11px] px-2 py-0.5 rounded bg-sky-600 text-white hover:bg-sky-700",children:"Enable in Settings"})})]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"hover:opacity-70 leading-none text-sm","aria-label":"Dismiss AI-off notice for this audit",title:"Dismiss for this audit",children:"×"})]})})}function Js(){const[t,s]=m.useState(!1);return m.useEffect(()=>be("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(Ge,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function fl(){var o;const[t,s]=m.useState(null);if(m.useEffect(()=>{kn().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await bs(),b.getState().startNewScan(),t.mode==="storybook-all"?je({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&je({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await bs(),s(null)}const r=t.mode==="storybook-all"?`Story ${((o=t.completedStories)==null?void 0:o.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Dt="storybook:hintDismissed";function bl(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var i;if((await chrome.storage.local.get(Dt))[Dt])return;const l=await me();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((i=p.result)==null?void 0:i.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Dt]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function vl(){var o;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.status),n=(o=t[0])==null?void 0:o.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${yl(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function yl(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const o=Math.round(r/60);if(o<60)return`${o}m ago`;const l=Math.round(o/60);if(l<24)return`${l}h ago`;const i=Math.round(l/24);return i<7?`${i}d ago`:a.toLocaleDateString()}function wl(){const t=b(i=>i.results),s=b(i=>i.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let i=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(i)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{i=!0}},[s]),t.length===0)return null;const r=t.flatMap(i=>i.violations),o=Sn(r,a.length>0?{runs:a,workflows:fe}:void 0),l=o.manual!==void 0&&o.manual.workflowsCompleted===o.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}const Fa={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 is clean on every check that automated lawsuit-targeting tools run.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix to drop off the easy-target list.",high:"High risk. Multiple findings here are patterns demand-letter mills target.",critical:"Critical risk. Your site has many high-frequency patterns ADA-targeting firms scan for."},version:0};Fa.ruleIds;function jl(){var t;return((t=An())==null?void 0:t.lawfare)??Fa}function Ma(t,s=jl()){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 Pa={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Nl={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Pa]},kl={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Pa]};function us(t){return t==="thorough"?kl:Nl}function Xs(t){const s=us(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}function Ga(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,o]=m.useState(0),[l,i]=m.useState(!1),[d,p]=m.useState(""),[c,u]=m.useState(""),[h,g]=m.useState(""),[f,y]=m.useState(!1);if(m.useEffect(()=>{let x=!1;return s(null),n(null),gt().then(C=>{x||s(C)}).catch(C=>{x||n(C instanceof Error?C.message:String(C))}),()=>{x=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const N=t.length,$=t.filter(x=>x.receipt).length,R=b(x=>x.tier),I=Ne(R,"exportPreLitigationReport");async function k(){if(!(!t||t.length===0)){y(!0);try{await ds({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),i(!1)}finally{y(!1)}}}async function S(){if(!t||t.length===0)return;const x={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},C=new Blob([JSON.stringify(x,null,2)],{type:"application/json"}),w=URL.createObjectURL(C),v=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,E=document.createElement("a");E.href=w,E.download=v,E.click(),setTimeout(()=>URL.revokeObjectURL(w),1e3)}return N===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[N," ",N===1?"entry":"entries",$>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[$," RFC 3161-anchored"]})]}),$===0&&N>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[I&&e.jsx("button",{type:"button",onClick:()=>i(x=>!x),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void S(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>o(x=>x+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:x=>p(x.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:x=>u(x.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:h,onChange:x=>g(x.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:f||N===0,onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:f?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(x=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${x.grade==="A"?"bg-emerald-100 text-emerald-700":x.grade==="B"?"bg-lime-100 text-lime-700":x.grade==="C"?"bg-yellow-100 text-yellow-700":x.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:x.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:x.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${x.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:x.receipt?`Anchored to ${x.receipt.tsaName} at ${x.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:x.receipt?`RFC 3161 (${x.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:x.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:x.capturedAt}),(x.totals.critical>0||x.totals.serious>0)&&e.jsxs("span",{children:[x.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[x.totals.critical," crit"]}),x.totals.critical>0&&x.totals.serious>0&&" · ",x.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[x.totals.serious," sev"]})]}),e.jsxs("span",{children:[x.statesAudited," ",x.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:x.hash,children:[x.hash.slice(0,12),"…"]})]})]},`${x.componentId}::${x.capturedAt}`))})]})}function Sl(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let d=!1;return gt().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,o=t[t.length-1],l=t.slice(0,3),i=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",o&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:o.capturedAt.slice(0,10)})]}),i>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[i," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(Ge,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(Ga,{})})})]})}function Al(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Cl={eyebrow:"You're on a trial",headline:"Full features unlocked while you evaluate.",body:"When your trial ends, a paid plan keeps RFC 3161 trusted-timestamp anchoring, AI fix suggestions, and audit-history evidence active for every scan."},Il={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},El={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Rl={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Va(){const t=b(u=>u.tier),s=b(u=>u.trialDaysRemaining),a=b(u=>u.seatsUsed),n=b(u=>u.seatsTotal),r=b(u=>u.planCode),o=b(u=>u.licenseDaysRemaining),l=b(u=>u.pastDue),[i,d]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=o,h=u!==null&&u<=7,g=u===null?"":u===0?"expires today":u===1?"1 day left":`${u} days left`;return e.jsxs("aside",{"aria-label":"License status",className:h?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:h?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),g&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",g]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Mt,{open:i,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?Rl:El,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,g=t==="team"&&a!==null&&n!==null&&a>n,f=t==="team"&&a!==null&&n!==null&&a===n,y=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:f?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${y.bg} border-b ${y.border} px-3 py-2 space-y-1 text-[11px] ${y.shadow}`,children:[e.jsxs("div",{className:y.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:y.subtitle,children:[" · ",h]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),g&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),f&&!g&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:y.link,children:"Manage license →"})})]})}const p=t==="trial"?Cl:Il,c=t==="trial"?Al(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Mt,{open:i,onClose:()=>d(!1)})]})}const Wa={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},Ba={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},jt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Tl={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},Zs={critical:0,serious:1,moderate:2,minor:3};function $l(){b(p=>p.setUserMode);const t=b(p=>p.status),s=b(p=>p.setStatus),a=b(p=>p.errorMessage),n=b(p=>p.setError),[r,o]=m.useState(!1),[l,i]=m.useState(!1),d=m.useRef(t);return m.useEffect(()=>{if(d.current==="running"&&t==="complete"){i(!0);const p=setTimeout(()=>i(!1),3500);return d.current=t,()=>clearTimeout(p)}d.current=t},[t]),m.useEffect(()=>{if(t!=="running")return;const p=setTimeout(()=>{b.getState().status==="running"&&(s("idle"),n("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[t,s,n]),e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(Va,{}),e.jsx(wa,{}),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(ja,{}),e.jsx(ya,{})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]})]}),t==="running"&&e.jsx(Ll,{}),e.jsx(Oa,{}),t==="failed"&&a&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:a}),e.jsx("button",{type:"button",onClick:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[r?e.jsx(_a,{onBack:()=>o(!1)}):e.jsx(_l,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Ul,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use, plus our extended DOM analyzers and AI walkthroughs covering all 50 WCAG 2.1 AA criteria."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function Ll(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 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 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void H({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function Ul(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function _l({onPickCrawl:t}){const s=b(h=>h.status),a=b(h=>h.results),n=b(h=>h.siteCrawlReport),[r,o]=m.useState("quick"),[l,i]=m.useState("all"),d=s==="running",p=a.flatMap(h=>h.violations),c=a.length>0;function u(){je({type:"START_AUDIT",mode:"full-page",matrixOverride:us(r)}),b.getState().startNewScan(),he.polite(`${r==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:u,disabled:d,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:d?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:d,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(Fl,{depth:r,onChange:o,disabled:d})]}),!c&&!d&&(n?e.jsx(Ol,{report:n,onView:t}):e.jsx(Dl,{})),c&&e.jsx(Ml,{violations:p,severityFilter:l,onSeverityFilterChange:i,scanDepth:r})]})}function Dl(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function Ol({report:t,onView:s}){const a=b(c=>c.tier),n=Ne(a,"lawfareRisk"),[r,o]=m.useState(null);m.useEffect(()=>{let c=!1;return Xe().then(u=>{c||o((u??[]).flatMap(h=>h.results.flatMap(g=>g.violations)))}),()=>{c=!0}},[t.startUrl,t.finishedAt]);let l=t.startUrl;try{l=new URL(t.startUrl).host}catch{}const i=`Whole-site crawl · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"} · ${l}`,d=e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline font-medium",children:"View full report →"});if(!n)return e.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:i}),e.jsxs("div",{className:"p-3 text-xs text-slate-600",children:["Whole-site crawl complete. ",d]})]});const p=r?Ma(r):null;return p?e.jsxs("div",{className:`border rounded-lg overflow-hidden ${Wa[p.tier]}`,children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:i}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ba[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}, whole site`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade · whole site"}),e.jsxs("p",{className:`text-base font-semibold ${jt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${jt[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged across ",t.pagesAudited," page",t.pagesAudited===1?"":"s",". ",d]}),p.flaggedRuleCount===0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:["No demand-letter-bait issues found site-wide. ",d]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners across the whole site. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade (open the full report or power/dev mode for that)."]})]})]})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:[e.jsx("p",{className:"text-[11px] text-brand-900 bg-brand-50 border-b border-brand-200 px-3 py-1.5",children:i}),e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Reading your last crawl…"})]})}function Fl({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:`${Xs("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:`${Xs("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})]})}function Ml({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var w;const r=b(v=>v.status),o=b(v=>v.results),l=b(v=>v.freshThisSession),i=b(v=>v.componentId),d=b(v=>v.tier),p=(w=o[0])==null?void 0:w.startedAt,u=Ne(d,"lawfareRisk")?Ma(t):null,h=r==="running",[g,f]=m.useState([]);m.useEffect(()=>{if(!i){f([]);return}let v=!1;return chrome.storage.local.get("igtRuns").then(E=>{if(v)return;const M=((E==null?void 0:E.igtRuns)??{})[i]??{};f(Object.values(M))}),()=>{v=!0}},[i]);const y=b(v=>v.acknowledgedKeys),N=o.length>0?oa(o,{runs:g,workflows:fe},"2.1","AA",y):void 0;function $(){je({type:"START_AUDIT",mode:"full-page",matrixOverride:us(n)}),b.getState().startNewScan(),he.polite("Re-scanning this page now.")}const R=s==="lawsuit-risk"?t.filter(v=>v.impact==="critical"||v.impact==="serious"):t,I=new Map;for(const v of R){const E=_e(v.ruleId,v.target.selector);I.has(E)||I.set(E,v)}const k=Array.from(I.values()),S=new Map;for(const v of k){const E=S.get(v.ruleId)??[];E.push(v),S.set(v.ruleId,E)}const x=Array.from(S.entries()).sort((v,E)=>(Zs[v[1][0].impact]??99)-(Zs[E[1][0].impact]??99)),C=t.filter(v=>v.impact==="critical"||v.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[p&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Hl,{iso:p})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void St(),disabled:h,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:$,disabled:h,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:h?"Scanning…":"↻ Scan again"})]})]}),h?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white 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",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):u?e.jsxs("div",{className:`border rounded-lg overflow-hidden ${Wa[u.tier]}`,children:[!l&&p&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ba[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${jt[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${jt[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 bg-slate-50",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-1",children:"Lawsuit-target risk grade isn’t available on your current plan"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Upgrade your plan to see the demand-letter exposure grade for this page."})]}),!h&&N&&!N.canClaimConformance&&e.jsx(Pl,{coverage:N}),!h&&N&&N.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",N.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(Bl,{}),e.jsx(Sl,{}),t.length>0&&e.jsx(Gl,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[x.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),x.map(([v,E])=>e.jsx(Vl,{ruleId:v,violations:E},v))]})]})}function Pl({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),H({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function Gl({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function Vl({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,o=Cn(t,r),l=s[0].impact,i=s[0],p=o.whatsWrong==="An accessibility rule failed on this page."&&i.description?i.description:o.whatsWrong,c=i.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Tl[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",o.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",o.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,g)=>e.jsx(Wl,{violation:h},g))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Wl({violation:t}){const s=b(o=>{var l;return(l=o.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(o){o.stopPropagation();const l=await me();if(l)try{const i=await Te(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(i.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const ot=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function Bl(){const t=b(c=>c.results),s=b(c=>c.componentId),[a,n]=m.useState(null),[r,o]=m.useState(!1),[l,i]=m.useState(null);async function d(c,u){if(t.length!==0){n(c);try{const h=await X({type:"EXPORT_REQUEST",format:c,results:t,wallClockMs:b.getState().lastAuditWallClockMs??void 0});if(c==="defense-bundle"||c==="evidence-bundle"){const g=Nt(c,s);await ha()?at(h.content,g):i({open:!0,format:c,content:h.content,filename:g})}else if(u)Ue(h.content);else{try{await navigator.clipboard.writeText(h.content),he.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const f=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
269
269
|
<style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
|
|
270
270
|
.banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
|
|
271
271
|
pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
|