@wcag-checkr/ci 1.0.0-rc.83 → 1.0.0-rc.85
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-edhCXS1l.js → ErrorBoundary-DkTwWwya.js} +43 -43
- package/dist/assets/color-suggestion-store-ClqdzGNO.js +1 -0
- package/dist/assets/devtools-panel-BnbmJr4R.js +1 -0
- package/dist/assets/{options-DGKfk9BH.js → options-DuBIC92M.js} +1 -1
- package/dist/assets/{parallel-tab-flow-DfPwgcjG.js → parallel-tab-flow-BvRkSiPP.js} +1 -1
- package/dist/assets/service-worker.ts-o0gZXi8R.js +791 -0
- package/dist/assets/side-panel-DTKKVWwa.js +1 -0
- package/dist/assets/styles-DHy73JkQ.css +1 -0
- package/dist/devtools/panel.html +5 -4
- package/dist/manifest.json +2 -2
- package/dist/options/options.html +3 -3
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/side-panel.html +5 -4
- package/package.json +1 -1
- package/dist/assets/devtools-panel-BWxBkSMj.js +0 -1
- package/dist/assets/service-worker.ts-CPD27rTF.js +0 -791
- package/dist/assets/side-panel-D4epz68O.js +0 -1
- package/dist/assets/styles-fx7lVjaT.css +0 -1
- /package/dist/assets/{styles--HFzXtFh.js → styles-VxXktT67.js} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/forensic-log-BGuH56yt.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-BIsozXtc.js","assets/site-report-renderer-CpRomwpZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var ls=Object.defineProperty;var cs=(t,s,a)=>s in t?ls(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ot=(t,s,a)=>cs(t,typeof s!="symbol"?s+"":s,a);import{R as we,i as se,r as f,j as e,M as me,C as Qe,l as ds,o as Ze,t as et,m as $t,s as _t,k as Ge}from"./styles--HFzXtFh.js";import{_ as $e}from"./preload-helper-D7HrI6pR.js";import{o as ee,r as Q,s as K,c as Lt,b as ne,d as ke}from"./crash-reporter-Dc5lvxvY.js";import{g as us,a as Z,u as ps,b as hs,c as ms,d as tt,A as z,l as st,e as Ee,f as Ut,h as xs,i as Dt,s as fs,j as gs,O as bs,k as vs,m as ys,n as lt,o as js,p as Ft,q as ws,r as Ns,t as ks,v as Ss,T as As,w as Cs,x as Rs}from"./forensic-log-BGuH56yt.js";import{B as Ve,i as Ot,b as Mt,T as Pt}from"./state-BIsozXtc.js";const ct=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,l={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,l);return l},Es=t=>t?ct(t):ct,Ts=t=>t;function Is(t,s=Ts){const a=we.useSyncExternalStore(t.subscribe,we.useCallback(()=>s(t.getState()),[t,s]),we.useCallback(()=>s(t.getInitialState()),[t,s]));return we.useDebugValue(a),a}const dt=t=>{const s=Es(t),a=n=>Is(s,n);return Object.assign(a,s),a},$s=t=>t?dt(t):dt,x=$s(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),_e="sidePanel:lastAudit";function _s(){const t=[];return t.push(ee("AUDIT_PROGRESS_EVENT",s=>{const a=x.getState().status==="running";x.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),x.getState().setStatus("running"),a||se.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ee("AUDIT_COMPLETE_EVENT",s=>{var i;x.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;se.polite(r),Ls({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(ee("AUDIT_FAILED_EVENT",s=>{x.getState().setError(s.error.message)})),t.push(ee("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=x.getState().aiProgress;x.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||se.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ee("AI_AUGMENTATION_FAILED_EVENT",s=>{x.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ee("SCORECARD_UPDATED_EVENT",()=>{Le()})),t.push(ee("LICENSE_CHANGED_EVENT",()=>{Gt()})),t.push(ee("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=x.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&se.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ee("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=x.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),se.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(ee("SITE_CRAWL_FAILED_EVENT",s=>{const a=x.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),se.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ls(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[_e]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Us(){const s=(await chrome.storage.local.get(_e))[_e];s&&x.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ds(){await chrome.storage.local.remove(_e)}async function at(){x.getState().clearResults(),await Ds()}async function Le(){const t=await Q({type:"BASELINE_LIST"});x.getState().setBaselineList(t.items)}async function Gt(t){const s=await Q({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});x.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Vt()}async function Vt(){const{fetchMessages:t}=await $e(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Hs);return{fetchMessages:n}},void 0),s=x.getState().userMode,a=await t(s);a&&x.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Fs(){const s=(await Q({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;x.getState().setUserMode(a)}function Os(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ue=null;async function Ms(){if(Ue===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ue=t.id)}catch{}}function Wt(){if(Ue===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ue}).catch(()=>{})}function ae(t){Wt(),K(t)}function Ps({onClose:t}){const[s,a]=f.useState(""),[n,r]=f.useState(""),[i,o]=f.useState(!0),[l,d]=f.useState(""),[p,c]=f.useState(!1),[u,h]=f.useState(null);async function g(m){var j;if(m.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const R=await Q({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});R.success?(h({ok:!0,msg:`Sent (ref: ${R.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=R.error)==null?void 0:j.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:m=>a(m.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:m=>r(m.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:m=>d(m.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:m=>o(m.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 ut({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 De=Lt("messages-client"),Gs="https://api.wcagcheckr.com",Bt="wcagcheckr",Vs=1e4;function Ws(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Ht(t,s){const a=await us();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ws()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Gs}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Vs)})}async function Bs(t){try{const s=await Ht(`/v1/products/${Bt}/messages`,{userMode:t??null});return s.ok?await s.json():(De.warn("fetchMessages http",s.status),null)}catch(s){return De.warn("fetchMessages failed",s),null}}async function ue(t,s){try{const a=await Ht(`/v1/products/${Bt}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(De.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return De.warn("ackMessage failed",a),!1}}const Hs=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ue,fetchMessages:Bs},Symbol.toStringTag,{value:"Module"})),zs=["http:","https:"];function Ks(t){try{const s=new URL(t);return zs.includes(s.protocol)}catch{return!1}}function pt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Ks(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(f.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(f.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function zt({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:pt(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:pt(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){o(),n.push(c[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const qs={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Qs={critical:"bg-rose-50 border-rose-200"};function Kt(){const t=x(h=>h.unreadMessageCount),s=x(h=>h.messages),a=x(h=>h.applyMessageAck),[n,r]=f.useState(!1),i=f.useRef(-1),[o,l]=f.useState(!1);f.useEffect(()=>{const h=s.filter(m=>!m.seen);if(h.length===0)return;const g=Math.max(...h.map(m=>m.id));if(g>i.current){i.current=g,l(!0);const m=setTimeout(()=>l(!1),1500);return()=>clearTimeout(m)}},[s]);async function d(){const h=s.filter(g=>!g.seen);if(h.length!==0)for(const g of h)a(g.id,"seen"),ue(g.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function c(h){a(h.id,"dismissed"),await ue(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),ue(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Js,{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(Ys,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function Js({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 Ys({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=f.useRef(null);return f.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{Vt()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${qs[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(zt,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function qt(){const t=x(i=>i.messages),s=x(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ue(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ue(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Qs.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(zt,{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 ge=["matrix","report","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Xs(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Zs(){var u,h;const t=x(g=>g.view),s=x(g=>g.setView),a=x(g=>g.setUserMode),n=x(g=>g.results),r=x(g=>g.status),[i,o]=f.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=Xs(l),p=n.length>0&&r!=="running";function c(){a("owner"),K({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Kt,{}),e.jsx(ut,{onClick:()=>void K({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(ut,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void at(),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(ea,{view:t,setView:s}),e.jsx(me,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Ps,{onClose:()=>o(!1)})})]})}function ea({view:t,setView:s}){const a=f.useRef([]);function n(i){var d;const o=(i+ge.length)%ge.length,l=ge[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ge.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ge.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function ta({feature:t,upgradeUrl:s}){const[a,n]=f.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(Qe,{open:a,onClose:()=>n(!1)})]})}const sa="https://wcagcheckr.com/upgrade";function aa(){const[t,s]=f.useState("single-element"),[a,n]=f.useState(!1),[r,i]=f.useState(null),[o,l]=f.useState(null),[d,p]=f.useState(Ve),[c,u]=f.useState(Ve[0].id),h=x(U=>U.status),g=x(U=>U.tier),m=x(U=>U.results.length>0),j=h==="running";f.useEffect(()=>{Promise.all([Q({type:"SETTINGS_GET",key:"matrixPresets"}),Q({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,C])=>{const F=Array.isArray(U.data)?U.data:null;p(F&&F.length>0?F:Ve),typeof C.data=="string"&&u(C.data)})},[]);function R(U){const C=d.find(F=>F.id===U);C&&(u(U),K({type:"SETTINGS_SET",key:"activePresetId",value:U}),K({type:"SETTINGS_SET",key:"stateMatrix",value:C.matrix}))}const I=Ot(g,"storybookAutoIterate");f.useEffect(()=>{const U=ee("ELEMENT_PICKED_EVENT",(F,P)=>{n(!1);const J=P.frameId;$(J),i({selector:F.selector,frameId:J})}),C=ee("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),C()}},[]);async function b(){const U=await Z();U&&(n(!0),await ne(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function v(){r&&($(r.frameId),ae({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),x.getState().startNewScan())}function y(){if(!I){l("storybook:auto-iterate");return}$(),ae({type:"START_AUDIT",mode:"storybook-all"}),x.getState().startNewScan()}function S(){$(),ae({type:"START_AUDIT",mode:"all-frames"}),x.getState().startNewScan()}function T(){$(),ae({type:"START_AUDIT",mode:"full-page"}),x.getState().startNewScan()}function w(){$(),ae({type:"START_AUDIT",mode:"quick-scan"}),x.getState().startNewScan()}function A(){$(),ae({type:"START_AUDIT",mode:"parallel-scan"}),x.getState().startNewScan()}function N(){K({type:"CANCEL_AUDIT"})}async function $(U){x.getState().setPinned(null);const C=await Z();if(C)try{await ne(C,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:C},U)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:U=>s(U.target.value),disabled:j||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)",I?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:U=>R(U.target.value),disabled:j||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(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),t==="single-element"?e.jsx(na,{picking:a,picked:r,isRunning:j,onPick:b,onRun:v,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:T,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:w,disabled:j,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:j?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:A,disabled:j,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:j?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:S,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all stories"}),j&&e.jsx("button",{onClick:N,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&m&&e.jsx("button",{type:"button",onClick:()=>void at(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!a&&!j&&e.jsx(ra,{selector:r.selector,onRepick:b,onClear:()=>i(null)})]}),e.jsx(me,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(ta,{feature:o??"",upgradeUrl:sa})})]})}function na({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function ra({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 ia={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},oa={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function la(){const[t,s]=f.useState(null),[a,n]=f.useState(!1),[r,i]=f.useState(null),[o,l]=f.useState("off"),p=x(g=>g.results).flatMap(g=>g.violations);async function c(g){const m=await Z();m&&(l(g),g==="off"?await ne(m,{type:"VISION_SIMULATOR_CLEAR",tabId:m}).catch(()=>{}):await ne(m,{type:"VISION_SIMULATOR_APPLY",tabId:m,mode:g}).catch(()=>{}))}async function u(g){const m=await Z();if(m){if(t&&await ne(m,{type:ia[t],tabId:m}).catch(()=>{}),t===g){s(null);return}await ne(m,{type:oa[g],tabId:m}).catch(()=>{}),s(g)}}async function h(){const g=await Z();if(g){if(a){await ne(g,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:g}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const m=await ke(g,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:g,violations:p});n(!0),i(`Previewing ${m.visualFixCount} visual fix${m.visualFixCount===1?"":"es"} + ${m.annotationCount} annotation${m.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(be,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(be,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(be,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(be,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(be,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:h}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:g=>void c(g.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function be({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 ca(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 da(){const t=x(d=>d.status),s=x(d=>d.progress),a=x(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}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":ca(s.currentState),o=n?100:s.current/s.total*100,l=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(ht,{label:r,detail:i,pct:o,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"}),l&&e.jsx(ht,{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 ht({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){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 ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const ve={"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 ua(t){return/^wcag\d/.test(t.wcagCriterion)?[ve["ada-iii"],ve[508],ve.eaa,ve["en-301-549"],ve.aoda]:[]}const pa={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 Fe({violation:t,alreadyAcknowledged:s}){const a=x(b=>b.pinnedMatchKey),n=x(b=>b.pinnedFound),r=x(b=>b.setPinned),i=x(b=>{var v;return(v=b.results[0])==null?void 0:v.frameId}),o=x(b=>{var v;return(v=b.results[0])==null?void 0:v.scope}),l=x(b=>b.results),d=x(b=>b.acknowledgedKeys.has(t.matchKey)),p=x(b=>b.markAcknowledged),c=x(b=>b.markUnacknowledged),u=s||d,h=a===t.matchKey,g=h&&!n;async function m(b){try{return(await ke(b,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:b,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const b=await Z();if(!b)return;if(h){r(null);try{await ne(b,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:b},i)}catch{}return}const v=await m(b);r(t.matchKey,v)}function R(b){b.stopPropagation(),t.currentState.breakpoint.width<=640&&Wt(),(async()=>{const v=await Z();if(!v)return;try{await Q({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:o,frameId:i})}catch{}const y=await m(v);r(t.matchKey,y)})()}async function I(b){b.stopPropagation();const v=await Z();if(!v)return;try{await Q({type:"STATE_DRIVE_REQUEST",tabId:v,state:fa(),scope:o,frameId:i})}catch{K({type:"STATE_RESET_REQUEST",tabId:v})}const y=await m(v);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:j,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
|
-
${h?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${pa[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(ga,{violation:t}),e.jsx(ya,{violation:t}),e.jsx(va,{violation:t}),e.jsx(ba,{text:t.target.failureSummary}),e.jsx(ja,{ruleId:t.ruleId}),h&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",ha(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:R,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),R(b))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:I,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),I(b))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),g&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),c(t.matchKey),xa(t,l)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),b.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),p(t.matchKey),ma(t,l)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),b.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:b=>b.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function ha(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 ma(t,s){await hs({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Qt(t.componentId,s)}async function xa(t,s){await ps(t.componentId,t.matchKey),await Qt(t.componentId,s)}async function Qt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Q({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});x.getState().setDelta(n.delta)}catch{}}function fa(){const t=Mt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Jt(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function ga({violation:t}){const s=Jt(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]})]})}function ba({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 va({violation:t}){const s=ua(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 ya({violation:t}){const s=Jt(t),[a,n]=f.useState({kind:"idle"});if(!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await Q({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);n(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function ja({ruleId:t}){const s=ms(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const Je=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function nt(t){const s=Je.map(i=>wa(i,t)),a=s.reduce((i,o)=>i+Na(o.letter),0)/Math.max(1,s.length),n=ka(Math.round(a)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:n,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function wa(t,s){const a=new Set(t.axeRules),n=s.violations.filter(w=>a.has(w.ruleId)),r=s.manualRuns.filter(w=>t.igtWorkflowIds.includes(w.workflowId)),i=t.igtWorkflowIds.map(w=>s.workflows.find(A=>A.id===w)).filter(w=>w!=null);let o=i.length>0;for(const w of i){const A=r.find($=>$.workflowId===w.id);if((A?Object.keys(A.steps).length:0)!==w.steps.length){o=!1;break}}const l=r.some(w=>Object.keys(w.steps).length>0),d=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(w=>d.includes(w.workflowId)),c=d.map(w=>s.workflows.find(A=>A.id===w)).filter(w=>w!=null);let u=d.length>0&&c.length===d.length;for(const w of c){const A=p.find($=>$.workflowId===w.id);if((A?Object.keys(A.steps).length:0)!==w.steps.length){u=!1;break}}let h=null;if(u)for(const w of p)w.completedAt&&(h===null||w.completedAt>h)&&(h=w.completedAt);const g=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,m=d[0]??t.igtWorkflowIds[0]??null;if(u&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:g,primaryVerifierWorkflowId:m,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j=t.axeRules.length>0||t.heuristic!=null,R=t.igtWorkflowIds.length>0;if(j?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:R||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const b={critical:0,serious:0,moderate:0,minor:0};for(const w of tt(n))b[w.impact]++;b.serious+=g;for(const w of r){const A=i.find(N=>N.id===w.workflowId);if(A)for(const N of A.steps){const $=w.steps[N.id];($==null?void 0:$.status)==="fail"&&(N.severity==="required"?b.serious++:b.moderate++)}}const v=b.critical>0,y=b.serious>0;let S;b.critical>=5?S="F":b.critical>=1?S="D":b.serious>=1?S="C":b.moderate>=1?S="B":S="A";const T=S!=="A"&&(R&&!o||d.length>0&&!u);return{id:t.id,label:t.label,letter:S,untested:!1,needsIgt:T,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:b,caps:{cappedAtC:v,cappedAtB:y}}}function Na(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function ka(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const Ye="dismissedFindings";function Me(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function pe(t){return`reading-order::${t}`}function he(t){return`tab-order::${t}`}async function Pe(){try{const t=await chrome.storage.local.get(Ye),s=t==null?void 0:t[Ye];if(s&&typeof s=="object")return s}catch{}return{}}async function rt(t){await chrome.storage.local.set({[Ye]:t})}async function Oe(t){return(await Pe())[Me(t)]??{}}async function Yt(t,s,a,n){const r=await Pe(),i=Me(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await rt(r)}async function Se(t,s){if(s.length===0)return;const a=await Pe(),n=Me(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await rt(a)}async function Xt(t,s){const a=await Pe(),n=Me(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await rt(a))}const Sa=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Yt,addDismissals:Se,dismissalKeyForReadingOrder:pe,dismissalKeyForTabOrder:he,getDismissalsForUrl:Oe,removeDismissal:Xt},Symbol.toStringTag,{value:"Module"}));function Zt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function es(t){return`${st(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Aa(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=es(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const mt={critical:0,serious:1,moderate:2,minor:3};function Ca(){var m,j,R,I;const t=x(b=>b.results),s=x(b=>b.componentId),a=x(b=>b.setView),n=((m=t[0])==null?void 0:m.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=f.useState({}),[o,l]=f.useState(new Set);if(f.useEffect(()=>{if(!n)return;Oe(n).then(i);const b=()=>{document.visibilityState==="visible"&&n&&Oe(n).then(i)};return document.addEventListener("visibilitychange",b),()=>document.removeEventListener("visibilitychange",b)},[n]),f.useEffect(()=>{if(!s){l(new Set);return}let b=!1;const v=async()=>{const S=await chrome.storage.local.get("igtRuns");if(b)return;const w=((S==null?void 0:S.igtRuns)??{})[s]??{},A=new Set;for(const N of z){const $=w[N.id];$&&Object.keys($.steps).length===N.steps.length&&A.add(N.id)}l(A)};v();const y=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",y),()=>{b=!0,document.removeEventListener("visibilitychange",y)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((b,v)=>b+v.durationMs,0),p=t.reduce((b,v)=>b+v.violations.length,0),c=Aa(t);c.sort((b,v)=>{const y=mt[b.representative.impact]??99,S=mt[v.representative.impact]??99;return y!==S?y-S:v.states.length-b.states.length});const u=t.map(b=>Zt(b.state)).join(`
|
|
4
|
-
`),h=o.has("keyboard")?0:(((
|
|
5
|
-
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const _a={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},La={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 Ua({violations:t,componentId:s}){var Y,te,X,re,ie,V,Ae;const[a,n]=f.useState([]),[r,i]=f.useState([]),[o,l]=f.useState(new Set),[d,p]=f.useState(null),[c,u]=f.useState({}),[h,g]=f.useState(new Set),m=x(_=>_.status),j=x(_=>_.progress),R=x(_=>_.freshThisSession),I=x(_=>_.results),b=(Y=I[0])==null?void 0:Y.startedAt,v=((te=I[0])==null?void 0:te.pageUrl)??((X=I[0])==null?void 0:X.scope)??null;if(f.useEffect(()=>{if(!s){n([]);return}let _=!1;return chrome.storage.local.get("igtRuns").then(B=>{if(_)return;const D=((B==null?void 0:B.igtRuns)??{})[s]??{};n(Object.values(D))}),()=>{_=!0}},[s]),f.useEffect(()=>{if(!v){i([]);return}let _=!1;return Ee(v).then(B=>{_||i(B)}),()=>{_=!0}},[v]),m==="running")return e.jsx(Va,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const y=nt({violations:t,auditRan:I.length>0,manualRuns:a,workflows:z,heuristicCounts:{tabOrder:((ie=(re=I[0])==null?void 0:re.tabOrderIssues)==null?void 0:ie.length)??0,readingOrder:((Ae=(V=I[0])==null?void 0:V.readingOrderIssues)==null?void 0:Ae.length)??0}}),S=x(_=>_.acknowledgedKeys),T=I.length>0?Ut(I,{runs:a,workflows:z},"2.1","AA",S,r):void 0,w=I.length>0?xs(Dt({audits:I,igtRuns:a,workflows:z,acknowledgedMatchKeys:S,incompleteResolutions:r}),z):void 0,A=T?T.failingCriteria.length>0||T.inconclusiveCriteria.length>0:!1,N=A&&y.overallLetter==="A"?"B":y.overallLetter;async function $(_){var H;if(!v||!((H=T==null?void 0:T.inconclusiveReasons)!=null&&H[_]))return;const k=T.inconclusiveReasons[_].filter(W=>W.source==="axe-incomplete"&&W.elements&&W.elements.length>0);if(k.length===0)return;l(W=>new Set(W).add(_)),p(null);const D=[];let L=0;try{for(const O of k){const q=await K({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:O.ruleOrStepId,pageUrl:O.pageUrl??v,wcagCriterion:_,elements:O.elements??[],targetLevel:"AA"});if(q!=null&&q.unavailableReason){p(q.unavailableReason);break}q!=null&&q.resolutions&&(D.push(...q.resolutions),L+=q.totalCostUsd??0)}if(v){const O=await Ee(v);i(O)}const W={total:D.length,pass:D.filter(O=>O.verdict==="pass").length,fail:D.filter(O=>O.verdict==="fail").length,uncertain:D.filter(O=>O.verdict==="uncertain").length,costUsd:L,resolutions:D};u(O=>({...O,[_]:W}))}finally{l(W=>{const O=new Set(W);return O.delete(_),O})}}function U(_){g(B=>{const k=new Set(B);return k.has(_)?k.delete(_):k.add(_),k})}async function C(_){var q,xe;if(!v)return;const B=((q=T==null?void 0:T.inconclusiveReasons)==null?void 0:q[_])??[],k=((xe=T==null?void 0:T.failingReasons)==null?void 0:xe[_])??[],D=[],L=new Set;for(const G of B){if(G.source!=="axe-incomplete"||!G.elements)continue;const oe=G.pageUrl??v;for(const le of G.elements){const fe=`${oe}::${G.ruleOrStepId}::${le.selector}`;L.has(fe)||(L.add(fe),D.push({ruleId:G.ruleOrStepId,pageUrl:oe,selector:le.selector}))}}for(const G of k){if(G.source!=="ai"||!G.selector)continue;const oe=G.ruleOrStepId.startsWith("ai-resolved::")?G.ruleOrStepId.slice(13):G.ruleOrStepId,le=G.pageUrl??v,fe=`${le}::${oe}::${G.selector}`;L.has(fe)||(L.add(fe),D.push({ruleId:oe,pageUrl:le,selector:G.selector}))}if(D.length===0)return;const H=new Date().toISOString(),W=[];for(const G of D){const oe=r.find(le=>le.pageUrl===G.pageUrl&&le.ruleId===G.ruleId&&le.selector===G.selector);oe&&oe.verdict==="pass"&&oe.reasoning.startsWith("Marked as visually verified")||W.push({pageUrl:G.pageUrl,ruleId:G.ruleId,selector:G.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${H.slice(0,10)}.`,resolvedAt:H,costUsd:0,wcagCriterion:_})}if(W.length===0)return;await fs(W);const O=await Ee(v);i(O),u(G=>({...G,[_]:{total:W.length,pass:W.length,fail:0,uncertain:0,costUsd:0,resolutions:W}}))}const F=(()=>{if(!A||y.overallLetter!=="A"||!T)return null;const _=T.inconclusiveCriteria.length,B=T.failingCriteria.length,k=[];B>0&&k.push(`${B} WCAG ${T.targetLevel} ${B===1?"criterion":"criteria"} failing`),_>0&&k.push(`${_} WCAG ${T.targetLevel} ${_===1?"criterion":"criteria"} inconclusive`);const D=B>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${k.join(" + ")}. ${D}`})();let P=0;for(const _ of z){const B=a.find(D=>D.workflowId===_.id);if(!B)continue;_.steps.every(D=>{const L=B.steps[D.id];return(L==null?void 0:L.status)==="pass"||(L==null?void 0:L.status)==="fail"||(L==null?void 0:L.status)==="skip"||(L==null?void 0:L.status)==="not-applicable"})&&P++}const J=tt(t.filter(_=>!S.has(_.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!R&&b&&e.jsx(Wa,{scannedAt:b}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${_a[N]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:N})}),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 ",y.subGrades.length," verification areas below. Untested areas count as F until verified."]}),F&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:F})]})]}),y.isLawsuitRisk&&e.jsx(Oa,{areas:y.warningAreas}),e.jsx(Ma,{grades:y.subGrades}),T&&e.jsx(Da,{coverage:T,onResolveWithAi:$,onMarkVisuallyVerified:C,resolving:o,resolveError:d,lastResolveResult:c,expandedResultFor:h,onToggleResultDetail:U}),w&&e.jsx(Fa,{layers:w}),e.jsx(Ga,{violationsRemaining:J,manualCompleted:P,manualTotal:z.length}),P>0||I.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:P})," of ",e.jsx("strong",{children:z.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:`${P/z.length*100}%`}})})]}):null]})}function Da({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,c]=f.useState(d>0&&d<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,g=[];return t.failingCriteria.length>0&&g.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&g.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&g.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${h?"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 ${h?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",u,"%)"]}),h&&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)."]}),!h&&(()=>{const m=[];t.failingCriteria.length>0&&m.push("failing"),t.inconclusiveCriteria.length>0&&m.push("inconclusive"),t.untestedCriteria.length>0&&m.push("untested");const j=m.length===0?"unresolved":m.length===1?m[0]:m.length===2?`${m[0]} or ${m[1]}`:`${m.slice(0,-1).join(", ")}, or ${m[m.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!h&&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."]}),!h&&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."]})]}),!h&&g.length>0&&e.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!h&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[g.map(m=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${m.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[m.kind==="untested"?"Untested":m.kind==="inconclusive"?"Inconclusive":"Failing"," (",m.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:m.ids.map(j=>{var w,A;const R=m.kind==="inconclusive"?(w=t.inconclusiveReasons)==null?void 0:w[j]:void 0,I=m.kind==="failing"?(A=t.failingReasons)==null?void 0:A[j]:void 0,b=R==null?void 0:R.some(N=>N.source==="axe-incomplete"&&N.elements&&N.elements.length>0),v=I==null?void 0:I.some(N=>N.source==="ai"),y=(n==null?void 0:n.has(j))??!1,S=i==null?void 0:i[j],T=(o==null?void 0:o.has(j))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",j]}),(m.kind==="inconclusive"&&b||m.kind==="failing"&&v)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[m.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:y,onClick:()=>s(j),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:y?"Resolving…":S?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:y,onClick:()=>a(j),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:m.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"})]})]}),S&&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 ",S.total," ",S.total===1?"verdict":"verdicts",":",S.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",S.pass," pass"]}),S.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",S.fail," fail"]}),S.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",S.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",S.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(j),className:"ml-auto text-[10px] underline text-brand-700",children:T?"hide reasoning":"show reasoning"})]}),S.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",S.uncertain," ",S.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),S.pass===S.total&&S.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."]}),T&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:S.resolutions.map((N,$)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:N.verdict==="pass"?"text-emerald-700 font-semibold":N.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:N.verdict==="pass"?"✓":N.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:N.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:N.reasoning})]},$))})]}),I&&I.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:I.map((N,$)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[N.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),N.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," fail — "]}),N.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," fail — "]}),N.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:N.selector}),N.notes&&e.jsx("span",{className:"text-rose-700",children:N.notes})]},$))}),R&&R.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:R.map((N,$)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[N.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," — "]}),N.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," skipped — "]}),N.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," — "]}),N.resolutionHint,N.elements&&N.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",N.elements.length===1?"element":`${N.elements.length} elements`,":"," ",N.elements.slice(0,3).map((U,C,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:U.selector}),C<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},C)),N.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",N.elements.length-3," more"]})]})]},$))}):m.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},j)})})]},m.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 ft={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 Fa({layers:t}){const s=x(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,d=r.cleared,p=i>0&&o===0&&l===0,c=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:ft[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:ft[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function Oa({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 Ma({grades:t}){const s=x(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${La[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(Pa,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Pa({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=z.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?ts(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",n?` ${n} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Ga({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=x(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const d=l===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function Va({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 Wa({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 (",ts(s)," old). Re-scan to grade the current page state."]})]})}function ts(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 Ba(){const t=x(a=>a.results),s=x(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(Ua,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(Ha,{})]})}function Ha(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(ye,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(ye,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(ye,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(ye,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(ye,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function ye({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const za={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 Ka({ruleId:t,violations:s}){const[a,n]=f.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Fe,{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 ${za[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(Fe,{violation:d},p))})]})}function qa(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 Qa={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function ss({open:t,onClose:s,format:a,content:n,filename:r}){const i=ds(new Blob([n]).size);function o(){et(n,r),s()}function l(){Ze(n),s()}return e.jsxs(me,{open:t,onClose:s,title:Qa[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const gt=7800;function Ja(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(m=>`${m.ruleId}::${m.target.selector}`===u);if(g){g._states.includes(h)||g._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
6
|
-
`),d=new URLSearchParams({title:i,body:l});let p=`${n}/issues/new?${d.toString()}`;return p.length>
|
|
7
|
-
`),d=new URLSearchParams({summary:i,description:l});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>bt&&(p=p.slice(0,bt)),{url:p,summary:i,description:l}}function
|
|
2
|
+
var cs=Object.defineProperty;var ds=(t,s,a)=>s in t?cs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ot=(t,s,a)=>ds(t,typeof s!="symbol"?s+"":s,a);import{R as Ne,i as se,r as x,j as e,M as xe,C as Ye,l as us,o as et,t as tt,m as _t,s as Lt,k as We}from"./styles-VxXktT67.js";import{_ as $e}from"./preload-helper-D7HrI6pR.js";import{o as te,r as q,s as Q,c as Ut,b as ne,d as Se}from"./crash-reporter-Dc5lvxvY.js";import{g as ps,a as X,u as hs,b as ms,c as xs,d as st,A as K,l as at,e as Ee,f as Dt,h as gs,i as Ot,s as fs,j as bs,O as vs,k as ys,m as js,n as lt,o as ws,p as Ft,q as Ns,r as ks,t as Ss,v as As,T as Cs,w as Rs,x as Es}from"./forensic-log-BGuH56yt.js";import{B as Ve,i as Mt,b as Pt,T as Gt}from"./state-BIsozXtc.js";import{getColorSuggestion as Is,saveColorSuggestion as Ts,saveColorSuggestions as $s}from"./color-suggestion-store-ClqdzGNO.js";const ct=t=>{let s;const a=new Set,n=(p,c)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=c??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(f=>f(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,l);return l},_s=t=>t?ct(t):ct,Ls=t=>t;function Us(t,s=Ls){const a=Ne.useSyncExternalStore(t.subscribe,Ne.useCallback(()=>s(t.getState()),[t,s]),Ne.useCallback(()=>s(t.getInitialState()),[t,s]));return Ne.useDebugValue(a),a}const dt=t=>{const s=_s(t),a=n=>Us(s,n);return Object.assign(a,s),a},Ds=t=>t?dt(t):dt,g=Ds(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),_e="sidePanel:lastAudit";function Os(){const t=[];return t.push(te("AUDIT_PROGRESS_EVENT",s=>{const a=g.getState().status==="running";g.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),g.getState().setStatus("running"),a||se.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(te("AUDIT_COMPLETE_EVENT",s=>{var i;g.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;se.polite(r),Fs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(te("AUDIT_FAILED_EVENT",s=>{g.getState().setError(s.error.message)})),t.push(te("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=g.getState().aiProgress;g.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||se.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(te("AI_AUGMENTATION_FAILED_EVENT",s=>{g.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(te("SCORECARD_UPDATED_EVENT",()=>{Le()})),t.push(te("LICENSE_CHANGED_EVENT",()=>{Wt()})),t.push(te("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&se.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(te("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),se.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(te("SITE_CRAWL_FAILED_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),se.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Fs(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[_e]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ms(){const s=(await chrome.storage.local.get(_e))[_e];s&&g.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ps(){await chrome.storage.local.remove(_e)}async function Me(){g.getState().clearResults(),await Ps()}async function Le(){const t=await q({type:"BASELINE_LIST"});g.getState().setBaselineList(t.items)}async function Wt(t){const s=await q({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});g.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Vt()}async function Vt(){const{fetchMessages:t}=await $e(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Qs);return{fetchMessages:n}},void 0),s=g.getState().userMode,a=await t(s);a&&g.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Gs(){const s=(await q({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;g.getState().setUserMode(a)}function Ws(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ue=null;async function Vs(){if(Ue===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ue=t.id)}catch{}}function Bt(){if(Ue===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ue}).catch(()=>{})}function ae(t){Bt(),Q(t)}function Bs({onClose:t}){const[s,a]=x.useState(""),[n,r]=x.useState(""),[i,o]=x.useState(!0),[l,d]=x.useState(""),[p,c]=x.useState(!1),[u,h]=x.useState(null);async function f(m){var j;if(m.preventDefault(),!(!s.trim()||!n.trim())){c(!0),h(null);try{const N=await q({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});N.success?(h({ok:!0,msg:`Sent (ref: ${N.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=N.error)==null?void 0:j.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:m=>a(m.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:m=>r(m.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:m=>d(m.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:m=>o(m.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 ut({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 De=Ut("messages-client"),Hs="https://api.wcagcheckr.com",Ht="wcagcheckr",zs=1e4;function Ks(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function zt(t,s){const a=await ps();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ks()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Hs}${t}`,{...s,headers:n,signal:AbortSignal.timeout(zs)})}async function qs(t){try{const s=await zt(`/v1/products/${Ht}/messages`,{userMode:t??null});return s.ok?await s.json():(De.warn("fetchMessages http",s.status),null)}catch(s){return De.warn("fetchMessages failed",s),null}}async function pe(t,s){try{const a=await zt(`/v1/products/${Ht}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(De.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return De.warn("ackMessage failed",a),!1}}const Qs=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:pe,fetchMessages:qs},Symbol.toStringTag,{value:"Module"})),Ys=["http:","https:"];function Js(t){try{const s=new URL(t);return Ys.includes(s.protocol)}catch{return!1}}function pt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Js(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(x.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Kt({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:pt(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:pt(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(p);if(c){o(),n.push(c[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Xs={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Zs={critical:"bg-rose-50 border-rose-200"};function qt(){const t=g(h=>h.unreadMessageCount),s=g(h=>h.messages),a=g(h=>h.applyMessageAck),[n,r]=x.useState(!1),i=x.useRef(-1),[o,l]=x.useState(!1);x.useEffect(()=>{const h=s.filter(m=>!m.seen);if(h.length===0)return;const f=Math.max(...h.map(m=>m.id));if(f>i.current){i.current=f,l(!0);const m=setTimeout(()=>l(!1),1500);return()=>clearTimeout(m)}},[s]);async function d(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)a(f.id,"seen"),pe(f.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 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(ea,{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(ta,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function ea({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 ta({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=x.useRef(null);return x.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{Vt()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Xs[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(Kt,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function Qt(){const t=g(i=>i.messages),s=g(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.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 ${Zs.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(Kt,{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 be=["matrix","report","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function sa(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function aa(){var u,h;const t=g(f=>f.view),s=g(f=>f.setView),a=g(f=>f.setUserMode),n=g(f=>f.results),r=g(f=>f.status),[i,o]=x.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=sa(l),p=n.length>0&&r!=="running";function c(){a("owner"),Q({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(qt,{}),e.jsx(ut,{onClick:()=>void Q({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(ut,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void Me(),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(na,{view:t,setView:s}),e.jsx(xe,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Bs,{onClose:()=>o(!1)})})]})}function na({view:t,setView:s}){const a=x.useRef([]);function n(i){var d;const o=(i+be.length)%be.length,l=be[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(be.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:be.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function ra({feature:t,upgradeUrl:s}){const[a,n]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ye,{open:a,onClose:()=>n(!1)})]})}const ia="https://wcagcheckr.com/upgrade";function oa(){const[t,s]=x.useState("single-element"),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState(null),[d,p]=x.useState(Ve),[c,u]=x.useState(Ve[0].id),h=g($=>$.status),f=g($=>$.tier),m=g($=>$.results.length>0),j=h==="running";x.useEffect(()=>{Promise.all([q({type:"SETTINGS_GET",key:"matrixPresets"}),q({type:"SETTINGS_GET",key:"activePresetId"})]).then(([$,A])=>{const F=Array.isArray($.data)?$.data:null;p(F&&F.length>0?F:Ve),typeof A.data=="string"&&u(A.data)})},[]);function N($){const A=d.find(F=>F.id===$);A&&(u($),Q({type:"SETTINGS_SET",key:"activePresetId",value:$}),Q({type:"SETTINGS_SET",key:"stateMatrix",value:A.matrix}))}const R=Mt(f,"storybookAutoIterate");x.useEffect(()=>{const $=te("ELEMENT_PICKED_EVENT",(F,O)=>{n(!1);const H=O.frameId;T(H),i({selector:F.selector,frameId:H})}),A=te("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{$(),A()}},[]);async function b(){const $=await X();$&&(n(!0),await ne($,{type:"PICKER_ACTIVATE_REQUEST",tabId:$}))}function k(){r&&(T(r.frameId),ae({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),g.getState().startNewScan())}function y(){if(!R){l("storybook:auto-iterate");return}T(),ae({type:"START_AUDIT",mode:"storybook-all"}),g.getState().startNewScan()}function C(){T(),ae({type:"START_AUDIT",mode:"all-frames"}),g.getState().startNewScan()}function L(){T(),ae({type:"START_AUDIT",mode:"full-page"}),g.getState().startNewScan()}function w(){T(),ae({type:"START_AUDIT",mode:"quick-scan"}),g.getState().startNewScan()}function I(){T(),ae({type:"START_AUDIT",mode:"parallel-scan"}),g.getState().startNewScan()}function v(){Q({type:"CANCEL_AUDIT"})}async function T($){g.getState().setPinned(null);const A=await X();if(A)try{await ne(A,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:A},$)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:$=>s($.target.value),disabled:j||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)",R?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:$=>N($.target.value),disabled:j||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($=>e.jsx("option",{value:$.id,children:$.name},$.id))}),t==="single-element"?e.jsx(la,{picking:a,picked:r,isRunning:j,onPick:b,onRun:k,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:L,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:w,disabled:j,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:j?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:I,disabled:j,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:j?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:C,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all stories"}),j&&e.jsx("button",{onClick:v,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&m&&e.jsx("button",{type:"button",onClick:()=>void Me(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!a&&!j&&e.jsx(ca,{selector:r.selector,onRepick:b,onClear:()=>i(null)})]}),e.jsx(xe,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(ra,{feature:o??"",upgradeUrl:ia})})]})}function la({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function ca({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 da={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},ua={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function pa(){const[t,s]=x.useState(null),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState("off"),p=g(f=>f.results).flatMap(f=>f.violations);async function c(f){const m=await X();m&&(l(f),f==="off"?await ne(m,{type:"VISION_SIMULATOR_CLEAR",tabId:m}).catch(()=>{}):await ne(m,{type:"VISION_SIMULATOR_APPLY",tabId:m,mode:f}).catch(()=>{}))}async function u(f){const m=await X();if(m){if(t&&await ne(m,{type:da[t],tabId:m}).catch(()=>{}),t===f){s(null);return}await ne(m,{type:ua[f],tabId:m}).catch(()=>{}),s(f)}}async function h(){const f=await X();if(f){if(a){await ne(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const m=await Se(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});n(!0),i(`Previewing ${m.visualFixCount} visual fix${m.visualFixCount===1?"":"es"} + ${m.annotationCount} annotation${m.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(ve,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ve,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(ve,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(ve,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ve,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:h}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void c(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ve({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 ha(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 ma(){const t=g(d=>d.status),s=g(d=>d.progress),a=g(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}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":ha(s.currentState),o=n?100:s.current/s.total*100,l=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(ht,{label:r,detail:i,pct:o,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"}),l&&e.jsx(ht,{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 ht({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){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 ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const ye={"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 xa(t){return/^wcag\d/.test(t.wcagCriterion)?[ye["ada-iii"],ye[508],ye.eaa,ye["en-301-549"],ye.aoda]:[]}const ga={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 Oe({violation:t,alreadyAcknowledged:s}){const a=g(b=>b.pinnedMatchKey),n=g(b=>b.pinnedFound),r=g(b=>b.setPinned),i=g(b=>{var k;return(k=b.results[0])==null?void 0:k.frameId}),o=g(b=>{var k;return(k=b.results[0])==null?void 0:k.scope}),l=g(b=>b.results),d=g(b=>b.acknowledgedKeys.has(t.matchKey)),p=g(b=>b.markAcknowledged),c=g(b=>b.markUnacknowledged),u=s||d,h=a===t.matchKey,f=h&&!n;async function m(b){try{return(await Se(b,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:b,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const b=await X();if(!b)return;if(h){r(null);try{await ne(b,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:b},i)}catch{}return}const k=await m(b);r(t.matchKey,k)}function N(b){b.stopPropagation(),t.currentState.breakpoint.width<=640&&Bt(),(async()=>{const k=await X();if(!k)return;try{await q({type:"STATE_DRIVE_REQUEST",tabId:k,state:t.currentState,scope:o,frameId:i})}catch{}const y=await m(k);r(t.matchKey,y)})()}async function R(b){b.stopPropagation();const k=await X();if(!k)return;try{await q({type:"STATE_DRIVE_REQUEST",tabId:k,state:ya(),scope:o,frameId:i})}catch{Q({type:"STATE_RESET_REQUEST",tabId:k})}const y=await m(k);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:j,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
|
+
${h?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${ga[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(ja,{violation:t}),e.jsx(ka,{violation:t}),e.jsx(Na,{violation:t}),e.jsx(wa,{text:t.target.failureSummary}),e.jsx(Sa,{ruleId:t.ruleId}),h&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",fa(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:N,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),N(b))},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:R,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),R(b))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),f&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),c(t.matchKey),va(t,l)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),b.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),p(t.matchKey),ba(t,l)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),b.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:b=>b.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function fa(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 ba(t,s){await ms({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Yt(t.componentId,s)}async function va(t,s){await hs(t.componentId,t.matchKey),await Yt(t.componentId,s)}async function Yt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await q({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});g.getState().setDelta(n.delta)}catch{}}function ya(){const t=Pt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Jt(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function ja({violation:t}){const s=Jt(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]})]})}function wa({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 Na({violation:t}){const s=xa(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 ka({violation:t}){const s=Jt(t),[a,n]=x.useState({kind:"idle"});if(x.useEffect(()=>{let i=!1;return Is(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await q({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);l?(await Ts(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Sa({ruleId:t}){const s=xs(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const Je=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function nt(t){const s=Je.map(i=>Aa(i,t)),a=s.reduce((i,o)=>i+Ca(o.letter),0)/Math.max(1,s.length),n=Ra(Math.round(a)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:n,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function Aa(t,s){const a=new Set(t.axeRules),n=s.violations.filter(w=>a.has(w.ruleId)),r=s.manualRuns.filter(w=>t.igtWorkflowIds.includes(w.workflowId)),i=t.igtWorkflowIds.map(w=>s.workflows.find(I=>I.id===w)).filter(w=>w!=null);let o=i.length>0;for(const w of i){const I=r.find(T=>T.workflowId===w.id);if((I?Object.keys(I.steps).length:0)!==w.steps.length){o=!1;break}}const l=r.some(w=>Object.keys(w.steps).length>0),d=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(w=>d.includes(w.workflowId)),c=d.map(w=>s.workflows.find(I=>I.id===w)).filter(w=>w!=null);let u=d.length>0&&c.length===d.length;for(const w of c){const I=p.find(T=>T.workflowId===w.id);if((I?Object.keys(I.steps).length:0)!==w.steps.length){u=!1;break}}let h=null;if(u)for(const w of p)w.completedAt&&(h===null||w.completedAt>h)&&(h=w.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,m=d[0]??t.igtWorkflowIds[0]??null;if(u&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:f,primaryVerifierWorkflowId:m,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j=t.axeRules.length>0||t.heuristic!=null,N=t.igtWorkflowIds.length>0;if(j?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:N||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const b={critical:0,serious:0,moderate:0,minor:0};for(const w of st(n))b[w.impact]++;b.serious+=f;for(const w of r){const I=i.find(v=>v.id===w.workflowId);if(I)for(const v of I.steps){const T=w.steps[v.id];(T==null?void 0:T.status)==="fail"&&(v.severity==="required"?b.serious++:b.moderate++)}}const k=b.critical>0,y=b.serious>0;let C;b.critical>=5?C="F":b.critical>=1?C="D":b.serious>=1?C="C":b.moderate>=1?C="B":C="A";const L=C!=="A"&&(N&&!o||d.length>0&&!u);return{id:t.id,label:t.label,letter:C,untested:!1,needsIgt:L,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:b,caps:{cappedAtC:k,cappedAtB:y}}}function Ca(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function Ra(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const Xe="dismissedFindings";function Pe(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function he(t){return`reading-order::${t}`}function me(t){return`tab-order::${t}`}async function Ge(){try{const t=await chrome.storage.local.get(Xe),s=t==null?void 0:t[Xe];if(s&&typeof s=="object")return s}catch{}return{}}async function rt(t){await chrome.storage.local.set({[Xe]:t})}async function Fe(t){return(await Ge())[Pe(t)]??{}}async function Xt(t,s,a,n){const r=await Ge(),i=Pe(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await rt(r)}async function Ae(t,s){if(s.length===0)return;const a=await Ge(),n=Pe(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await rt(a)}async function Zt(t,s){const a=await Ge(),n=Pe(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await rt(a))}const Ea=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Xt,addDismissals:Ae,dismissalKeyForReadingOrder:he,dismissalKeyForTabOrder:me,getDismissalsForUrl:Fe,removeDismissal:Zt},Symbol.toStringTag,{value:"Module"}));function es(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ts(t){return`${at(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Ia(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=ts(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const mt={critical:0,serious:1,moderate:2,minor:3};function Ta(){var m,j,N,R;const t=g(b=>b.results),s=g(b=>b.componentId),a=g(b=>b.setView),n=((m=t[0])==null?void 0:m.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=x.useState({}),[o,l]=x.useState(new Set);if(x.useEffect(()=>{if(!n)return;Fe(n).then(i);const b=()=>{document.visibilityState==="visible"&&n&&Fe(n).then(i)};return document.addEventListener("visibilitychange",b),()=>document.removeEventListener("visibilitychange",b)},[n]),x.useEffect(()=>{if(!s){l(new Set);return}let b=!1;const k=async()=>{const C=await chrome.storage.local.get("igtRuns");if(b)return;const w=((C==null?void 0:C.igtRuns)??{})[s]??{},I=new Set;for(const v of K){const T=w[v.id];T&&Object.keys(T.steps).length===v.steps.length&&I.add(v.id)}l(I)};k();const y=()=>{document.visibilityState==="visible"&&k()};return document.addEventListener("visibilitychange",y),()=>{b=!0,document.removeEventListener("visibilitychange",y)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((b,k)=>b+k.durationMs,0),p=t.reduce((b,k)=>b+k.violations.length,0),c=Ia(t);c.sort((b,k)=>{const y=mt[b.representative.impact]??99,C=mt[k.representative.impact]??99;return y!==C?y-C:k.states.length-b.states.length});const u=t.map(b=>es(b.state)).join(`
|
|
4
|
+
`),h=o.has("keyboard")?0:(((N=t[0])==null?void 0:N.tabOrderIssues)??[]).filter(b=>!(me(b.selector)in r)).length,f=o.has("page-structure")?0:(((R=t[0])==null?void 0:R.readingOrderIssues)??[]).filter(b=>!(he(b.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Ua,{violations:t.flatMap(b=>b.violations),componentId:s,manualRuns:[]}),(h>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:h})," tab-order issue",h===1?"":"s"," (WCAG 2.4.3)"]}),h>0&&f>0&&" · ",f>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:f})," reading-order issue",f===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:u,"aria-label":`${t.length} states tested: ${u.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",c.length," unique ",c.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(_a,{groups:c,totalStates:t.length,violations:t.flatMap(b=>b.violations)})]})}const $a={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 _a({groups:t,totalStates:s,violations:a}){const n=nt({violations:a,auditRan:!0,manualRuns:[],workflows:K,heuristicCounts:{}}),r=new Map,i=new Set;for(const l of Je){for(const d of l.axeRules)i.add(d);r.set(l.id,[])}const o=[];for(const l of t){let d=!1;for(const p of Je)if(p.axeRules.includes(l.representative.ruleId)){r.get(p.id).push(l),d=!0;break}d||o.push(l)}return e.jsxs("div",{className:"space-y-1.5",children:[n.subGrades.map(l=>{const d=r.get(l.id)??[];return e.jsx(xt,{subGrade:l,groups:d,totalStates:s},l.id)}),o.length>0&&e.jsx(xt,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:o,totalStates:s})]})}function xt({subGrade:t,groups:s,totalStates:a}){const[n,r]=x.useState(!1),[i,o]=x.useState("idle"),[l,d]=x.useState(null),[p,c]=x.useState(0),u=s.length>0,h=$a[t.letter],f=s.filter(N=>N.representative.ruleId==="color-contrast"||N.representative.ruleId==="color-contrast-enhanced"),m=f.length>=2;async function j(N){N.stopPropagation(),o("loading"),d(null);try{const R=f.map(k=>{const y=k.representative.target.outerHTML,C=k.representative.target.failureSummary,L=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(C),w=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(C);if(!L||!w)return null;const I=k.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:k.representative.matchKey,foreground:L[1],background:w[1],fontSize:16,fontWeight:400,targetLevel:I,_html:y}}).filter(k=>k!==null);if(R.length===0){o("error"),d("Could not parse fg/bg colors from the violation failure summaries.");return}const b=await q({type:"AI_COLOR_SUGGEST_REQUEST",inputs:R.map(({_html:k,...y})=>y)});if(b.unavailableReason&&b.results.length===0){o("error"),d(b.unavailableReason);return}await $s(b.results),o("done"),c(k=>k+1),n||r(!0)}catch(R){o("error"),d(R instanceof Error?R.message:String(R))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(N=>!N),"aria-expanded":n,disabled:!u,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${h}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:u?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),m&&e.jsx("span",{role:"button",tabIndex:0,onClick:N=>void j(N),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j(N))},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 ${f.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${f.length}`:`✨ Suggest for all ${f.length}`}),u&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&l&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:l}),n&&u&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(N=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Oe,{violation:N.representative}),e.jsx(Da,{states:N.states,totalStates:a})]},`${ts(N.representative)}::${p}`))})]})}const La={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 Ua({violations:t,componentId:s,manualRuns:a}){const n=g(d=>d.setView),i=nt({violations:t,auditRan:!0,manualRuns:a,workflows:K,heuristicCounts:{}}).overallLetter,l=st(t).length;return e.jsx("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${La[i]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:i})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:l===0?"No issues found by automation":`${l} issue${l===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>n("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function Da({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(es))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
|
|
5
|
+
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const Oa={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Fa={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 Ma({violations:t,componentId:s}){var ee,le,Z,re,ce,G,J;const[a,n]=x.useState([]),[r,i]=x.useState([]),[o,l]=x.useState(new Set),[d,p]=x.useState(null),[c,u]=x.useState({}),[h,f]=x.useState(new Set),m=g(_=>_.status),j=g(_=>_.progress),N=g(_=>_.freshThisSession),R=g(_=>_.results),b=(ee=R[0])==null?void 0:ee.startedAt,k=((le=R[0])==null?void 0:le.pageUrl)??((Z=R[0])==null?void 0:Z.scope)??null;if(x.useEffect(()=>{if(!s){n([]);return}let _=!1;return chrome.storage.local.get("igtRuns").then(V=>{if(_)return;const D=((V==null?void 0:V.igtRuns)??{})[s]??{};n(Object.values(D))}),()=>{_=!0}},[s]),x.useEffect(()=>{if(!k){i([]);return}let _=!1;return Ee(k).then(V=>{_||i(V)}),()=>{_=!0}},[k]),m==="running")return e.jsx(za,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const y=nt({violations:t,auditRan:R.length>0,manualRuns:a,workflows:K,heuristicCounts:{tabOrder:((ce=(re=R[0])==null?void 0:re.tabOrderIssues)==null?void 0:ce.length)??0,readingOrder:((J=(G=R[0])==null?void 0:G.readingOrderIssues)==null?void 0:J.length)??0}}),C=g(_=>_.acknowledgedKeys),L=R.length>0?Dt(R,{runs:a,workflows:K},"2.1","AA",C,r):void 0,w=R.length>0?gs(Ot({audits:R,igtRuns:a,workflows:K,acknowledgedMatchKeys:C,incompleteResolutions:r}),K):void 0,I=L?L.failingCriteria.length>0||L.inconclusiveCriteria.length>0:!1,v=I&&y.overallLetter==="A"?"B":y.overallLetter;async function T(_){var z;if(!k||!((z=L==null?void 0:L.inconclusiveReasons)!=null&&z[_]))return;const S=L.inconclusiveReasons[_].filter(B=>B.source==="axe-incomplete"&&B.elements&&B.elements.length>0);if(S.length===0)return;l(B=>new Set(B).add(_)),p(null);const D=[];let U=0;try{for(const M of S){const Y=await Q({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:M.ruleOrStepId,pageUrl:M.pageUrl??k,wcagCriterion:_,elements:M.elements??[],targetLevel:"AA"});if(Y!=null&&Y.unavailableReason){p(Y.unavailableReason);break}Y!=null&&Y.resolutions&&(D.push(...Y.resolutions),U+=Y.totalCostUsd??0)}if(k){const M=await Ee(k);i(M)}const B={total:D.length,pass:D.filter(M=>M.verdict==="pass").length,fail:D.filter(M=>M.verdict==="fail").length,uncertain:D.filter(M=>M.verdict==="uncertain").length,costUsd:U,resolutions:D};u(M=>({...M,[_]:B}))}finally{l(B=>{const M=new Set(B);return M.delete(_),M})}}function $(_){f(V=>{const S=new Set(V);return S.has(_)?S.delete(_):S.add(_),S})}async function A(_){var Y,ge;if(!k)return;const V=((Y=L==null?void 0:L.inconclusiveReasons)==null?void 0:Y[_])??[],S=((ge=L==null?void 0:L.failingReasons)==null?void 0:ge[_])??[],D=[],U=new Set;for(const W of V){if(W.source!=="axe-incomplete"||!W.elements)continue;const ie=W.pageUrl??k;for(const oe of W.elements){const fe=`${ie}::${W.ruleOrStepId}::${oe.selector}`;U.has(fe)||(U.add(fe),D.push({ruleId:W.ruleOrStepId,pageUrl:ie,selector:oe.selector}))}}for(const W of S){if(W.source!=="ai"||!W.selector)continue;const ie=W.ruleOrStepId.startsWith("ai-resolved::")?W.ruleOrStepId.slice(13):W.ruleOrStepId,oe=W.pageUrl??k,fe=`${oe}::${ie}::${W.selector}`;U.has(fe)||(U.add(fe),D.push({ruleId:ie,pageUrl:oe,selector:W.selector}))}if(D.length===0)return;const z=new Date().toISOString(),B=[];for(const W of D){const ie=r.find(oe=>oe.pageUrl===W.pageUrl&&oe.ruleId===W.ruleId&&oe.selector===W.selector);ie&&ie.verdict==="pass"&&ie.reasoning.startsWith("Marked as visually verified")||B.push({pageUrl:W.pageUrl,ruleId:W.ruleId,selector:W.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${z.slice(0,10)}.`,resolvedAt:z,costUsd:0,wcagCriterion:_})}if(B.length===0)return;await fs(B);const M=await Ee(k);i(M),u(W=>({...W,[_]:{total:B.length,pass:B.length,fail:0,uncertain:0,costUsd:0,resolutions:B}}))}const F=(()=>{if(!I||y.overallLetter!=="A"||!L)return null;const _=L.inconclusiveCriteria.length,V=L.failingCriteria.length,S=[];V>0&&S.push(`${V} WCAG ${L.targetLevel} ${V===1?"criterion":"criteria"} failing`),_>0&&S.push(`${_} WCAG ${L.targetLevel} ${_===1?"criterion":"criteria"} inconclusive`);const D=V>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${S.join(" + ")}. ${D}`})();let O=0;for(const _ of K){const V=a.find(D=>D.workflowId===_.id);if(!V)continue;_.steps.every(D=>{const U=V.steps[D.id];return(U==null?void 0:U.status)==="pass"||(U==null?void 0:U.status)==="fail"||(U==null?void 0:U.status)==="skip"||(U==null?void 0:U.status)==="not-applicable"})&&O++}const H=st(t.filter(_=>!C.has(_.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!N&&b&&e.jsx(Ka,{scannedAt:b}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Oa[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 ",y.subGrades.length," verification areas below. Untested areas count as F until verified."]}),F&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:F})]})]}),y.isLawsuitRisk&&e.jsx(Wa,{areas:y.warningAreas}),e.jsx(Va,{grades:y.subGrades}),L&&e.jsx(Pa,{coverage:L,onResolveWithAi:T,onMarkVisuallyVerified:A,resolving:o,resolveError:d,lastResolveResult:c,expandedResultFor:h,onToggleResultDetail:$}),w&&e.jsx(Ga,{layers:w}),e.jsx(Ha,{violationsRemaining:H,manualCompleted:O,manualTotal:K.length}),O>0||R.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:O})," of ",e.jsx("strong",{children:K.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${O/K.length*100}%`}})})]}):null]})}function Pa({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,c]=x.useState(d>0&&d<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,f=[];return t.failingCriteria.length>0&&f.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&f.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&f.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${h?"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 ${h?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",u,"%)"]}),h&&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)."]}),!h&&(()=>{const m=[];t.failingCriteria.length>0&&m.push("failing"),t.inconclusiveCriteria.length>0&&m.push("inconclusive"),t.untestedCriteria.length>0&&m.push("untested");const j=m.length===0?"unresolved":m.length===1?m[0]:m.length===2?`${m[0]} or ${m[1]}`:`${m.slice(0,-1).join(", ")}, or ${m[m.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!h&&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."]}),!h&&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."]})]}),!h&&f.length>0&&e.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!h&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[f.map(m=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${m.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[m.kind==="untested"?"Untested":m.kind==="inconclusive"?"Inconclusive":"Failing"," (",m.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:m.ids.map(j=>{var w,I;const N=m.kind==="inconclusive"?(w=t.inconclusiveReasons)==null?void 0:w[j]:void 0,R=m.kind==="failing"?(I=t.failingReasons)==null?void 0:I[j]:void 0,b=N==null?void 0:N.some(v=>v.source==="axe-incomplete"&&v.elements&&v.elements.length>0),k=R==null?void 0:R.some(v=>v.source==="ai"),y=(n==null?void 0:n.has(j))??!1,C=i==null?void 0:i[j],L=(o==null?void 0:o.has(j))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",j]}),(m.kind==="inconclusive"&&b||m.kind==="failing"&&k)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[m.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:y,onClick:()=>s(j),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:y?"Resolving…":C?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:y,onClick:()=>a(j),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:m.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"})]})]}),C&&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 ",C.total," ",C.total===1?"verdict":"verdicts",":",C.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",C.pass," pass"]}),C.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",C.fail," fail"]}),C.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",C.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",C.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(j),className:"ml-auto text-[10px] underline text-brand-700",children:L?"hide reasoning":"show reasoning"})]}),C.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",C.uncertain," ",C.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),C.pass===C.total&&C.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."]}),L&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:C.resolutions.map((v,T)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:v.verdict==="pass"?"text-emerald-700 font-semibold":v.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:v.verdict==="pass"?"✓":v.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:v.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:v.reasoning})]},T))})]}),R&&R.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:R.map((v,T)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[v.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),v.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," fail — "]}),v.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," fail — "]}),v.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:v.selector}),v.notes&&e.jsx("span",{className:"text-rose-700",children:v.notes})]},T))}),N&&N.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:N.map((v,T)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[v.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," — "]}),v.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," skipped — "]}),v.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:v.ruleOrStepId})," — "]}),v.resolutionHint,v.elements&&v.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",v.elements.length===1?"element":`${v.elements.length} elements`,":"," ",v.elements.slice(0,3).map(($,A,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:$.selector}),A<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},A)),v.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",v.elements.length-3," more"]})]})]},T))}):m.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},j)})})]},m.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 gt={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 Ga({layers:t}){const s=g(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,d=r.cleared,p=i>0&&o===0&&l===0,c=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:gt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:gt[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function Wa({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 Va({grades:t}){const s=g(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Fa[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(Ba,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Ba({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=K.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?ss(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",n?` ${n} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Ha({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=g(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const d=l===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function za({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 Ka({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 (",ss(s)," old). Re-scan to grade the current page state."]})]})}function ss(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 qa(){const t=g(a=>a.results),s=g(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(Ma,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(Qa,{})]})}function Qa(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(je,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(je,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(je,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(je,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(je,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function je({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Ya={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 Ja({ruleId:t,violations:s}){const[a,n]=x.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Oe,{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 ${Ya[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(Oe,{violation:d},p))})]})}function Xa(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 Za={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function as({open:t,onClose:s,format:a,content:n,filename:r}){const i=us(new Blob([n]).size);function o(){tt(n,r),s()}function l(){et(n),s()}return e.jsxs(xe,{open:t,onClose:s,title:Za[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const ft=7800;function en(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,f=r.find(m=>`${m.ruleId}::${m.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
6
|
+
`),d=new URLSearchParams({title:i,body:l});let p=`${n}/issues/new?${d.toString()}`;return p.length>ft&&(p=p.slice(0,ft)),{url:p,title:i,body:l}}const bt=7800;function tn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const u=`${c.ruleId}::${c.target.selector}`,h=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,f=r.find(m=>`${m.ruleId}::${m.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...c,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`Rule: ${c.ruleId} (${c.impact})`),o.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),o.push(`Description: ${c.description}`),o.push(`Selector: ${c.target.selector}`),o.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&o.push(`More info: ${c.helpUrl}`),o.push(""),o.push(`HTML: ${c.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
|
|
7
|
+
`),d=new URLSearchParams({summary:i,description:l});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>bt&&(p=p.slice(0,bt)),{url:p,summary:i,description:l}}const vt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest"],sn=["wcag-component-auditor","wcag-forensic-log"];async function an(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(vt);s=Object.keys(n).length,await chrome.storage.local.remove(vt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of sn)try{await nn(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 nn(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"))})}function rn(){const t=g(v=>v.delta),s=g(v=>v.componentId),a=g(v=>v.results),n=g(v=>v.tier),r=g(v=>v.baselineList),i=g(v=>v.siteCrawlReport),[o,l]=x.useState(""),[d,p]=x.useState(""),[c,u]=x.useState(!1),[h,f]=x.useState(!1),[m,j]=x.useState(null),[N,R]=x.useState(null);x.useEffect(()=>{Promise.all([q({type:"SETTINGS_GET",key:"githubRepoUrl"}),q({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,T])=>{l(typeof v.data=="string"?v.data:""),p(typeof T.data=="string"?T.data:"")})},[]);const b=Mt(n,"exportJson"),k=Gt[n].maxBaselines,y=r.some(v=>v.componentId===s),C=y||r.length<k;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 L(){if(!s||a.length===0)return;const v=a.flatMap(ee=>ee.violations),T=a.flatMap(ee=>ee.announcements??[]),$=a.flatMap(ee=>ee.focusEvents??[]),A=a[0],O=(await q({type:"SETTINGS_GET",key:"stateMatrix"})).data??Pt;await Q({type:"BASELINE_SET",componentId:s,violations:v,announcements:T,focusEvents:$,snapshotMeta:{url:window.location.href,axeVersion:A.axeVersion,matrixConfig:O,capturedAt:new Date().toISOString()}});const H=await q({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:T,focusEvents:$,currentMatrix:O});g.getState().setDelta(H.delta),se.polite(`Baseline saved for ${s}.`)}async function w(){if(!s||!y||!window.confirm(`Remove the saved baseline for "${s}"?
|
|
8
8
|
|
|
9
|
-
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await
|
|
9
|
+
Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Q({type:"BASELINE_DELETE",componentId:s});const T=a.flatMap(H=>H.violations),$=a.flatMap(H=>H.announcements??[]),A=a.flatMap(H=>H.focusEvents??[]),F=await q({type:"BASELINE_COMPARE",componentId:s,currentViolations:T,announcements:$,focusEvents:A});g.getState().setDelta(F.delta);const O=await q({type:"BASELINE_LIST"});g.getState().setBaselineList(O.items),se.polite(`Baseline cleared for ${s}.`)}async function I(v,T=!1){var ce,G;if(a.length===0)return;let $;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const J=await chrome.storage.local.get("igtRuns"),V=((J==null?void 0:J.igtRuns)??{})[s]??{};$=Object.values(V)}let A,F;if(v==="ai-prompt"){const J=((ce=a[0])==null?void 0:ce.pageUrl)??((G=a[0])==null?void 0:G.scope)??"";if(J){const{getDismissalsForUrl:_}=await $e(async()=>{const{getDismissalsForUrl:D}=await Promise.resolve().then(()=>Ea);return{getDismissalsForUrl:D}},void 0),V=await _(J);A=Object.keys(V);const{getResolutionsForPage:S}=await $e(async()=>{const{getResolutionsForPage:D}=await import("./forensic-log-BGuH56yt.js").then(U=>U.M);return{getResolutionsForPage:D}},__vite__mapDeps([0,1,2]));F=await S(J)}}const O=await q({type:"EXPORT_REQUEST",format:v,results:a,delta:T?void 0:t??void 0,manualRuns:$,siteCrawlReport:v==="ai-prompt"?i??void 0:void 0,dismissedKeys:A,incompleteResolutions:F});if(v==="defense-bundle"||v==="evidence-bundle"){const J=_t(v,s);await Lt()?tt(O.content,J):R({open:!0,format:v,content:O.content,filename:J});return}if(v==="html-print"||v==="vpat"){et(O.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText(O.content)}catch{}const _=`<!doctype html><html><head><meta charset="utf-8"><title>AI fix prompt</title>
|
|
10
10
|
<style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
|
|
11
11
|
.banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
|
|
12
12
|
pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}
|
|
@@ -17,46 +17,46 @@ button:hover{background:#f1f5f9;}</style></head>
|
|
|
17
17
|
<strong>Already copied to your clipboard.</strong> Paste it into Claude, Cursor, Copilot Chat, or any LLM with codebase access.
|
|
18
18
|
<button id="copy" style="margin-left:12px;">Copy again</button>
|
|
19
19
|
</div>
|
|
20
|
-
<pre id="content">${
|
|
20
|
+
<pre id="content">${O.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>
|
|
21
21
|
<script>
|
|
22
22
|
document.getElementById('copy').addEventListener('click', () => {
|
|
23
23
|
navigator.clipboard.writeText(document.getElementById('content').textContent || '');
|
|
24
24
|
});
|
|
25
25
|
<\/script>
|
|
26
|
-
</body></html>`,X=new Blob([te],{type:"text/html"}),re=URL.createObjectURL(X);window.open(re,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(re),6e4);return}const N=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",$=v==="junit"?"xml":v,U=new Blob([A.content],{type:N}),C=URL.createObjectURL(U),F=document.createElement("a");F.href=C,F.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${$}`,F.click(),URL.revokeObjectURL(C)}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:R,disabled:!j,title:j?void 0:`Free tier limits you to ${g} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),m&&e.jsx("button",{onClick:I,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx(sn,{disabled:!h,onExport:b,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!j&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const v=We(t.new),y=We(t.persistent),S=We(t.fixed),T=[...v.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(je,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>en(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>tn(d,s,v.findings)}]:[]]}),e.jsx(je,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(je,{title:"Fixed",violations:S.findings,count:t.fixedCount,accent:"green"}),T.length>0&&e.jsx(je,{title:"Needs review (does not affect grade)",violations:T,count:T.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(je,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),c&&e.jsx(ss,{open:c.open,onClose:()=>u(null),format:c.format,content:c.content,filename:c.filename})]})}const Za={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function We(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 je({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=f.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Za[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,p)=>e.jsx(Fe,{violation:d,alreadyAcknowledged:!0},p)):qa(s).map(d=>e.jsx(Ka,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function en(t,s,a){if(a.length===0)return;const{url:n}=Ja(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function tn(t,s,a){if(a.length===0)return;const{url:n}=Ya(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function sn({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=f.useState(!1),[i,o]=f.useState(!1);function l(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ce,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ce,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ce,{onClick:()=>l("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>l("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ce,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ce,{onClick:()=>l("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ce,{onClick:()=>l("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ce({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 vt="igtRuns";async function an(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(vt))[vt];return s&&typeof s=="object"?s:{}}async function nn(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await an())[t];if(i)for(const d of z){const p=i[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const g=a.tabOrderIssues??[];if(g.length===0)continue;await Se(n,g.map(m=>({key:he(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const g=a.readingOrderIssues??[];if(g.length===0)continue;await Se(n,g.map(m=>({key:pe(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}}}}const rn=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"]),on=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 ln(t){return rn.has(t.ruleId)}function cn(t){return on.has(t.ruleId)}function dn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function un(){var A,N,$,U;const t=x(C=>C.results),s=x(C=>C.delta),a=x(C=>C.componentId),n=((A=t[0])==null?void 0:A.pageUrl)??((N=t[0])==null?void 0:N.scope)??"",[r,i]=f.useState({}),[o,l]=f.useState(0);f.useEffect(()=>{if(!n)return;let C=!1;return(async()=>{if(a&&t.length>0)try{await nn(a,t)}catch{}if(C)return;const F=await Oe(n);C||i(F)})(),()=>{C=!0}},[n,o,a,t]);async function d(C,F){if(!n)return;const P=window.prompt(`Why is this finding a false positive?
|
|
26
|
+
</body></html>`,V=new Blob([_],{type:"text/html"}),S=URL.createObjectURL(V);window.open(S,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(S),6e4);return}const H=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",ee=v==="junit"?"xml":v,le=new Blob([O.content],{type:H}),Z=URL.createObjectURL(le),re=document.createElement("a");re.href=Z,re.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${ee}`,re.click(),URL.revokeObjectURL(Z)}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:L,disabled:!C,title:C?void 0:`Free tier limits you to ${k} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),y&&e.jsx("button",{onClick:w,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>u(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx(dn,{disabled:!b,onExport:I,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!C&&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 v=Be(t.new),T=Be(t.persistent),$=Be(t.fixed),A=[...v.review,...T.review];return e.jsxs(e.Fragment,{children:[e.jsx(we,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>ln(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>cn(d,s,v.findings)}]:[]]}),e.jsx(we,{title:"Persistent",violations:T.findings,count:T.findings.length,accent:"slate"}),e.jsx(we,{title:"Fixed",violations:$.findings,count:t.fixedCount,accent:"green"}),A.length>0&&e.jsx(we,{title:"Needs review (does not affect grade)",violations:A,count:A.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(we,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),N&&e.jsx(as,{open:N.open,onClose:()=>R(null),format:N.format,content:N.content,filename:N.filename}),c&&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"})]})]}),m&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",m.chromeStorageKeysCleared," chrome.storage key",m.chromeStorageKeysCleared===1?"":"s"," + ",m.indexedDbsCleared.length," database",m.indexedDbsCleared.length===1?"":"s",".",m.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",m.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:m?e.jsx("button",{type:"button",onClick:()=>{u(!1),j(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>u(!1),disabled:h,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()=>{f(!0);try{const v=await an();j(v),await Me(),se.polite("Audit data reset. Ready for a fresh scan.")}catch(v){j({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[v instanceof Error?v.message:String(v)]})}finally{f(!1)}},disabled:h,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:h?"Resetting…":"Reset everything"})]})})]})})]})}const on={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Be(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 we({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=x.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${on[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,p)=>e.jsx(Oe,{violation:d,alreadyAcknowledged:!0},p)):Xa(s).map(d=>e.jsx(Ja,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function ln(t,s,a){if(a.length===0)return;const{url:n}=en(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function cn(t,s,a){if(a.length===0)return;const{url:n}=tn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function dn({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=x.useState(!1),[i,o]=x.useState(!1);function l(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(de,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(de,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(de,{onClick:()=>l("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(de,{onClick:()=>l("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(de,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(de,{onClick:()=>l("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(de,{onClick:()=>l("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(de,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function de({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 yt="igtRuns";async function un(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(yt))[yt];return s&&typeof s=="object"?s:{}}async function pn(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await un())[t];if(i)for(const d of K){const p=i[d.id];if(p)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const f=a.tabOrderIssues??[];if(f.length===0)continue;await Ae(n,f.map(m=>({key:me(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const f=a.readingOrderIssues??[];if(f.length===0)continue;await Ae(n,f.map(m=>({key:he(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}}}}const hn=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"]),mn=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 xn(t){return hn.has(t.ruleId)}function gn(t){return mn.has(t.ruleId)}function fn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function bn(){var I,v,T,$;const t=g(A=>A.results),s=g(A=>A.delta),a=g(A=>A.componentId),n=((I=t[0])==null?void 0:I.pageUrl)??((v=t[0])==null?void 0:v.scope)??"",[r,i]=x.useState({}),[o,l]=x.useState(0);x.useEffect(()=>{if(!n)return;let A=!1;return(async()=>{if(a&&t.length>0)try{await pn(a,t)}catch{}if(A)return;const F=await Fe(n);A||i(F)})(),()=>{A=!0}},[n,o,a,t]);async function d(A,F){if(!n)return;const O=window.prompt(`Why is this finding a false positive?
|
|
27
27
|
|
|
28
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");P!==null&&(await Yt(n,C,P||"(no reason given)",F),l(J=>J+1))}async function p(C){n&&(await Xt(n,C),l(F=>F+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((C,F)=>{var P;return C+(((P=F.announcements)==null?void 0:P.length)??0)},0),u=t.reduce((C,F)=>{var P;return C+(((P=F.focusEvents)==null?void 0:P.length)??0)},0),h=t.reduce((C,F)=>{var P;return C+(((P=F.focusEvents)==null?void 0:P.filter(J=>J.isFocusReset).length)??0)},0),g=yt(t,ln),m=yt(t,cn),j=g.length,R=m.length,I=(($=t[0])==null?void 0:$.readingOrderIssues)??[],b=((U=t[0])==null?void 0:U.tabOrderIssues)??[],v=I.filter(C=>!(pe(C.selector)in r)),y=I.filter(C=>pe(C.selector)in r),S=b.filter(C=>!(he(C.selector)in r)),T=b.filter(C=>he(C.selector)in r);if(c===0&&u===0&&j===0&&R===0&&v.length===0&&S.length===0&&y.length===0&&T.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=y.length+T.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:[j," structural · ",R," form ·"," ",S.length," tab-order ·"," ",v.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),w>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",w," dismissed"]})]}),S.length>0&&e.jsx(mn,{issues:S,onDismiss:d}),v.length>0&&e.jsx(xn,{issues:v,onDismiss:d}),w>0&&e.jsx(fn,{dismissedReadingOrder:y,dismissedTabOrder:T,dismissals:r,onRestore:p}),j>0&&e.jsx(jt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:g}),R>0&&e.jsx(jt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:m}),e.jsx(pn,{delta:s}),t.map((C,F)=>{const P=C.announcements??[],J=C.focusEvents??[];return P.length===0&&J.length===0?null:e.jsx(hn,{state:C.state,announcements:P,focusEvents:J},F)})]})}function pn({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function yt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=st(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function jt({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 hn({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:dn(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 mn({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function xn({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 fn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=f.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Xe="igtRuns";async function gn(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Se(r,o.map(l=>({key:he(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Se(r,o.map(l=>({key:pe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const bn={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"}},vn={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"}},yn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function wt(t,s){const a=await Z();if(!a)return;const n=s?bn[t]:vn[t];try{await ne(a,n)}catch{}}async function jn(){const s=(await chrome.storage.local.get(Xe))[Xe];return s&&typeof s=="object"?s:{}}async function Nt(t){await chrome.storage.local.set({[Xe]:t})}function wn(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 Nn(){const t=x(c=>c.componentId),s=x(c=>c.results),[a,n]=f.useState({}),[r,i]=f.useState(null);if(f.useEffect(()=>{jn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,u,h){var m;const g={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((m=o[c])==null?void 0:m.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(g),Nt(g),h.status==="pass"){const j=z.find(I=>I.id===c),R=j==null?void 0:j.steps.find(I=>I.id===u);R!=null&&R.autoDismissActivity&&gn(R.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[c];const h={...a,[t]:u};n(h),Nt(h)}const p=z.find(c=>c.id===r);if(p){const c=o[p.id];return e.jsx(kn,{workflow:p,run:c,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),z.map(c=>{const u=o[c.id],h=u?gs(u,c):null,g=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",m={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:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${m}`,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:j=>{j.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function kn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=f.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=wn(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void wt(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",yn[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void wt(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(Ce,{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(Ce,{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(Ce,{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(Ce,{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 Sn={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 Ce({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?Sn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Te="savedFlows";async function An(){const t=await chrome.storage.local.get(Te);return Array.isArray(t[Te])?t[Te]:[]}async function kt(t){await chrome.storage.local.set({[Te]:t})}function Cn(){const[t,s]=f.useState([]),[a,n]=f.useState(!1),[r,i]=f.useState(null);f.useEffect(()=>{An().then(s)},[]);async function o(){const c=await Z();if(!c){i("No audit-target tab found.");return}try{await ne(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await Z();if(c)try{const u=await ke(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},m=[g,...t];s(m),await kt(m),i(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await Z();if(u){i(`Replaying "${c.name}"…`);try{const h=await ke(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==c);s(u),await kt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Rn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(En).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function En(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Tn(){const t=x(l=>l.baselineList),s=x(l=>l.tier),a=Pt[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=f.useState(!1);if(f.useEffect(()=>{Le().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await K({type:"BASELINE_DELETE",componentId:l}),await Le()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=Rn(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(de,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(de,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(de,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(de,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(de,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(de,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(de,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const In={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 de({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${In[t]}`,children:a})}const $n={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"},_n={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Ln={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function as({onBack:t}){const s=x(u=>u.siteCrawlStatus),a=x(u=>u.siteCrawlProgress),n=x(u=>u.siteCrawlReport),r=x(u=>u.siteCrawlError),[i,o]=f.useState(""),[l,d]=f.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var g;const h=(g=u[0])==null?void 0:g.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(x.getState().setSiteCrawlStatus("running"),x.getState().setSiteCrawlReport(null),x.getState().setSiteCrawlError(null),ae({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function c(){K({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>d(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Un,{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 Un({report:t}){function s(){$e(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-CpRomwpZ.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,0,1,2])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${$n[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${_n[t.siteRisk]}`,children:bs[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(a=>{const n=vs(a.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ln[a.impact]}`,children:a.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:n.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:a.urlsAffected})," page",a.urlsAffected===1?"":"s"," · ",a.totalOccurrences," total spot",a.totalOccurrences===1?"":"s"]})]})]})},a.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(a=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${a.grade==="A"?"text-emerald-700":a.grade==="B"?"text-lime-700":a.grade==="C"?"text-yellow-700":a.grade==="D"?"text-orange-700":"text-rose-700"}`,children:a.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:a.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:a.uniqueViolations})]},a.url))})]})]})}const Be="onboardingDismissed",He=[{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 Dn(){const[t,s]=f.useState(!1),[a,n]=f.useState(0);f.useEffect(()=>{chrome.storage.local.get(Be).then(l=>{l[Be]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Be]:!0}),s(!1),n(0)}const i=a===He.length-1,o=He[a];return e.jsxs(me,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",He.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Fn(){const t=x(n=>n.status),s=x(n=>n.errorMessage),a=x(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 On(){const t=x(d=>d.aiFailure),s=x(d=>d.clearAiFailure),[a,n]=f.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function St(){const[t,s]=f.useState(!1);return f.useEffect(()=>ee("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),x.getState().setStatus("idle"))}),[]),e.jsxs(me,{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 Mn(){var i;const[t,s]=f.useState(null);if(f.useEffect(()=>{ys().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await lt(),x.getState().startNewScan(),t.mode==="storybook-all"?ae({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ae({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await lt(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const ze="storybook:hintDismissed";function Pn(){const[t,s]=f.useState(!1),[a,n]=f.useState();f.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(ze))[ze])return;const o=await Z();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[ze]:!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 Gn(){var i;const t=x(o=>o.results),s=x(o=>o.baselineList),a=x(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Vn(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 Vn(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Wn(){const t=x(l=>l.results),s=x(l=>l.componentId),[a,n]=f.useState([]);if(f.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=js(r,a.length>0?{runs:a,workflows:z}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Bn(){const t=x(a=>a.setUserMode);function s(a){t(a),K({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Hn=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],zn={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function Kn(t){const s=new Set(Hn),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:zn[o]}}const ns={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},qn={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[ns]},Qn={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[ns]};function it(t){return t==="thorough"?Qn:qn}function At(t){const s=it(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Ie="wcagcheckr";function M(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ne(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 Jn(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Yn(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 Xn(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 Zn(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 er(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 (${M(t.receipt.tsaName)}) — anchored ${M(Ne(t.receipt.anchoredAt))}</td></tr>
|
|
29
|
-
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${
|
|
30
|
-
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${
|
|
28
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");O!==null&&(await Xt(n,A,O||"(no reason given)",F),l(H=>H+1))}async function p(A){n&&(await Zt(n,A),l(F=>F+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((A,F)=>{var O;return A+(((O=F.announcements)==null?void 0:O.length)??0)},0),u=t.reduce((A,F)=>{var O;return A+(((O=F.focusEvents)==null?void 0:O.length)??0)},0),h=t.reduce((A,F)=>{var O;return A+(((O=F.focusEvents)==null?void 0:O.filter(H=>H.isFocusReset).length)??0)},0),f=jt(t,xn),m=jt(t,gn),j=f.length,N=m.length,R=((T=t[0])==null?void 0:T.readingOrderIssues)??[],b=(($=t[0])==null?void 0:$.tabOrderIssues)??[],k=R.filter(A=>!(he(A.selector)in r)),y=R.filter(A=>he(A.selector)in r),C=b.filter(A=>!(me(A.selector)in r)),L=b.filter(A=>me(A.selector)in r);if(c===0&&u===0&&j===0&&N===0&&k.length===0&&C.length===0&&y.length===0&&L.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=y.length+L.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:[j," structural · ",N," form ·"," ",C.length," tab-order ·"," ",k.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),w>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",w," dismissed"]})]}),C.length>0&&e.jsx(jn,{issues:C,onDismiss:d}),k.length>0&&e.jsx(wn,{issues:k,onDismiss:d}),w>0&&e.jsx(Nn,{dismissedReadingOrder:y,dismissedTabOrder:L,dismissals:r,onRestore:p}),j>0&&e.jsx(wt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:f}),N>0&&e.jsx(wt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:m}),e.jsx(vn,{delta:s}),t.map((A,F)=>{const O=A.announcements??[],H=A.focusEvents??[];return O.length===0&&H.length===0?null:e.jsx(yn,{state:A.state,announcements:O,focusEvents:H},F)})]})}function vn({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function jt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=at(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function wt({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 yn({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:fn(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 jn({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function wn({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 Nn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Ze="igtRuns";async function kn(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ae(r,o.map(l=>({key:me(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Ae(r,o.map(l=>({key:he(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Sn={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"}},An={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"}},Cn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Nt(t,s){const a=await X();if(!a)return;const n=s?Sn[t]:An[t];try{await ne(a,n)}catch{}}async function Rn(){const s=(await chrome.storage.local.get(Ze))[Ze];return s&&typeof s=="object"?s:{}}async function kt(t){await chrome.storage.local.set({[Ze]:t})}function En(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 In(){const t=g(c=>c.componentId),s=g(c=>c.results),[a,n]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{Rn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,u,h){var m;const f={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((m=o[c])==null?void 0:m.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(f),kt(f),h.status==="pass"){const j=K.find(R=>R.id===c),N=j==null?void 0:j.steps.find(R=>R.id===u);N!=null&&N.autoDismissActivity&&kn(N.autoDismissActivity,s,u)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[c];const h={...a,[t]:u};n(h),kt(h)}const p=K.find(c=>c.id===r);if(p){const c=o[p.id];return e.jsx(Tn,{workflow:p,run:c,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),K.map(c=>{const u=o[c.id],h=u?bs(u,c):null,f=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",m={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[f];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${m}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),f==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),f==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),u&&e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function Tn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=x.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=En(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Nt(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Cn[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Nt(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(Ce,{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(Ce,{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(Ce,{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(Ce,{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 $n={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 Ce({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?$n[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Ie="savedFlows";async function _n(){const t=await chrome.storage.local.get(Ie);return Array.isArray(t[Ie])?t[Ie]:[]}async function St(t){await chrome.storage.local.set({[Ie]:t})}function Ln(){const[t,s]=x.useState([]),[a,n]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{_n().then(s)},[]);async function o(){const c=await X();if(!c){i("No audit-target tab found.");return}try{await ne(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await X();if(c)try{const u=await Se(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},m=[f,...t];s(m),await St(m),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(c){const u=await X();if(u){i(`Replaying "${c.name}"…`);try{const h=await Se(u,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==c);s(u),await St(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function Un(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(Dn).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function Dn(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function On(){const t=g(l=>l.baselineList),s=g(l=>l.tier),a=Gt[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=x.useState(!1);if(x.useEffect(()=>{Le().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await Q({type:"BASELINE_DELETE",componentId:l}),await Le()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=Un(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(ue,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(ue,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(ue,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(ue,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(ue,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(ue,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(ue,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const Fn={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 ue({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Fn[t]}`,children:a})}const Mn={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"},Pn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Gn={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function ns({onBack:t}){const s=g(u=>u.siteCrawlStatus),a=g(u=>u.siteCrawlProgress),n=g(u=>u.siteCrawlReport),r=g(u=>u.siteCrawlError),[i,o]=x.useState(""),[l,d]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var f;const h=(f=u[0])==null?void 0:f.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(g.getState().setSiteCrawlStatus("running"),g.getState().setSiteCrawlReport(null),g.getState().setSiteCrawlError(null),ae({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function c(){Q({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>d(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Wn,{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 Wn({report:t}){function s(){$e(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-CpRomwpZ.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,0,1,2])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Mn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Pn[t.siteRisk]}`,children:vs[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(a=>{const n=ys(a.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Gn[a.impact]}`,children:a.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:n.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:a.urlsAffected})," page",a.urlsAffected===1?"":"s"," · ",a.totalOccurrences," total spot",a.totalOccurrences===1?"":"s"]})]})]})},a.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(a=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${a.grade==="A"?"text-emerald-700":a.grade==="B"?"text-lime-700":a.grade==="C"?"text-yellow-700":a.grade==="D"?"text-orange-700":"text-rose-700"}`,children:a.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:a.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:a.uniqueViolations})]},a.url))})]})]})}const He="onboardingDismissed",ze=[{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 Vn(){const[t,s]=x.useState(!1),[a,n]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(He).then(l=>{l[He]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[He]:!0}),s(!1),n(0)}const i=a===ze.length-1,o=ze[a];return e.jsxs(xe,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",ze.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Bn(){const t=g(n=>n.status),s=g(n=>n.errorMessage),a=g(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 Hn(){const t=g(d=>d.aiFailure),s=g(d=>d.clearAiFailure),[a,n]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function At(){const[t,s]=x.useState(!1);return x.useEffect(()=>te("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),g.getState().setStatus("idle"))}),[]),e.jsxs(xe,{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 zn(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{js().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await lt(),g.getState().startNewScan(),t.mode==="storybook-all"?ae({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ae({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await lt(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Ke="storybook:hintDismissed";function Kn(){const[t,s]=x.useState(!1),[a,n]=x.useState();x.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(Ke))[Ke])return;const o=await X();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(u=c.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(c=>{var u;return(u=c.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Ke]:!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 qn(){var i;const t=g(o=>o.results),s=g(o=>o.baselineList),a=g(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Qn(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 Qn(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Yn(){const t=g(l=>l.results),s=g(l=>l.componentId),[a,n]=x.useState([]);if(x.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=ws(r,a.length>0?{runs:a,workflows:K}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Jn(){const t=g(a=>a.setUserMode);function s(a){t(a),Q({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Xn=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],Zn={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function er(t){const s=new Set(Xn),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Zn[o]}}const rs={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},tr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[rs]},sr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[rs]};function it(t){return t==="thorough"?sr:tr}function Ct(t){const s=it(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Te="wcagcheckr";function P(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ke(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 ar(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function nr(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 rr(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 ir(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 or(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 (${P(t.receipt.tsaName)}) — anchored ${P(ke(t.receipt.anchoredAt))}</td></tr>
|
|
29
|
+
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${P(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
30
|
+
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${P(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${P(Te)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
31
31
|
<article class="entry">
|
|
32
32
|
<header class="entry-header">
|
|
33
|
-
<span class="grade-badge ${
|
|
33
|
+
<span class="grade-badge ${ir(t.grade)}">${P(t.grade)}</span>
|
|
34
34
|
<div class="entry-headline">
|
|
35
|
-
<div class="entry-time">${
|
|
35
|
+
<div class="entry-time">${P(ke(t.capturedAt))}</div>
|
|
36
36
|
<div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
|
|
37
37
|
</div>
|
|
38
38
|
</header>
|
|
39
39
|
<table class="entry-fields">
|
|
40
|
-
<tr><th>Audit identity hash</th><td><code class="hash">${
|
|
41
|
-
<tr><th>Page URL</th><td><code>${
|
|
42
|
-
<tr><th>Scope</th><td><code>${
|
|
43
|
-
<tr><th>axe-core version</th><td>${
|
|
40
|
+
<tr><th>Audit identity hash</th><td><code class="hash">${P(t.hash)}</code></td></tr>
|
|
41
|
+
<tr><th>Page URL</th><td><code>${P(t.pageUrl)}</code></td></tr>
|
|
42
|
+
<tr><th>Scope</th><td><code>${P(t.scope)}</code></td></tr>
|
|
43
|
+
<tr><th>axe-core version</th><td>${P(t.axeVersion)}</td></tr>
|
|
44
44
|
<tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
|
|
45
45
|
${n}
|
|
46
46
|
</table>
|
|
47
|
-
</article>`}function
|
|
47
|
+
</article>`}function lr(t){return`
|
|
48
48
|
<section class="component-section">
|
|
49
49
|
<h2>
|
|
50
|
-
<span class="component-id">${
|
|
50
|
+
<span class="component-id">${P(t.componentId)}</span>
|
|
51
51
|
<span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
|
|
52
52
|
</h2>
|
|
53
|
-
<p class="component-url"><strong>Page audited:</strong> <code>${
|
|
54
|
-
${t.entries.map(
|
|
55
|
-
</section>`}function
|
|
53
|
+
<p class="component-url"><strong>Page audited:</strong> <code>${P(t.pageUrl)}</code></p>
|
|
54
|
+
${t.entries.map(or).join("")}
|
|
55
|
+
</section>`}function cr(t){const{entries:s,extensionVersion:a}=t,n=rr(s),r=nr(s),i=(t.axeVersions??ar(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,p=ke(new Date().toISOString());return`<!doctype html>
|
|
56
56
|
<html lang="en">
|
|
57
57
|
<head>
|
|
58
58
|
<meta charset="utf-8" />
|
|
59
|
-
<title>Pre-litigation accessibility audit report — ${
|
|
59
|
+
<title>Pre-litigation accessibility audit report — ${P(t.matterReference??p)}</title>
|
|
60
60
|
<style>
|
|
61
61
|
*, *::before, *::after { box-sizing: border-box; }
|
|
62
62
|
:root {
|
|
@@ -197,17 +197,17 @@ document.getElementById('copy').addEventListener('click', () => {
|
|
|
197
197
|
<p class="eyebrow">Accessibility audit — pre-litigation report</p>
|
|
198
198
|
<h1>Audit history & chain-of-custody</h1>
|
|
199
199
|
<dl class="cover-meta">
|
|
200
|
-
${t.matterReference?`<dt>Matter reference</dt><dd>${
|
|
201
|
-
${t.preparedBy?`<dt>Prepared by</dt><dd>${
|
|
202
|
-
${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${
|
|
203
|
-
<dt>Report generated</dt><dd>${
|
|
204
|
-
<dt>Audit period</dt><dd>${r?`${
|
|
200
|
+
${t.matterReference?`<dt>Matter reference</dt><dd>${P(t.matterReference)}</dd>`:""}
|
|
201
|
+
${t.preparedBy?`<dt>Prepared by</dt><dd>${P(t.preparedBy)}</dd>`:""}
|
|
202
|
+
${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${P(t.jurisdiction)}</dd>`:""}
|
|
203
|
+
<dt>Report generated</dt><dd>${P(p)}</dd>
|
|
204
|
+
<dt>Audit period</dt><dd>${r?`${P(ke(r.earliest))} — ${P(ke(r.latest))}`:"No audits recorded"}</dd>
|
|
205
205
|
</dl>
|
|
206
206
|
</section>
|
|
207
207
|
|
|
208
208
|
<aside class="attestation">
|
|
209
209
|
<h3>Attestation</h3>
|
|
210
|
-
<p>The audit records summarized below were captured by the <strong>${
|
|
210
|
+
<p>The audit records summarized below were captured by the <strong>${P(Te)}</strong> Chrome extension, version <strong>${P(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${P(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
|
|
211
211
|
<p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
|
|
212
212
|
<p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
|
|
213
213
|
</aside>
|
|
@@ -217,11 +217,11 @@ document.getElementById('copy').addEventListener('click', () => {
|
|
|
217
217
|
<tr><th>RFC 3161-anchored audits</th><td>${l}</td></tr>
|
|
218
218
|
<tr><th>Local-only audits</th><td>${d}</td></tr>
|
|
219
219
|
<tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
|
|
220
|
-
<tr><th>axe-core version(s) observed</th><td>${
|
|
221
|
-
<tr><th>Tool</th><td>${
|
|
220
|
+
<tr><th>axe-core version(s) observed</th><td>${P(i||"n/a")}</td></tr>
|
|
221
|
+
<tr><th>Tool</th><td>${P(Te)} ${P(a)}</td></tr>
|
|
222
222
|
</table>
|
|
223
223
|
|
|
224
|
-
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(
|
|
224
|
+
${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(lr).join("")}
|
|
225
225
|
|
|
226
226
|
<section class="methodology">
|
|
227
227
|
<h2>Methodology</h2>
|
|
@@ -245,16 +245,16 @@ document.getElementById('copy').addEventListener('click', () => {
|
|
|
245
245
|
</section>
|
|
246
246
|
|
|
247
247
|
<footer>
|
|
248
|
-
<span>Generated ${
|
|
248
|
+
<span>Generated ${P(p)} by ${P(Te)} ${P(a)}</span>
|
|
249
249
|
<span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
|
|
250
250
|
</footer>
|
|
251
251
|
</body>
|
|
252
|
-
</html>`}async function ar(t){const s=sr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function rs(){const[t,s]=f.useState(null),[a,n]=f.useState(null),[r,i]=f.useState(0),[o,l]=f.useState(!1),[d,p]=f.useState(""),[c,u]=f.useState(""),[h,g]=f.useState(""),[m,j]=f.useState(!1);if(f.useEffect(()=>{let y=!1;return s(null),n(null),Ft().then(S=>{y||s(S)}).catch(S=>{y||n(S instanceof Error?S.message:String(S))}),()=>{y=!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 R=t.length,I=t.filter(y=>y.receipt).length;async function b(){if(!(!t||t.length===0)){j(!0);try{await ar({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{j(!1)}}}async function v(){if(!t||t.length===0)return;const y={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},S=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),T=URL.createObjectURL(S),w=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,A=document.createElement("a");A.href=T,A.download=w,A.click(),setTimeout(()=>URL.revokeObjectURL(T),1e3)}return R===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:[R," ",R===1?"entry":"entries",I>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[I," RFC 3161-anchored"]})]}),I===0&&R>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:[e.jsx("button",{type:"button",onClick:()=>l(y=>!y),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void v(),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:()=>i(y=>y+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&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:y=>p(y.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:y=>u(y.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:y=>g(y.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:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:m||R===0,onClick:b,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:m?"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(y=>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 ${y.grade==="A"?"bg-emerald-100 text-emerald-700":y.grade==="B"?"bg-lime-100 text-lime-700":y.grade==="C"?"bg-yellow-100 text-yellow-700":y.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:y.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:y.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${y.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:y.receipt?`Anchored to ${y.receipt.tsaName} at ${y.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:y.receipt?`RFC 3161 (${y.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:y.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:y.capturedAt}),(y.totals.critical>0||y.totals.serious>0)&&e.jsxs("span",{children:[y.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[y.totals.critical," crit"]}),y.totals.critical>0&&y.totals.serious>0&&" · ",y.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[y.totals.serious," sev"]})]}),e.jsxs("span",{children:[y.statesAudited," ",y.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:y.hash,children:[y.hash.slice(0,12),"…"]})]})]},`${y.componentId}::${y.capturedAt}`))})]})}function nr(){const[t,s]=f.useState(null),[a,n]=f.useState(!1);if(f.useEffect(()=>{let d=!1;return Ft().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=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",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," 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:o.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(me,{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(rs,{})})})]})}function rr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const ir={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."},or={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."},lr={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},cr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function is(){const t=x(u=>u.tier),s=x(u=>u.trialDaysRemaining),a=x(u=>u.seatsUsed),n=x(u=>u.seatsTotal),r=x(u=>u.planCode),i=x(u=>u.licenseDaysRemaining),o=x(u=>u.pastDue),[l,d]=f.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,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 K({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Qe,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?cr:lr,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,g=t==="team"&&a!==null&&n!==null&&a>n,m=t==="team"&&a!==null&&n!==null&&a===n,j=o?{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"}:m?{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 ${j.bg} border-b ${j.border} px-3 py-2 space-y-1 text-[11px] ${j.shadow}`,children:[e.jsxs("div",{className:j.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:j.subtitle,children:[" · ",h]})]}),o&&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."}),m&&!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 K({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const p=t==="trial"?ir:or,c=t==="trial"?rr(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 K({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(Qe,{open:l,onClose:()=>d(!1)})]})}const dr={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"},ur={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Ct={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},pr={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"},Rt={critical:0,serious:1,moderate:2,minor:3};function hr(){const t=x(u=>u.setUserMode),s=x(u=>u.status),a=x(u=>u.setStatus),n=x(u=>u.errorMessage),r=x(u=>u.setError),[i,o]=f.useState(!1),[l,d]=f.useState(!1),p=f.useRef(s);f.useEffect(()=>{if(p.current==="running"&&s==="complete"){d(!0);const u=setTimeout(()=>d(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),f.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{x.getState().status==="running"&&(a("idle"),r("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(u)},[s,a,r]);function c(){t("dev"),K({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(is,{}),e.jsx(qt,{}),e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2 flex items-center justify-between",children:[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"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kt,{}),e.jsx("button",{type:"button",onClick:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(mr,{}),s==="failed"&&n&&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:n}),e.jsx("button",{type:"button",onClick:()=>{x.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:[i?e.jsx(as,{onBack:()=>o(!1)}):e.jsx(fr,{onPickCrawl:()=>o(!0)}),l&&e.jsx(xr,{})]}),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. Automated checks catch ~30–50% of accessibility issues; a human review covers the rest."}),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 mr(){const t=x(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 K({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 xr(){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 fr({onPickCrawl:t}){const s=x(u=>u.status),a=x(u=>u.results),[n,r]=f.useState("quick"),[i,o]=f.useState("all"),l=s==="running",d=a.flatMap(u=>u.violations),p=a.length>0;function c(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:it(n)}),x.getState().startNewScan(),se.polite(`${n==="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:c,disabled:l,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:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,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(br,{depth:n,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(gr,{}),p&&e.jsx(vr,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function gr(){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 br({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(Et,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${At("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Et,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${At("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Et({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){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:i})]})}function vr({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var T;const r=x(w=>w.status),i=x(w=>w.results),o=x(w=>w.freshThisSession),l=x(w=>w.componentId),d=(T=i[0])==null?void 0:T.startedAt,p=Kn(t),c=r==="running",[u,h]=f.useState([]);f.useEffect(()=>{if(!l){h([]);return}let w=!1;return chrome.storage.local.get("igtRuns").then(A=>{if(w)return;const $=((A==null?void 0:A.igtRuns)??{})[l]??{};h(Object.values($))}),()=>{w=!0}},[l]);const g=x(w=>w.acknowledgedKeys),m=i.length>0?Ut(i,{runs:u,workflows:z},"2.1","AA",g):void 0;function j(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:it(n)}),x.getState().startNewScan(),se.polite("Re-scanning this page now.")}const R=s==="lawsuit-risk"?t.filter(w=>w.impact==="critical"||w.impact==="serious"):t,I=new Map;for(const w of R){const A=st(w.ruleId,w.target.selector);I.has(A)||I.set(A,w)}const b=Array.from(I.values()),v=new Map;for(const w of b){const A=v.get(w.ruleId)??[];A.push(w),v.set(w.ruleId,A)}const y=Array.from(v.entries()).sort((w,A)=>(Rt[w[1][0].impact]??99)-(Rt[A[1][0].impact]??99)),S=t.filter(w=>w.impact==="critical"||w.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:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Sr,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void at(),disabled:c,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:j,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?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."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${dr[p.tier]}`,children:[!o&&d&&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 ${ur[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,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"}),e.jsxs("p",{className:`text-base font-semibold ${Ct[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Ct[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",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.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."]})]})]})]}),!c&&m&&!m.canClaimConformance&&e.jsx(yr,{coverage:m}),!c&&m&&m.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 ",m.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(kr,{}),e.jsx(nr,{}),t.length>0&&e.jsx(jr,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:S}),e.jsxs("div",{className:"space-y-2",children:[y.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."]}),y.map(([w,A])=>e.jsx(wr,{ruleId:w,violations:A},w))]})]})}function yr({coverage:t}){const s=x(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"),K({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 jr({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 wr({ruleId:t,violations:s}){var u;const[a,n]=f.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=ws(t,r),o=s[0].impact,l=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,c=l.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 ${pr[o]}`,children:o}),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:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,g)=>e.jsx(Nr,{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 Nr({violation:t}){const s=x(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=f.useState(null);async function r(i){i.stopPropagation();const o=await Z();if(o)try{const l=await ke(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.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 Re=[{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 kr(){const t=x(c=>c.results),s=x(c=>c.componentId),[a,n]=f.useState(null),[r,i]=f.useState(!1),[o,l]=f.useState(null);async function d(c,u){if(t.length!==0){n(c);try{const h=await Q({type:"EXPORT_REQUEST",format:c,results:t});if(c==="defense-bundle"||c==="evidence-bundle"){const g=$t(c,s);await _t()?et(h.content,g):l({open:!0,format:c,content:h.content,filename:g})}else if(u)Ze(h.content);else{try{await navigator.clipboard.writeText(h.content),se.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const m=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
252
|
+
</html>`}async function dr(t){const s=cr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function is(){const[t,s]=x.useState(null),[a,n]=x.useState(null),[r,i]=x.useState(0),[o,l]=x.useState(!1),[d,p]=x.useState(""),[c,u]=x.useState(""),[h,f]=x.useState(""),[m,j]=x.useState(!1);if(x.useEffect(()=>{let y=!1;return s(null),n(null),Ft().then(C=>{y||s(C)}).catch(C=>{y||n(C instanceof Error?C.message:String(C))}),()=>{y=!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,R=t.filter(y=>y.receipt).length;async function b(){if(!(!t||t.length===0)){j(!0);try{await dr({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{j(!1)}}}async function k(){if(!t||t.length===0)return;const y={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(y,null,2)],{type:"application/json"}),L=URL.createObjectURL(C),w=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,I=document.createElement("a");I.href=L,I.download=w,I.click(),setTimeout(()=>URL.revokeObjectURL(L),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",R>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[R," RFC 3161-anchored"]})]}),R===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:[e.jsx("button",{type:"button",onClick:()=>l(y=>!y),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void k(),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:()=>i(y=>y+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&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:y=>p(y.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:y=>u(y.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:y=>f(y.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:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:m||N===0,onClick:b,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:m?"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(y=>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 ${y.grade==="A"?"bg-emerald-100 text-emerald-700":y.grade==="B"?"bg-lime-100 text-lime-700":y.grade==="C"?"bg-yellow-100 text-yellow-700":y.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:y.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:y.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${y.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:y.receipt?`Anchored to ${y.receipt.tsaName} at ${y.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:y.receipt?`RFC 3161 (${y.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:y.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:y.capturedAt}),(y.totals.critical>0||y.totals.serious>0)&&e.jsxs("span",{children:[y.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[y.totals.critical," crit"]}),y.totals.critical>0&&y.totals.serious>0&&" · ",y.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[y.totals.serious," sev"]})]}),e.jsxs("span",{children:[y.statesAudited," ",y.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:y.hash,children:[y.hash.slice(0,12),"…"]})]})]},`${y.componentId}::${y.capturedAt}`))})]})}function ur(){const[t,s]=x.useState(null),[a,n]=x.useState(!1);if(x.useEffect(()=>{let d=!1;return Ft().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=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",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," 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:o.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(xe,{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(is,{})})})]})}function pr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const hr={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."},mr={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."},xr={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},gr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function os(){const t=g(u=>u.tier),s=g(u=>u.trialDaysRemaining),a=g(u=>u.seatsUsed),n=g(u=>u.seatsTotal),r=g(u=>u.planCode),i=g(u=>u.licenseDaysRemaining),o=g(u=>u.pastDue),[l,d]=x.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,h=u!==null&&u<=7,f=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"}),f&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",f]})]}),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 Q({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ye,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?gr:xr,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,f=t==="team"&&a!==null&&n!==null&&a>n,m=t==="team"&&a!==null&&n!==null&&a===n,j=o?{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-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"}:m?{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 ${j.bg} border-b ${j.border} px-3 py-2 space-y-1 text-[11px] ${j.shadow}`,children:[e.jsxs("div",{className:j.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:j.subtitle,children:[" · ",h]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),f&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),m&&!f&&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 Q({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const p=t==="trial"?hr:mr,c=t==="trial"?pr(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 Q({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(Ye,{open:l,onClose:()=>d(!1)})]})}const fr={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"},br={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Rt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},vr={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"},Et={critical:0,serious:1,moderate:2,minor:3};function yr(){const t=g(u=>u.setUserMode),s=g(u=>u.status),a=g(u=>u.setStatus),n=g(u=>u.errorMessage),r=g(u=>u.setError),[i,o]=x.useState(!1),[l,d]=x.useState(!1),p=x.useRef(s);x.useEffect(()=>{if(p.current==="running"&&s==="complete"){d(!0);const u=setTimeout(()=>d(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),x.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{g.getState().status==="running"&&(a("idle"),r("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(u)},[s,a,r]);function c(){t("dev"),Q({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(os,{}),e.jsx(Qt,{}),e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2 flex items-center justify-between",children:[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"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qt,{}),e.jsx("button",{type:"button",onClick:c,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(jr,{}),s==="failed"&&n&&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:n}),e.jsx("button",{type:"button",onClick:()=>{g.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:[i?e.jsx(ns,{onBack:()=>o(!1)}):e.jsx(Nr,{onPickCrawl:()=>o(!0)}),l&&e.jsx(wr,{})]}),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. Automated checks catch ~30–50% of accessibility issues; a human review covers the rest."}),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 jr(){const t=g(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 Q({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 wr(){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 Nr({onPickCrawl:t}){const s=g(u=>u.status),a=g(u=>u.results),[n,r]=x.useState("quick"),[i,o]=x.useState("all"),l=s==="running",d=a.flatMap(u=>u.violations),p=a.length>0;function c(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:it(n)}),g.getState().startNewScan(),se.polite(`${n==="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:c,disabled:l,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:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,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(Sr,{depth:n,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(kr,{}),p&&e.jsx(Ar,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function kr(){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 Sr({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(It,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Ct("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(It,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Ct("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function It({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){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:i})]})}function Ar({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var L;const r=g(w=>w.status),i=g(w=>w.results),o=g(w=>w.freshThisSession),l=g(w=>w.componentId),d=(L=i[0])==null?void 0:L.startedAt,p=er(t),c=r==="running",[u,h]=x.useState([]);x.useEffect(()=>{if(!l){h([]);return}let w=!1;return chrome.storage.local.get("igtRuns").then(I=>{if(w)return;const T=((I==null?void 0:I.igtRuns)??{})[l]??{};h(Object.values(T))}),()=>{w=!0}},[l]);const f=g(w=>w.acknowledgedKeys),m=i.length>0?Dt(i,{runs:u,workflows:K},"2.1","AA",f):void 0;function j(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:it(n)}),g.getState().startNewScan(),se.polite("Re-scanning this page now.")}const N=s==="lawsuit-risk"?t.filter(w=>w.impact==="critical"||w.impact==="serious"):t,R=new Map;for(const w of N){const I=at(w.ruleId,w.target.selector);R.has(I)||R.set(I,w)}const b=Array.from(R.values()),k=new Map;for(const w of b){const I=k.get(w.ruleId)??[];I.push(w),k.set(w.ruleId,I)}const y=Array.from(k.entries()).sort((w,I)=>(Et[w[1][0].impact]??99)-(Et[I[1][0].impact]??99)),C=t.filter(w=>w.impact==="critical"||w.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:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx($r,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Me(),disabled:c,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:j,disabled:c,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:c?"Scanning…":"↻ Scan again"})]})]}),c?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."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${fr[p.tier]}`,children:[!o&&d&&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 ${br[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,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"}),e.jsxs("p",{className:`text-base font-semibold ${Rt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Rt[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",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.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."]})]})]})]}),!c&&m&&!m.canClaimConformance&&e.jsx(Cr,{coverage:m}),!c&&m&&m.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 ",m.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(Tr,{}),e.jsx(ur,{}),t.length>0&&e.jsx(Rr,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[y.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."]}),y.map(([w,I])=>e.jsx(Er,{ruleId:w,violations:I},w))]})]})}function Cr({coverage:t}){const s=g(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"),Q({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 Rr({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 Er({ruleId:t,violations:s}){var u;const[a,n]=x.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=Ns(t,r),o=s[0].impact,l=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,c=l.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 ${vr[o]}`,children:o}),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:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,f)=>e.jsx(Ir,{violation:h},f))}),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 Ir({violation:t}){const s=g(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=x.useState(null);async function r(i){i.stopPropagation();const o=await X();if(o)try{const l=await Se(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.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 Re=[{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 Tr(){const t=g(c=>c.results),s=g(c=>c.componentId),[a,n]=x.useState(null),[r,i]=x.useState(!1),[o,l]=x.useState(null);async function d(c,u){if(t.length!==0){n(c);try{const h=await q({type:"EXPORT_REQUEST",format:c,results:t});if(c==="defense-bundle"||c==="evidence-bundle"){const f=_t(c,s);await Lt()?tt(h.content,f):l({open:!0,format:c,content:h.content,filename:f})}else if(u)et(h.content);else{try{await navigator.clipboard.writeText(h.content),se.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const m=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
|
|
253
253
|
<style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
|
|
254
254
|
.banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
|
|
255
255
|
pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
|
|
256
256
|
<div class="banner"><strong>✓ Copied to clipboard.</strong> Paste this into ChatGPT, Claude, or your favorite AI assistant. The AI will walk you through fixes for your specific situation.</div>
|
|
257
|
-
<pre>${h.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,j=new Blob([m],{type:"text/html"}),
|
|
257
|
+
<pre>${h.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`,j=new Blob([m],{type:"text/html"}),N=URL.createObjectURL(j);window.open(N,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(N),6e4)}}finally{n(null)}}}const p=r?Re:Re.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(c=>e.jsx("button",{type:"button",onClick:()=>void d(c.id,c.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:c.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:c.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:c.desc})]}),a===c.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},c.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",Re.length-2," more report option",Re.length-2===1?"":"s"," ↓"]}),o&&e.jsx(as,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function $r({iso:t}){const[,s]=x.useState(0);x.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function _r(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const d of l){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:o,selector:c.target.selector})}const p=d.axeRulesEvaluated;if(p){for(const c of p.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of p.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Lr(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const p of a){const c=p.steps.filter(u=>u.wcag===t);if(c.length!==0){r+=c.length;for(const[u,h]of s){const f=h[p.id];if(!f){i+=c.length;continue}for(const m of c){const j=f.steps[m.id];if(!j){i++;continue}j.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${p.id}.${m.id}`,description:m.question,pageUrl:u,notes:j.notes})):j.status==="skip"?i++:j.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function Ur(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function Dr(t,s,a){switch(s){case"pass":return`${a.axeRulesFiringForCriterion+a.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${a.axeFailures.length} automated finding(s), ${a.igtFailures.length} manual finding(s) failed this criterion.`;case"inconclusive":return"Some manual checks for this criterion are unanswered or skipped; rerun the relevant IGT workflow to resolve.";case"not-evaluated":return"No automated rule and no guided-test step in the wcagcheckr ruleset maps to this criterion. Manual review required.";case"not-applicable":return"Marked not applicable by the evaluator."}}function Or(t,s){var u;const a=[];for(const h of s.auditsByUrl.values())a.push(...h);const n=[];for(const h of s.igtRunsByUrl.values())n.push(...Object.values(h));const r=Ot({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions}),i=ks(t.targetVersion,t.targetLevel),o=[];for(const h of i){const f=_r(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),m=Lr(h.id,s.igtRunsByUrl,s.workflows),j=f.rulesFiring.size===0&&m.stepsCovering===0,N={axeRulesFiringForCriterion:f.rulesFiring.size,axeFailures:f.failures,igtStepsCoveringCriterion:m.stepsCovering,igtFailures:m.failures,unmapped:j},R=(u=t.overrides)==null?void 0:u[h.id];let b,k,y=!1;if(R)b=R.verdict,k=R.rationale,y=!0;else{const C=r.get(h.id);C?b=C.state:b=Ur(N,m.unanswered,f.hasIncomplete,m.allNotApplicable),k=Dr(h,b,N)}o.push({criterion:h,understandingUrl:Ss(h,t.targetVersion),verdict:b,signals:N,overridden:y,rationale:k})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of o)h.verdict==="pass"?l.pass++:h.verdict==="fail"?l.fail++:h.verdict==="inconclusive"?l.inconclusive++:h.verdict==="not-applicable"?l.notApplicable++:h.verdict==="not-evaluated"&&l.notEvaluated++;function d(h){const f={A:1,AA:2,AAA:3},m=f[h];return o.every(j=>f[j.criterion.level]>m?!0:j.verdict==="pass"||j.verdict==="not-applicable")}let p=null;d("AAA")?p="AAA":d("AA")?p="AA":d("A")&&(p="A");const c=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:p,meetsTarget:c}}}const Fr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Tt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function E(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qe(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function Mr(t,s){const{inputs:a,rows:n,summary:r,generatedAt:i}=t,o=r.meetsTarget?`MEETS WCAG ${a.targetVersion} Level ${a.targetLevel}`:`DOES NOT MEET WCAG ${a.targetVersion} Level ${a.targetLevel}`,l=new Map;for(const p of n){const c=p.criterion.id.split(".").slice(0,2).join("."),u=l.get(c)??[];u.push(p),l.set(c,u)}const d=Array.from(l.entries()).sort(([p],[c])=>p.localeCompare(c,void 0,{numeric:!0})).map(([p,c])=>`
|
|
258
258
|
<h3 class="guideline-h">Guideline ${E(p)}</h3>
|
|
259
259
|
<table class="criteria-table">
|
|
260
260
|
<thead>
|
|
@@ -268,7 +268,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
268
268
|
<td><a href="${E(u.understandingUrl)}" target="_blank" rel="noopener">${E(u.criterion.id)}</a></td>
|
|
269
269
|
<td>${E(u.criterion.title)}</td>
|
|
270
270
|
<td>${E(u.criterion.level)}</td>
|
|
271
|
-
<td><span class="verdict-badge ${Tt[u.verdict]}">${
|
|
271
|
+
<td><span class="verdict-badge ${Tt[u.verdict]}">${Fr[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
|
|
272
272
|
<td class="rationale">${E(u.rationale)}</td>
|
|
273
273
|
</tr>
|
|
274
274
|
${u.signals.axeFailures.length>0||u.signals.igtFailures.length>0?`
|
|
@@ -410,7 +410,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
410
410
|
<dt>Target conformance level</dt>
|
|
411
411
|
<dd>WCAG ${E(a.targetVersion)} Level ${E(a.targetLevel)}</dd>
|
|
412
412
|
<dt>Report generated</dt>
|
|
413
|
-
<dd>${E(
|
|
413
|
+
<dd>${E(qe(i))}</dd>
|
|
414
414
|
<dt>Evaluator</dt>
|
|
415
415
|
<dd>
|
|
416
416
|
${E(a.evaluator.name)}
|
|
@@ -485,7 +485,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
485
485
|
<p style="font-size: 10pt;">The content of this report was hashed and the hash was anchored to a public RFC 3161 Time Stamping Authority, then counter-signed by the wcagcheckr server's ed25519 key. Any alteration to the conformance-bearing content above invalidates the hash; the receipt below is verifiable offline by anyone with the wcagcheckr-ci CLI.</p>
|
|
486
486
|
<table class="anchor-table">
|
|
487
487
|
<tr><th>Report content hash (SHA-256)</th><td><code class="hash">${E(s.reportHash)}</code></td></tr>
|
|
488
|
-
<tr><th>Anchored at</th><td>${E(
|
|
488
|
+
<tr><th>Anchored at</th><td>${E(qe(s.receipt.anchoredAt))}</td></tr>
|
|
489
489
|
<tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${E(s.receipt.tsaName)}</td></tr>
|
|
490
490
|
<tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${E(s.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
491
491
|
${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${E(s.receipt.prevAuditHash)}</code></td></tr>`:""}
|
|
@@ -515,10 +515,10 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
|
|
|
515
515
|
</section>
|
|
516
516
|
|
|
517
517
|
<footer class="report-footer">
|
|
518
|
-
<span>Generated ${E(
|
|
518
|
+
<span>Generated ${E(qe(i))} by wcagcheckr</span>
|
|
519
519
|
<span>${r.totalCriteria} criteria · ${r.pass} pass · ${r.fail} fail · ${r.inconclusive} inconclusive</span>
|
|
520
520
|
</footer>
|
|
521
521
|
</body>
|
|
522
|
-
</html>`}async function
|
|
523
|
-
`).map(
|
|
524
|
-
https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:
|
|
522
|
+
</html>`}async function Pr(t,s){const a=Mr(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const Qe=Ut("wcag-em-anchor"),Gr="https://api.wcagcheckr.com",Wr="wcagcheckr",Vr=15e3;function ls(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function Br(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function Hr(t){return Br(As(ls(t)))}function zr(t){if(typeof t!="object"||t===null)return!1;const s=t;return s.schemaVersion!==1&&s.schemaVersion!==2||!(typeof s.anchoredAt=="string"&&typeof s.tsaName=="string"&&typeof s.rfc3161TokenBase64=="string"&&s.rfc3161TokenBase64.length>0&&typeof s.serverSignatureBase64=="string"&&s.serverSignatureBase64.length>0&&typeof s.serverKeyFingerprint=="string"&&s.serverKeyFingerprint.length>0)?!1:s.schemaVersion===2?typeof s.prevAuditHash=="string"&&/^[0-9a-f]{64}$/.test(s.prevAuditHash):!0}async function Kr(t,s){const a=await Hr(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Gr}/v1/products/${Wr}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Vr)});if(!i.ok)return Qe.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return zr(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Qe.warn("anchor returned malformed receipt",o),null)}catch(i){return Qe.warn("anchor request failed",i),null}}function qr(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:ls(t)}}const $t="igtRuns",Qr={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",inconclusive:"bg-amber-100 text-amber-800","not-evaluated":"bg-slate-100 text-slate-700","not-applicable":"bg-slate-50 text-slate-500"},Yr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Jr(){const t=g(S=>S.results),s=g(S=>S.acknowledgedKeys),[a,n]=x.useState(""),[r,i]=x.useState(""),o=Rs,l=Cs,[d,p]=x.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,u]=x.useState(""),[h,f]=x.useState(""),[m,j]=x.useState(""),[N,R]=x.useState(""),[b,k]=x.useState(""),[y,C]=x.useState(""),[L,w]=x.useState({}),[I,v]=x.useState(!1),[T,$]=x.useState([]),[A,F]=x.useState(null),[O,H]=x.useState(!1),[ee,le]=x.useState(null);x.useEffect(()=>{let S=!1;return chrome.storage.local.get($t).then(D=>{if(S)return;const U=D[$t]??{};w(U),v(!0)}).catch(()=>{S||v(!0)}),()=>{S=!0}},[]),x.useEffect(()=>{var S;if(!a&&((S=t[0])!=null&&S.pageUrl))try{const D=new URL(t[0].pageUrl);n(D.hostname),i(D.origin)}catch{}},[t,a]),x.useEffect(()=>{const S=new Set;for(const U of t)S.add(U.pageUrl??U.scope);if(S.size===0){$([]);return}let D=!1;return Promise.all(Array.from(S).map(U=>Ee(U))).then(U=>{D||$(U.flat())}).catch(()=>{}),()=>{D=!0}},[t]);const Z=x.useMemo(()=>{const S=new Map,D=new Map;for(const z of t){const B=z.pageUrl??z.scope,M=S.get(B)??[];M.push(z),S.set(B,M)}const U=new Map;for(const z of t){const B=z.pageUrl??z.scope;U.set(z.componentId,B)}for(const[z,B]of Object.entries(L)){const M=U.get(z);if(!M)continue;const Y=D.get(M)??{};Object.assign(Y,B),D.set(M,Y)}return{auditsByUrl:S,igtRunsByUrl:D,workflows:K,acknowledgedMatchKeys:s,incompleteResolutions:T}},[t,L,s,T]),re=x.useMemo(()=>{const S=[],D=new Set;for(const U of Z.auditsByUrl.keys())D.has(U)||(D.add(U),S.push({url:U,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const U of y.split(`
|
|
523
|
+
`).map(z=>z.trim()).filter(Boolean))D.has(U)||(D.add(U),S.push({url:U,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return S},[Z,y]),ce=x.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(S=>S.trim()).filter(Boolean),pageSample:re,evaluator:{name:h||"(evaluator name pending)",organization:m||void 0,qualifications:N||void 0,contact:b||void 0}}),[a,r,o,l,d,c,re,h,m,N,b]),G=x.useMemo(()=>I?Or(ce,Z):null,[ce,Z,I]);async function J(){G&&await Pr(G,A)}async function _(){if(G){H(!0),le(null);try{const S=await Kr(G);if(!S){le("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}F(S)}finally{H(!1)}}}function V(){var Y,ge,W;if(!G||!A)return;const S=((W=(ge=(Y=chrome.runtime).getManifest)==null?void 0:ge.call(Y))==null?void 0:W.version)??"0.0.0",D=qr(G,A,S),U=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),z=URL.createObjectURL(U),B=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,M=document.createElement("a");M.href=z,M.download=B,M.click(),setTimeout(()=>URL.revokeObjectURL(z),1e3)}return x.useEffect(()=>{F(null),le(null)},[a,r,d,c,h,m,N,b,y]),I?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),G&&G.summary.totalCriteria>0&&e.jsx(Xr,{totalCriteria:G.summary.totalCriteria,pass:G.summary.pass,fail:G.summary.fail,inconclusive:G.summary.inconclusive,notEvaluated:G.summary.notEvaluated,notApplicable:G.summary.notApplicable,levelAchieved:G.summary.levelAchieved,meetsTarget:G.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:Z.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:S=>n(S.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:S=>i(S.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:S=>p(S.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:S=>u(S.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",Z.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:Z.auditsByUrl.size})," URL",Z.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:y,onChange:S=>C(S.target.value),rows:3,placeholder:`https://app.example.com/checkout
|
|
524
|
+
https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:S=>f(S.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:m,onChange:S=>j(S.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:N,onChange:S=>R(S.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:b,onChange:S=>k(S.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),G&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",G.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:G.rows.map(S=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[S.criterion.id," · ",S.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:S.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Qr[S.verdict]}`,children:Yr[S.verdict]})]},S.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),A?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[A.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",A.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),ee&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:ee}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!G||!a||!h||O,onClick:()=>void _(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:O?"Anchoring…":A?"Re-anchor":"Anchor this report"}),A&&e.jsx("button",{type:"button",onClick:V,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!G||!a||!h,onClick:()=>void J(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function Xr({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:p,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${d} Level ${p}`:`Does not currently meet WCAG ${d} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}function ii(){const t=g(a=>a.view),s=g(a=>a.userMode);return x.useEffect(()=>{const a=Ws(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=Os();Wt({forceRefresh:!0}).catch(()=>{}),Le().catch(()=>{}),Gs().catch(()=>{}),Vs().catch(()=>{}),Ms().catch(()=>{}),Es().then(l=>{g.getState().setAcknowledgedKeys(new Set(l.map(d=>d.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:p,results:c}=g.getState();d&&(p(null),X().then(u=>{var h;u&&ne(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(h=c[0])==null?void 0:h.frameId).catch(()=>{})}))};return window.addEventListener("keydown",o),()=>{i(),a.disconnect(),r==null||r.disconnect(),window.removeEventListener("keydown",o)}},[]),s===null?e.jsxs(e.Fragment,{children:[e.jsx(Jn,{}),e.jsx(We,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(yr,{}),e.jsx(At,{}),e.jsx(We,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(os,{}),e.jsx(Qt,{}),e.jsx(aa,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(oa,{}),e.jsx(pa,{}),e.jsx(Kn,{}),e.jsx(zn,{}),e.jsx(ma,{}),e.jsx(Bn,{}),e.jsx(Hn,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Ta,{}),t==="report"&&e.jsx(qa,{}),t==="delta"&&e.jsx(rn,{}),t==="activity"&&e.jsx(bn,{}),t==="guided"&&e.jsx(In,{}),t==="flows"&&e.jsx(Ln,{}),t==="scorecard"&&e.jsx(On,{}),t==="crawl"&&e.jsx(ns,{}),t==="forensic"&&e.jsx(is,{}),t==="compliance"&&e.jsx(Jr,{})]})]}),e.jsx(Yn,{}),e.jsx(qn,{}),e.jsx(Vn,{}),e.jsx(At,{}),e.jsx(We,{})]})}class oi extends Ne.Component{constructor(){super(...arguments);ot(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{ii as A,oi as E};
|