@wcag-checkr/ci 1.0.0-rc.84 → 1.0.0-rc.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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 x,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 K,s as q,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 gs,j as fs,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";import{getColorSuggestion as Es,saveColorSuggestion as Ts,saveColorSuggestions as Is}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,_s=t=>t;function Ls(t,s=_s){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=$s(t),a=n=>Ls(s,n);return Object.assign(a,s),a},Us=t=>t?dt(t):dt,g=Us(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 Ds(){const t=[];return t.push(ee("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(ee("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(ee("AUDIT_FAILED_EVENT",s=>{g.getState().setError(s.error.message)})),t.push(ee("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(ee("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(ee("SCORECARD_UPDATED_EVENT",()=>{Le()})),t.push(ee("LICENSE_CHANGED_EVENT",()=>{Gt()})),t.push(ee("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(ee("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(ee("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 Os(){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 Ms(){await chrome.storage.local.remove(_e)}async function at(){g.getState().clearResults(),await Ms()}async function Le(){const t=await K({type:"BASELINE_LIST"});g.getState().setBaselineList(t.items)}async function Gt(t){const s=await K({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 Ps(){const s=(await K({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;g.getState().setUserMode(a)}function Gs(){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 Wt(){if(Ue===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ue}).catch(()=>{})}function ae(t){Wt(),q(t)}function Ws({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 K({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=Lt("messages-client"),Bs="https://api.wcagcheckr.com",Bt="wcagcheckr",Hs=1e4;function zs(){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":zs()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Bs}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Hs)})}async function Ks(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 qs=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ue,fetchMessages:Ks},Symbol.toStringTag,{value:"Module"})),Qs=["http:","https:"];function Js(t){try{const s=new URL(t);return Qs.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 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 Ys={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Xs={critical:"bg-rose-50 border-rose-200"};function Kt(){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"),ue(f.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(Zs,{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(ea,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:u})]})}function Zs({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 ea({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 ${Ys[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=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 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 ${Xs.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 fe=["matrix","report","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function ta(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function sa(){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=ta(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(Kt,{}),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 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(aa,{view:t,setView:s}),e.jsx(me,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Ws,{onClose:()=>o(!1)})})]})}function aa({view:t,setView:s}){const a=x.useRef([]);function n(i){var d;const o=(i+fe.length)%fe.length,l=fe[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(fe.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:fe.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 na({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(Qe,{open:a,onClose:()=>n(!1)})]})}const ra="https://wcagcheckr.com/upgrade";function ia(){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(U=>U.status),f=g(U=>U.tier),m=g(U=>U.results.length>0),j=h==="running";x.useEffect(()=>{Promise.all([K({type:"SETTINGS_GET",key:"matrixPresets"}),K({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,R])=>{const F=Array.isArray(U.data)?U.data:null;p(F&&F.length>0?F:Ve),typeof R.data=="string"&&u(R.data)})},[]);function N(U){const R=d.find(F=>F.id===U);R&&(u(U),q({type:"SETTINGS_SET",key:"activePresetId",value:U}),q({type:"SETTINGS_SET",key:"stateMatrix",value:R.matrix}))}const E=Ot(f,"storybookAutoIterate");x.useEffect(()=>{const U=ee("ELEMENT_PICKED_EVENT",(F,P)=>{n(!1);const J=P.frameId;$(J),i({selector:F.selector,frameId:J})}),R=ee("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),R()}},[]);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}),g.getState().startNewScan())}function y(){if(!E){l("storybook:auto-iterate");return}$(),ae({type:"START_AUDIT",mode:"storybook-all"}),g.getState().startNewScan()}function k(){$(),ae({type:"START_AUDIT",mode:"all-frames"}),g.getState().startNewScan()}function T(){$(),ae({type:"START_AUDIT",mode:"full-page"}),g.getState().startNewScan()}function w(){$(),ae({type:"START_AUDIT",mode:"quick-scan"}),g.getState().startNewScan()}function C(){$(),ae({type:"START_AUDIT",mode:"parallel-scan"}),g.getState().startNewScan()}function S(){q({type:"CANCEL_AUDIT"})}async function $(U){g.getState().setPinned(null);const R=await Z();if(R)try{await ne(R,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:R},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)",E?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:U=>N(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(oa,{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:C,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:k,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:S,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(la,{selector:r.selector,onRepick:b,onClear:()=>i(null)})]}),e.jsx(me,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(na,{feature:o??"",upgradeUrl:ra})})]})}function oa({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 la({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 ca={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},da={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function ua(){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 Z();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 Z();if(m){if(t&&await ne(m,{type:ca[t],tabId:m}).catch(()=>{}),t===f){s(null);return}await ne(m,{type:da[f],tabId:m}).catch(()=>{}),s(f)}}async function h(){const f=await Z();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 ke(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(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: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 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 pa(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 ha(){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":pa(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 ma(t){return/^wcag\d/.test(t.wcagCriterion)?[ve["ada-iii"],ve[508],ve.eaa,ve["en-301-549"],ve.aoda]:[]}const xa={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=g(b=>b.pinnedMatchKey),n=g(b=>b.pinnedFound),r=g(b=>b.setPinned),i=g(b=>{var v;return(v=b.results[0])==null?void 0:v.frameId}),o=g(b=>{var v;return(v=b.results[0])==null?void 0:v.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 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 N(b){b.stopPropagation(),t.currentState.breakpoint.width<=640&&Wt(),(async()=>{const v=await Z();if(!v)return;try{await K({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 E(b){b.stopPropagation();const v=await Z();if(!v)return;try{await K({type:"STATE_DRIVE_REQUEST",tabId:v,state:va(),scope:o,frameId:i})}catch{q({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 ${xa[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(ya,{violation:t}),e.jsx(Na,{violation:t}),e.jsx(wa,{violation:t}),e.jsx(ja,{text:t.target.failureSummary}),e.jsx(ka,{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: ",ga(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:E,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),E(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),ba(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),fa(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 ga(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 fa(t,s){await hs({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Qt(t.componentId,s)}async function ba(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 K({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});g.getState().setDelta(n.delta)}catch{}}function va(){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 ya({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 ja({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 wa({violation:t}){const s=ma(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 Na({violation:t}){const s=Jt(t),[a,n]=x.useState({kind:"idle"});if(x.useEffect(()=>{let i=!1;return Es(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 K({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 ka({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=>Sa(i,t)),a=s.reduce((i,o)=>i+Aa(o.letter),0)/Math.max(1,s.length),n=Ca(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 Sa(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(C=>C.id===w)).filter(w=>w!=null);let o=i.length>0;for(const w of i){const C=r.find($=>$.workflowId===w.id);if((C?Object.keys(C.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(C=>C.id===w)).filter(w=>w!=null);let u=d.length>0&&c.length===d.length;for(const w of c){const C=p.find($=>$.workflowId===w.id);if((C?Object.keys(C.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 tt(n))b[w.impact]++;b.serious+=f;for(const w of r){const C=i.find(S=>S.id===w.workflowId);if(C)for(const S of C.steps){const $=w.steps[S.id];($==null?void 0:$.status)==="fail"&&(S.severity==="required"?b.serious++:b.moderate++)}}const v=b.critical>0,y=b.serious>0;let k;b.critical>=5?k="F":b.critical>=1?k="D":b.serious>=1?k="C":b.moderate>=1?k="B":k="A";const T=k!=="A"&&(N&&!o||d.length>0&&!u);return{id:t.id,label:t.label,letter:k,untested:!1,needsIgt:T,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:b,caps:{cappedAtC:v,cappedAtB:y}}}function Aa(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function Ca(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 Ra=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 Ea(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 Ta(){var m,j,N,E;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;Oe(n).then(i);const b=()=>{document.visibilityState==="visible"&&n&&Oe(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 v=async()=>{const k=await chrome.storage.local.get("igtRuns");if(b)return;const w=((k==null?void 0:k.igtRuns)??{})[s]??{},C=new Set;for(const S of z){const $=w[S.id];$&&Object.keys($.steps).length===S.steps.length&&C.add(S.id)}l(C)};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=Ea(t);c.sort((b,v)=>{const y=mt[b.representative.impact]??99,k=mt[v.representative.impact]??99;return y!==k?y-k:v.states.length-b.states.length});const u=t.map(b=>Zt(b.state)).join(`
4
- `),h=o.has("keyboard")?0:(((N=t[0])==null?void 0:N.tabOrderIssues)??[]).filter(b=>!(he(b.selector)in r)).length,f=o.has("page-structure")?0:(((E=t[0])==null?void 0:E.readingOrderIssues)??[]).filter(b=>!(pe(b.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(La,{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 Ia={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:z,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=Ia[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 E=f.map(v=>{const y=v.representative.target.outerHTML,k=v.representative.target.failureSummary,T=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(k),w=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(k);if(!T||!w)return null;const C=v.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:v.representative.matchKey,foreground:T[1],background:w[1],fontSize:16,fontWeight:400,targetLevel:C,_html:y}}).filter(v=>v!==null);if(E.length===0){o("error"),d("Could not parse fg/bg colors from the violation failure summaries.");return}const b=await K({type:"AI_COLOR_SUGGEST_REQUEST",inputs:E.map(({_html:v,...y})=>y)});if(b.unavailableReason&&b.results.length===0){o("error"),d(b.unavailableReason);return}await Is(b.results),o("done"),c(v=>v+1),n||r(!0)}catch(E){o("error"),d(E instanceof Error?E.message:String(E))}}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(Fe,{violation:N.representative}),e.jsx(Ua,{states:N.states,totalStates:a})]},`${es(N.representative)}::${p}`))})]})}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 La({violations:t,componentId:s,manualRuns:a}){const n=g(d=>d.setView),i=nt({violations:t,auditRan:!0,manualRuns:a,workflows:z,heuristicCounts:{}}).overallLetter,l=tt(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 ${_a[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 Ua({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(Zt))),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 Da={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 Oa({violations:t,componentId:s}){var Y,te,X,re,ie,V,Ae;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),E=g(_=>_.results),b=(Y=E[0])==null?void 0:Y.startedAt,v=((te=E[0])==null?void 0:te.pageUrl)??((X=E[0])==null?void 0:X.scope)??null;if(x.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]),x.useEffect(()=>{if(!v){i([]);return}let _=!1;return Ee(v).then(B=>{_||i(B)}),()=>{_=!0}},[v]),m==="running")return e.jsx(Ha,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const y=nt({violations:t,auditRan:E.length>0,manualRuns:a,workflows:z,heuristicCounts:{tabOrder:((ie=(re=E[0])==null?void 0:re.tabOrderIssues)==null?void 0:ie.length)??0,readingOrder:((Ae=(V=E[0])==null?void 0:V.readingOrderIssues)==null?void 0:Ae.length)??0}}),k=g(_=>_.acknowledgedKeys),T=E.length>0?Ut(E,{runs:a,workflows:z},"2.1","AA",k,r):void 0,w=E.length>0?xs(Dt({audits:E,igtRuns:a,workflows:z,acknowledgedMatchKeys:k,incompleteResolutions:r}),z):void 0,C=T?T.failingCriteria.length>0||T.inconclusiveCriteria.length>0:!1,S=C&&y.overallLetter==="A"?"B":y.overallLetter;async function $(_){var H;if(!v||!((H=T==null?void 0:T.inconclusiveReasons)!=null&&H[_]))return;const A=T.inconclusiveReasons[_].filter(W=>W.source==="axe-incomplete"&&W.elements&&W.elements.length>0);if(A.length===0)return;l(W=>new Set(W).add(_)),p(null);const D=[];let L=0;try{for(const O of A){const Q=await q({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(_){f(B=>{const A=new Set(B);return A.has(_)?A.delete(_):A.add(_),A})}async function R(_){var Q,xe;if(!v)return;const B=((Q=T==null?void 0:T.inconclusiveReasons)==null?void 0:Q[_])??[],A=((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 ge=`${oe}::${G.ruleOrStepId}::${le.selector}`;L.has(ge)||(L.add(ge),D.push({ruleId:G.ruleOrStepId,pageUrl:oe,selector:le.selector}))}}for(const G of A){if(G.source!=="ai"||!G.selector)continue;const oe=G.ruleOrStepId.startsWith("ai-resolved::")?G.ruleOrStepId.slice(13):G.ruleOrStepId,le=G.pageUrl??v,ge=`${le}::${oe}::${G.selector}`;L.has(ge)||(L.add(ge),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 gs(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(!C||y.overallLetter!=="A"||!T)return null;const _=T.inconclusiveCriteria.length,B=T.failingCriteria.length,A=[];B>0&&A.push(`${B} WCAG ${T.targetLevel} ${B===1?"criterion":"criteria"} failing`),_>0&&A.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 — ${A.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(_=>!k.has(_.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!N&&b&&e.jsx(za,{scannedAt:b}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Da[S]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:S})}),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(Ga,{areas:y.warningAreas}),e.jsx(Va,{grades:y.subGrades}),T&&e.jsx(Ma,{coverage:T,onResolveWithAi:$,onMarkVisuallyVerified:R,resolving:o,resolveError:d,lastResolveResult:c,expandedResultFor:h,onToggleResultDetail:U}),w&&e.jsx(Pa,{layers:w}),e.jsx(Ba,{violationsRemaining:J,manualCompleted:P,manualTotal:z.length}),P>0||E.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 Ma({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,C;const N=m.kind==="inconclusive"?(w=t.inconclusiveReasons)==null?void 0:w[j]:void 0,E=m.kind==="failing"?(C=t.failingReasons)==null?void 0:C[j]:void 0,b=N==null?void 0:N.some(S=>S.source==="axe-incomplete"&&S.elements&&S.elements.length>0),v=E==null?void 0:E.some(S=>S.source==="ai"),y=(n==null?void 0:n.has(j))??!1,k=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…":k?"✨ 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"})]})]}),k&&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 ",k.total," ",k.total===1?"verdict":"verdicts",":",k.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",k.pass," pass"]}),k.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",k.fail," fail"]}),k.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",k.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",k.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"})]}),k.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",k.uncertain," ",k.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),k.pass===k.total&&k.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:k.resolutions.map((S,$)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:S.verdict==="pass"?"text-emerald-700 font-semibold":S.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:S.verdict==="pass"?"✓":S.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:S.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:S.reasoning})]},$))})]}),E&&E.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:E.map((S,$)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[S.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),S.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," fail — "]}),S.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," fail — "]}),S.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:S.selector}),S.notes&&e.jsx("span",{className:"text-rose-700",children:S.notes})]},$))}),N&&N.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:N.map((S,$)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[S.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," — "]}),S.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," skipped — "]}),S.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:S.ruleOrStepId})," — "]}),S.resolutionHint,S.elements&&S.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",S.elements.length===1?"element":`${S.elements.length} elements`,":"," ",S.elements.slice(0,3).map((U,R,F)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:U.selector}),R<F.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},R)),S.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",S.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 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 Pa({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 Ga({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(Wa,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Wa({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 Ba({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 Ha({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 za({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 Ka(){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(Oa,{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(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 Qa={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(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 ${Qa[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 Ya(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 Xa={"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:Xa[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 Za(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 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(`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}}function tn(){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(null);x.useEffect(()=>{Promise.all([K({type:"SETTINGS_GET",key:"githubRepoUrl"}),K({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,y])=>{l(typeof v.data=="string"?v.data:""),p(typeof y.data=="string"?y.data:"")})},[]);const h=Ot(n,"exportJson"),f=Pt[n].maxBaselines,m=r.some(v=>v.componentId===s),j=m||r.length<f;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 N(){if(!s||a.length===0)return;const v=a.flatMap($=>$.violations),y=a.flatMap($=>$.announcements??[]),k=a.flatMap($=>$.focusEvents??[]),T=a[0],C=(await K({type:"SETTINGS_GET",key:"stateMatrix"})).data??Mt;await q({type:"BASELINE_SET",componentId:s,violations:v,announcements:y,focusEvents:k,snapshotMeta:{url:window.location.href,axeVersion:T.axeVersion,matrixConfig:C,capturedAt:new Date().toISOString()}});const S=await K({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:y,focusEvents:k,currentMatrix:C});g.getState().setDelta(S.delta),se.polite(`Baseline saved for ${s}.`)}async function E(){if(!s||!m||!window.confirm(`Remove the saved baseline for "${s}"?
2
+ var xs=Object.defineProperty;var gs=(t,s,a)=>s in t?xs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var ut=(t,s,a)=>gs(t,typeof s!="symbol"?s+"":s,a);import{R as ke,i as re,r as h,j as e,M as ge,C as Ye,l as fs,o as st,t as at,m as Ot,s as Ft,k as Ve}from"./styles-TzYIhCDc.js";import{_ as Le}from"./preload-helper-D7HrI6pR.js";import{o as se,r as Q,s as Y,c as Mt,b as oe,d as Ae}from"./crash-reporter-Dc5lvxvY.js";import{g as bs,a as X,u as vs,b as ys,c as js,d as nt,A as q,l as rt,e as Ie,f as Pt,h as ws,i as Gt,s as Ns,j as ks,O as Ss,k as As,m as Cs,n as pt,o as Rs,p as Wt,q as Es,r as Is,t as Ts,v as $s,T as Ls,w as _s,x as Ds}from"./forensic-log-BGuH56yt.js";import{B as Be,i as Vt,b as Bt,T as Ht}from"./state-BIsozXtc.js";import{getColorSuggestion as Us,saveColorSuggestion as Os,saveColorSuggestions as Fs}from"./color-suggestion-store-ClqdzGNO.js";const mt=t=>{let s;const a=new Set,n=(p,c)=>{const m=typeof p=="function"?p(s):p;if(!Object.is(m,s)){const u=s;s=c??(typeof m!="object"||m===null)?m:Object.assign({},s,m),a.forEach(g=>g(s,u))}},i=()=>s,l={setState:n,getState:i,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,i,l);return l},Ms=t=>t?mt(t):mt,Ps=t=>t;function Gs(t,s=Ps){const a=ke.useSyncExternalStore(t.subscribe,ke.useCallback(()=>s(t.getState()),[t,s]),ke.useCallback(()=>s(t.getInitialState()),[t,s]));return ke.useDebugValue(a),a}const ht=t=>{const s=Ms(t),a=n=>Gs(s,n);return Object.assign(a,s),a},Ws=t=>t?ht(t):ht,f=Ws(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 i=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),r=i.filter(l=>!l.seen).length,o=i.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:i,unreadMessageCount:r,criticalUnacked:o}})})),_e="sidePanel:lastAudit";function Vs(){const t=[];return t.push(se("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||re.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(se("AUDIT_COMPLETE_EVENT",s=>{var r;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((r=s.delta)==null?void 0:r.newCount)??0,i=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"}.`;re.polite(i),Bs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(se("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(se("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||re.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(se("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(se("SCORECARD_UPDATED_EVENT",()=>{De()})),t.push(se("LICENSE_CHANGED_EVENT",()=>{zt()})),t.push(se("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&re.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(se("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),re.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(se("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),re.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Bs(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 Hs(){const s=(await chrome.storage.local.get(_e))[_e];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function zs(){await chrome.storage.local.remove(_e)}async function Pe(){f.getState().clearResults(),await zs()}async function De(){const t=await Q({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function zt(t){const s=await Q({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Kt()}async function Kt(){const{fetchMessages:t}=await Le(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>ta);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Ks(){const s=(await Q({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function qs(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ue=null;async function Qs(){if(Ue===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ue=t.id)}catch{}}function qt(){if(Ue===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ue}).catch(()=>{})}function ie(t){qt(),Y(t)}function Ys({onClose:t}){const[s,a]=h.useState(""),[n,i]=h.useState(""),[r,o]=h.useState(!0),[l,d]=h.useState(""),[p,c]=h.useState(!1),[m,u]=h.useState(null);async function g(x){var j;if(x.preventDefault(),!(!s.trim()||!n.trim())){c(!0),u(null);try{const S=await Q({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:r,replyEmail:l.trim()||void 0});S.success?(u({ok:!0,msg:`Sent (ref: ${S.ticketRef??"n/a"})`}),setTimeout(t,1200)):u({ok:!1,msg:((j=S.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:x=>a(x.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:x=>i(x.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:x=>d(x.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:r,onChange:x=>o(x.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)."})]}),m&&e.jsx("p",{id:"support-form-result",role:m.ok?"status":"alert",className:`text-xs ${m.ok?"text-green-700":"text-red-700"}`,children:m.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 xt({onClick:t,ariaLabel:s,title:a,children:n,className:i}){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 ${i??""}`,children:n})}const Oe=Mt("messages-client"),Js="https://api.wcagcheckr.com",Qt="wcagcheckr",Xs=1e4;function Zs(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Yt(t,s){const a=await bs();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Zs()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Js}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Xs)})}async function ea(t){try{const s=await Yt(`/v1/products/${Qt}/messages`,{userMode:t??null});return s.ok?await s.json():(Oe.warn("fetchMessages http",s.status),null)}catch(s){return Oe.warn("fetchMessages failed",s),null}}async function me(t,s){try{const a=await Yt(`/v1/products/${Qt}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Oe.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Oe.warn("ackMessage failed",a),!1}}const ta=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:me,fetchMessages:ea},Symbol.toStringTag,{value:"Module"})),sa=["http:","https:"];function aa(t){try{const s=new URL(t);return sa.includes(s.protocol)}catch{return!1}}function gt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const r=t.indexOf("]",a+1);if(r!==-1&&t[r+1]==="("){const o=t.indexOf(")",r+2);if(o!==-1){const l=t.slice(a+1,r),d=t.slice(r+2,o);aa(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(h.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const r=t.indexOf("**",a+2);if(r!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,r)},`b-${n++}`)),a=r+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const r=t.indexOf("*",a+1);if(r!==-1&&t[r+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,r)},`i-${n++}`)),a=r+1;continue}}let i=a+1;for(;i<t.length&&t[i]!=="*"&&t[i]!=="[";)i++;s.push(e.jsx(h.Fragment,{children:t.slice(a,i)},`t-${n++}`)),a=i}return s}function Jt({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],i=[],r=0;function o(){if(i.length===0)return;const d=i.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:gt(d)},`p-${r++}`)),i=[]}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:gt(d)},p))},`u-${r++}`)),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(),i.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const na={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},ra={critical:"bg-rose-50 border-rose-200"};function Xt(){const t=f(u=>u.unreadMessageCount),s=f(u=>u.messages),a=f(u=>u.applyMessageAck),[n,i]=h.useState(!1),r=h.useRef(-1),[o,l]=h.useState(!1);h.useEffect(()=>{const u=s.filter(x=>!x.seen);if(u.length===0)return;const g=Math.max(...u.map(x=>x.id));if(g>r.current){r.current=g,l(!0);const x=setTimeout(()=>l(!1),1500);return()=>clearTimeout(x)}},[s]);async function d(){const u=s.filter(g=>!g.seen);if(u.length!==0)for(const g of u)a(g.id,"seen"),me(g.id,"seen")}function p(){const u=!n;i(u),u&&d()}async function c(u){a(u.id,"dismissed"),await me(u.id,"dismissed")}async function m(u){u.ctaUrl&&(a(u.id,"clicked"),me(u.id,"clicked"),chrome.tabs.create({url:u.ctaUrl}).catch(()=>{window.open(u.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(ia,{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(oa,{messages:s,onClose:()=>i(!1),onDismiss:c,onCtaClick:m})]})}function ia({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 oa({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const i=h.useRef(null);return h.useEffect(()=>{const r=l=>{i.current&&(i.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:i,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:()=>{Kt()},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(r=>e.jsx("li",{className:`p-3 ${r.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${na[r.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:r.title}),r.dismissible&&r.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(r),"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(Jt,{source:r.bodyMd})}),r.ctaLabel&&r.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(r),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:r.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(r.createdAt).toLocaleString()})]})]})},r.id))})]})}function Zt(){const t=f(r=>r.messages),s=f(r=>r.applyMessageAck),a=t.find(r=>r.severity==="critical"&&!r.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await me(a.id,"acknowledged")}async function i(){a.ctaUrl&&(s(a.id,"clicked"),me(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${ra.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(Jt,{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:i,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 la(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function ca(){var m,u;const t=f(g=>g.view),s=f(g=>g.setView),a=f(g=>g.setUserMode),n=f(g=>g.results),i=f(g=>g.status),[r,o]=h.useState(!1),l=((m=n[0])==null?void 0:m.pageUrl)??((u=n[0])==null?void 0:u.scope),d=la(l),p=n.length>0&&i!=="running";function c(){a("owner"),Y({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(Xt,{}),e.jsx(xt,{onClick:()=>void Y({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(xt,{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 Pe(),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(da,{view:t,setView:s}),e.jsx(ge,{open:r,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Ys,{onClose:()=>o(!1)})})]})}function da({view:t,setView:s}){const a=h.useRef([]);function n(r){var d;const o=(r+be.length)%be.length,l=be[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function i(r,o){switch(r.key){case"ArrowRight":r.preventDefault(),n(o+1);break;case"ArrowLeft":r.preventDefault(),n(o-1);break;case"Home":r.preventDefault(),n(0);break;case"End":r.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((r,o)=>{const l=t===r;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(r),onKeyDown:d=>i(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:r[0].toUpperCase()+r.slice(1)},r)})})}function ua({feature:t,upgradeUrl:s}){const[a,n]=h.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ye,{open:a,onClose:()=>n(!1)})]})}const pa="https://wcagcheckr.com/upgrade";function ma(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[i,r]=h.useState(null),[o,l]=h.useState(null),[d,p]=h.useState(Be),[c,m]=h.useState(Be[0].id),u=f(L=>L.status),g=f(L=>L.tier),x=f(L=>L.results.length>0),j=u==="running";h.useEffect(()=>{Promise.all([Q({type:"SETTINGS_GET",key:"matrixPresets"}),Q({type:"SETTINGS_GET",key:"activePresetId"})]).then(([L,C])=>{const O=Array.isArray(L.data)?L.data:null;p(O&&O.length>0?O:Be),typeof C.data=="string"&&m(C.data)})},[]);function S(L){const C=d.find(O=>O.id===L);C&&(m(L),Y({type:"SETTINGS_SET",key:"activePresetId",value:L}),Y({type:"SETTINGS_SET",key:"stateMatrix",value:C.matrix}))}const E=Vt(g,"storybookAutoIterate");h.useEffect(()=>{const L=se("ELEMENT_PICKED_EVENT",(O,U)=>{n(!1);const H=U.frameId;$(H),r({selector:O.selector,frameId:H})}),C=se("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{L(),C()}},[]);async function b(){const L=await X();L&&(n(!0),await oe(L,{type:"PICKER_ACTIVATE_REQUEST",tabId:L}))}function A(){i&&($(i.frameId),ie({type:"START_AUDIT",mode:"single-element",scope:i.selector,frameId:i.frameId}),f.getState().startNewScan())}function y(){if(!E){l("storybook:auto-iterate");return}$(),ie({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function N(){$(),ie({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function I(){$(),ie({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function w(){$(),ie({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function T(){$(),ie({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function v(){Y({type:"CANCEL_AUDIT"})}async function $(L){f.getState().setPinned(null);const C=await X();if(C)try{await oe(C,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:C},L)}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:L=>s(L.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)",E?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:L=>S(L.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(L=>e.jsx("option",{value:L.id,children:L.name},L.id))}),t==="single-element"?e.jsx(ha,{picking:a,picked:i,isRunning:j,onPick:b,onRun:A,onClearPick:()=>r(null)}):t==="full-page"?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",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:T,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:N,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&&x&&e.jsx("button",{type:"button",onClick:()=>void Pe(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&i&&!a&&!j&&e.jsx(xa,{selector:i.selector,onRepick:b,onClear:()=>r(null)})]}),e.jsx(ge,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(ua,{feature:o??"",upgradeUrl:pa})})]})}function ha({picking:t,picked:s,isRunning:a,onPick:n,onRun:i,onClearPick:r}){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:i,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 xa({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 ga={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},fa={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function ba(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[i,r]=h.useState(null),[o,l]=h.useState("off"),p=f(g=>g.results).flatMap(g=>g.violations);async function c(g){const x=await X();x&&(l(g),g==="off"?await oe(x,{type:"VISION_SIMULATOR_CLEAR",tabId:x}).catch(()=>{}):await oe(x,{type:"VISION_SIMULATOR_APPLY",tabId:x,mode:g}).catch(()=>{}))}async function m(g){const x=await X();if(x){if(t&&await oe(x,{type:ga[t],tabId:x}).catch(()=>{}),t===g){s(null);return}await oe(x,{type:fa[g],tabId:x}).catch(()=>{}),s(g)}}async function u(){const g=await X();if(g){if(a){await oe(g,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:g}).catch(()=>{}),n(!1),r(null);return}if(p.length===0){r("Run an audit first.");return}try{const x=await Ae(g,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:g,violations:p});n(!0),r(`Previewing ${x.visualFixCount} visual fix${x.visualFixCount===1?"":"es"} + ${x.annotationCount} annotation${x.annotationCount===1?"":"s"}.`)}catch{r("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:()=>m("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:()=>m("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:()=>m("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:()=>m("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:u}),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)"})]})]})]}),i&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:i})]})}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 va(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 ya(){const t=f(d=>d.status),s=f(d=>d.progress),a=f(d=>d.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,i=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,r=n?"reading order · tab order · typography · CSS vars · AI candidates":va(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(ft,{label:i,detail:r,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(ft,{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 ft({label:t,detail:s,pct:a,valuenow:n,valuemax:i,ariaLabel:r,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":i,"aria-label":r,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 ja(t){return/^wcag\d/.test(t.wcagCriterion)?[ye["ada-iii"],ye[508],ye.eaa,ye["en-301-549"],ye.aoda]:[]}const wa={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=f(b=>b.pinnedMatchKey),n=f(b=>b.pinnedFound),i=f(b=>b.setPinned),r=f(b=>{var A;return(A=b.results[0])==null?void 0:A.frameId}),o=f(b=>{var A;return(A=b.results[0])==null?void 0:A.scope}),l=f(b=>b.results),d=f(b=>b.acknowledgedKeys.has(t.matchKey)),p=f(b=>b.markAcknowledged),c=f(b=>b.markUnacknowledged),m=s||d,u=a===t.matchKey,g=u&&!n;async function x(b){try{return(await Ae(b,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:b,selector:t.target.selector},r)).found}catch{return!0}}async function j(){const b=await X();if(!b)return;if(u){i(null);try{await oe(b,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:b},r)}catch{}return}const A=await x(b);i(t.matchKey,A)}function S(b){b.stopPropagation(),t.currentState.breakpoint.width<=640&&qt(),(async()=>{const A=await X();if(!A)return;try{await Q({type:"STATE_DRIVE_REQUEST",tabId:A,state:t.currentState,scope:o,frameId:r})}catch{}const y=await x(A);i(t.matchKey,y)})()}async function E(b){b.stopPropagation();const A=await X();if(!A)return;try{await Q({type:"STATE_DRIVE_REQUEST",tabId:A,state:Aa(),scope:o,frameId:r})}catch{Y({type:"STATE_RESET_REQUEST",tabId:A})}const y=await x(A);i(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:j,"aria-pressed":u,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
+ ${u?"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 ${wa[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(Ca,{violation:t}),e.jsx(Ia,{violation:t}),e.jsx(Ea,{violation:t}),e.jsx(Ra,{text:t.target.failureSummary}),e.jsx(Ta,{ruleId:t.ruleId}),u&&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: ",Na(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),S(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:E,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),E(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:m?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),Sa(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),ka(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 Na(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 ka(t,s){await ys({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await es(t.componentId,s)}async function Sa(t,s){await vs(t.componentId,t.matchKey),await es(t.componentId,s)}async function es(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Q({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function Aa(){const t=Bt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function ts(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),i=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),r=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(i==null?void 0:i[1])??"#000000",bg:(r==null?void 0:r[1])??"#ffffff"}}function Ca({violation:t}){const s=ts(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 Ra({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 Ea({violation:t}){const s=ja(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 Ia({violation:t}){const s=ts(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let r=!1;return Us(t.matchKey).then(o=>{o&&!r&&n({kind:"ready",suggestion:o})}),()=>{r=!0}},[t.matchKey]),!s)return null;async function i(){n({kind:"loading"});try{const r=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:r}]}),l=o.results.find(d=>d.matchKey===t.matchKey);l?(await Os(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(r){n({kind:"empty",reason:r instanceof Error?r.message:String(r)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),i()},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((r,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:r.background,color:r.foreground},title:`fg ${r.foreground} on bg ${r.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:r.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:r.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[r.contrast.toFixed(2)," : 1"]})]}),r.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:r.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Ta({ruleId:t}){const s=js(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 it(t){const s=Je.map(r=>$a(r,t)),a=s.reduce((r,o)=>r+La(o.letter),0)/Math.max(1,s.length),n=_a(Math.round(a)),i=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:n,subGrades:s,warningAreas:i,isLawsuitRisk:i.length>0}}function $a(t,s){const a=new Set(t.axeRules),n=s.violations.filter(w=>a.has(w.ruleId)),i=s.manualRuns.filter(w=>t.igtWorkflowIds.includes(w.workflowId)),r=t.igtWorkflowIds.map(w=>s.workflows.find(T=>T.id===w)).filter(w=>w!=null);let o=r.length>0;for(const w of r){const T=i.find($=>$.workflowId===w.id);if((T?Object.keys(T.steps).length:0)!==w.steps.length){o=!1;break}}const l=i.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(T=>T.id===w)).filter(w=>w!=null);let m=d.length>0&&c.length===d.length;for(const w of c){const T=p.find($=>$.workflowId===w.id);if((T?Object.keys(T.steps).length:0)!==w.steps.length){m=!1;break}}let u=null;if(m)for(const w of p)w.completedAt&&(u===null||w.completedAt>u)&&(u=w.completedAt);const g=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,x=d[0]??t.igtWorkflowIds[0]??null;if(m&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:u,suppressedHeuristicCount:g,primaryVerifierWorkflowId:x,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j=t.axeRules.length>0||t.heuristic!=null,S=t.igtWorkflowIds.length>0;if(j?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:S||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:x,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 nt(n))b[w.impact]++;b.serious+=g;for(const w of i){const T=r.find(v=>v.id===w.workflowId);if(T)for(const v of T.steps){const $=w.steps[v.id];($==null?void 0:$.status)==="fail"&&(v.severity==="required"?b.serious++:b.moderate++)}}const A=b.critical>0,y=b.serious>0;let N;b.critical>=5?N="F":b.critical>=1?N="D":b.serious>=1?N="C":b.moderate>=1?N="B":N="A";const I=N!=="A"&&(S&&!o||d.length>0&&!m);return{id:t.id,label:t.label,letter:N,untested:!1,needsIgt:I,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:x,counts:b,caps:{cappedAtC:A,cappedAtB:y}}}function La(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function _a(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const Xe="dismissedFindings";function Ge(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function he(t){return`reading-order::${t}`}function xe(t){return`tab-order::${t}`}async function We(){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 ot(t){await chrome.storage.local.set({[Xe]:t})}async function Me(t){return(await We())[Ge(t)]??{}}async function ss(t,s,a,n){const i=await We(),r=Ge(t),o=i[r]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},i[r]=o,await ot(i)}async function Ce(t,s){if(s.length===0)return;const a=await We(),n=Ge(t),i=a[n]??{},r=new Date().toISOString();for(const o of s)i[o.key]={reason:o.reason,dismissedAt:r,snippet:o.snippet};a[n]=i,await ot(a)}async function as(t,s){const a=await We(),n=Ge(t),i=a[n];!i||!(s in i)||(delete i[s],Object.keys(i).length===0?delete a[n]:a[n]=i,await ot(a))}const Da=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:ss,addDismissals:Ce,dismissalKeyForReadingOrder:he,dismissalKeyForTabOrder:xe,getDismissalsForUrl:Me,removeDismissal:as},Symbol.toStringTag,{value:"Module"}));function ns(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function rs(t){return`${rt(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Ua(t){const s=new Map;for(const a of t)for(const n of a.violations){const i=rs(n),r=s.get(i);r?r.states.push(n.currentState):s.set(i,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const bt={critical:0,serious:1,moderate:2,minor:3};function Oa(){var x,j,S,E;const t=f(b=>b.results),s=f(b=>b.componentId),a=f(b=>b.setView),n=((x=t[0])==null?void 0:x.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[i,r]=h.useState({}),[o,l]=h.useState(new Set);if(h.useEffect(()=>{if(!n)return;Me(n).then(r);const b=()=>{document.visibilityState==="visible"&&n&&Me(n).then(r)};return document.addEventListener("visibilitychange",b),()=>document.removeEventListener("visibilitychange",b)},[n]),h.useEffect(()=>{if(!s){l(new Set);return}let b=!1;const A=async()=>{const N=await chrome.storage.local.get("igtRuns");if(b)return;const w=((N==null?void 0:N.igtRuns)??{})[s]??{},T=new Set;for(const v of q){const $=w[v.id];$&&Object.keys($.steps).length===v.steps.length&&T.add(v.id)}l(T)};A();const y=()=>{document.visibilityState==="visible"&&A()};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,A)=>b+A.durationMs,0),p=t.reduce((b,A)=>b+A.violations.length,0),c=Ua(t);c.sort((b,A)=>{const y=bt[b.representative.impact]??99,N=bt[A.representative.impact]??99;return y!==N?y-N:A.states.length-b.states.length});const m=t.map(b=>ns(b.state)).join(`
4
+ `),u=o.has("keyboard")?0:(((S=t[0])==null?void 0:S.tabOrderIssues)??[]).filter(b=>!(xe(b.selector)in i)).length,g=o.has("page-structure")?0:(((E=t[0])==null?void 0:E.readingOrderIssues)??[]).filter(b=>!(he(b.selector)in i)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(Ga,{violations:t.flatMap(b=>b.violations),componentId:s,manualRuns:[]}),(u>0||g>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:[u>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:u})," tab-order issue",u===1?"":"s"," (WCAG 2.4.3)"]}),u>0&&g>0&&" · ",g>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:g})," reading-order issue",g===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:m,"aria-label":`${t.length} states tested: ${m.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(Ma,{groups:c,totalStates:t.length,violations:t.flatMap(b=>b.violations)})]})}const 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({groups:t,totalStates:s,violations:a}){const n=it({violations:a,auditRan:!0,manualRuns:[],workflows:q,heuristicCounts:{}}),i=new Map,r=new Set;for(const l of Je){for(const d of l.axeRules)r.add(d);i.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)){i.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=i.get(l.id)??[];return e.jsx(vt,{subGrade:l,groups:d,totalStates:s},l.id)}),o.length>0&&e.jsx(vt,{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 vt({subGrade:t,groups:s,totalStates:a}){const[n,i]=h.useState(!1),[r,o]=h.useState("idle"),[l,d]=h.useState(null),[p,c]=h.useState(0),m=s.length>0,u=Fa[t.letter],g=s.filter(S=>S.representative.ruleId==="color-contrast"||S.representative.ruleId==="color-contrast-enhanced"),x=g.length>=2;async function j(S){S.stopPropagation(),o("loading"),d(null);try{const E=g.map(A=>{const y=A.representative.target.outerHTML,N=A.representative.target.failureSummary,I=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(N),w=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(N);if(!I||!w)return null;const T=A.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:A.representative.matchKey,foreground:I[1],background:w[1],fontSize:16,fontWeight:400,targetLevel:T,_html:y}}).filter(A=>A!==null);if(E.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:E.map(({_html:A,...y})=>y)});if(b.unavailableReason&&b.results.length===0){o("error"),d(b.unavailableReason);return}await Fs(b.results),o("done"),c(A=>A+1),n||i(!0)}catch(E){o("error"),d(E instanceof Error?E.message:String(E))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(S=>!S),"aria-expanded":n,disabled:!m,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 ${u}`,"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:m?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),x&&e.jsx("span",{role:"button",tabIndex:0,onClick:S=>void j(S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),j(S))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${g.length} contrast issues at once`,children:r==="loading"?"Asking AI…":r==="done"?`✓ Suggested for all ${g.length}`:`✨ Suggest for all ${g.length}`}),m&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),r==="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&&m&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(S=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Fe,{violation:S.representative}),e.jsx(Wa,{states:S.states,totalStates:a})]},`${rs(S.representative)}::${p}`))})]})}const Pa={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 Ga({violations:t,componentId:s,manualRuns:a}){const n=f(d=>d.setView),r=it({violations:t,auditRan:!0,manualRuns:a,workflows:q,heuristicCounts:{}}).overallLetter,l=nt(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 ${Pa[r]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:r})}),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 Wa({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(ns))),n=a.slice(0,3).join(", "),i=a.length>3?`, +${a.length-3} more`:"",r=a.join(`
5
+ `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:r,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,i]})]})}const Va={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Ba={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 Ha({violations:t,componentId:s}){var ee,ce,Z,le,de,F,J;const[a,n]=h.useState([]),[i,r]=h.useState([]),[o,l]=h.useState(new Set),[d,p]=h.useState(null),[c,m]=h.useState({}),[u,g]=h.useState(new Set),x=f(_=>_.status),j=f(_=>_.progress),S=f(_=>_.freshThisSession),E=f(_=>_.results),b=(ee=E[0])==null?void 0:ee.startedAt,A=((ce=E[0])==null?void 0:ce.pageUrl)??((Z=E[0])==null?void 0:Z.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let _=!1;return chrome.storage.local.get("igtRuns").then(W=>{if(_)return;const V=((W==null?void 0:W.igtRuns)??{})[s]??{};n(Object.values(V))}),()=>{_=!0}},[s]),h.useEffect(()=>{if(!A){r([]);return}let _=!1;return Ie(A).then(W=>{_||r(W)}),()=>{_=!0}},[A]),x==="running")return e.jsx(Xa,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const y=it({violations:t,auditRan:E.length>0,manualRuns:a,workflows:q,heuristicCounts:{tabOrder:((de=(le=E[0])==null?void 0:le.tabOrderIssues)==null?void 0:de.length)??0,readingOrder:((J=(F=E[0])==null?void 0:F.readingOrderIssues)==null?void 0:J.length)??0}}),N=f(_=>_.acknowledgedKeys),I=E.length>0?Pt(E,{runs:a,workflows:q},"2.1","AA",N,i):void 0,w=E.length>0?ws(Gt({audits:E,igtRuns:a,workflows:q,acknowledgedMatchKeys:N,incompleteResolutions:i}),q):void 0,T=I?I.failingCriteria.length>0||I.inconclusiveCriteria.length>0:!1,v=T&&y.overallLetter==="A"?"B":y.overallLetter;async function $(_){var B;if(!A||!((B=I==null?void 0:I.inconclusiveReasons)!=null&&B[_]))return;const z=I.inconclusiveReasons[_].filter(D=>D.source==="axe-incomplete"&&D.elements&&D.elements.length>0);if(z.length===0)return;l(D=>new Set(D).add(_)),p(null);const V=[];let k=0;try{for(const M of z){const K=await Y({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:M.ruleOrStepId,pageUrl:M.pageUrl??A,wcagCriterion:_,elements:M.elements??[],targetLevel:"AA"});if(K!=null&&K.unavailableReason){p(K.unavailableReason);break}K!=null&&K.resolutions&&(V.push(...K.resolutions),k+=K.totalCostUsd??0)}if(A){const M=await Ie(A);r(M)}const D={total:V.length,pass:V.filter(M=>M.verdict==="pass").length,fail:V.filter(M=>M.verdict==="fail").length,uncertain:V.filter(M=>M.verdict==="uncertain").length,costUsd:k,resolutions:V};m(M=>({...M,[_]:D}))}finally{l(D=>{const M=new Set(D);return M.delete(_),M})}}function L(_){g(W=>{const z=new Set(W);return z.has(_)?z.delete(_):z.add(_),z})}async function C(_){var K,te;if(!A)return;const W=((K=I==null?void 0:I.inconclusiveReasons)==null?void 0:K[_])??[],z=((te=I==null?void 0:I.failingReasons)==null?void 0:te[_])??[],V=[],k=new Set;for(const P of W){if(P.source!=="axe-incomplete"||!P.elements)continue;const ae=P.pageUrl??A;for(const ne of P.elements){const fe=`${ae}::${P.ruleOrStepId}::${ne.selector}`;k.has(fe)||(k.add(fe),V.push({ruleId:P.ruleOrStepId,pageUrl:ae,selector:ne.selector}))}}for(const P of z){if(P.source!=="ai"||!P.selector)continue;const ae=P.ruleOrStepId.startsWith("ai-resolved::")?P.ruleOrStepId.slice(13):P.ruleOrStepId,ne=P.pageUrl??A,fe=`${ne}::${ae}::${P.selector}`;k.has(fe)||(k.add(fe),V.push({ruleId:ae,pageUrl:ne,selector:P.selector}))}if(V.length===0)return;const B=new Date().toISOString(),D=[];for(const P of V){const ae=i.find(ne=>ne.pageUrl===P.pageUrl&&ne.ruleId===P.ruleId&&ne.selector===P.selector);ae&&ae.verdict==="pass"&&ae.reasoning.startsWith("Marked as visually verified")||D.push({pageUrl:P.pageUrl,ruleId:P.ruleId,selector:P.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${B.slice(0,10)}.`,resolvedAt:B,costUsd:0,wcagCriterion:_})}if(D.length===0)return;await Ns(D);const M=await Ie(A);r(M),m(P=>({...P,[_]:{total:D.length,pass:D.length,fail:0,uncertain:0,costUsd:0,resolutions:D}}))}const O=(()=>{if(!T||y.overallLetter!=="A"||!I)return null;const _=I.inconclusiveCriteria.length,W=I.failingCriteria.length,z=[];W>0&&z.push(`${W} WCAG ${I.targetLevel} ${W===1?"criterion":"criteria"} failing`),_>0&&z.push(`${_} WCAG ${I.targetLevel} ${_===1?"criterion":"criteria"} inconclusive`);const V=W>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 — ${z.join(" + ")}. ${V}`})();let U=0;for(const _ of q){const W=a.find(V=>V.workflowId===_.id);if(!W)continue;_.steps.every(V=>{const k=W.steps[V.id];return(k==null?void 0:k.status)==="pass"||(k==null?void 0:k.status)==="fail"||(k==null?void 0:k.status)==="skip"||(k==null?void 0:k.status)==="not-applicable"})&&U++}const H=nt(t.filter(_=>!N.has(_.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!S&&b&&e.jsx(Za,{scannedAt:b}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Va[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."]}),O&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:O})]})]}),y.isLawsuitRisk&&e.jsx(qa,{areas:y.warningAreas}),e.jsx(Qa,{grades:y.subGrades}),I&&e.jsx(za,{coverage:I,onResolveWithAi:$,onMarkVisuallyVerified:C,resolving:o,resolveError:d,lastResolveResult:c,expandedResultFor:u,onToggleResultDetail:L}),w&&e.jsx(Ka,{layers:w}),e.jsx(Ja,{violationsRemaining:H,manualCompleted:U,manualTotal:q.length}),U>0||E.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:U})," of ",e.jsx("strong",{children:q.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:`${U/q.length*100}%`}})})]}):null]})}function za({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:i,lastResolveResult:r,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,c]=h.useState(d>0&&d<=3),m=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),u=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 ${u?"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 ${u?"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 (",m,"%)"]}),u&&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)."]}),!u&&(()=>{const x=[];t.failingCriteria.length>0&&x.push("failing"),t.inconclusiveCriteria.length>0&&x.push("inconclusive"),t.untestedCriteria.length>0&&x.push("untested");const j=x.length===0?"unresolved":x.length===1?x[0]:x.length===2?`${x[0]} or ${x[1]}`:`${x.slice(0,-1).join(", ")}, or ${x[x.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!u&&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."]}),!u&&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."]})]}),!u&&g.length>0&&e.jsx("button",{type:"button",onClick:()=>c(x=>!x),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!u&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[g.map(x=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${x.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[x.kind==="untested"?"Untested":x.kind==="inconclusive"?"Inconclusive":"Failing"," (",x.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:x.ids.map(j=>{var w,T;const S=x.kind==="inconclusive"?(w=t.inconclusiveReasons)==null?void 0:w[j]:void 0,E=x.kind==="failing"?(T=t.failingReasons)==null?void 0:T[j]:void 0,b=S==null?void 0:S.some(v=>v.source==="axe-incomplete"&&v.elements&&v.elements.length>0),A=E==null?void 0:E.some(v=>v.source==="ai"),y=(n==null?void 0:n.has(j))??!1,N=r==null?void 0:r[j],I=(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]}),(x.kind==="inconclusive"&&b||x.kind==="failing"&&A)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[x.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…":N?"✨ 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:x.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"})]})]}),N&&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 ",N.total," ",N.total===1?"verdict":"verdicts",":",N.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",N.pass," pass"]}),N.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",N.fail," fail"]}),N.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",N.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",N.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(j),className:"ml-auto text-[10px] underline text-brand-700",children:I?"hide reasoning":"show reasoning"})]}),N.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",N.uncertain," ",N.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),N.pass===N.total&&N.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."]}),I&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:N.resolutions.map((v,$)=>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})]},$))})]}),E&&E.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:E.map((v,$)=>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})]},$))}),S&&S.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:S.map((v,$)=>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((L,C,O)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),C<O.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},C)),v.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",v.elements.length-3," more"]})]})]},$))}):x.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)})})]},x.kind)),i&&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:i})]})]})}const yt={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 Ka({layers:t}){const s=f(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 i=t[n],r=i.coveredCriteria.length,o=i.blocked.length,l=i.unevaluated.length,d=i.cleared,p=r>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:yt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:r===0?"no coverage yet":`${d}/${r}`}),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:yt[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 qa({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 Qa({grades:t}){const s=f(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 ${Ba[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(Ya,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Ya({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const i=q.find(r=>r.id===n);return(i==null?void 0:i.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?is(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 Ja({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(o=>o.setView),i=[{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.`}],r=i.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:i.map((o,l)=>{const d=l===r,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 Xa({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 Za({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 (",is(s)," old). Re-scan to grade the current page state."]})]})}function is(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 en(){const t=f(a=>a.results),s=f(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(Ha,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(tn,{})]})}function tn(){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 sn={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 an({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),i=s[0];if(!i)return null;const r=i.impact,o=i.description,l=s.length;return l===1?e.jsx(Fe,{violation:i}):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 ${sn[r]}`,children:r}),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 nn(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 rn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function os({open:t,onClose:s,format:a,content:n,filename:i}){const r=fs(new Blob([n]).size);function o(){at(n,i),s()}function l(){st(n),s()}return e.jsxs(ge,{open:t,onClose:s,title:rn[a],description:`Generated bundle — ${r}. 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:i})]}),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 jt=7800;function on(t,s,a){const n=t.replace(/\/$/,""),i=[];for(const c of a){const m=`${c.ruleId}::${c.target.selector}`,u=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=i.find(x=>`${x.ruleId}::${x.target.selector}`===m);if(g){g._states.includes(u)||g._states.push(u);continue}i.push({...c,_states:[u]})}const r=`a11y: ${i.length} new violation${i.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 i)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:r,body:l});let p=`${n}/issues/new?${d.toString()}`;return p.length>jt&&(p=p.slice(0,jt)),{url:p,title:r,body:l}}const wt=7800;function ln(t,s,a){const n=t.replace(/\/$/,""),i=[];for(const c of a){const m=`${c.ruleId}::${c.target.selector}`,u=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,g=i.find(x=>`${x.ruleId}::${x.target.selector}`===m);if(g){g._states.includes(u)||g._states.push(u);continue}i.push({...c,_states:[u]})}const r=`a11y: ${i.length} new violation${i.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 i)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:r,description:l});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>wt&&(p=p.slice(0,wt)),{url:p,summary:r,description:l}}const Nt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations"],cn=["wcag-component-auditor","wcag-forensic-log"];async function dn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Nt);s=Object.keys(n).length,await chrome.storage.local.remove(Nt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of cn)try{await un(n),a.push(n)}catch(i){t.push(`IndexedDB ${n}: ${i instanceof Error?i.message:String(i)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function un(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var i;return a(new Error(((i=n.error)==null?void 0:i.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}function pn(){const t=f(v=>v.delta),s=f(v=>v.componentId),a=f(v=>v.results),n=f(v=>v.tier),i=f(v=>v.baselineList),r=f(v=>v.siteCrawlReport),[o,l]=h.useState(""),[d,p]=h.useState(""),[c,m]=h.useState(!1),[u,g]=h.useState(!1),[x,j]=h.useState(null),[S,E]=h.useState(null);h.useEffect(()=>{Promise.all([Q({type:"SETTINGS_GET",key:"githubRepoUrl"}),Q({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,$])=>{l(typeof v.data=="string"?v.data:""),p(typeof $.data=="string"?$.data:"")})},[]);const b=Vt(n,"exportJson"),A=Ht[n].maxBaselines,y=i.some(v=>v.componentId===s),N=y||i.length<A;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 I(){if(!s||a.length===0)return;const v=a.flatMap(ee=>ee.violations),$=a.flatMap(ee=>ee.announcements??[]),L=a.flatMap(ee=>ee.focusEvents??[]),C=a[0],U=(await Q({type:"SETTINGS_GET",key:"stateMatrix"})).data??Bt;await Y({type:"BASELINE_SET",componentId:s,violations:v,announcements:$,focusEvents:L,snapshotMeta:{url:window.location.href,axeVersion:C.axeVersion,matrixConfig:U,capturedAt:new Date().toISOString()}});const H=await Q({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:$,focusEvents:L,currentMatrix:U});f.getState().setDelta(H.delta),re.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 q({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(S=>S.violations),k=a.flatMap(S=>S.announcements??[]),T=a.flatMap(S=>S.focusEvents??[]),w=await K({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:k,focusEvents:T});g.getState().setDelta(w.delta);const C=await K({type:"BASELINE_LIST"});g.getState().setBaselineList(C.items),se.polite(`Baseline cleared for ${s}.`)}async function b(v,y=!1){var P,J;if(a.length===0)return;let k;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const Y=await chrome.storage.local.get("igtRuns"),X=((Y==null?void 0:Y.igtRuns)??{})[s]??{};k=Object.values(X)}let T,w;if(v==="ai-prompt"){const Y=((P=a[0])==null?void 0:P.pageUrl)??((J=a[0])==null?void 0:J.scope)??"";if(Y){const{getDismissalsForUrl:te}=await $e(async()=>{const{getDismissalsForUrl:ie}=await Promise.resolve().then(()=>Ra);return{getDismissalsForUrl:ie}},void 0),X=await te(Y);T=Object.keys(X);const{getResolutionsForPage:re}=await $e(async()=>{const{getResolutionsForPage:ie}=await import("./forensic-log-BGuH56yt.js").then(V=>V.M);return{getResolutionsForPage:ie}},__vite__mapDeps([0,1,2]));w=await re(Y)}}const C=await K({type:"EXPORT_REQUEST",format:v,results:a,delta:y?void 0:t??void 0,manualRuns:k,siteCrawlReport:v==="ai-prompt"?i??void 0:void 0,dismissedKeys:T,incompleteResolutions:w});if(v==="defense-bundle"||v==="evidence-bundle"){const Y=$t(v,s);await _t()?et(C.content,Y):u({open:!0,format:v,content:C.content,filename:Y});return}if(v==="html-print"||v==="vpat"){Ze(C.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText(C.content)}catch{}const te=`<!doctype html><html><head><meta charset="utf-8"><title>AI fix prompt</title>
9
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Y({type:"BASELINE_DELETE",componentId:s});const $=a.flatMap(H=>H.violations),L=a.flatMap(H=>H.announcements??[]),C=a.flatMap(H=>H.focusEvents??[]),O=await Q({type:"BASELINE_COMPARE",componentId:s,currentViolations:$,announcements:L,focusEvents:C});f.getState().setDelta(O.delta);const U=await Q({type:"BASELINE_LIST"});f.getState().setBaselineList(U.items),re.polite(`Baseline cleared for ${s}.`)}async function T(v,$=!1){var de,F;if(a.length===0)return;let L;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const J=await chrome.storage.local.get("igtRuns"),W=((J==null?void 0:J.igtRuns)??{})[s]??{};L=Object.values(W)}let C,O;if(v==="ai-prompt"){const J=((de=a[0])==null?void 0:de.pageUrl)??((F=a[0])==null?void 0:F.scope)??"";if(J){const{getDismissalsForUrl:_}=await Le(async()=>{const{getDismissalsForUrl:V}=await Promise.resolve().then(()=>Da);return{getDismissalsForUrl:V}},void 0),W=await _(J);C=Object.keys(W);const{getResolutionsForPage:z}=await Le(async()=>{const{getResolutionsForPage:V}=await import("./forensic-log-BGuH56yt.js").then(k=>k.M);return{getResolutionsForPage:V}},__vite__mapDeps([0,1,2]));O=await z(J)}}const U=await Q({type:"EXPORT_REQUEST",format:v,results:a,delta:$?void 0:t??void 0,manualRuns:L,siteCrawlReport:v==="ai-prompt"?r??void 0:void 0,dismissedKeys:C,incompleteResolutions:O});if(v==="defense-bundle"||v==="evidence-bundle"){const J=Ot(v,s);await Ft()?at(U.content,J):E({open:!0,format:v,content:U.content,filename:J});return}if(v==="html-print"||v==="vpat"){st(U.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText(U.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">${C.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>
20
+ <pre id="content">${U.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</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 S=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",$=v==="junit"?"xml":v,U=new Blob([C.content],{type:S}),R=URL.createObjectURL(U),F=document.createElement("a");F.href=R,F.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${$}`,F.click(),URL.revokeObjectURL(R)}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:N,disabled:!j,title:j?void 0:`Free tier limits you to ${f} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),m&&e.jsx("button",{onClick:E,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(rn,{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),k=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:()=>an(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>nn(d,s,v.findings)}]:[]]}),e.jsx(je,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(je,{title:"Fixed",violations:k.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 sn={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]=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 ${sn[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)):Ya(s).map(d=>e.jsx(Ja,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function an(t,s,a){if(a.length===0)return;const{url:n}=Za(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function nn(t,s,a){if(a.length===0)return;const{url:n}=en(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function rn({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(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 on(){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 ln(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await on())[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 f=a.tabOrderIssues??[];if(f.length===0)continue;await Se(n,f.map(m=>({key:he(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 Se(n,f.map(m=>({key:pe(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}}}}const cn=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"]),dn=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 un(t){return cn.has(t.ruleId)}function pn(t){return dn.has(t.ruleId)}function hn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function mn(){var C,S,$,U;const t=g(R=>R.results),s=g(R=>R.delta),a=g(R=>R.componentId),n=((C=t[0])==null?void 0:C.pageUrl)??((S=t[0])==null?void 0:S.scope)??"",[r,i]=x.useState({}),[o,l]=x.useState(0);x.useEffect(()=>{if(!n)return;let R=!1;return(async()=>{if(a&&t.length>0)try{await ln(a,t)}catch{}if(R)return;const F=await Oe(n);R||i(F)})(),()=>{R=!0}},[n,o,a,t]);async function d(R,F){if(!n)return;const P=window.prompt(`Why is this finding a false positive?
26
+ </body></html>`,W=new Blob([_],{type:"text/html"}),z=URL.createObjectURL(W);window.open(z,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(z),6e4);return}const H=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",ee=v==="junit"?"xml":v,ce=new Blob([U.content],{type:H}),Z=URL.createObjectURL(ce),le=document.createElement("a");le.href=Z,le.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${ee}`,le.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:I,disabled:!N,title:N?void 0:`Free tier limits you to ${A} 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:()=>m(!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(gn,{disabled:!b,onExport:T,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!N&&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=He(t.new),$=He(t.persistent),L=He(t.fixed),C=[...v.review,...$.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:()=>hn(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>xn(d,s,v.findings)}]:[]]}),e.jsx(we,{title:"Persistent",violations:$.findings,count:$.findings.length,accent:"slate"}),e.jsx(we,{title:"Fixed",violations:L.findings,count:t.fixedCount,accent:"green"}),C.length>0&&e.jsx(we,{title:"Needs review (does not affect grade)",violations:C,count:C.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})]})})(),S&&e.jsx(os,{open:S.open,onClose:()=>E(null),format:S.format,content:S.content,filename:S.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"})]})]}),x&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",x.chromeStorageKeysCleared," chrome.storage key",x.chromeStorageKeysCleared===1?"":"s"," + ",x.indexedDbsCleared.length," database",x.indexedDbsCleared.length===1?"":"s",".",x.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",x.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:x?e.jsx("button",{type:"button",onClick:()=>{m(!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:()=>m(!1),disabled:u,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()=>{g(!0);try{const v=await dn();j(v),await Pe(),re.polite("Audit data reset. Ready for a fresh scan.")}catch(v){j({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[v instanceof Error?v.message:String(v)]})}finally{g(!1)}},disabled:u,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:u?"Resetting…":"Reset everything"})]})})]})})]})}const mn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function He(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:i,renderAsAcknowledged:r}){const[o,l]=h.useState(!r);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 ${mn[n]} ${r?"cursor-pointer select-none":""}`,onClick:r?()=>l(d=>!d):void 0,children:[r&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),i&&i.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:i.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:r?s.map((d,p)=>e.jsx(Fe,{violation:d,alreadyAcknowledged:!0},p)):nn(s).map(d=>e.jsx(an,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function hn(t,s,a){if(a.length===0)return;const{url:n}=on(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function xn(t,s,a){if(a.length===0)return;const{url:n}=ln(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function gn({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,i]=h.useState(!1),[r,o]=h.useState(!1);function l(d){i(!1),s(d,r)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[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:r,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(ue,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{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(ue,{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(ue,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{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(ue,{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(ue,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ue({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 kt="igtRuns";async function fn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(kt))[kt];return s&&typeof s=="object"?s:{}}async function bn(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,r=(await fn())[t];if(r)for(const d of q){const p=r[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 u=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const g=a.tabOrderIssues??[];if(g.length===0)continue;await Ce(n,g.map(x=>({key:xe(x.selector),reason:u,snippet:`${x.selector} — ${x.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const g=a.readingOrderIssues??[];if(g.length===0)continue;await Ce(n,g.map(x=>({key:he(x.selector),reason:u,snippet:`${x.selector} — ${x.textSnippet||"(no text)"}`})))}}}}const vn=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"]),yn=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 jn(t){return vn.has(t.ruleId)}function wn(t){return yn.has(t.ruleId)}function Nn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function kn(){var T,v,$,L;const t=f(C=>C.results),s=f(C=>C.delta),a=f(C=>C.componentId),n=((T=t[0])==null?void 0:T.pageUrl)??((v=t[0])==null?void 0:v.scope)??"",[i,r]=h.useState({}),[o,l]=h.useState(0);h.useEffect(()=>{if(!n)return;let C=!1;return(async()=>{if(a&&t.length>0)try{await bn(a,t)}catch{}if(C)return;const O=await Me(n);C||r(O)})(),()=>{C=!0}},[n,o,a,t]);async function d(C,O){if(!n)return;const U=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,R,P||"(no reason given)",F),l(J=>J+1))}async function p(R){n&&(await Xt(n,R),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((R,F)=>{var P;return R+(((P=F.announcements)==null?void 0:P.length)??0)},0),u=t.reduce((R,F)=>{var P;return R+(((P=F.focusEvents)==null?void 0:P.length)??0)},0),h=t.reduce((R,F)=>{var P;return R+(((P=F.focusEvents)==null?void 0:P.filter(J=>J.isFocusReset).length)??0)},0),f=yt(t,un),m=yt(t,pn),j=f.length,N=m.length,E=(($=t[0])==null?void 0:$.readingOrderIssues)??[],b=((U=t[0])==null?void 0:U.tabOrderIssues)??[],v=E.filter(R=>!(pe(R.selector)in r)),y=E.filter(R=>pe(R.selector)in r),k=b.filter(R=>!(he(R.selector)in r)),T=b.filter(R=>he(R.selector)in r);if(c===0&&u===0&&j===0&&N===0&&v.length===0&&k.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 · ",N," form ·"," ",k.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"]})]}),k.length>0&&e.jsx(fn,{issues:k,onDismiss:d}),v.length>0&&e.jsx(bn,{issues:v,onDismiss:d}),w>0&&e.jsx(vn,{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:f}),N>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(xn,{delta:s}),t.map((R,F)=>{const P=R.announcements??[],J=R.focusEvents??[];return P.length===0&&J.length===0?null:e.jsx(gn,{state:R.state,announcements:P,focusEvents:J},F)})]})}function xn({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 gn({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:hn(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 fn({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 bn({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 vn({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 Xe="igtRuns";async function yn(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 jn={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"}},wn={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"}},Nn={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?jn[t]:wn[t];try{await ne(a,n)}catch{}}async function kn(){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 Sn(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 An(){const t=g(c=>c.componentId),s=g(c=>c.results),[a,n]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{kn().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),Nt(f),h.status==="pass"){const j=z.find(E=>E.id===c),N=j==null?void 0:j.steps.find(E=>E.id===u);N!=null&&N.autoDismissActivity&&yn(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),Nt(h)}const p=z.find(c=>c.id===r);if(p){const c=o[p.id];return e.jsx(Cn,{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?fs(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 Cn({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]=Sn(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 ",Nn[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 Rn={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?Rn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Te="savedFlows";async function En(){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 Tn(){const[t,s]=x.useState([]),[a,n]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{En().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 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 kt(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 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 In(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($n).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function $n(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function _n(){const t=g(l=>l.baselineList),s=g(l=>l.tier),a=Pt[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=In(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 Ln={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 ${Ln[t]}`,children:a})}const Un={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"},Dn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Fn={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=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(On,{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 On({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 ${Un[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Dn[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 ${Fn[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 Mn(){const[t,s]=x.useState(!1),[a,n]=x.useState(0);x.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 Pn(){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 Gn(){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 St(){const[t,s]=x.useState(!1);return x.useEffect(()=>ee("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),g.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 Vn(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{ys().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 ze="storybook:hintDismissed";function Wn(){const[t,s]=x.useState(!1),[a,n]=x.useState();x.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 Bn(){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 ${Hn(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 Hn(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 zn(){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=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 Kn(){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 qn=["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"],Qn={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 Jn(t){const s=new Set(qn),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:Qn[o]}}const ns={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Yn={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[ns]},Xn={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[ns]};function it(t){return t==="thorough"?Xn:Yn}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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}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 Zn(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function er(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 tr(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 sr(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 ar(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>${M(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
- ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${M(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${M(Ie)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
28
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");U!==null&&(await ss(n,C,U||"(no reason given)",O),l(H=>H+1))}async function p(C){n&&(await as(n,C),l(O=>O+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((C,O)=>{var U;return C+(((U=O.announcements)==null?void 0:U.length)??0)},0),m=t.reduce((C,O)=>{var U;return C+(((U=O.focusEvents)==null?void 0:U.length)??0)},0),u=t.reduce((C,O)=>{var U;return C+(((U=O.focusEvents)==null?void 0:U.filter(H=>H.isFocusReset).length)??0)},0),g=St(t,jn),x=St(t,wn),j=g.length,S=x.length,E=(($=t[0])==null?void 0:$.readingOrderIssues)??[],b=((L=t[0])==null?void 0:L.tabOrderIssues)??[],A=E.filter(C=>!(he(C.selector)in i)),y=E.filter(C=>he(C.selector)in i),N=b.filter(C=>!(xe(C.selector)in i)),I=b.filter(C=>xe(C.selector)in i);if(c===0&&m===0&&j===0&&S===0&&A.length===0&&N.length===0&&y.length===0&&I.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+I.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 · ",S," form ·"," ",N.length," tab-order ·"," ",A.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",m," focus ",m===1?"event":"events",u>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",u," focus reset",u===1?"":"s"]}),w>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",w," dismissed"]})]}),N.length>0&&e.jsx(Cn,{issues:N,onDismiss:d}),A.length>0&&e.jsx(Rn,{issues:A,onDismiss:d}),w>0&&e.jsx(En,{dismissedReadingOrder:y,dismissedTabOrder:I,dismissals:i,onRestore:p}),j>0&&e.jsx(At,{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}),S>0&&e.jsx(At,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:x}),e.jsx(Sn,{delta:s}),t.map((C,O)=>{const U=C.announcements??[],H=C.focusEvents??[];return U.length===0&&H.length===0?null:e.jsx(An,{state:C.state,announcements:U,focusEvents:H},O)})]})}function Sn({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(i=>i.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((i,r)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",i.role??i.politeness,"]"]})," ",e.jsx("span",{children:i.text})]},r))})]}),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((i,r)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[i.fromSelector??"(none)"," → ",i.toSelector,i.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},r))})]})]})}function St(t,s){const a=new Map;for(const n of t)for(const i of n.violations){if(!s(i))continue;const r=rt(i.ruleId,i.target.selector),o=a.get(r);o?o.states.push(i.currentState):a.set(r,{violation:i,states:[i.currentState]})}return Array.from(a.values()).sort((n,i)=>{const r={critical:0,serious:1,moderate:2,minor:3};return(r[n.violation.impact]??99)-(r[i.violation.impact]??99)})}function At({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,i)=>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})]},i))})]})}function An({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:Nn(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,i)=>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})]},i))})]}),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,i)=>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"})]},i))})]})]})}function Cn({issues:t,onDismiss:s}){const a=t.filter(i=>i.flag==="visual"||i.flag==="both").length,n=t.filter(i=>i.flag==="tabindex"||i.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((i,r)=>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] ${i.flag==="visual"||i.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:i.flag==="visual"?"Tab order does not match visual layout — focus jumps around":i.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",i.tabPosition,"→vis",i.visualPosition,(i.flag==="tabindex"||i.flag==="both")&&` (DOM${i.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:i.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:i.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${i.selector}`,`${i.selector} — ${i.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"})]},r)),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 Rn({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 En({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[i,r]=h.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:()=>r(!i),"aria-expanded":i,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:i?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",i?"collapse":"review"]})]}),i&&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 In(t,s,a){const n=s[0];if(!n)return;const i=n.pageUrl;if(!i)return;const r=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ce(i,o.map(l=>({key:xe(l.selector),reason:r,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Ce(i,o.map(l=>({key:he(l.selector),reason:r,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Tn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},$n={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"}},Ln={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Ct(t,s){const a=await X();if(!a)return;const n=s?Tn[t]:$n[t];try{await oe(a,n)}catch{}}async function _n(){const s=(await chrome.storage.local.get(Ze))[Ze];return s&&typeof s=="object"?s:{}}async function Rt(t){await chrome.storage.local.set({[Ze]:t})}function Dn(t,s){if(!t.relatedAxeRule||s.length===0)return null;const a=s.flatMap(n=>n.violations.filter(i=>i.ruleId===t.relatedAxeRule));if(a.length>0){const n=Array.from(new Set(a.map(i=>`${i.currentState.pseudoState}·${i.currentState.theme}·${i.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:a.length,states:n}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function Un(){const t=f(c=>c.componentId),s=f(c=>c.results),[a,n]=h.useState({}),[i,r]=h.useState(null);if(h.useEffect(()=>{_n().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,m,u){var x;const g={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((x=o[c])==null?void 0:x.steps)??{},[m]:u},completedAt:new Date().toISOString()}}};if(n(g),Rt(g),u.status==="pass"){const j=q.find(E=>E.id===c),S=j==null?void 0:j.steps.find(E=>E.id===m);S!=null&&S.autoDismissActivity&&In(S.autoDismissActivity,s,m)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const m={...o};delete m[c];const u={...a,[t]:m};n(u),Rt(u)}const p=q.find(c=>c.id===i);if(p){const c=o[p.id];return e.jsx(On,{workflow:p,run:c,results:s,onAnswer:(m,u)=>l(p.id,m,u),onBack:()=>r(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."}),q.map(c=>{const m=o[c.id],u=m?ks(m,c):null,g=m?u!=null&&u.failed&&u.failed>0?"failed":u!=null&&u.unanswered&&u.unanswered>0?"in-progress":"done":"unstarted",x={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:()=>r(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${x}`,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"&&u&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[u.unanswered," unanswered"]})]}),u&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[u.passed," pass"]}),u.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",u.failed," fail"]}),u.notApplicable>0&&e.jsxs("span",{children:[" · ",u.notApplicable," N/A"]}),u.skipped>0&&e.jsxs("span",{children:[" · ",u.skipped," skip"]})," / ",u.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),m&&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 On({workflow:t,run:s,results:a,onAnswer:n,onBack:i}){const r=h.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=Dn(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=r[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=r[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:i,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 m=r[d.id];return m?m.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:m.ruleId})," ran clean across ",m.statesAudited," state",m.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 (${m.ruleId}, ${m.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:m.ruleId})," already found ",m.violationCount," violation",m.violationCount===1?"":"s"," in"," ",m.states.length," state",m.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 (${m.ruleId}, ${m.violationCount} hits in: ${m.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 Ct(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Ln[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Ct(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(Re,{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(Re,{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(Re,{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(Re,{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:m=>n(d.id,{status:c.status,notes:m.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const Fn={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 Re({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?Fn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Te="savedFlows";async function Mn(){const t=await chrome.storage.local.get(Te);return Array.isArray(t[Te])?t[Te]:[]}async function Et(t){await chrome.storage.local.set({[Te]:t})}function Pn(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[i,r]=h.useState(null);h.useEffect(()=>{Mn().then(s)},[]);async function o(){const c=await X();if(!c){r("No audit-target tab found.");return}try{await oe(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),r("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{r("Failed to start recording.")}}async function l(){const c=await X();if(c)try{const m=await Ae(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),m.steps.length===0){r("Recording stopped — no steps captured.");return}const u=typeof prompt=="function"?prompt(`Captured ${m.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!u.trim()){r("Save canceled.");return}const g={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:u.trim(),steps:m.steps,savedAt:new Date().toISOString()},x=[g,...t];s(x),await Et(x),r(`Saved "${g.name}" with ${g.steps.length} steps.`)}catch(m){r(`Stop failed: ${m instanceof Error?m.message:String(m)}`)}}async function d(c){const m=await X();if(m){r(`Replaying "${c.name}"…`);try{const u=await Ae(m,{type:"FLOW_PLAY_REQUEST",steps:c.steps});r(`Replayed ${u.played} step${u.played===1?"":"s"}`+(u.errored?`, ${u.errored} errored (selector not found)`:"")+".")}catch(u){r(`Replay failed: ${u instanceof Error?u.message:String(u)}`)}}}async function p(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const m=t.filter(u=>u.id!==c);s(m),await Et(m)}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"})}),i&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:i}),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 Gn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),i=n.indexOf(":");if(i===-1)return{primary:n};const r=n.slice(0,i),o=n.slice(i+1);return r==="story"?{primary:o.split("--").map(d=>d.split("-").map(Wn).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||r}}function Wn(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Vn(){const t=f(l=>l.baselineList),s=f(l=>l.tier),a=Ht[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[i,r]=h.useState(!1);if(h.useEffect(()=>{De().finally(()=>r(!0))},[]),!i)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 Y({type:"BASELINE_DELETE",componentId:l}),await De()}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=Gn(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(pe,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(pe,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(pe,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(pe,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(pe,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(pe,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(pe,{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 Bn={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 pe({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Bn[t]}`,children:a})}const Hn={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"},zn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Kn={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 ls({onBack:t}){const s=f(m=>m.siteCrawlStatus),a=f(m=>m.siteCrawlProgress),n=f(m=>m.siteCrawlReport),i=f(m=>m.siteCrawlError),[r,o]=h.useState(""),[l,d]=h.useState(25);r===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(m=>{var g;const u=(g=m[0])==null?void 0:g.url;u&&/^https?:\/\//.test(u)&&r===""&&o(u)});function p(){r&&(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),ie({type:"START_SITE_CRAWL",startUrl:r,maxPages:l}))}function c(){Y({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:r,onChange:m=>o(m.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:m=>d(Math.min(200,Math.max(1,parseInt(m.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:!r,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(qn,{report:n}),s==="failed"&&i&&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:"})," ",i]})]})}function qn({report:t}){function s(){Le(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),i=new Blob([n],{type:"text/html"}),r=URL.createObjectURL(i);window.open(r,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(r),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Hn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${zn[t.siteRisk]}`,children:Ss[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=As(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 ${Kn[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 ze="onboardingDismissed",Ke=[{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 Qn(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(ze).then(l=>{l[ze]||s(!0)})},[]);async function i(){await chrome.storage.local.set({[ze]:!0}),s(!1),n(0)}const r=a===Ke.length-1,o=Ke[a];return e.jsxs(ge,{open:t,onClose:i,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," / ",Ke.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"}),r?e.jsx("button",{onClick:i,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 Yn(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(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 Jn(){const t=f(d=>d.aiFailure),s=f(d=>d.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const i=t.severity==="total",r=i?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=i?"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 ${r}`,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 It(){const[t,s]=h.useState(!1);return h.useEffect(()=>se("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(ge,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Xn(){var r;const[t,s]=h.useState(null);if(h.useEffect(()=>{Cs().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await pt(),f.getState().startNewScan(),t.mode==="storybook-all"?ie({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ie({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await pt(),s(null)}const i=t.mode==="storybook-all"?`Story ${((r=t.completedStories)==null?void 0:r.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 (",i,")."]}),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 qe="storybook:hintDismissed";function Zn(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(qe))[qe])return;const o=await X();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var m;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(m=c.__STORYBOOK_PREVIEW__)==null?void 0:m.version}}})).find(c=>{var m;return(m=c.result)==null?void 0:m.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function i(){await chrome.storage.local.set({[qe]:!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:i,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function er(){var r;const t=f(o=>o.results),s=f(o=>o.baselineList),a=f(o=>o.status),n=(r=t[0])==null?void 0:r.startedAt,i=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:i>0?`${i} ${i===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${tr(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 tr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),i=Math.round(n/1e3);if(i<60)return"just now";const r=Math.round(i/60);if(r<60)return`${r}m ago`;const o=Math.round(r/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function sr(){const t=f(l=>l.results),s=f(l=>l.componentId),[a,n]=h.useState([]);if(h.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 i=t.flatMap(l=>l.violations),r=Rs(i,a.length>0?{runs:a,workflows:q}:void 0),o=r.manual!==void 0&&r.manual.workflowsCompleted===r.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 ar(){const t=f(a=>a.setUserMode);function s(a){t(a),Y({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 nr=["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"],rr={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 ir(t){const s=new Set(nr),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),i=n.length,r=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return i===0?o="low":i===1?o="moderate":i<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:i,flaggedInstanceCount:r,flaggedRules:n,headline:rr[o]}}const cs={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},or={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[cs]},lr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[cs]};function lt(t){return t==="thorough"?lr:or}function Tt(t){const s=lt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const $e="wcagcheckr";function G(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Se(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 cr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function dr(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 ur(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,i)=>i.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function pr(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 mr(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 (${G(t.receipt.tsaName)}) — anchored ${G(Se(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>${G(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${G(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${G($e)}; 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 ${sr(t.grade)}">${M(t.grade)}</span>
33
+ <span class="grade-badge ${pr(t.grade)}">${G(t.grade)}</span>
34
34
  <div class="entry-headline">
35
- <div class="entry-time">${M(Ne(t.capturedAt))}</div>
35
+ <div class="entry-time">${G(Se(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">${M(t.hash)}</code></td></tr>
41
- <tr><th>Page URL</th><td><code>${M(t.pageUrl)}</code></td></tr>
42
- <tr><th>Scope</th><td><code>${M(t.scope)}</code></td></tr>
43
- <tr><th>axe-core version</th><td>${M(t.axeVersion)}</td></tr>
40
+ <tr><th>Audit identity hash</th><td><code class="hash">${G(t.hash)}</code></td></tr>
41
+ <tr><th>Page URL</th><td><code>${G(t.pageUrl)}</code></td></tr>
42
+ <tr><th>Scope</th><td><code>${G(t.scope)}</code></td></tr>
43
+ <tr><th>axe-core version</th><td>${G(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 nr(t){return`
47
+ </article>`}function hr(t){return`
48
48
  <section class="component-section">
49
49
  <h2>
50
- <span class="component-id">${M(t.componentId)}</span>
50
+ <span class="component-id">${G(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>${M(t.pageUrl)}</code></p>
54
- ${t.entries.map(ar).join("")}
55
- </section>`}function rr(t){const{entries:s,extensionVersion:a}=t,n=tr(s),r=er(s),i=(t.axeVersions??Zn(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,p=Ne(new Date().toISOString());return`<!doctype html>
53
+ <p class="component-url"><strong>Page audited:</strong> <code>${G(t.pageUrl)}</code></p>
54
+ ${t.entries.map(mr).join("")}
55
+ </section>`}function xr(t){const{entries:s,extensionVersion:a}=t,n=ur(s),i=dr(s),r=(t.axeVersions??cr(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,p=Se(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 — ${M(t.matterReference??p)}</title>
59
+ <title>Pre-litigation accessibility audit report — ${G(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 &amp; chain-of-custody</h1>
199
199
  <dl class="cover-meta">
200
- ${t.matterReference?`<dt>Matter reference</dt><dd>${M(t.matterReference)}</dd>`:""}
201
- ${t.preparedBy?`<dt>Prepared by</dt><dd>${M(t.preparedBy)}</dd>`:""}
202
- ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${M(t.jurisdiction)}</dd>`:""}
203
- <dt>Report generated</dt><dd>${M(p)}</dd>
204
- <dt>Audit period</dt><dd>${r?`${M(Ne(r.earliest))} — ${M(Ne(r.latest))}`:"No audits recorded"}</dd>
200
+ ${t.matterReference?`<dt>Matter reference</dt><dd>${G(t.matterReference)}</dd>`:""}
201
+ ${t.preparedBy?`<dt>Prepared by</dt><dd>${G(t.preparedBy)}</dd>`:""}
202
+ ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${G(t.jurisdiction)}</dd>`:""}
203
+ <dt>Report generated</dt><dd>${G(p)}</dd>
204
+ <dt>Audit period</dt><dd>${i?`${G(Se(i.earliest))} — ${G(Se(i.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>${M(Ie)}</strong> Chrome extension, version <strong>${M(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${M(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>
210
+ <p>The audit records summarized below were captured by the <strong>${G($e)}</strong> Chrome extension, version <strong>${G(a)}</strong>, running <strong>axe-core</strong> ${r?`version(s) ${G(r)}`:"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>${M(i||"n/a")}</td></tr>
221
- <tr><th>Tool</th><td>${M(Ie)} ${M(a)}</td></tr>
220
+ <tr><th>axe-core version(s) observed</th><td>${G(r||"n/a")}</td></tr>
221
+ <tr><th>Tool</th><td>${G($e)} ${G(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(nr).join("")}
224
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(hr).join("")}
225
225
 
226
226
  <section class="methodology">
227
227
  <h2>Methodology</h2>
@@ -245,17 +245,17 @@ document.getElementById('copy').addEventListener('click', () => {
245
245
  </section>
246
246
 
247
247
  <footer>
248
- <span>Generated ${M(p)} by ${M(Ie)} ${M(a)}</span>
248
+ <span>Generated ${G(p)} by ${G($e)} ${G(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 ir(t){const s=rr(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]=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(k=>{y||s(k)}).catch(k=>{y||n(k instanceof Error?k.message:String(k))}),()=>{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,E=t.filter(y=>y.receipt).length;async function b(){if(!(!t||t.length===0)){j(!0);try{await ir({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},k=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),T=URL.createObjectURL(k),w=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,C=document.createElement("a");C.href=T,C.download=w,C.click(),setTimeout(()=>URL.revokeObjectURL(T),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",E>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[E," RFC 3161-anchored"]})]}),E===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 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=>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 or(){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(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 lr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const cr={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."},dr={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."},ur={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},pr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function is(){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(Qe,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?pr:ur,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"?cr:dr,c=t==="trial"?lr(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(Qe,{open:l,onClose:()=>d(!1)})]})}const hr={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"},mr={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"},xr={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 gr(){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(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(fr,{}),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(as,{onBack:()=>o(!1)}):e.jsx(vr,{onPickCrawl:()=>o(!0)}),l&&e.jsx(br,{})]}),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 fr(){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 br(){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 vr({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(jr,{depth:n,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(yr,{}),p&&e.jsx(wr,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function yr(){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 jr({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 wr({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var T;const r=g(w=>w.status),i=g(w=>w.results),o=g(w=>w.freshThisSession),l=g(w=>w.componentId),d=(T=i[0])==null?void 0:T.startedAt,p=Jn(t),c=r==="running",[u,h]=x.useState([]);x.useEffect(()=>{if(!l){h([]);return}let w=!1;return chrome.storage.local.get("igtRuns").then(C=>{if(w)return;const $=((C==null?void 0:C.igtRuns)??{})[l]??{};h(Object.values($))}),()=>{w=!0}},[l]);const f=g(w=>w.acknowledgedKeys),m=i.length>0?Ut(i,{runs:u,workflows:z},"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,E=new Map;for(const w of N){const C=st(w.ruleId,w.target.selector);E.has(C)||E.set(C,w)}const b=Array.from(E.values()),v=new Map;for(const w of b){const C=v.get(w.ruleId)??[];C.push(w),v.set(w.ruleId,C)}const y=Array.from(v.entries()).sort((w,C)=>(Rt[w[1][0].impact]??99)-(Rt[C[1][0].impact]??99)),k=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(Rr,{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 ${hr[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 ${mr[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(Nr,{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(Cr,{}),e.jsx(or,{}),t.length>0&&e.jsx(kr,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:k}),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,C])=>e.jsx(Sr,{ruleId:w,violations:C},w))]})]})}function Nr({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 kr({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 Sr({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=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 ${xr[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(Ar,{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 Ar({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 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 Cr(){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 K({type:"EXPORT_REQUEST",format:c,results:t});if(c==="defense-bundle"||c==="evidence-bundle"){const f=$t(c,s);await _t()?et(h.content,f):l({open:!0,format:c,content:h.content,filename:f})}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 gr(t){const s=xr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function ds(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[i,r]=h.useState(0),[o,l]=h.useState(!1),[d,p]=h.useState(""),[c,m]=h.useState(""),[u,g]=h.useState(""),[x,j]=h.useState(!1);if(h.useEffect(()=>{let y=!1;return s(null),n(null),Wt().then(N=>{y||s(N)}).catch(N=>{y||n(N instanceof Error?N.message:String(N))}),()=>{y=!0}},[i]),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 S=t.length,E=t.filter(y=>y.receipt).length;async function b(){if(!(!t||t.length===0)){j(!0);try{await gr({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:u.trim()||void 0}),l(!1)}finally{j(!1)}}}async function A(){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},N=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),I=URL.createObjectURL(N),w=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,T=document.createElement("a");T.href=I,T.download=w,T.click(),setTimeout(()=>URL.revokeObjectURL(I),1e3)}return S===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:[S," ",S===1?"entry":"entries",E>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[E," RFC 3161-anchored"]})]}),E===0&&S>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 A(),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:()=>r(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=>m(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:u,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:x||S===0,onClick:b,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:x?"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 fr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let d=!1;return Wt().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const i=t.length,r=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:i})," ",i===1?"audit":"audits"," on record",r&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:r.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(ge,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(ds,{})})})]})}function br(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const vr={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."},yr={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."},jr={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},wr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function us(){const t=f(m=>m.tier),s=f(m=>m.trialDaysRemaining),a=f(m=>m.seatsUsed),n=f(m=>m.seatsTotal),i=f(m=>m.planCode),r=f(m=>m.licenseDaysRemaining),o=f(m=>m.pastDue),[l,d]=h.useState(!1);if(t==="solo"&&i==="solo-single-month"){const m=r,u=m!==null&&m<=7,g=m===null?"":m===0?"expires today":m===1?"1 day left":`${m} days left`;return e.jsxs("aside",{"aria-label":"License status",className:u?"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:u?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),g&&e.jsxs("span",{className:u?"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:u?"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:u?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"OPEN_SETTINGS"}),className:u?"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 m=t==="team"?wr:jr,u=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:m.perks,g=t==="team"&&a!==null&&n!==null&&a>n,x=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"}:x?{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:["✓ ",m.label]}),e.jsxs("span",{className:j.subtitle,children:[" · ",u]})]}),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."}),x&&!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 Y({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const p=t==="trial"?vr:yr,c=t==="trial"?br(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 Y({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 Nr={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"},kr={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},$t={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Sr={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"},Lt={critical:0,serious:1,moderate:2,minor:3};function Ar(){const t=f(m=>m.setUserMode),s=f(m=>m.status),a=f(m=>m.setStatus),n=f(m=>m.errorMessage),i=f(m=>m.setError),[r,o]=h.useState(!1),[l,d]=h.useState(!1),p=h.useRef(s);h.useEffect(()=>{if(p.current==="running"&&s==="complete"){d(!0);const m=setTimeout(()=>d(!1),3500);return p.current=s,()=>clearTimeout(m)}p.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const m=setTimeout(()=>{f.getState().status==="running"&&(a("idle"),i("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(m)},[s,a,i]);function c(){t("dev"),Y({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(us,{}),e.jsx(Zt,{}),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(Xt,{}),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(Cr,{}),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:()=>{f.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[r?e.jsx(ls,{onBack:()=>o(!1)}):e.jsx(Er,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Rr,{})]}),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 Cr(){const t=f(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 Y({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 Rr(){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 Er({onPickCrawl:t}){const s=f(m=>m.status),a=f(m=>m.results),[n,i]=h.useState("quick"),[r,o]=h.useState("all"),l=s==="running",d=a.flatMap(m=>m.violations),p=a.length>0;function c(){ie({type:"START_AUDIT",mode:"full-page",matrixOverride:lt(n)}),f.getState().startNewScan(),re.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(Tr,{depth:n,onChange:i,disabled:l})]}),!p&&!l&&e.jsx(Ir,{}),p&&e.jsx($r,{violations:d,severityFilter:r,onSeverityFilterChange:o,scanDepth:n})]})}function Ir(){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 Tr({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(_t,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Tt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(_t,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Tt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function _t({active:t,disabled:s,onClick:a,title:n,subtitle:i,desc:r}){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:i}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:r})]})}function $r({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var I;const i=f(w=>w.status),r=f(w=>w.results),o=f(w=>w.freshThisSession),l=f(w=>w.componentId),d=(I=r[0])==null?void 0:I.startedAt,p=ir(t),c=i==="running",[m,u]=h.useState([]);h.useEffect(()=>{if(!l){u([]);return}let w=!1;return chrome.storage.local.get("igtRuns").then(T=>{if(w)return;const $=((T==null?void 0:T.igtRuns)??{})[l]??{};u(Object.values($))}),()=>{w=!0}},[l]);const g=f(w=>w.acknowledgedKeys),x=r.length>0?Pt(r,{runs:m,workflows:q},"2.1","AA",g):void 0;function j(){ie({type:"START_AUDIT",mode:"full-page",matrixOverride:lt(n)}),f.getState().startNewScan(),re.polite("Re-scanning this page now.")}const S=s==="lawsuit-risk"?t.filter(w=>w.impact==="critical"||w.impact==="serious"):t,E=new Map;for(const w of S){const T=rt(w.ruleId,w.target.selector);E.has(T)||E.set(T,w)}const b=Array.from(E.values()),A=new Map;for(const w of b){const T=A.get(w.ruleId)??[];T.push(w),A.set(w.ruleId,T)}const y=Array.from(A.entries()).sort((w,T)=>(Lt[w[1][0].impact]??99)-(Lt[T[1][0].impact]??99)),N=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(Fr,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Pe(),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 ${Nr[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 ${kr[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 ${$t[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${$t[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&&x&&!x.canClaimConformance&&e.jsx(Lr,{coverage:x}),!c&&x&&x.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 ",x.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(Or,{}),e.jsx(fr,{}),t.length>0&&e.jsx(_r,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:N}),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,T])=>e.jsx(Dr,{ruleId:w,violations:T},w))]})]})}function Lr({coverage:t}){const s=f(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"),Y({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 _r({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 Dr({ruleId:t,violations:s}){var m;const[a,n]=h.useState(!1),i=(m=s.find(u=>u.target.opacityContext))==null?void 0:m.target.opacityContext,r=Es(t,i),o=s[0].impact,l=s[0],p=r.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:r.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 ${Sr[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:"})," ",r.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",r.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((u,g)=>e.jsx(Ur,{violation:u},g))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Ur({violation:t}){const s=f(r=>{var o;return(o=r.results[0])==null?void 0:o.frameId}),[a,n]=h.useState(null);async function i(r){r.stopPropagation();const o=await X();if(o)try{const l=await Ae(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:i,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 Ee=[{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 Or(){const t=f(c=>c.results),s=f(c=>c.componentId),[a,n]=h.useState(null),[i,r]=h.useState(!1),[o,l]=h.useState(null);async function d(c,m){if(t.length!==0){n(c);try{const u=await Q({type:"EXPORT_REQUEST",format:c,results:t});if(c==="defense-bundle"||c==="evidence-bundle"){const g=Ot(c,s);await Ft()?at(u.content,g):l({open:!0,format:c,content:u.content,filename:g})}else if(m)st(u.content);else{try{await navigator.clipboard.writeText(u.content),re.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const x=`<!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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</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(ss,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Rr({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 Er(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 Tr(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 Ir(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 $r(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 _r(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=Dt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions}),i=Ns(t.targetVersion,t.targetLevel),o=[];for(const h of i){const f=Er(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),m=Tr(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},E=(u=t.overrides)==null?void 0:u[h.id];let b,v,y=!1;if(E)b=E.verdict,v=E.rationale,y=!0;else{const k=r.get(h.id);k?b=k.state:b=Ir(N,m.unanswered,f.hasIncomplete,m.allNotApplicable),v=$r(h,b,N)}o.push({criterion:h,understandingUrl:ks(h,t.targetVersion),verdict:b,signals:N,overridden:y,rationale:v})}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 Lr={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 I(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ke(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 Ur(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
- <h3 class="guideline-h">Guideline ${I(p)}</h3>
257
+ <pre>${u.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,j=new Blob([x],{type:"text/html"}),S=URL.createObjectURL(j);window.open(S,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(S),6e4)}}finally{n(null)}}}const p=i?Ee:Ee.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))}),!i&&e.jsxs("button",{type:"button",onClick:()=>r(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",Ee.length-2," more report option",Ee.length-2===1?"":"s"," ↓"]}),o&&e.jsx(os,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Fr({iso:t}){const[,s]=h.useState(0);h.useEffect(()=>{const n=setInterval(()=>s(i=>i+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 Mr(t,s,a){const n=new Set,i=[];let r=!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),r=!0;continue}n.add(c.ruleId),i.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),r=!0)}}return{rulesFiring:n,failures:i,hasIncomplete:r}}function Pr(t,s,a){const n=[];let i=0,r=0,o=0,l=0;for(const p of a){const c=p.steps.filter(m=>m.wcag===t);if(c.length!==0){i+=c.length;for(const[m,u]of s){const g=u[p.id];if(!g){r+=c.length;continue}for(const x of c){const j=g.steps[x.id];if(!j){r++;continue}j.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${p.id}.${x.id}`,description:x.question,pageUrl:m,notes:j.notes})):j.status==="skip"?r++:j.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:i,failures:n,unanswered:r,allNotApplicable:d}}function Gr(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 Wr(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 Vr(t,s){var m;const a=[];for(const u of s.auditsByUrl.values())a.push(...u);const n=[];for(const u of s.igtRunsByUrl.values())n.push(...Object.values(u));const i=Gt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions}),r=Is(t.targetVersion,t.targetLevel),o=[];for(const u of r){const g=Mr(u.id,s.auditsByUrl,s.acknowledgedMatchKeys),x=Pr(u.id,s.igtRunsByUrl,s.workflows),j=g.rulesFiring.size===0&&x.stepsCovering===0,S={axeRulesFiringForCriterion:g.rulesFiring.size,axeFailures:g.failures,igtStepsCoveringCriterion:x.stepsCovering,igtFailures:x.failures,unmapped:j},E=(m=t.overrides)==null?void 0:m[u.id];let b,A,y=!1;if(E)b=E.verdict,A=E.rationale,y=!0;else{const N=i.get(u.id);N?b=N.state:b=Gr(S,x.unanswered,g.hasIncomplete,x.allNotApplicable),A=Wr(u,b,S)}o.push({criterion:u,understandingUrl:Ts(u,t.targetVersion),verdict:b,signals:S,overridden:y,rationale:A})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const u of o)u.verdict==="pass"?l.pass++:u.verdict==="fail"?l.fail++:u.verdict==="inconclusive"?l.inconclusive++:u.verdict==="not-applicable"?l.notApplicable++:u.verdict==="not-evaluated"&&l.notEvaluated++;function d(u){const g={A:1,AA:2,AAA:3},x=g[u];return o.every(j=>g[j.criterion.level]>x?!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 Br={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Dt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function R(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ne(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 Hr(t,s,a){const{inputs:n,rows:i,summary:r,generatedAt:o}=t,l=r.meetsTarget?`MEETS WCAG ${n.targetVersion} Level ${n.targetLevel}`:`DOES NOT MEET WCAG ${n.targetVersion} Level ${n.targetLevel}`,d=new Map;for(const c of i){const m=c.criterion.id.split(".").slice(0,2).join("."),u=d.get(m)??[];u.push(c),d.set(m,u)}const p=Array.from(d.entries()).sort(([c],[m])=>c.localeCompare(m,void 0,{numeric:!0})).map(([c,m])=>`
258
+ <h3 class="guideline-h">Guideline ${R(c)}</h3>
259
259
  <table class="criteria-table">
260
260
  <thead>
261
261
  <tr>
@@ -263,13 +263,13 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
263
263
  </tr>
264
264
  </thead>
265
265
  <tbody>
266
- ${c.map(u=>`
267
- <tr class="${Tt[u.verdict]}">
268
- <td><a href="${I(u.understandingUrl)}" target="_blank" rel="noopener">${I(u.criterion.id)}</a></td>
269
- <td>${I(u.criterion.title)}</td>
270
- <td>${I(u.criterion.level)}</td>
271
- <td><span class="verdict-badge ${Tt[u.verdict]}">${Lr[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
272
- <td class="rationale">${I(u.rationale)}</td>
266
+ ${m.map(u=>`
267
+ <tr class="${Dt[u.verdict]}">
268
+ <td><a href="${R(u.understandingUrl)}" target="_blank" rel="noopener">${R(u.criterion.id)}</a></td>
269
+ <td>${R(u.criterion.title)}</td>
270
+ <td>${R(u.criterion.level)}</td>
271
+ <td><span class="verdict-badge ${Dt[u.verdict]}">${Br[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
272
+ <td class="rationale">${R(u.rationale)}</td>
273
273
  </tr>
274
274
  ${u.signals.axeFailures.length>0||u.signals.igtFailures.length>0?`
275
275
  <tr class="evidence-row">
@@ -278,13 +278,13 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
278
278
  <details>
279
279
  <summary>${u.signals.axeFailures.length+u.signals.igtFailures.length} failure instance${u.signals.axeFailures.length+u.signals.igtFailures.length===1?"":"s"}</summary>
280
280
  <ul>
281
- ${[...u.signals.axeFailures,...u.signals.igtFailures].slice(0,20).map(h=>`
281
+ ${[...u.signals.axeFailures,...u.signals.igtFailures].slice(0,20).map(g=>`
282
282
  <li>
283
- <code>${I(h.ruleOrStepId)}</code>
284
- ${h.pageUrl?` on <a href="${I(h.pageUrl)}" target="_blank" rel="noopener"><code>${I(h.pageUrl)}</code></a>`:""}
285
- — ${I(h.description)}
286
- ${h.selector?`<br><span class="ev-selector"><code>${I(h.selector)}</code></span>`:""}
287
- ${h.notes?`<br><em>${I(h.notes)}</em>`:""}
283
+ <code>${R(g.ruleOrStepId)}</code>
284
+ ${g.pageUrl?` on <a href="${R(g.pageUrl)}" target="_blank" rel="noopener"><code>${R(g.pageUrl)}</code></a>`:""}
285
+ — ${R(g.description)}
286
+ ${g.selector?`<br><span class="ev-selector"><code>${R(g.selector)}</code></span>`:""}
287
+ ${g.notes?`<br><em>${R(g.notes)}</em>`:""}
288
288
  </li>
289
289
  `).join("")}
290
290
  ${u.signals.axeFailures.length+u.signals.igtFailures.length>20?`<li class="ev-more">…and ${u.signals.axeFailures.length+u.signals.igtFailures.length-20} more.</li>`:""}
@@ -300,7 +300,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
300
300
  <html lang="en">
301
301
  <head>
302
302
  <meta charset="utf-8" />
303
- <title>WCAG ${I(a.targetVersion)} Level ${I(a.targetLevel)} Conformance Report — ${I(a.siteName)}</title>
303
+ <title>WCAG ${R(n.targetVersion)} Level ${R(n.targetLevel)} Conformance Report — ${R(n.siteName)}</title>
304
304
  <style>
305
305
  *, *::before, *::after { box-sizing: border-box; }
306
306
  body {
@@ -378,6 +378,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
378
378
  .attestation h3, .methodology h3, .declaration h3, .anchor-block h3 { font-size: 11pt; margin: 0 0 6pt; }
379
379
  .anchor-block { background: #f0f9ff; border-left: 3px solid #0ea5e9; }
380
380
  .anchor-block.anchor-missing { background: #fef3c7; border-left-color: #f59e0b; }
381
+ .declaration-signed { background: #ecfdf5; border-left: 3px solid #10b981; }
381
382
  table.anchor-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin-top: 6pt; }
382
383
  table.anchor-table th, table.anchor-table td { text-align: left; vertical-align: top; padding: 3pt 6pt; }
383
384
  table.anchor-table th { width: 35%; color: #475569; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 9pt; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
@@ -398,24 +399,24 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
398
399
  </head>
399
400
  <body>
400
401
  <section class="cover">
401
- <p class="eyebrow">WCAG ${I(a.targetVersion)} Conformance Evaluation Report</p>
402
- <h1>${I(a.siteName)}</h1>
403
- <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${I(a.siteUrl)}</code></p>
402
+ <p class="eyebrow">WCAG ${R(n.targetVersion)} Conformance Evaluation Report</p>
403
+ <h1>${R(n.siteName)}</h1>
404
+ <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${R(n.siteUrl)}</code></p>
404
405
  <div class="conformance-banner ${r.meetsTarget?"met":"not-met"}">
405
- ${I(o)}
406
+ ${R(l)}
406
407
  </div>
407
408
  <dl class="meta">
408
409
  <dt>Highest level fully satisfied</dt>
409
- <dd>${r.levelAchieved?`WCAG ${I(a.targetVersion)} Level ${I(r.levelAchieved)}`:"None (target level not met)"}</dd>
410
+ <dd>${r.levelAchieved?`WCAG ${R(n.targetVersion)} Level ${R(r.levelAchieved)}`:"None (target level not met)"}</dd>
410
411
  <dt>Target conformance level</dt>
411
- <dd>WCAG ${I(a.targetVersion)} Level ${I(a.targetLevel)}</dd>
412
+ <dd>WCAG ${R(n.targetVersion)} Level ${R(n.targetLevel)}</dd>
412
413
  <dt>Report generated</dt>
413
- <dd>${I(Ke(i))}</dd>
414
+ <dd>${R(Ne(o))}</dd>
414
415
  <dt>Evaluator</dt>
415
416
  <dd>
416
- ${I(a.evaluator.name)}
417
- ${a.evaluator.organization?`, ${I(a.evaluator.organization)}`:""}
418
- ${a.evaluator.qualifications?`<br><span style="color: #64748b">${I(a.evaluator.qualifications)}</span>`:""}
417
+ ${R(n.evaluator.name)}
418
+ ${n.evaluator.organization?`, ${R(n.evaluator.organization)}`:""}
419
+ ${n.evaluator.qualifications?`<br><span style="color: #64748b">${R(n.evaluator.qualifications)}</span>`:""}
419
420
  </dd>
420
421
  </dl>
421
422
  </section>
@@ -431,27 +432,27 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
431
432
 
432
433
  <h2>1 — Evaluation scope</h2>
433
434
  <dl class="meta">
434
- <dt>Website / application</dt><dd><strong>${I(a.siteName)}</strong> — <code>${I(a.siteUrl)}</code></dd>
435
- <dt>Conformance target</dt><dd>WCAG ${I(a.targetVersion)} Level ${I(a.targetLevel)}</dd>
435
+ <dt>Website / application</dt><dd><strong>${R(n.siteName)}</strong> — <code>${R(n.siteUrl)}</code></dd>
436
+ <dt>Conformance target</dt><dd>WCAG ${R(n.targetVersion)} Level ${R(n.targetLevel)}</dd>
436
437
  <dt>Accessibility-support baseline</dt>
437
- <dd>${I(a.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
438
- ${a.additionalStandards&&a.additionalStandards.length>0?`
438
+ <dd>${R(n.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
439
+ ${n.additionalStandards&&n.additionalStandards.length>0?`
439
440
  <dt>Additional standards evaluated against</dt>
440
- <dd>${a.additionalStandards.map(I).join(", ")}</dd>
441
+ <dd>${n.additionalStandards.map(R).join(", ")}</dd>
441
442
  `:""}
442
443
  </dl>
443
444
 
444
445
  <h2>2 — Sample of representative pages</h2>
445
- ${a.pageSample.length===0?"<p><em>No page sample recorded.</em></p>":`
446
+ ${n.pageSample.length===0?"<p><em>No page sample recorded.</em></p>":`
446
447
  <table class="sample-table">
447
448
  <thead><tr><th>URL</th><th>Page type</th><th>Selection</th><th>Data?</th></tr></thead>
448
449
  <tbody>
449
- ${a.pageSample.map(p=>`
450
+ ${n.pageSample.map(c=>`
450
451
  <tr>
451
- <td><a href="${I(p.url)}" target="_blank" rel="noopener"><code>${I(p.url)}</code></a></td>
452
- <td>${I(p.pageType)}</td>
453
- <td>${I(p.selectionType)}</td>
454
- <td>${p.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
452
+ <td><a href="${R(c.url)}" target="_blank" rel="noopener"><code>${R(c.url)}</code></a></td>
453
+ <td>${R(c.pageType)}</td>
454
+ <td>${R(c.selectionType)}</td>
455
+ <td>${c.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
455
456
  </tr>
456
457
  `).join("")}
457
458
  </tbody>
@@ -459,7 +460,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
459
460
  `}
460
461
 
461
462
  <h2>3 — Detailed per-criterion findings</h2>
462
- ${d}
463
+ ${p}
463
464
 
464
465
  <section class="methodology">
465
466
  <h3>Evaluation methodology</h3>
@@ -475,7 +476,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
475
476
 
476
477
  <section class="attestation">
477
478
  <h3>Conformance claim</h3>
478
- <p>${r.meetsTarget?`Based on the evidence collected, <strong>${I(a.siteName)}</strong> meets the success criteria required for <strong>WCAG ${I(a.targetVersion)} Level ${I(a.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${I(a.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${I(a.targetVersion)} Level ${I(a.targetLevel)} conformance. ${r.fail>0?`${r.fail} criterion failure${r.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
479
+ <p>${r.meetsTarget?`Based on the evidence collected, <strong>${R(n.siteName)}</strong> meets the success criteria required for <strong>WCAG ${R(n.targetVersion)} Level ${R(n.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${R(n.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${R(n.targetVersion)} Level ${R(n.targetLevel)} conformance. ${r.fail>0?`${r.fail} criterion failure${r.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
479
480
  <p style="font-size: 9.5pt; color: #475569;">This conformance claim is the responsibility of the named evaluator. The wcagcheckr tooling assembled the per-criterion evidence; the evaluator's signature attests that the methodology was followed and the verdicts reflect the site under evaluation.</p>
480
481
  </section>
481
482
 
@@ -484,11 +485,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
484
485
  <h3>Forensic anchor — report integrity proof</h3>
485
486
  <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
487
  <table class="anchor-table">
487
- <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${I(s.reportHash)}</code></td></tr>
488
- <tr><th>Anchored at</th><td>${I(Ke(s.receipt.anchoredAt))}</td></tr>
489
- <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${I(s.receipt.tsaName)}</td></tr>
490
- <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${I(s.receipt.serverKeyFingerprint)}</code></td></tr>
491
- ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${I(s.receipt.prevAuditHash)}</code></td></tr>`:""}
488
+ <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${R(s.reportHash)}</code></td></tr>
489
+ <tr><th>Anchored at</th><td>${R(Ne(s.receipt.anchoredAt))}</td></tr>
490
+ <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${R(s.receipt.tsaName)}</td></tr>
491
+ <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${R(s.receipt.serverKeyFingerprint)}</code></td></tr>
492
+ ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${R(s.receipt.prevAuditHash)}</code></td></tr>`:""}
492
493
  </table>
493
494
  <p style="font-size: 9pt; color: #64748b; margin-top: 8pt;">
494
495
  To verify: download the verification bundle JSON from the wcagcheckr Compliance tab,
@@ -499,7 +500,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
499
500
  <!-- Machine-readable receipt — verifier can extract from the printed PDF
500
501
  if the JSON bundle was lost. Inert in browsers; serves only as
501
502
  structured-data preservation. -->
502
- <script type="application/json" id="wcagcheckr-anchor-receipt">${I(JSON.stringify(s))}<\/script>
503
+ <script type="application/json" id="wcagcheckr-anchor-receipt">${R(JSON.stringify(s))}<\/script>
503
504
  </section>
504
505
  `:`
505
506
  <section class="anchor-block anchor-missing">
@@ -508,17 +509,35 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
508
509
  </section>
509
510
  `}
510
511
 
512
+ ${a?`
513
+ <section class="declaration declaration-signed">
514
+ <h3>Evaluator declaration — signed and sealed</h3>
515
+ <p>I, <strong>${R(a.signerName)}</strong>${a.signerOrganization?` of <strong>${R(a.signerOrganization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${a.signerQualifications?`My qualifications: ${R(a.signerQualifications)}.`:""}</p>
516
+ <p style="margin-top: 10pt; white-space: pre-wrap;">${R(a.claim)}</p>
517
+ <table class="anchor-table" style="margin-top: 14pt;">
518
+ <tr><th>Signed by</th><td><strong>${R(a.signerName)}</strong>${a.signerOrganization?` &middot; ${R(a.signerOrganization)}`:""} &middot; <code>${R(a.signerEmail)}</code></td></tr>
519
+ ${a.signerQualifications?`<tr><th>Qualifications</th><td>${R(a.signerQualifications)}</td></tr>`:""}
520
+ <tr><th>Signed at</th><td>${R(Ne(a.signedAt))}</td></tr>
521
+ <tr><th>Audit captured at</th><td>${R(Ne(a.auditCapturedAt))}</td></tr>
522
+ <tr><th>Scope of attestation</th><td>${R(a.scope)}</td></tr>
523
+ ${a.signatureReceipt?`<tr><th>Signature anchor</th><td>${R(a.signatureReceipt.tsaName)} &middot; <code class="hash">${R(a.signatureReceipt.timestampHex.slice(0,24))}…</code></td></tr>`:""}
524
+ </table>
525
+ <p style="font-size: 9pt; color: #475569; margin-top: 8pt;">This is a digitally-recorded attestation captured in the wcagcheckr extension at the time of signing. The signer takes responsibility for the conclusions presented.</p>
526
+ </section>
527
+ `:`
511
528
  <section class="declaration">
512
- <h3>Evaluator declaration</h3>
513
- <p>I, <strong>${I(a.evaluator.name)}</strong>${a.evaluator.organization?` of <strong>${I(a.evaluator.organization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${a.evaluator.qualifications?`My qualifications: ${I(a.evaluator.qualifications)}.`:""} ${a.evaluator.contact?`I may be contacted at <code>${I(a.evaluator.contact)}</code>.`:""}</p>
529
+ <h3>Evaluator declaration — unsigned</h3>
530
+ <p>I, <strong>${R(n.evaluator.name)}</strong>${n.evaluator.organization?` of <strong>${R(n.evaluator.organization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${n.evaluator.qualifications?`My qualifications: ${R(n.evaluator.qualifications)}.`:""} ${n.evaluator.contact?`I may be contacted at <code>${R(n.evaluator.contact)}</code>.`:""}</p>
531
+ <p style="font-size: 9.5pt; color: #92400e; background: #fef3c7; border-left: 3px solid #f59e0b; padding: 6pt 10pt; margin-top: 10pt;">This report has not been signed inside the wcagcheckr extension. Use the <em>Sign and seal</em> step on the Compliance tab to attach a digital attestation, or sign the line below by hand.</p>
514
532
  <p style="margin-top: 14pt;">Signature: <span style="display:inline-block; min-width:200pt; border-bottom:1px solid #94a3b8;">&nbsp;</span> &nbsp; Date: <span style="display:inline-block; min-width:90pt; border-bottom:1px solid #94a3b8;">&nbsp;</span></p>
515
533
  </section>
534
+ `}
516
535
 
517
536
  <footer class="report-footer">
518
- <span>Generated ${I(Ke(i))} by wcagcheckr</span>
537
+ <span>Generated ${R(Ne(o))} by wcagcheckr</span>
519
538
  <span>${r.totalCriteria} criteria · ${r.pass} pass · ${r.fail} fail · ${r.inconclusive} inconclusive</span>
520
539
  </footer>
521
540
  </body>
522
- </html>`}async function Dr(t,s){const a=Ur(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const qe=Lt("wcag-em-anchor"),Fr="https://api.wcagcheckr.com",Or="wcagcheckr",Mr=15e3;function os(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 Pr(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 Gr(t){return Pr(Ss(os(t)))}function Vr(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 Wr(t,s){const a=await Gr(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Fr}/v1/products/${Or}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Mr)});if(!i.ok)return qe.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return Vr(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 Br(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:os(t)}}const It="igtRuns",Hr={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"},zr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Kr(){const t=g(A=>A.results),s=g(A=>A.acknowledgedKeys),[a,n]=x.useState(""),[r,i]=x.useState(""),o=Cs,l=As,[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,E]=x.useState(""),[b,v]=x.useState(""),[y,k]=x.useState(""),[T,w]=x.useState({}),[C,S]=x.useState(!1),[$,U]=x.useState([]),[R,F]=x.useState(null),[P,J]=x.useState(!1),[Y,te]=x.useState(null);x.useEffect(()=>{let A=!1;return chrome.storage.local.get(It).then(D=>{if(A)return;const L=D[It]??{};w(L),S(!0)}).catch(()=>{A||S(!0)}),()=>{A=!0}},[]),x.useEffect(()=>{var A;if(!a&&((A=t[0])!=null&&A.pageUrl))try{const D=new URL(t[0].pageUrl);n(D.hostname),i(D.origin)}catch{}},[t,a]),x.useEffect(()=>{const A=new Set;for(const L of t)A.add(L.pageUrl??L.scope);if(A.size===0){U([]);return}let D=!1;return Promise.all(Array.from(A).map(L=>Ee(L))).then(L=>{D||U(L.flat())}).catch(()=>{}),()=>{D=!0}},[t]);const X=x.useMemo(()=>{const A=new Map,D=new Map;for(const H of t){const W=H.pageUrl??H.scope,O=A.get(W)??[];O.push(H),A.set(W,O)}const L=new Map;for(const H of t){const W=H.pageUrl??H.scope;L.set(H.componentId,W)}for(const[H,W]of Object.entries(T)){const O=L.get(H);if(!O)continue;const Q=D.get(O)??{};Object.assign(Q,W),D.set(O,Q)}return{auditsByUrl:A,igtRunsByUrl:D,workflows:z,acknowledgedMatchKeys:s,incompleteResolutions:$}},[t,T,s,$]),re=x.useMemo(()=>{const A=[],D=new Set;for(const L of X.auditsByUrl.keys())D.has(L)||(D.add(L),A.push({url:L,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const L of y.split(`
523
- `).map(H=>H.trim()).filter(Boolean))D.has(L)||(D.add(L),A.push({url:L,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return A},[X,y]),ie=x.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(A=>A.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]),V=x.useMemo(()=>C?_r(ie,X):null,[ie,X,C]);async function Ae(){V&&await Dr(V,R)}async function _(){if(V){J(!0),te(null);try{const A=await Wr(V);if(!A){te("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(A)}finally{J(!1)}}}function B(){var Q,xe,G;if(!V||!R)return;const A=((G=(xe=(Q=chrome.runtime).getManifest)==null?void 0:xe.call(Q))==null?void 0:G.version)??"0.0.0",D=Br(V,R,A),L=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),H=URL.createObjectURL(L),W=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,O=document.createElement("a");O.href=H,O.download=W,O.click(),setTimeout(()=>URL.revokeObjectURL(H),1e3)}return x.useEffect(()=>{F(null),te(null)},[a,r,d,c,h,m,N,b,y]),C?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."})]}),V&&V.summary.totalCriteria>0&&e.jsx(qr,{totalCriteria:V.summary.totalCriteria,pass:V.summary.pass,fail:V.summary.fail,inconclusive:V.summary.inconclusive,notEvaluated:V.summary.notEvaluated,notApplicable:V.summary.notApplicable,levelAchieved:V.summary.levelAchieved,meetsTarget:V.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:X.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:A=>n(A.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:A=>i(A.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:A=>p(A.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:A=>u(A.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.",X.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:X.auditsByUrl.size})," URL",X.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:A=>k(A.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:A=>f(A.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:A=>j(A.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:A=>E(A.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:A=>v(A.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),V&&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 (",V.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:V.rows.map(A=>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:[A.criterion.id," · ",A.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:A.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Hr[A.verdict]}`,children:zr[A.verdict]})]},A.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"}),R?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:[R.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",R.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.`}),Y&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:Y}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!V||!a||!h||P,onClick:()=>void _(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:P?"Anchoring…":R?"Re-anchor":"Anchor this report"}),R&&e.jsx("button",{type:"button",onClick:B,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:!V||!a||!h,onClick:()=>void Ae(),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 qr({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 si(){const t=g(a=>a.view),s=g(a=>a.userMode);return x.useEffect(()=>{const a=Gs(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=Ds();Gt({forceRefresh:!0}).catch(()=>{}),Le().catch(()=>{}),Ps().catch(()=>{}),Vs().catch(()=>{}),Os().catch(()=>{}),Rs().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),Z().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(Kn,{}),e.jsx(Ge,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(gr,{}),e.jsx(St,{}),e.jsx(Ge,{})]}):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(is,{}),e.jsx(qt,{}),e.jsx(sa,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(ia,{}),e.jsx(ua,{}),e.jsx(Wn,{}),e.jsx(Vn,{}),e.jsx(ha,{}),e.jsx(Pn,{}),e.jsx(Gn,{}),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(Ka,{}),t==="delta"&&e.jsx(tn,{}),t==="activity"&&e.jsx(mn,{}),t==="guided"&&e.jsx(An,{}),t==="flows"&&e.jsx(Tn,{}),t==="scorecard"&&e.jsx(_n,{}),t==="crawl"&&e.jsx(as,{}),t==="forensic"&&e.jsx(rs,{}),t==="compliance"&&e.jsx(Kr,{})]})]}),e.jsx(zn,{}),e.jsx(Bn,{}),e.jsx(Mn,{}),e.jsx(St,{}),e.jsx(Ge,{})]})}class ai extends we.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{si as A,ai as E};
541
+ </html>`}async function zr(t,s,a){const n=Hr(t,s,a),i=new Blob([n],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(i);await chrome.tabs.create({url:r})}const Qe=Mt("wcag-em-anchor"),Kr="https://api.wcagcheckr.com",qr="wcagcheckr",Qr=15e3;function ps(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 Yr(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 Jr(t){return Yr($s(ps(t)))}function Xr(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 Zr(t,s){const a=await Jr(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},i=`${Kr}/v1/products/${qr}/forensic/anchor`;try{const r=await fetch(i,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Qr)});if(!r.ok)return Qe.warn(`anchor HTTP ${r.status}`),null;const o=await r.json();return Xr(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Qe.warn("anchor returned malformed receipt",o),null)}catch(r){return Qe.warn("anchor request failed",r),null}}function ei(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:ps(t)}}const et="auditAttestations",tt="auditAttestation:defaultSigner";function ct(t,s){return`${t}::${s}`}async function dt(){try{const s=(await chrome.storage.local.get(et))[et];return s&&typeof s=="object"?s:{}}catch{return{}}}async function ms(t){await chrome.storage.local.set({[et]:t})}async function ti(t){const s=await dt();s[ct(t.componentId,t.auditCapturedAt)]=t,await ms(s)}async function hs(t,s){return(await dt())[ct(t,s)]??null}async function si(t,s){const a=await dt();delete a[ct(t,s)],await ms(a)}async function ai(){try{const s=(await chrome.storage.local.get(tt))[tt];return s&&typeof s=="object"?s:null}catch{return null}}async function ni(t){await chrome.storage.local.set({[tt]:t})}function ri(t,s){return t.auditCapturedAt!==s}function ii(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function oi(t){const[s,a]=h.useState(null),[n,i]=h.useState(!0),[r,o]=h.useState(!1),[l,d]=h.useState(""),[p,c]=h.useState(""),[m,u]=h.useState(""),[g,x]=h.useState(""),[j,S]=h.useState("");h.useEffect(()=>{let N=!1;return Promise.all([hs(t.componentId,t.auditCapturedAt),ai()]).then(([I,w])=>{N||(a(I),I?(d(I.signerName),c(I.signerEmail),u(I.signerOrganization??""),x(I.signerQualifications??""),S(I.claim)):w&&(d(w.signerName),c(w.signerEmail),u(w.signerOrganization??""),x(w.signerQualifications??"")),S(T=>T||ii({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),i(!1))}),()=>{N=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function E(){if(!l.trim()||!p.trim())return;const N={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:p.trim(),signerOrganization:m.trim()||void 0,signerQualifications:g.trim()||void 0,claim:j.trim(),scope:t.scope};await ti(N),await ni({signerName:N.signerName,signerEmail:N.signerEmail,signerOrganization:N.signerOrganization,signerQualifications:N.signerQualifications}),a(N),o(!1)}async function b(){await si(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const A=s&&ri(s,t.auditCapturedAt);if(s&&!A&&!r)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void b(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&A&&!r)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const y=l.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:l,onChange:N=>d(N.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:N=>c(N.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:m,onChange:N=>u(N.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:g,onChange:N=>x(N.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:j,onChange:N=>S(N.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[r&&e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!y,onClick:()=>void E(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const Ut="igtRuns",li={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"},ci={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function di(){var z,V;const t=f(k=>k.results),s=f(k=>k.acknowledgedKeys),[a,n]=h.useState(""),[i,r]=h.useState(""),o=_s,l=Ls,[d,p]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,m]=h.useState(""),[u,g]=h.useState(""),[x,j]=h.useState(""),[S,E]=h.useState(""),[b,A]=h.useState(""),[y,N]=h.useState(""),[I,w]=h.useState({}),[T,v]=h.useState(!1),[$,L]=h.useState([]),[C,O]=h.useState(null),[U,H]=h.useState(!1),[ee,ce]=h.useState(null);h.useEffect(()=>{let k=!1;return chrome.storage.local.get(Ut).then(B=>{if(k)return;const D=B[Ut]??{};w(D),v(!0)}).catch(()=>{k||v(!0)}),()=>{k=!0}},[]),h.useEffect(()=>{var k;if(!a&&((k=t[0])!=null&&k.pageUrl))try{const B=new URL(t[0].pageUrl);n(B.hostname),r(B.origin)}catch{}},[t,a]),h.useEffect(()=>{const k=new Set;for(const D of t)k.add(D.pageUrl??D.scope);if(k.size===0){L([]);return}let B=!1;return Promise.all(Array.from(k).map(D=>Ie(D))).then(D=>{B||L(D.flat())}).catch(()=>{}),()=>{B=!0}},[t]);const Z=h.useMemo(()=>{const k=new Map,B=new Map;for(const M of t){const K=M.pageUrl??M.scope,te=k.get(K)??[];te.push(M),k.set(K,te)}const D=new Map;for(const M of t){const K=M.pageUrl??M.scope;D.set(M.componentId,K)}for(const[M,K]of Object.entries(I)){const te=D.get(M);if(!te)continue;const P=B.get(te)??{};Object.assign(P,K),B.set(te,P)}return{auditsByUrl:k,igtRunsByUrl:B,workflows:q,acknowledgedMatchKeys:s,incompleteResolutions:$}},[t,I,s,$]),le=h.useMemo(()=>{const k=[],B=new Set;for(const D of Z.auditsByUrl.keys())B.has(D)||(B.add(D),k.push({url:D,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const D of y.split(`
542
+ `).map(M=>M.trim()).filter(Boolean))B.has(D)||(B.add(D),k.push({url:D,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return k},[Z,y]),de=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:i||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(k=>k.trim()).filter(Boolean),pageSample:le,evaluator:{name:u||"(evaluator name pending)",organization:x||void 0,qualifications:S||void 0,contact:b||void 0}}),[a,i,o,l,d,c,le,u,x,S,b]),F=h.useMemo(()=>T?Vr(de,Z):null,[de,Z,T]);async function J(){if(!F)return;const k=t[0],B=k!=null&&k.componentId&&(k!=null&&k.startedAt)?await hs(k.componentId,k.startedAt):null;await zr(F,C,B)}async function _(){if(F){H(!0),ce(null);try{const k=await Zr(F);if(!k){ce("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}O(k)}finally{H(!1)}}}function W(){var P,ae,ne;if(!F||!C)return;const k=((ne=(ae=(P=chrome.runtime).getManifest)==null?void 0:ae.call(P))==null?void 0:ne.version)??"0.0.0",B=ei(F,C,k),D=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),M=URL.createObjectURL(D),K=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,te=document.createElement("a");te.href=M,te.download=K,te.click(),setTimeout(()=>URL.revokeObjectURL(M),1e3)}return h.useEffect(()=>{O(null),ce(null)},[a,i,d,c,u,x,S,b,y]),T?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."})]}),F&&F.summary.totalCriteria>0&&e.jsx(ui,{totalCriteria:F.summary.totalCriteria,pass:F.summary.pass,fail:F.summary.fail,inconclusive:F.summary.inconclusive,notEvaluated:F.summary.notEvaluated,notApplicable:F.summary.notApplicable,levelAchieved:F.summary.levelAchieved,meetsTarget:F.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:k=>n(k.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:i,onChange:k=>r(k.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:k=>p(k.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:k=>m(k.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:k=>N(k.target.value),rows:3,placeholder:`https://app.example.com/checkout
543
+ 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:u,onChange:k=>g(k.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:x,onChange:k=>j(k.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:S,onChange:k=>E(k.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:k=>A(k.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),F&&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 (",F.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:F.rows.map(k=>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:[k.criterion.id," · ",k.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:k.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${li[k.verdict]}`,children:ci[k.verdict]})]},k.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"}),C?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:[C.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",C.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:!F||!a||!u||U,onClick:()=>void _(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:U?"Anchoring…":C?"Re-anchor":"Anchor this report"}),C&&e.jsx("button",{type:"button",onClick:W,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"})]})]}),F&&((z=t[0])==null?void 0:z.componentId)&&((V=t[0])==null?void 0:V.startedAt)&&e.jsx(oi,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:i||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:F.summary.pass+F.summary.fail+F.summary.inconclusive+F.summary.notApplicable,totalCount:F.summary.totalCriteria,canClaimConformance:F.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!F||!a||!u,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 ui({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:i,notApplicable:r,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,r>0&&e.jsxs(e.Fragment,{children:[" · N/A ",r]})," · ","Not evaluated ",i]})]})}function vi(){const t=f(a=>a.view),s=f(a=>a.userMode);return h.useEffect(()=>{const a=qs(),i=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),r=Vs();zt({forceRefresh:!0}).catch(()=>{}),De().catch(()=>{}),Ks().catch(()=>{}),Qs().catch(()=>{}),Hs().catch(()=>{}),Ds().then(l=>{f.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}=f.getState();d&&(p(null),X().then(m=>{var u;m&&oe(m,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:m},(u=c[0])==null?void 0:u.frameId).catch(()=>{})}))};return window.addEventListener("keydown",o),()=>{r(),a.disconnect(),i==null||i.disconnect(),window.removeEventListener("keydown",o)}},[]),s===null?e.jsxs(e.Fragment,{children:[e.jsx(ar,{}),e.jsx(Ve,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Ar,{}),e.jsx(It,{}),e.jsx(Ve,{})]}):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(us,{}),e.jsx(Zt,{}),e.jsx(ca,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(ma,{}),e.jsx(ba,{}),e.jsx(Zn,{}),e.jsx(Xn,{}),e.jsx(ya,{}),e.jsx(Yn,{}),e.jsx(Jn,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Oa,{}),t==="report"&&e.jsx(en,{}),t==="delta"&&e.jsx(pn,{}),t==="activity"&&e.jsx(kn,{}),t==="guided"&&e.jsx(Un,{}),t==="flows"&&e.jsx(Pn,{}),t==="scorecard"&&e.jsx(Vn,{}),t==="crawl"&&e.jsx(ls,{}),t==="forensic"&&e.jsx(ds,{}),t==="compliance"&&e.jsx(di,{})]})]}),e.jsx(sr,{}),e.jsx(er,{}),e.jsx(Qn,{}),e.jsx(It,{}),e.jsx(Ve,{})]})}class yi extends ke.Component{constructor(){super(...arguments);ut(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{vi as A,yi as E};