@wcag-checkr/ci 1.0.0-rc.41 → 1.0.0-rc.42

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
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-BJxX-AaN.js","assets/forensic-log-DD-VdXBF.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-PELIq3oj.js"])))=>i.map(i=>d[i]);
2
- var Jt=Object.defineProperty;var Yt=(t,s,n)=>s in t?Jt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Qe=(t,s,n)=>Yt(t,typeof s!="symbol"?s+"":s,n);import{R as pe,i as K,r as g,j as e,M as ie,C as Ue,l as Xt,o as Oe,t as Pe,m as ft,s as bt,k as Ce}from"./styles-IBhtavYg.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as z,r as O,s as P,c as vt,b as Q,d as be}from"./crash-reporter-Dc5lvxvY.js";import{g as Zt,a as H,u as es,b as ts,c as ss,d as ns,A as q,l as Ve,s as as,O as yt,e as rs,f as is,h as Je,i as wt,j as jt,k as os,m as ls,n as cs,o as ds}from"./forensic-log-DD-VdXBF.js";import{B as Ie,i as Nt,b as St,T as At}from"./state-PELIq3oj.js";const Ye=t=>{let s;const n=new Set,a=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),n.forEach(f=>f(s,h))}},r=()=>s,l={setState:a,getState:r,getInitialState:()=>c,subscribe:p=>(n.add(p),()=>n.delete(p))},c=s=t(a,r,l);return l},us=t=>t?Ye(t):Ye,ps=t=>t;function hs(t,s=ps){const n=pe.useSyncExternalStore(t.subscribe,pe.useCallback(()=>s(t.getState()),[t,s]),pe.useCallback(()=>s(t.getInitialState()),[t,s]));return pe.useDebugValue(n),n}const Xe=t=>{const s=us(t),n=a=>hs(s,a);return Object.assign(n,s),n},ms=t=>t?Xe(t):Xe,x=ms(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,n,a)=>t({results:s,delta:n,componentId:a,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,n)=>t({tier:s,trialDaysRemaining:(n==null?void 0:n.trialDaysRemaining)??null,seatsUsed:(n==null?void 0:n.seatsUsed)??null,seatsTotal:(n==null?void 0:n.seatsTotal)??null,planCode:(n==null?void 0:n.planCode)??null,licenseDaysRemaining:(n==null?void 0:n.licenseDaysRemaining)??null,pastDue:(n==null?void 0:n.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,n=!0)=>t({pinnedMatchKey:s,pinnedFound:n}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(n=>({acknowledgedKeys:new Set(n.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(n=>{const a=new Set(n.acknowledgedKeys);return a.delete(s),{acknowledgedKeys:a}}),setMessages:(s,n,a)=>t({messages:s,unreadMessageCount:n,criticalUnacked:a}),applyMessageAck:(s,n)=>t(a=>{const r=a.messages.map(l=>l.id!==s?l:n==="seen"?{...l,seen:!0}:n==="dismissed"?{...l,dismissed:!0}:n==="acknowledged"?{...l,acknowledged:!0}:n==="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}})})),ve="sidePanel:lastAudit";function xs(){const t=[];return t.push(z("AUDIT_PROGRESS_EVENT",s=>{const n=x.getState().status==="running";x.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),x.getState().setStatus("running"),n||K.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(z("AUDIT_COMPLETE_EVENT",s=>{var i;x.getState().setResults(s.results,s.delta,s.componentId);const n=s.results.reduce((o,l)=>o+l.violations.length,0),a=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${a} new violation${a===1?"":"s"} versus baseline.`:`Audit complete. ${n} violation${n===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;K.polite(r),gs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(z("AUDIT_FAILED_EVENT",s=>{x.getState().setError(s.error.message)})),t.push(z("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const n=x.getState().aiProgress;x.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),n||K.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(z("AI_AUGMENTATION_FAILED_EVENT",s=>{x.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(z("SCORECARD_UPDATED_EVENT",()=>{ye()})),t.push(z("LICENSE_CHANGED_EVENT",()=>{kt()})),t.push(z("SITE_CRAWL_PROGRESS_EVENT",s=>{const n=x.getState();n.setSiteCrawlStatus("running"),n.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&K.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(z("SITE_CRAWL_COMPLETE_EVENT",s=>{const n=x.getState();n.setSiteCrawlStatus("complete"),n.setSiteCrawlReport(s.report),n.setSiteCrawlProgress(null),K.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(z("SITE_CRAWL_FAILED_EVENT",s=>{const n=x.getState();n.setSiteCrawlStatus("failed"),n.setSiteCrawlError(s.error.message),n.setSiteCrawlProgress(null),K.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function gs(t){const s={...t,results:t.results.map(({screenshotDataUrl:n,...a})=>a)};try{await chrome.storage.local.set({[ve]:s})}catch(n){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",n)}}async function fs(){const s=(await chrome.storage.local.get(ve))[ve];s&&x.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function bs(){await chrome.storage.local.remove(ve)}async function We(){x.getState().clearResults(),await bs()}async function ye(){const t=await O({type:"BASELINE_LIST"});x.getState().setBaselineList(t.items)}async function kt(t){const s=await O({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});x.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ct()}async function Ct(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:a}=await Promise.resolve().then(()=>Cs);return{fetchMessages:a}},void 0),s=x.getState().userMode,n=await t(s);n&&x.getState().setMessages(n.messages,n.unreadCount,n.criticalUnacked)}async function vs(){const s=(await O({type:"SETTINGS_GET",key:"userMode"})).data,n=s==="owner"||s==="dev"?s:null;x.getState().setUserMode(n)}function ys(){return chrome.runtime.connect({name:"audit-keepalive"})}let we=null;async function ws(){if(we===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(we=t.id)}catch{}}function It(){if(we===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:we}).catch(()=>{})}function X(t){It(),P(t)}function js({onClose:t}){const[s,n]=g.useState(""),[a,r]=g.useState(""),[i,o]=g.useState(!0),[l,c]=g.useState(""),[p,d]=g.useState(!1),[u,h]=g.useState(null);async function f(v){var w;if(v.preventDefault(),!(!s.trim()||!a.trim())){d(!0),h(null);try{const C=await O({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:a.trim(),includeContext:i,replyEmail:l.trim()||void 0});C.success?(h({ok:!0,msg:`Sent (ref: ${C.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=C.error)==null?void 0:w.message)??"Failed to send"})}finally{d(!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:v=>n(v.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:a,onChange:v=>r(v.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:v=>c(v.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:v=>o(v.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 Ze({onClick:t,ariaLabel:s,title:n,children:a,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:n??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:a})}const je=vt("messages-client"),Ns="https://api.wcagcheckr.com",Et="wcagcheckr",Ss=1e4;function As(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Rt(t,s){const n=await Zt();if(!n)throw new Error("no_license_token");const a={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${n}`,"X-Extension-Version":As()};return s!=null&&s.userMode&&(a["X-User-Mode"]=s.userMode),fetch(`${Ns}${t}`,{...s,headers:a,signal:AbortSignal.timeout(Ss)})}async function ks(t){try{const s=await Rt(`/v1/products/${Et}/messages`,{userMode:t??null});return s.ok?await s.json():(je.warn("fetchMessages http",s.status),null)}catch(s){return je.warn("fetchMessages failed",s),null}}async function ne(t,s){try{const n=await Rt(`/v1/products/${Et}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return n.ok?!0:(je.warn("ackMessage http",n.status,"action",s),!1)}catch(n){return je.warn("ackMessage failed",n),!1}}const Cs=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ne,fetchMessages:ks},Symbol.toStringTag,{value:"Module"})),Is=["http:","https:"];function Es(t){try{const s=new URL(t);return Is.includes(s.protocol)}catch{return!1}}function et(t){const s=[];let n=0,a=0;for(;n<t.length;){if(t[n]==="["){const i=t.indexOf("]",n+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(n+1,i),c=t.slice(i+2,o);Es(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${a++}`)):s.push(e.jsx(g.Fragment,{children:l},`l-${a++}`)),n=o+1;continue}}}if(t[n]==="*"&&t[n+1]==="*"){const i=t.indexOf("**",n+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(n+2,i)},`b-${a++}`)),n=i+2;continue}}if(t[n]==="*"&&t[n+1]!=="*"){const i=t.indexOf("*",n+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(n+1,i)},`i-${a++}`)),n=i+1;continue}}let r=n+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(g.Fragment,{children:t.slice(n,r)},`t-${a++}`)),n=r}return s}function Tt({source:t}){const s=t.split(/\r?\n/),n=[];let a=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");n.push(e.jsx("p",{className:"leading-snug",children:et(c)},`p-${i++}`)),r=[]}function l(){a.length!==0&&(n.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:a.map((c,p)=>e.jsx("li",{children:et(c)},p))},`u-${i++}`)),a=[])}for(const c of s){const p=c.trimEnd();if(p===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){o(),a.push(d[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:n})}const Rs={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Ts={critical:"bg-rose-50 border-rose-200"};function $t(){const t=x(h=>h.unreadMessageCount),s=x(h=>h.messages),n=x(h=>h.applyMessageAck),[a,r]=g.useState(!1),i=g.useRef(-1),[o,l]=g.useState(!1);g.useEffect(()=>{const h=s.filter(v=>!v.seen);if(h.length===0)return;const f=Math.max(...h.map(v=>v.id));if(f>i.current){i.current=f,l(!0);const v=setTimeout(()=>l(!1),1500);return()=>clearTimeout(v)}},[s]);async function c(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)n(f.id,"seen"),ne(f.id,"seen")}function p(){const h=!a;r(h),h&&c()}async function d(h){n(h.id,"dismissed"),await ne(h.id,"dismissed")}async function u(h){h.ctaUrl&&(n(h.id,"clicked"),ne(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":a,"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($s,{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"})]}),a&&e.jsx(Ds,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function $s({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 Ds({messages:t,onClose:s,onDismiss:n,onCtaClick:a}){const r=g.useRef(null);return g.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:()=>{Ct()},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 ${Rs[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:()=>n(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(Tt,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>a(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 Dt(){const t=x(i=>i.messages),s=x(i=>i.applyMessageAck),n=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!n)return null;async function a(){s(n.id,"acknowledged"),await ne(n.id,"acknowledged")}async function r(){n.ctaUrl&&(s(n.id,"clicked"),ne(n.id,"clicked"),chrome.tabs.create({url:n.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Ts.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:n.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(Tt,{source:n.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[n.ctaLabel&&n.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:n.ctaLabel}),e.jsx("button",{type:"button",onClick:a,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const le=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function _s(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ls(){var u,h;const t=x(f=>f.view),s=x(f=>f.setView),n=x(f=>f.setUserMode),a=x(f=>f.results),r=x(f=>f.status),[i,o]=g.useState(!1),l=((u=a[0])==null?void 0:u.pageUrl)??((h=a[0])==null?void 0:h.scope),c=_s(l),p=a.length>0&&r!=="running";function d(){n("owner"),P({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx($t,{}),e.jsx(Ze,{onClick:()=>void P({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ze,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title: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 ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void We(),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(Us,{view:t,setView:s}),e.jsx(ie,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(js,{onClose:()=>o(!1)})})]})}function Us({view:t,setView:s}){const n=g.useRef([]);function a(i){var c;const o=(i+le.length)%le.length,l=le[o];l&&(s(l),(c=n.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),a(o+1);break;case"ArrowLeft":i.preventDefault(),a(o-1);break;case"Home":i.preventDefault(),a(0);break;case"End":i.preventDefault(),a(le.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:le.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{n.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,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 Fs({feature:t,upgradeUrl:s}){const[n,a]=g.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:()=>a(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ue,{open:n,onClose:()=>a(!1)})]})}const Ms="https://wcagcheckr.com/upgrade";function Os(){const[t,s]=g.useState("single-element"),[n,a]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState(null),[c,p]=g.useState(Ie),[d,u]=g.useState(Ie[0].id),h=x(j=>j.status),f=x(j=>j.tier),v=x(j=>j.results.length>0),w=h==="running";g.useEffect(()=>{Promise.all([O({type:"SETTINGS_GET",key:"matrixPresets"}),O({type:"SETTINGS_GET",key:"activePresetId"})]).then(([j,T])=>{const _=Array.isArray(j.data)?j.data:null;p(_&&_.length>0?_:Ie),typeof T.data=="string"&&u(T.data)})},[]);function C(j){const T=c.find(_=>_.id===j);T&&(u(j),P({type:"SETTINGS_SET",key:"activePresetId",value:j}),P({type:"SETTINGS_SET",key:"stateMatrix",value:T.matrix}))}const A=Nt(f,"storybookAutoIterate");g.useEffect(()=>{const j=z("ELEMENT_PICKED_EVENT",(_,E)=>{a(!1);const L=E.frameId;R(L),i({selector:_.selector,frameId:L})}),T=z("PICKER_CANCELLED_EVENT",()=>a(!1));return()=>{j(),T()}},[]);async function m(){const j=await H();j&&(a(!0),await Q(j,{type:"PICKER_ACTIVATE_REQUEST",tabId:j}))}function b(){r&&(R(r.frameId),X({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),x.getState().startNewScan())}function y(){if(!A){l("storybook:auto-iterate");return}R(),X({type:"START_AUDIT",mode:"storybook-all"}),x.getState().startNewScan()}function I(){R(),X({type:"START_AUDIT",mode:"all-frames"}),x.getState().startNewScan()}function D(){R(),X({type:"START_AUDIT",mode:"full-page"}),x.getState().startNewScan()}function S(){P({type:"CANCEL_AUDIT"})}async function R(j){x.getState().setPinned(null);const T=await H();if(T)try{await Q(T,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:T},j)}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:j=>s(j.target.value),disabled:w||n,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:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",A?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:j=>C(j.target.value),disabled:w||n,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(j=>e.jsx("option",{value:j.id,children:j.name},j.id))}),t==="single-element"?e.jsx(Ps,{picking:n,picked:r,isRunning:w,onPick:m,onRun:b,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:D,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Scan page"}):t==="all-frames"?e.jsx("button",{onClick:I,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all stories"}),w&&e.jsx("button",{onClick:S,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&v&&e.jsx("button",{type:"button",onClick:()=>void We(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!n&&!w&&e.jsx(Gs,{selector:r.selector,onRepick:m,onClear:()=>i(null)})]}),e.jsx(ie,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Fs,{feature:o??"",upgradeUrl:Ms})})]})}function Ps({picking:t,picked:s,isRunning:n,onPick:a,onRun:r,onClearPick:i}){return n?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:a,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Gs({selector:t,onRepick:s,onClear:n}){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:n,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Vs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Ws={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Bs(){const[t,s]=g.useState(null),[n,a]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState("off"),p=x(f=>f.results).flatMap(f=>f.violations);async function d(f){const v=await H();v&&(l(f),f==="off"?await Q(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await Q(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function u(f){const v=await H();if(v){if(t&&await Q(v,{type:Vs[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await Q(v,{type:Ws[f],tabId:v}).catch(()=>{}),s(f)}}async function h(){const f=await H();if(f){if(n){await Q(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),a(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const v=await be(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});a(!0),i(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.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(ce,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ce,{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(ce,{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(ce,{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(ce,{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:n,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 d(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 ce({label:t,title:s,on:n,onClick:a}){return e.jsx("button",{type:"button",title:s,"aria-pressed":n,onClick:a,className:`text-xs px-2 py-1 rounded border transition-colors ${n?"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 Hs(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 zs(){const t=x(p=>p.status),s=x(p=>p.progress),n=x(p=>p.aiProgress);if(t!=="running"||!s)return null;const a=n!=null,r=!a&&s.current>=s.total,i=a?n.current/n.total*100:s.current/s.total*100,o=a?n.current:s.current,l=a?n.total:s.total,c=a?`AI augmentation: ${n.current} of ${n.total} checks. ${n.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:a?e.jsxs(e.Fragment,{children:["AI augmentation… ",n.current,"/",n.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:a?n.candidatesTotal&&n.candidatesTotal>0?`${n.currentCheckLabel} (${n.candidatesDone??0}/${n.candidatesTotal})`:n.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Hs(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void P({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${a?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":c,children:e.jsx("div",{className:`h-full transition-all ${a?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const de={"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 qs(t){return/^wcag\d/.test(t.wcagCriterion)?[de["ada-iii"],de[508],de.eaa,de["en-301-549"],de.aoda]:[]}const Ks={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 Ne({violation:t,alreadyAcknowledged:s}){const n=x(m=>m.pinnedMatchKey),a=x(m=>m.pinnedFound),r=x(m=>m.setPinned),i=x(m=>{var b;return(b=m.results[0])==null?void 0:b.frameId}),o=x(m=>{var b;return(b=m.results[0])==null?void 0:b.scope}),l=x(m=>m.results),c=x(m=>m.acknowledgedKeys.has(t.matchKey)),p=x(m=>m.markAcknowledged),d=x(m=>m.markUnacknowledged),u=s||c,h=n===t.matchKey,f=h&&!a;async function v(m){try{return(await be(m,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:m,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const m=await H();if(!m)return;if(h){r(null);try{await Q(m,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:m},i)}catch{}return}const b=await v(m);r(t.matchKey,b)}function C(m){m.stopPropagation(),t.currentState.breakpoint.width<=640&&It(),(async()=>{const b=await H();if(!b)return;try{await O({type:"STATE_DRIVE_REQUEST",tabId:b,state:t.currentState,scope:o,frameId:i})}catch{}const y=await v(b);r(t.matchKey,y)})()}async function A(m){m.stopPropagation();const b=await H();if(!b)return;try{await O({type:"STATE_DRIVE_REQUEST",tabId:b,state:Xs(),scope:o,frameId:i})}catch{P({type:"STATE_RESET_REQUEST",tabId:b})}const y=await v(b);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:w,"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 ${Ks[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(Zs,{violation:t}),e.jsx(sn,{violation:t}),e.jsx(tn,{violation:t}),e.jsx(en,{text:t.target.failureSummary}),e.jsx(nn,{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: ",Qs(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:C,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),C(m))},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:A,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),A(m))},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:m=>{m.stopPropagation(),d(t.matchKey),Ys(t,l)},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.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:m=>{m.stopPropagation(),p(t.matchKey),Js(t,l)},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.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:m=>m.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Qs(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 Js(t,s){await ts({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await _t(t.componentId,s)}async function Ys(t,s){await es(t.componentId,t.matchKey),await _t(t.componentId,s)}async function _t(t,s){const n=s.flatMap(a=>a.violations);try{const a=await O({type:"BASELINE_COMPARE",componentId:t,currentViolations:n});x.getState().setDelta(a.delta)}catch{}}function Xs(){const t=St.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(n=>n.id==="desktop")??t[0]}}function Lt(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",n=/contrast of (\d+(?:\.\d+)?)/i.exec(s),a=/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!n||!a?null:{ratio:parseFloat(n[1]),required:parseFloat(a[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function Zs({violation:t}){const s=Lt(t);if(!s)return null;const n=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:n?"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 en({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 tn({violation:t}){const s=qs(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(n=>e.jsx("span",{title:`${n.region} — ${n.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:n.name},n.id))})}function sn({violation:t}){const s=Lt(t),[n,a]=g.useState({kind:"idle"});if(!s)return null;async function r(){a({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await O({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(c=>c.matchKey===t.matchKey);a(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){a({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[n.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"}),n.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),n.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:n.reason}),n.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 (",n.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:n.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))}),n.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:n.suggestion.reasoning})]})]})}function nn({ruleId:t}){const s=ss(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 an=[{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"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics"],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"]},{id:"other-manual",label:"Other manual checks",axeRules:[],igtWorkflowIds:["reflow","hover-focus-content","pointer","time-based","error-prevention","consistency"]}];function rn(t){const s=an.map(i=>on(i,t)),n=s.reduce((i,o)=>i+ln(o.letter),0)/Math.max(1,s.length),a=cn(Math.round(n)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function on(t,s){const n=new Set(t.axeRules),a=s.violations.filter(S=>n.has(S.ruleId)),r=s.manualRuns.filter(S=>t.igtWorkflowIds.includes(S.workflowId)),i=t.igtWorkflowIds.map(S=>s.workflows.find(R=>R.id===S)).filter(S=>S!=null);let o=i.length>0;for(const S of i){const R=r.find(T=>T.workflowId===S.id);if((R?Object.keys(R.steps).length:0)!==S.steps.length){o=!1;break}}const l=r.some(S=>Object.keys(S.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(S=>c.includes(S.workflowId)),d=c.map(S=>s.workflows.find(R=>R.id===S)).filter(S=>S!=null);let u=c.length>0&&d.length===c.length;for(const S of d){const R=p.find(T=>T.workflowId===S.id);if((R?Object.keys(R.steps).length:0)!==S.steps.length){u=!1;break}}let h=null;if(u)for(const S of p)S.completedAt&&(h===null||S.completedAt>h)&&(h=S.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,v=c[0]??t.igtWorkflowIds[0]??null;if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:f,primaryVerifierWorkflowId:v,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w=t.axeRules.length>0||t.heuristic!=null,C=t.igtWorkflowIds.length>0;let A=!1;if(w&&C?A=!s.auditRan&&!l:w?A=!s.auditRan:C?A=!l:A=!0,A)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:C||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:v,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const m={critical:0,serious:0,moderate:0,minor:0};for(const S of ns(a))m[S.impact]++;m.serious+=f;for(const S of r){const R=i.find(j=>j.id===S.workflowId);if(R)for(const j of R.steps){const T=S.steps[j.id];(T==null?void 0:T.status)==="fail"&&(j.severity==="required"?m.serious++:m.moderate++)}}const b=m.critical>0,y=m.serious>0;let I;m.critical>=5?I="F":m.critical>=1?I="D":m.serious>=1?I="C":m.moderate>=1?I="B":I="A";const D=C&&!o||c.length>0&&!u;return{id:t.id,label:t.label,letter:I,untested:!1,needsIgt:D,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:v,counts:m,caps:{cappedAtC:b,cappedAtB:y}}}function ln(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function cn(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const dn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},un={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 pn({violations:t,componentId:s}){var h,f,v,w,C;const[n,a]=g.useState([]),r=x(A=>A.status),i=x(A=>A.progress),o=x(A=>A.freshThisSession),l=x(A=>A.results),c=(h=l[0])==null?void 0:h.startedAt;if(g.useEffect(()=>{if(!s){a([]);return}let A=!1;return chrome.storage.local.get("igtRuns").then(m=>{if(A)return;const y=((m==null?void 0:m.igtRuns)??{})[s]??{};a(Object.values(y))}),()=>{A=!0}},[s]),r==="running")return e.jsx(fn,{current:i==null?void 0:i.current,total:i==null?void 0:i.total});const p=rn({violations:t,auditRan:l.length>0,manualRuns:n,workflows:q,heuristicCounts:{tabOrder:((v=(f=l[0])==null?void 0:f.tabOrderIssues)==null?void 0:v.length)??0,readingOrder:((C=(w=l[0])==null?void 0:w.readingOrderIssues)==null?void 0:C.length)??0}});let d=0;for(const A of q){const m=n.find(b=>b.workflowId===A.id);m&&Object.keys(m.steps).length===A.steps.length&&d++}const u=t.length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!o&&c&&e.jsx(bn,{scannedAt:c}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${dn[p.overallLetter]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.overallLetter})}),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 ",p.subGrades.length," verification areas below. Untested areas count as F until verified."]})]})]}),p.isLawsuitRisk&&e.jsx(hn,{areas:p.warningAreas}),e.jsx(mn,{grades:p.subGrades}),e.jsx(gn,{violationsRemaining:u,manualCompleted:d,manualTotal:q.length}),d>0||l.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:d})," 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:`${d/q.length*100}%`}})})]}):null]})}function hn({areas:t}){const s=t.map(n=>n.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((n,a)=>e.jsxs("span",{children:[e.jsx("strong",{children:n}),a<s.length-1?", ":""]},n)),". Fix these before relying on the overall grade."]})})]})}function mn({grades:t}){const s=x(n=>n.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(n=>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 ${un[n.letter]}`,"aria-label":`Grade ${n.letter}`,children:n.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:n.label}),e.jsx(xn,{grade:n,onOpenGuided:()=>s("guided")})]},n.id))})]})}function xn({grade:t,onOpenGuided:s}){const n=a=>{if(!a)return"";const r=q.find(i=>i.id===a);return(r==null?void 0:r.name)??a};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 ",n(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const a=t.verifiedAt?Ut(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",a?` ${a} 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 ",n(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 gn({violationsRemaining:t,manualCompleted:s,manualTotal:n}){const a=x(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:s===n,label:`Run Guided Tests (${s}/${n} workflows complete)`,action:()=>a("guided"),tooltip:'12 separate workflows total. Click → pick a workflow → mark each step pass/fail/skip → "Back to workflows" → click again for the next. Repeat until 12/12.'},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>a("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 c=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":c?"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:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function fn({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 bn({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 (",Ut(s)," old). Re-scan to grade the current page state."]})]})}function Ut(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 n=Math.floor(s/86400);return n===1?"1 day":`${n} days`}const Fe="dismissedFindings";function Ae(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ae(t){return`reading-order::${t}`}function re(t){return`tab-order::${t}`}async function ke(){try{const t=await chrome.storage.local.get(Fe),s=t==null?void 0:t[Fe];if(s&&typeof s=="object")return s}catch{}return{}}async function Be(t){await chrome.storage.local.set({[Fe]:t})}async function Se(t){return(await ke())[Ae(t)]??{}}async function Ft(t,s,n,a){const r=await ke(),i=Ae(t),o=r[i]??{};o[s]={reason:n,dismissedAt:new Date().toISOString(),snippet:a},r[i]=o,await Be(r)}async function me(t,s){if(s.length===0)return;const n=await ke(),a=Ae(t),r=n[a]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};n[a]=r,await Be(n)}async function Mt(t,s){const n=await ke(),a=Ae(t),r=n[a];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete n[a]:n[a]=r,await Be(n))}const vn=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Ft,addDismissals:me,dismissalKeyForReadingOrder:ae,dismissalKeyForTabOrder:re,getDismissalsForUrl:Se,removeDismissal:Mt},Symbol.toStringTag,{value:"Module"}));function Ot(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Pt(t){return`${Ve(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function yn(t){const s=new Map;for(const n of t)for(const a of n.violations){const r=Pt(a),i=s.get(r);i?i.states.push(a.currentState):s.set(r,{representative:a,states:[a.currentState]})}return Array.from(s.values())}const tt={critical:0,serious:1,moderate:2,minor:3};function wn(){var v,w,C,A;const t=x(m=>m.results),s=x(m=>m.componentId),n=x(m=>m.setView),a=((v=t[0])==null?void 0:v.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(new Set);if(g.useEffect(()=>{if(!a)return;Se(a).then(i);const m=()=>{document.visibilityState==="visible"&&a&&Se(a).then(i)};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[a]),g.useEffect(()=>{if(!s){l(new Set);return}let m=!1;const b=async()=>{const I=await chrome.storage.local.get("igtRuns");if(m)return;const S=((I==null?void 0:I.igtRuns)??{})[s]??{},R=new Set;for(const j of q){const T=S[j.id];T&&Object.keys(T.steps).length===j.steps.length&&R.add(j.id)}l(R)};b();const y=()=>{document.visibilityState==="visible"&&b()};return document.addEventListener("visibilitychange",y),()=>{m=!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 c=t.reduce((m,b)=>m+b.durationMs,0),p=t.reduce((m,b)=>m+b.violations.length,0),d=yn(t);d.sort((m,b)=>{const y=tt[m.representative.impact]??99,I=tt[b.representative.impact]??99;return y!==I?y-I:b.states.length-m.states.length});const u=t.map(m=>Ot(m.state)).join(`
4
- `),h=o.has("keyboard")?0:(((C=t[0])==null?void 0:C.tabOrderIssues)??[]).filter(m=>!(re(m.selector)in r)).length,f=o.has("page-structure")?0:(((A=t[0])==null?void 0:A.readingOrderIssues)??[]).filter(m=>!(ae(m.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(pn,{violations:t.flatMap(m=>m.violations),componentId:s}),(h>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>n("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"]})," · ",d.length," unique ",d.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(c/1e3).toFixed(1),"s"]}),d.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic px-1",children:"No violations found."}):e.jsx("div",{className:"space-y-1.5",children:d.map(m=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ne,{violation:m.representative}),e.jsx(jn,{states:m.states,totalStates:t.length})]},Pt(m.representative)))})]})}function jn({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 n=Array.from(new Set(t.map(Ot))),a=n.slice(0,3).join(", "),r=n.length>3?`, +${n.length-3} more`:"",i=n.join(`
5
- `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",n.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[a,r]})]})}const Nn={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 Sn({ruleId:t,violations:s}){const[n,a]=g.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(Ne,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>a(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":n,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 ${Nn[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:n?"▾":"▸"})]})]}),n&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Ne,{violation:c},p))})]})}function An(t){const s=[],n=new Map;for(const a of t)n.has(a.ruleId)||(s.push(a.ruleId),n.set(a.ruleId,[])),n.get(a.ruleId).push(a);return s.map(a=>({ruleId:a,violations:n.get(a)}))}const kn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Gt({open:t,onClose:s,format:n,content:a,filename:r}){const i=Xt(new Blob([a]).size);function o(){Pe(a,r),s()}function l(){Oe(a),s()}return e.jsxs(ie,{open:t,onClose:s,title:kn[n],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 st=7800;function Cn(t,s,n){const a=t.replace(/\/$/,""),r=[];for(const d of n){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,f=r.find(v=>`${v.ruleId}::${v.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...d,_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 d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.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
- `),c=new URLSearchParams({title:i,body:l});let p=`${a}/issues/new?${c.toString()}`;return p.length>st&&(p=p.slice(0,st)),{url:p,title:i,body:l}}const nt=7800;function In(t,s,n){const a=t.replace(/\/$/,""),r=[];for(const d of n){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,f=r.find(v=>`${v.ruleId}::${v.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...d,_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 d of r)o.push(`Rule: ${d.ruleId} (${d.impact})`),o.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),o.push(`Description: ${d.description}`),o.push(`Selector: ${d.target.selector}`),o.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&o.push(`More info: ${d.helpUrl}`),o.push(""),o.push(`HTML: ${d.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
- `),c=new URLSearchParams({summary:i,description:l});let p=`${a}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>nt&&(p=p.slice(0,nt)),{url:p,summary:i,description:l}}function En(){const t=x(b=>b.delta),s=x(b=>b.componentId),n=x(b=>b.results),a=x(b=>b.tier),r=x(b=>b.baselineList),i=x(b=>b.siteCrawlReport),[o,l]=g.useState(""),[c,p]=g.useState(""),[d,u]=g.useState(null);g.useEffect(()=>{Promise.all([O({type:"SETTINGS_GET",key:"githubRepoUrl"}),O({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([b,y])=>{l(typeof b.data=="string"?b.data:""),p(typeof y.data=="string"?y.data:"")})},[]);const h=Nt(a,"exportJson"),f=At[a].maxBaselines,v=r.some(b=>b.componentId===s),w=v||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 C(){if(!s||n.length===0)return;const b=n.flatMap(T=>T.violations),y=n.flatMap(T=>T.announcements??[]),I=n.flatMap(T=>T.focusEvents??[]),D=n[0],R=(await O({type:"SETTINGS_GET",key:"stateMatrix"})).data??St;await P({type:"BASELINE_SET",componentId:s,violations:b,announcements:y,focusEvents:I,snapshotMeta:{url:window.location.href,axeVersion:D.axeVersion,matrixConfig:R,capturedAt:new Date().toISOString()}});const j=await O({type:"BASELINE_COMPARE",componentId:s,currentViolations:b,announcements:y,focusEvents:I,currentMatrix:R});x.getState().setDelta(j.delta),K.polite(`Baseline saved for ${s}.`)}async function A(){if(!s||!v||!window.confirm(`Remove the saved baseline for "${s}"?
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-y0iEnnW8.js","assets/forensic-log-CGElsCy4.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-PELIq3oj.js"])))=>i.map(i=>d[i]);
2
+ var Jt=Object.defineProperty;var Yt=(t,s,a)=>s in t?Jt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Qe=(t,s,a)=>Yt(t,typeof s!="symbol"?s+"":s,a);import{R as pe,i as q,r as g,j as e,M as ie,C as Ue,l as Xt,o as Me,t as Pe,m as ft,s as bt,k as Ce}from"./styles-IBhtavYg.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as z,r as M,s as P,c as vt,b as Q,d as be}from"./crash-reporter-Dc5lvxvY.js";import{g as Zt,a as H,u as es,b as ts,c as ss,d as as,A as K,l as Ve,s as ns,O as yt,e as rs,f as is,h as Je,i as jt,j as wt,k as os,m as ls,n as cs,o as ds,p as us,q as ps}from"./forensic-log-CGElsCy4.js";import{B as Ee,i as Nt,b as kt,T as St}from"./state-PELIq3oj.js";const Ye=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(f=>f(s,h))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,l);return l},hs=t=>t?Ye(t):Ye,xs=t=>t;function ms(t,s=xs){const a=pe.useSyncExternalStore(t.subscribe,pe.useCallback(()=>s(t.getState()),[t,s]),pe.useCallback(()=>s(t.getInitialState()),[t,s]));return pe.useDebugValue(a),a}const Xe=t=>{const s=hs(t),a=n=>ms(s,n);return Object.assign(a,s),a},gs=t=>t?Xe(t):Xe,m=gs(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}})})),ve="sidePanel:lastAudit";function fs(){const t=[];return t.push(z("AUDIT_PROGRESS_EVENT",s=>{const a=m.getState().status==="running";m.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),m.getState().setStatus("running"),a||q.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(z("AUDIT_COMPLETE_EVENT",s=>{var i;m.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"}.`;q.polite(r),bs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(z("AUDIT_FAILED_EVENT",s=>{m.getState().setError(s.error.message)})),t.push(z("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=m.getState().aiProgress;m.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||q.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(z("AI_AUGMENTATION_FAILED_EVENT",s=>{m.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(z("SCORECARD_UPDATED_EVENT",()=>{ye()})),t.push(z("LICENSE_CHANGED_EVENT",()=>{At()})),t.push(z("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&q.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(z("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),q.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(z("SITE_CRAWL_FAILED_EVENT",s=>{const a=m.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),q.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({[ve]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function vs(){const s=(await chrome.storage.local.get(ve))[ve];s&&m.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ys(){await chrome.storage.local.remove(ve)}async function We(){m.getState().clearResults(),await ys()}async function ye(){const t=await M({type:"BASELINE_LIST"});m.getState().setBaselineList(t.items)}async function At(t){const s=await M({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});m.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ct()}async function Ct(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Rs);return{fetchMessages:n}},void 0),s=m.getState().userMode,a=await t(s);a&&m.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function js(){const s=(await M({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;m.getState().setUserMode(a)}function ws(){return chrome.runtime.connect({name:"audit-keepalive"})}let je=null;async function Ns(){if(je===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(je=t.id)}catch{}}function Et(){if(je===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:je}).catch(()=>{})}function X(t){Et(),P(t)}function ks({onClose:t}){const[s,a]=g.useState(""),[n,r]=g.useState(""),[i,o]=g.useState(!0),[l,c]=g.useState(""),[p,d]=g.useState(!1),[u,h]=g.useState(null);async function f(v){var j;if(v.preventDefault(),!(!s.trim()||!n.trim())){d(!0),h(null);try{const C=await M({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});C.success?(h({ok:!0,msg:`Sent (ref: ${C.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=C.error)==null?void 0:j.message)??"Failed to send"})}finally{d(!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:v=>a(v.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:v=>r(v.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:v=>c(v.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:v=>o(v.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 Ze({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 we=vt("messages-client"),Ss="https://api.wcagcheckr.com",Rt="wcagcheckr",As=1e4;function Cs(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Tt(t,s){const a=await Zt();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Cs()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Ss}${t}`,{...s,headers:n,signal:AbortSignal.timeout(As)})}async function Es(t){try{const s=await Tt(`/v1/products/${Rt}/messages`,{userMode:t??null});return s.ok?await s.json():(we.warn("fetchMessages http",s.status),null)}catch(s){return we.warn("fetchMessages failed",s),null}}async function ae(t,s){try{const a=await Tt(`/v1/products/${Rt}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(we.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return we.warn("ackMessage failed",a),!1}}const Rs=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ae,fetchMessages:Es},Symbol.toStringTag,{value:"Module"})),Ts=["http:","https:"];function Is(t){try{const s=new URL(t);return Ts.includes(s.protocol)}catch{return!1}}function et(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),c=t.slice(i+2,o);Is(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(g.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(g.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function It({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:et(c)},`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((c,p)=>e.jsx("li",{children:et(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){o(),n.push(d[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const $s={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},_s={critical:"bg-rose-50 border-rose-200"};function $t(){const t=m(h=>h.unreadMessageCount),s=m(h=>h.messages),a=m(h=>h.applyMessageAck),[n,r]=g.useState(!1),i=g.useRef(-1),[o,l]=g.useState(!1);g.useEffect(()=>{const h=s.filter(v=>!v.seen);if(h.length===0)return;const f=Math.max(...h.map(v=>v.id));if(f>i.current){i.current=f,l(!0);const v=setTimeout(()=>l(!1),1500);return()=>clearTimeout(v)}},[s]);async function c(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)a(f.id,"seen"),ae(f.id,"seen")}function p(){const h=!n;r(h),h&&c()}async function d(h){a(h.id,"dismissed"),await ae(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),ae(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(Ls,{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(Ds,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function Ls({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 Ds({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=g.useRef(null);return g.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:()=>{Ct()},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 ${$s[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(It,{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 _t(){const t=m(i=>i.messages),s=m(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ae(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ae(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${_s.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(It,{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 le=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Us(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Os(){var u,h;const t=m(f=>f.view),s=m(f=>f.setView),a=m(f=>f.setUserMode),n=m(f=>f.results),r=m(f=>f.status),[i,o]=g.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),c=Us(l),p=n.length>0&&r!=="running";function d(){a("owner"),P({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx($t,{}),e.jsx(Ze,{onClick:()=>void P({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ze,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title: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 ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void We(),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(Fs,{view:t,setView:s}),e.jsx(ie,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(ks,{onClose:()=>o(!1)})})]})}function Fs({view:t,setView:s}){const a=g.useRef([]);function n(i){var c;const o=(i+le.length)%le.length,l=le[o];l&&(s(l),(c=a.current[o])==null||c.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(le.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:le.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{a.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,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 Ms({feature:t,upgradeUrl:s}){const[a,n]=g.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(Ue,{open:a,onClose:()=>n(!1)})]})}const Ps="https://wcagcheckr.com/upgrade";function Gs(){const[t,s]=g.useState("single-element"),[a,n]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState(null),[c,p]=g.useState(Ee),[d,u]=g.useState(Ee[0].id),h=m(w=>w.status),f=m(w=>w.tier),v=m(w=>w.results.length>0),j=h==="running";g.useEffect(()=>{Promise.all([M({type:"SETTINGS_GET",key:"matrixPresets"}),M({type:"SETTINGS_GET",key:"activePresetId"})]).then(([w,I])=>{const L=Array.isArray(w.data)?w.data:null;p(L&&L.length>0?L:Ee),typeof I.data=="string"&&u(I.data)})},[]);function C(w){const I=c.find(L=>L.id===w);I&&(u(w),P({type:"SETTINGS_SET",key:"activePresetId",value:w}),P({type:"SETTINGS_SET",key:"stateMatrix",value:I.matrix}))}const S=Nt(f,"storybookAutoIterate");g.useEffect(()=>{const w=z("ELEMENT_PICKED_EVENT",(L,R)=>{n(!1);const D=R.frameId;T(D),i({selector:L.selector,frameId:D})}),I=z("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{w(),I()}},[]);async function x(){const w=await H();w&&(n(!0),await Q(w,{type:"PICKER_ACTIVATE_REQUEST",tabId:w}))}function b(){r&&(T(r.frameId),X({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),m.getState().startNewScan())}function y(){if(!S){l("storybook:auto-iterate");return}T(),X({type:"START_AUDIT",mode:"storybook-all"}),m.getState().startNewScan()}function E(){T(),X({type:"START_AUDIT",mode:"all-frames"}),m.getState().startNewScan()}function _(){T(),X({type:"START_AUDIT",mode:"full-page"}),m.getState().startNewScan()}function k(){P({type:"CANCEL_AUDIT"})}async function T(w){m.getState().setPinned(null);const I=await H();if(I)try{await Q(I,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:I},w)}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:w=>s(w.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:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",S?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:w=>C(w.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:c.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))}),t==="single-element"?e.jsx(Vs,{picking:a,picked:r,isRunning:j,onPick:x,onRun:b,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:_,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==="all-frames"?e.jsx("button",{onClick:E,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:k,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&v&&e.jsx("button",{type:"button",onClick:()=>void We(),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(Ws,{selector:r.selector,onRepick:x,onClear:()=>i(null)})]}),e.jsx(ie,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Ms,{feature:o??"",upgradeUrl:Ps})})]})}function Vs({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 Ws({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 Bs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Hs={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function zs(){const[t,s]=g.useState(null),[a,n]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState("off"),p=m(f=>f.results).flatMap(f=>f.violations);async function d(f){const v=await H();v&&(l(f),f==="off"?await Q(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await Q(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function u(f){const v=await H();if(v){if(t&&await Q(v,{type:Bs[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await Q(v,{type:Hs[f],tabId:v}).catch(()=>{}),s(f)}}async function h(){const f=await H();if(f){if(a){await Q(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 v=await be(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});n(!0),i(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.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(ce,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ce,{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(ce,{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(ce,{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(ce,{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 d(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 ce({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 Ks(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 qs(){const t=m(p=>p.status),s=m(p=>p.progress),a=m(p=>p.aiProgress);if(t!=="running"||!s)return null;const n=a!=null,r=!n&&s.current>=s.total,i=n?a.current/a.total*100:s.current/s.total*100,o=n?a.current:s.current,l=n?a.total:s.total,c=n?`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:n?e.jsxs(e.Fragment,{children:["AI augmentation… ",a.current,"/",a.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:n?a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Ks(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void P({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${n?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":c,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const de={"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 Qs(t){return/^wcag\d/.test(t.wcagCriterion)?[de["ada-iii"],de[508],de.eaa,de["en-301-549"],de.aoda]:[]}const Js={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 Ne({violation:t,alreadyAcknowledged:s}){const a=m(x=>x.pinnedMatchKey),n=m(x=>x.pinnedFound),r=m(x=>x.setPinned),i=m(x=>{var b;return(b=x.results[0])==null?void 0:b.frameId}),o=m(x=>{var b;return(b=x.results[0])==null?void 0:b.scope}),l=m(x=>x.results),c=m(x=>x.acknowledgedKeys.has(t.matchKey)),p=m(x=>x.markAcknowledged),d=m(x=>x.markUnacknowledged),u=s||c,h=a===t.matchKey,f=h&&!n;async function v(x){try{return(await be(x,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:x,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const x=await H();if(!x)return;if(h){r(null);try{await Q(x,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:x},i)}catch{}return}const b=await v(x);r(t.matchKey,b)}function C(x){x.stopPropagation(),t.currentState.breakpoint.width<=640&&Et(),(async()=>{const b=await H();if(!b)return;try{await M({type:"STATE_DRIVE_REQUEST",tabId:b,state:t.currentState,scope:o,frameId:i})}catch{}const y=await v(b);r(t.matchKey,y)})()}async function S(x){x.stopPropagation();const b=await H();if(!b)return;try{await M({type:"STATE_DRIVE_REQUEST",tabId:b,state:ea(),scope:o,frameId:i})}catch{P({type:"STATE_RESET_REQUEST",tabId:b})}const y=await v(b);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 ${Js[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(ta,{violation:t}),e.jsx(na,{violation:t}),e.jsx(aa,{violation:t}),e.jsx(sa,{text:t.target.failureSummary}),e.jsx(ra,{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: ",Ys(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:C,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),C(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),S(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),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:x=>{x.stopPropagation(),d(t.matchKey),Zs(t,l)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),p(t.matchKey),Xs(t,l)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.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:x=>x.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Ys(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 Xs(t,s){await ts({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Lt(t.componentId,s)}async function Zs(t,s){await es(t.componentId,t.matchKey),await Lt(t.componentId,s)}async function Lt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await M({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});m.getState().setDelta(n.delta)}catch{}}function ea(){const t=kt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Dt(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 ta({violation:t}){const s=Dt(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 sa({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 aa({violation:t}){const s=Qs(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=Dt(t),[a,n]=g.useState({kind:"idle"});if(!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await M({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(c=>c.matchKey===t.matchKey);n(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function ra({ruleId:t}){const s=ss(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 ia=[{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"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics"],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"]},{id:"other-manual",label:"Other manual checks",axeRules:[],igtWorkflowIds:["reflow","hover-focus-content","pointer","time-based","error-prevention","consistency"]}];function oa(t){const s=ia.map(i=>la(i,t)),a=s.reduce((i,o)=>i+ca(o.letter),0)/Math.max(1,s.length),n=da(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 la(t,s){const a=new Set(t.axeRules),n=s.violations.filter(k=>a.has(k.ruleId)),r=s.manualRuns.filter(k=>t.igtWorkflowIds.includes(k.workflowId)),i=t.igtWorkflowIds.map(k=>s.workflows.find(T=>T.id===k)).filter(k=>k!=null);let o=i.length>0;for(const k of i){const T=r.find(I=>I.workflowId===k.id);if((T?Object.keys(T.steps).length:0)!==k.steps.length){o=!1;break}}const l=r.some(k=>Object.keys(k.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(k=>c.includes(k.workflowId)),d=c.map(k=>s.workflows.find(T=>T.id===k)).filter(k=>k!=null);let u=c.length>0&&d.length===c.length;for(const k of d){const T=p.find(I=>I.workflowId===k.id);if((T?Object.keys(T.steps).length:0)!==k.steps.length){u=!1;break}}let h=null;if(u)for(const k of p)k.completedAt&&(h===null||k.completedAt>h)&&(h=k.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,v=c[0]??t.igtWorkflowIds[0]??null;if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:f,primaryVerifierWorkflowId:v,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j=t.axeRules.length>0||t.heuristic!=null,C=t.igtWorkflowIds.length>0;let S=!1;if(j&&C?S=!s.auditRan&&!l:j?S=!s.auditRan:C?S=!l:S=!0,S)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:C||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:v,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const x={critical:0,serious:0,moderate:0,minor:0};for(const k of as(n))x[k.impact]++;x.serious+=f;for(const k of r){const T=i.find(w=>w.id===k.workflowId);if(T)for(const w of T.steps){const I=k.steps[w.id];(I==null?void 0:I.status)==="fail"&&(w.severity==="required"?x.serious++:x.moderate++)}}const b=x.critical>0,y=x.serious>0;let E;x.critical>=5?E="F":x.critical>=1?E="D":x.serious>=1?E="C":x.moderate>=1?E="B":E="A";const _=C&&!o||c.length>0&&!u;return{id:t.id,label:t.label,letter:E,untested:!1,needsIgt:_,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:v,counts:x,caps:{cappedAtC:b,cappedAtB:y}}}function ca(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function da(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const ua={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},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 ha({violations:t,componentId:s}){var h,f,v,j,C;const[a,n]=g.useState([]),r=m(S=>S.status),i=m(S=>S.progress),o=m(S=>S.freshThisSession),l=m(S=>S.results),c=(h=l[0])==null?void 0:h.startedAt;if(g.useEffect(()=>{if(!s){n([]);return}let S=!1;return chrome.storage.local.get("igtRuns").then(x=>{if(S)return;const y=((x==null?void 0:x.igtRuns)??{})[s]??{};n(Object.values(y))}),()=>{S=!0}},[s]),r==="running")return e.jsx(ba,{current:i==null?void 0:i.current,total:i==null?void 0:i.total});const p=oa({violations:t,auditRan:l.length>0,manualRuns:a,workflows:K,heuristicCounts:{tabOrder:((v=(f=l[0])==null?void 0:f.tabOrderIssues)==null?void 0:v.length)??0,readingOrder:((C=(j=l[0])==null?void 0:j.readingOrderIssues)==null?void 0:C.length)??0}});let d=0;for(const S of K){const x=a.find(b=>b.workflowId===S.id);x&&Object.keys(x.steps).length===S.steps.length&&d++}const u=t.length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!o&&c&&e.jsx(va,{scannedAt:c}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ua[p.overallLetter]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.overallLetter})}),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 ",p.subGrades.length," verification areas below. Untested areas count as F until verified."]})]})]}),p.isLawsuitRisk&&e.jsx(xa,{areas:p.warningAreas}),e.jsx(ma,{grades:p.subGrades}),e.jsx(fa,{violationsRemaining:u,manualCompleted:d,manualTotal:K.length}),d>0||l.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:d})," of ",e.jsx("strong",{children:K.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${d/K.length*100}%`}})})]}):null]})}function xa({areas:t}){const s=t.map(a=>a.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((a,n)=>e.jsxs("span",{children:[e.jsx("strong",{children:a}),n<s.length-1?", ":""]},a)),". Fix these before relying on the overall grade."]})})]})}function ma({grades:t}){const s=m(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 ${pa[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(ga,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function ga({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=K.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?Ut(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 fa({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=m(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:s===a,label:`Run Guided Tests (${s}/${a} workflows complete)`,action:()=>n("guided"),tooltip:'12 separate workflows total. Click → pick a workflow → mark each step pass/fail/skip → "Back to workflows" → click again for the next. Repeat until 12/12.'},{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 c=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":c?"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:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function ba({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 va({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 (",Ut(s)," old). Re-scan to grade the current page state."]})]})}function Ut(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`}const Oe="dismissedFindings";function Se(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ne(t){return`reading-order::${t}`}function re(t){return`tab-order::${t}`}async function Ae(){try{const t=await chrome.storage.local.get(Oe),s=t==null?void 0:t[Oe];if(s&&typeof s=="object")return s}catch{}return{}}async function Be(t){await chrome.storage.local.set({[Oe]:t})}async function ke(t){return(await Ae())[Se(t)]??{}}async function Ot(t,s,a,n){const r=await Ae(),i=Se(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await Be(r)}async function xe(t,s){if(s.length===0)return;const a=await Ae(),n=Se(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 Be(a)}async function Ft(t,s){const a=await Ae(),n=Se(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Be(a))}const ya=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Ot,addDismissals:xe,dismissalKeyForReadingOrder:ne,dismissalKeyForTabOrder:re,getDismissalsForUrl:ke,removeDismissal:Ft},Symbol.toStringTag,{value:"Module"}));function Mt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Pt(t){return`${Ve(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function ja(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Pt(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 tt={critical:0,serious:1,moderate:2,minor:3};function wa(){var v,j,C,S;const t=m(x=>x.results),s=m(x=>x.componentId),a=m(x=>x.setView),n=((v=t[0])==null?void 0:v.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(new Set);if(g.useEffect(()=>{if(!n)return;ke(n).then(i);const x=()=>{document.visibilityState==="visible"&&n&&ke(n).then(i)};return document.addEventListener("visibilitychange",x),()=>document.removeEventListener("visibilitychange",x)},[n]),g.useEffect(()=>{if(!s){l(new Set);return}let x=!1;const b=async()=>{const E=await chrome.storage.local.get("igtRuns");if(x)return;const k=((E==null?void 0:E.igtRuns)??{})[s]??{},T=new Set;for(const w of K){const I=k[w.id];I&&Object.keys(I.steps).length===w.steps.length&&T.add(w.id)}l(T)};b();const y=()=>{document.visibilityState==="visible"&&b()};return document.addEventListener("visibilitychange",y),()=>{x=!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 c=t.reduce((x,b)=>x+b.durationMs,0),p=t.reduce((x,b)=>x+b.violations.length,0),d=ja(t);d.sort((x,b)=>{const y=tt[x.representative.impact]??99,E=tt[b.representative.impact]??99;return y!==E?y-E:b.states.length-x.states.length});const u=t.map(x=>Mt(x.state)).join(`
4
+ `),h=o.has("keyboard")?0:(((C=t[0])==null?void 0:C.tabOrderIssues)??[]).filter(x=>!(re(x.selector)in r)).length,f=o.has("page-structure")?0:(((S=t[0])==null?void 0:S.readingOrderIssues)??[]).filter(x=>!(ne(x.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(ha,{violations:t.flatMap(x=>x.violations),componentId:s}),(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"]})," · ",d.length," unique ",d.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(c/1e3).toFixed(1),"s"]}),d.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic px-1",children:"No violations found."}):e.jsx("div",{className:"space-y-1.5",children:d.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ne,{violation:x.representative}),e.jsx(Na,{states:x.states,totalStates:t.length})]},Pt(x.representative)))})]})}function Na({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(Mt))),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 ka={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 Sa({ruleId:t,violations:s}){const[a,n]=g.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(Ne,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ka[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((c,p)=>e.jsx(Ne,{violation:c},p))})]})}function Aa(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 Ca={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Gt({open:t,onClose:s,format:a,content:n,filename:r}){const i=Xt(new Blob([n]).size);function o(){Pe(n,r),s()}function l(){Me(n),s()}return e.jsxs(ie,{open:t,onClose:s,title:Ca[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 st=7800;function Ea(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,f=r.find(v=>`${v.ruleId}::${v.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...d,_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 d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.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
+ `),c=new URLSearchParams({title:i,body:l});let p=`${n}/issues/new?${c.toString()}`;return p.length>st&&(p=p.slice(0,st)),{url:p,title:i,body:l}}const at=7800;function Ra(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,f=r.find(v=>`${v.ruleId}::${v.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...d,_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 d of r)o.push(`Rule: ${d.ruleId} (${d.impact})`),o.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),o.push(`Description: ${d.description}`),o.push(`Selector: ${d.target.selector}`),o.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&o.push(`More info: ${d.helpUrl}`),o.push(""),o.push(`HTML: ${d.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
+ `),c=new URLSearchParams({summary:i,description:l});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>at&&(p=p.slice(0,at)),{url:p,summary:i,description:l}}function Ta(){const t=m(b=>b.delta),s=m(b=>b.componentId),a=m(b=>b.results),n=m(b=>b.tier),r=m(b=>b.baselineList),i=m(b=>b.siteCrawlReport),[o,l]=g.useState(""),[c,p]=g.useState(""),[d,u]=g.useState(null);g.useEffect(()=>{Promise.all([M({type:"SETTINGS_GET",key:"githubRepoUrl"}),M({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([b,y])=>{l(typeof b.data=="string"?b.data:""),p(typeof y.data=="string"?y.data:"")})},[]);const h=Nt(n,"exportJson"),f=St[n].maxBaselines,v=r.some(b=>b.componentId===s),j=v||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 C(){if(!s||a.length===0)return;const b=a.flatMap(I=>I.violations),y=a.flatMap(I=>I.announcements??[]),E=a.flatMap(I=>I.focusEvents??[]),_=a[0],T=(await M({type:"SETTINGS_GET",key:"stateMatrix"})).data??kt;await P({type:"BASELINE_SET",componentId:s,violations:b,announcements:y,focusEvents:E,snapshotMeta:{url:window.location.href,axeVersion:_.axeVersion,matrixConfig:T,capturedAt:new Date().toISOString()}});const w=await M({type:"BASELINE_COMPARE",componentId:s,currentViolations:b,announcements:y,focusEvents:E,currentMatrix:T});m.getState().setDelta(w.delta),q.polite(`Baseline saved for ${s}.`)}async function S(){if(!s||!v||!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 P({type:"BASELINE_DELETE",componentId:s});const y=n.flatMap(j=>j.violations),I=n.flatMap(j=>j.announcements??[]),D=n.flatMap(j=>j.focusEvents??[]),S=await O({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:I,focusEvents:D});x.getState().setDelta(S.delta);const R=await O({type:"BASELINE_LIST"});x.getState().setBaselineList(R.items),K.polite(`Baseline cleared for ${s}.`)}async function m(b,y=!1){var L,U;if(n.length===0)return;let I;if((b==="defense-bundle"||b==="evidence-bundle"||b==="ai-prompt")&&s){const F=await chrome.storage.local.get("igtRuns"),V=((F==null?void 0:F.igtRuns)??{})[s]??{};I=Object.values(V)}let D;if(b==="ai-prompt"){const F=((L=n[0])==null?void 0:L.pageUrl)??((U=n[0])==null?void 0:U.scope)??"";if(F){const{getDismissalsForUrl:Y}=await Ge(async()=>{const{getDismissalsForUrl:te}=await Promise.resolve().then(()=>vn);return{getDismissalsForUrl:te}},void 0),V=await Y(F);D=Object.keys(V)}}const S=await O({type:"EXPORT_REQUEST",format:b,results:n,delta:y?void 0:t??void 0,manualRuns:I,siteCrawlReport:b==="ai-prompt"?i??void 0:void 0,dismissedKeys:D});if(b==="defense-bundle"||b==="evidence-bundle"){const F=ft(b,s);await bt()?Pe(S.content,F):u({open:!0,format:b,content:S.content,filename:F});return}if(b==="html-print"||b==="vpat"){Oe(S.content);return}if(b==="ai-prompt"){try{await navigator.clipboard.writeText(S.content)}catch{}const Y=`<!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 P({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(w=>w.violations),E=a.flatMap(w=>w.announcements??[]),_=a.flatMap(w=>w.focusEvents??[]),k=await M({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:E,focusEvents:_});m.getState().setDelta(k.delta);const T=await M({type:"BASELINE_LIST"});m.getState().setBaselineList(T.items),q.polite(`Baseline cleared for ${s}.`)}async function x(b,y=!1){var D,U;if(a.length===0)return;let E;if((b==="defense-bundle"||b==="evidence-bundle"||b==="ai-prompt")&&s){const O=await chrome.storage.local.get("igtRuns"),V=((O==null?void 0:O.igtRuns)??{})[s]??{};E=Object.values(V)}let _;if(b==="ai-prompt"){const O=((D=a[0])==null?void 0:D.pageUrl)??((U=a[0])==null?void 0:U.scope)??"";if(O){const{getDismissalsForUrl:Y}=await Ge(async()=>{const{getDismissalsForUrl:te}=await Promise.resolve().then(()=>ya);return{getDismissalsForUrl:te}},void 0),V=await Y(O);_=Object.keys(V)}}const k=await M({type:"EXPORT_REQUEST",format:b,results:a,delta:y?void 0:t??void 0,manualRuns:E,siteCrawlReport:b==="ai-prompt"?i??void 0:void 0,dismissedKeys:_});if(b==="defense-bundle"||b==="evidence-bundle"){const O=ft(b,s);await bt()?Pe(k.content,O):u({open:!0,format:b,content:k.content,filename:O});return}if(b==="html-print"||b==="vpat"){Me(k.content);return}if(b==="ai-prompt"){try{await navigator.clipboard.writeText(k.content)}catch{}const Y=`<!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,20 +17,20 @@ 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">${S.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>
20
+ <pre id="content">${k.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>`,V=new Blob([Y],{type:"text/html"}),te=URL.createObjectURL(V);window.open(te,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(te),6e4);return}const R=b==="json"?"application/json":b==="sarif"?"application/sarif+json":"application/xml",j=b==="junit"?"xml":b,T=new Blob([S.content],{type:R}),_=URL.createObjectURL(T),E=document.createElement("a");E.href=_,E.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${j}`,E.click(),URL.revokeObjectURL(_)}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:C,disabled:!w,title:w?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"}),v&&e.jsx("button",{onClick:A,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(Dn,{disabled:!h,onExport:m,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!w&&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 b=Ee(t.new),y=Ee(t.persistent),I=Ee(t.fixed),D=[...b.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(ue,{title:"New",violations:b.findings,count:b.findings.length,accent:"red",actions:[...o&&b.findings.length>0?[{label:"File GitHub issue",onClick:()=>Tn(o,s,b.findings)}]:[],...c&&b.findings.length>0?[{label:"File Jira issue",onClick:()=>$n(c,s,b.findings)}]:[]]}),e.jsx(ue,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(ue,{title:"Fixed",violations:I.findings,count:t.fixedCount,accent:"green"}),D.length>0&&e.jsx(ue,{title:"Needs review (does not affect grade)",violations:D,count:D.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ue,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),d&&e.jsx(Gt,{open:d.open,onClose:()=>u(null),format:d.format,content:d.content,filename:d.filename})]})}const Rn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ee(t){const s=[],n=[];for(const a of t)a.needsReview?n.push(a):s.push(a);return{findings:s,review:n,fixed:0}}function ue({title:t,violations:s,count:n,accent:a,actions:r,renderAsAcknowledged:i}){const[o,l]=g.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 ${Rn[a]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",n,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),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((c,p)=>e.jsx(Ne,{violation:c,alreadyAcknowledged:!0},p)):An(s).map(c=>e.jsx(Sn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Tn(t,s,n){if(n.length===0)return;const{url:a}=Cn(t,s,n);window.open(a,"_blank","noopener,noreferrer")}function $n(t,s,n){if(n.length===0)return;const{url:a}=In(t,s,n);window.open(a,"_blank","noopener,noreferrer")}function Dn({disabled:t,onExport:s,hasBaselineDelta:n}){const[a,r]=g.useState(!1),[i,o]=g.useState(!1);function l(c){r(!1),s(c,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(c=>!c),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 ▾"}),a&&!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:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c=>o(c.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(ee,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ee,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ee,{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(ee,{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(ee,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ee,{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(ee,{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(ee,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ee({onClick:t,title:s,children:n}){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:n})}const at="igtRuns";async function _n(){var n;if(typeof chrome>"u"||!((n=chrome.storage)!=null&&n.local))return{};const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:{}}async function Ln(t,s){var o,l;const n=s[0];if(!(n!=null&&n.pageUrl))return;const a=n.pageUrl,i=(await _n())[t];if(i)for(const c of q){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const f=n.tabOrderIssues??[];if(f.length===0)continue;await me(a,f.map(v=>({key:re(v.selector),reason:h,snippet:`${v.selector} — ${v.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const f=n.readingOrderIssues??[];if(f.length===0)continue;await me(a,f.map(v=>({key:ae(v.selector),reason:h,snippet:`${v.selector} — ${v.textSnippet||"(no text)"}`})))}}}}const Un=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"]),Fn=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 Mn(t){return Un.has(t.ruleId)}function On(t){return Fn.has(t.ruleId)}function Pn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Gn(){var R,j,T,_;const t=x(E=>E.results),s=x(E=>E.delta),n=x(E=>E.componentId),a=((R=t[0])==null?void 0:R.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(0);g.useEffect(()=>{if(!a)return;let E=!1;return(async()=>{if(n&&t.length>0)try{await Ln(n,t)}catch{}if(E)return;const L=await Se(a);E||i(L)})(),()=>{E=!0}},[a,o,n,t]);async function c(E,L){if(!a)return;const U=window.prompt(`Why is this finding a false positive?
26
+ </body></html>`,V=new Blob([Y],{type:"text/html"}),te=URL.createObjectURL(V);window.open(te,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(te),6e4);return}const T=b==="json"?"application/json":b==="sarif"?"application/sarif+json":"application/xml",w=b==="junit"?"xml":b,I=new Blob([k.content],{type:T}),L=URL.createObjectURL(I),R=document.createElement("a");R.href=L,R.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${w}`,R.click(),URL.revokeObjectURL(L)}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:C,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"}),v&&e.jsx("button",{onClick:S,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(La,{disabled:!h,onExport:x,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 b=Re(t.new),y=Re(t.persistent),E=Re(t.fixed),_=[...b.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(ue,{title:"New",violations:b.findings,count:b.findings.length,accent:"red",actions:[...o&&b.findings.length>0?[{label:"File GitHub issue",onClick:()=>$a(o,s,b.findings)}]:[],...c&&b.findings.length>0?[{label:"File Jira issue",onClick:()=>_a(c,s,b.findings)}]:[]]}),e.jsx(ue,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(ue,{title:"Fixed",violations:E.findings,count:t.fixedCount,accent:"green"}),_.length>0&&e.jsx(ue,{title:"Needs review (does not affect grade)",violations:_,count:_.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ue,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),d&&e.jsx(Gt,{open:d.open,onClose:()=>u(null),format:d.format,content:d.content,filename:d.filename})]})}const Ia={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Re(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 ue({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=g.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 ${Ia[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):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(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),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((c,p)=>e.jsx(Ne,{violation:c,alreadyAcknowledged:!0},p)):Aa(s).map(c=>e.jsx(Sa,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function $a(t,s,a){if(a.length===0)return;const{url:n}=Ea(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function _a(t,s,a){if(a.length===0)return;const{url:n}=Ra(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function La({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=g.useState(!1),[i,o]=g.useState(!1);function l(c){r(!1),s(c,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(c=>!c),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:c=>o(c.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(ee,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ee,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ee,{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(ee,{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(ee,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ee,{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(ee,{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(ee,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ee({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 nt="igtRuns";async function Da(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}async function Ua(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Da())[t];if(i)for(const c of K){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const f=a.tabOrderIssues??[];if(f.length===0)continue;await xe(n,f.map(v=>({key:re(v.selector),reason:h,snippet:`${v.selector} — ${v.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const f=a.readingOrderIssues??[];if(f.length===0)continue;await xe(n,f.map(v=>({key:ne(v.selector),reason:h,snippet:`${v.selector} — ${v.textSnippet||"(no text)"}`})))}}}}const Oa=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"]),Fa=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 Ma(t){return Oa.has(t.ruleId)}function Pa(t){return Fa.has(t.ruleId)}function Ga(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Va(){var T,w,I,L;const t=m(R=>R.results),s=m(R=>R.delta),a=m(R=>R.componentId),n=((T=t[0])==null?void 0:T.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(0);g.useEffect(()=>{if(!n)return;let R=!1;return(async()=>{if(a&&t.length>0)try{await Ua(a,t)}catch{}if(R)return;const D=await ke(n);R||i(D)})(),()=>{R=!0}},[n,o,a,t]);async function c(R,D){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.)`,"");U!==null&&(await Ft(a,E,U||"(no reason given)",L),l(F=>F+1))}async function p(E){a&&(await Mt(a,E),l(L=>L+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((E,L)=>{var U;return E+(((U=L.announcements)==null?void 0:U.length)??0)},0),u=t.reduce((E,L)=>{var U;return E+(((U=L.focusEvents)==null?void 0:U.length)??0)},0),h=t.reduce((E,L)=>{var U;return E+(((U=L.focusEvents)==null?void 0:U.filter(F=>F.isFocusReset).length)??0)},0),f=rt(t,Mn),v=rt(t,On),w=f.length,C=v.length,A=((T=t[0])==null?void 0:T.readingOrderIssues)??[],m=((_=t[0])==null?void 0:_.tabOrderIssues)??[],b=A.filter(E=>!(ae(E.selector)in r)),y=A.filter(E=>ae(E.selector)in r),I=m.filter(E=>!(re(E.selector)in r)),D=m.filter(E=>re(E.selector)in r);if(d===0&&u===0&&w===0&&C===0&&b.length===0&&I.length===0&&y.length===0&&D.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 S=y.length+D.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[w," structural · ",C," form ·"," ",I.length," tab-order ·"," ",b.length," reading-order ·"," ",d," ",d===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"]}),S>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",S," dismissed"]})]}),I.length>0&&e.jsx(Bn,{issues:I,onDismiss:c}),b.length>0&&e.jsx(Hn,{issues:b,onDismiss:c}),S>0&&e.jsx(zn,{dismissedReadingOrder:y,dismissedTabOrder:D,dismissals:r,onRestore:p}),w>0&&e.jsx(it,{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}),C>0&&e.jsx(it,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:v}),e.jsx(Vn,{delta:s}),t.map((E,L)=>{const U=E.announcements??[],F=E.focusEvents??[];return U.length===0&&F.length===0?null:e.jsx(Wn,{state:E.state,announcements:U,focusEvents:F},L)})]})}function Vn({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],n=t.newFocusEvents??[],a=n.filter(r=>r.isFocusReset);return s.length===0&&n.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."}),a.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",a.length," new focus reset",a.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))})]}),n.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",n.length,")"]}),e.jsx("ul",{className:"space-y-1",children:n.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 rt(t,s){const n=new Map;for(const a of t)for(const r of a.violations){if(!s(r))continue;const i=Ve(r.ruleId,r.target.selector),o=n.get(i);o?o.states.push(r.currentState):n.set(i,{violation:r,states:[r.currentState]})}return Array.from(n.values()).sort((a,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[a.violation.impact]??99)-(i[r.violation.impact]??99)})}function it({title:t,subtitle:s,groups:n}){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:n.map((a,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:a.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${a.violation.impact==="critical"||a.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:a.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:a.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:a.violation.target.selector})]},r))})]})}function Wn({state:t,announcements:s,focusEvents:n}){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:Pn(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((a,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:a.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",a.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${a.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:a.role??a.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:a.text})]},r))})]}),n.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",n.length,")"]}),e.jsx("ol",{className:"space-y-1",children:n.map((a,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${a.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",a.msSinceArm,"ms"]}),a.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:a.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:a.toSelector}),a.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Bn({issues:t,onDismiss:s}){const n=t.filter(r=>r.flag==="visual"||r.flag==="both").length,a=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:[n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," visual mismatch",n===1?"":"es",a>0&&" · "]}),a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," positive-tabindex reordering",a===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 Hn({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((n,a)=>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",n.domIndex,"→vis",n.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:n.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:n.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${n.selector}`,`${n.selector} — ${n.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"})]},a)),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 zn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:n,onRestore:a}){const[r,i]=g.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 c=`tab-order::${l.selector}`,p=n[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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 a(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,p=n[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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 a(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const Me="igtRuns";async function qn(t,s,n){const a=s[0];if(!a)return;const r=a.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${n}" marked pass`;if(t==="tab-order"){const o=a.tabOrderIssues??[];if(o.length===0)return;await me(r,o.map(l=>({key:re(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=a.readingOrderIssues??[];if(o.length===0)return;await me(r,o.map(l=>({key:ae(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Kn={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"}},Qn={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"}},Jn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ot(t,s){const n=await H();if(!n)return;const a=s?Kn[t]:Qn[t];try{await Q(n,a)}catch{}}async function Yn(){const s=(await chrome.storage.local.get(Me))[Me];return s&&typeof s=="object"?s:{}}async function lt(t){await chrome.storage.local.set({[Me]:t})}function Xn(t,s){if(!t.relatedAxeRule||s.length===0)return null;const n=s.flatMap(a=>a.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(n.length>0){const a=Array.from(new Set(n.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:n.length,states:a}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function Zn(){const t=x(d=>d.componentId),s=x(d=>d.results),[n,a]=g.useState({}),[r,i]=g.useState(null);if(g.useEffect(()=>{Yn().then(a)},[]),!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=n[t]??{};function l(d,u,h){var v;const f={...n,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((v=o[d])==null?void 0:v.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(a(f),lt(f),h.status==="pass"){const w=q.find(A=>A.id===d),C=w==null?void 0:w.steps.find(A=>A.id===u);C!=null&&C.autoDismissActivity&&qn(C.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[d];const h={...n,[t]:u};a(h),lt(h)}const p=q.find(d=>d.id===r);if(p){const d=o[p.id];return e.jsx(ea,{workflow:p,run:d,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."}),q.map(d=>{const u=o[d.id],h=u?as(u,d):null;return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:"w-full text-left border border-slate-200 rounded p-2 bg-white hover:bg-slate-50 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),h&&e.jsxs("span",{className:"text-[10px] text-slate-500 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.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function ea({workflow:t,run:s,results:n,onAnswer:a,onBack:r}){const i=g.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=Xn(p,n);return c},[t,n]);function o(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&a(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),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((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>a(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>a(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ot(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Jn[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ot(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Re,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>a(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Re,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>a(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Re,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>a(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>a(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const ta={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:n,onClick:a}){return e.jsx("button",{type:"button",onClick:a,className:`text-[11px] px-2 py-1 rounded border ${s?ta[n]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const ge="savedFlows";async function sa(){const t=await chrome.storage.local.get(ge);return Array.isArray(t[ge])?t[ge]:[]}async function ct(t){await chrome.storage.local.set({[ge]:t})}function na(){const[t,s]=g.useState([]),[n,a]=g.useState(!1),[r,i]=g.useState(null);g.useEffect(()=>{sa().then(s)},[]);async function o(){const d=await H();if(!d){i("No audit-target tab found.");return}try{await Q(d,{type:"FLOW_RECORD_START_REQUEST"}),a(!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 d=await H();if(d)try{const u=await be(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(a(!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()},v=[f,...t];s(v),await ct(v),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await H();if(u){i(`Replaying "${d.name}"…`);try{const h=await be(u,{type:"FLOW_PLAY_REQUEST",steps:d.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(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==d);s(u),await ct(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:n?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(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function aa(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const n=t.slice(0,s),a=t.slice(s+2),r=a.indexOf(":");if(r===-1)return{primary:a};const i=a.slice(0,r),o=a.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(ra).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:n||i}}function ra(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function ia(){const t=x(l=>l.baselineList),s=x(l=>l.tier),n=At[s].maxBaselines,a=t.length>=n&&Number.isFinite(n),[r,i]=g.useState(!1);if(g.useEffect(()=>{ye().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 P({type:"BASELINE_DELETE",componentId:l}),await ye()}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(n)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",n]})]}),a&&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 c=aa(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:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[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(se,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(se,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(se,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(se,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(se,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(se,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(se,{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 oa={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 se({tone:t,title:s,children:n}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${oa[t]}`,children:n})}const la={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"},ca={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},da={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 Vt({onBack:t}){const s=x(u=>u.siteCrawlStatus),n=x(u=>u.siteCrawlProgress),a=x(u=>u.siteCrawlReport),r=x(u=>u.siteCrawlError),[i,o]=g.useState(""),[l,c]=g.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&&(x.getState().setSiteCrawlStatus("running"),x.getState().setSiteCrawlReport(null),x.getState().setSiteCrawlError(null),X({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function d(){P({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=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),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"&&n&&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:n.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:`${n.current/Math.max(1,n.total)*100}%`},role:"progressbar","aria-valuenow":n.current,"aria-valuemin":0,"aria-valuemax":n.total,"aria-label":`Page ${n.current} of ${n.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",n.current," of ",n.total,n.lastViolations!==void 0&&` · last had ${n.lastViolations} issue${n.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&a&&e.jsx(ua,{report:a}),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 ua({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:n}=await import("./site-report-renderer-BJxX-AaN.js");return{renderSiteReportHtml:n}},__vite__mapDeps([0,1,2,3])).then(({renderSiteReportHtml:n})=>{const a=n(t),r=new Blob([a],{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 ${la[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${ca[t.siteRisk]}`,children:yt[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(n=>{const a=rs(n.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 ${da[n.impact]}`,children:n.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:a.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:n.urlsAffected})," page",n.urlsAffected===1?"":"s"," · ",n.totalOccurrences," total spot",n.totalOccurrences===1?"":"s"]})]})]})},n.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(n=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${n.grade==="A"?"text-emerald-700":n.grade==="B"?"text-lime-700":n.grade==="C"?"text-yellow-700":n.grade==="D"?"text-orange-700":"text-rose-700"}`,children:n.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:n.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:n.uniqueViolations})]},n.url))})]})]})}const Te="onboardingDismissed",$e=[{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 pa(){const[t,s]=g.useState(!1),[n,a]=g.useState(0);g.useEffect(()=>{chrome.storage.local.get(Te).then(l=>{l[Te]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Te]:!0}),s(!1),a(0)}const i=n===$e.length-1,o=$e[n];return e.jsxs(ie,{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:[n+1," / ",$e.length]}),e.jsxs("div",{className:"flex gap-2",children:[n>0&&e.jsx("button",{onClick:()=>a(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:()=>a(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function ha(){const t=x(a=>a.status),s=x(a=>a.errorMessage),n=x(a=>a.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:()=>n("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function ma(){const t=x(c=>c.aiFailure),s=x(c=>c.clearAiFailure),[n,a]=g.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:()=>a(c=>!c),className:"underline hover:no-underline","aria-expanded":n,children:n?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),n&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function dt(){const[t,s]=g.useState(!1);return g.useEffect(()=>z("AUDIT_FAILED_EVENT",n=>{n.error.code==="DEBUGGER_BUSY"&&(s(!0),x.getState().setStatus("idle"))}),[]),e.jsxs(ie,{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 xa(){var i;const[t,s]=g.useState(null);if(g.useEffect(()=>{is().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function n(){t&&(await Je(),x.getState().startNewScan(),t.mode==="storybook-all"?X({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&X({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function a(){await Je(),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:n,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:a,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const De="storybook:hintDismissed";function ga(){const[t,s]=g.useState(!1),[n,a]=g.useState();g.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(De))[De])return;const o=await H();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(a((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[De]:!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 ",n??""," 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 fa(){var i;const t=x(o=>o.results),s=x(o=>o.baselineList),n=x(o=>o.status),a=(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:n==="running"?"auditing…":a?`last audit ${ba(a)}`:"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 ba(t,s=new Date){const n=new Date(t),a=s.getTime()-n.getTime(),r=Math.round(a/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`:n.toLocaleDateString()}function va(){const t=x(l=>l.results),s=x(l=>l.componentId),[n,a]=g.useState([]);if(g.useEffect(()=>{if(!s){a([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};a(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=wt(r,n.length>0?{runs:n,workflows:q}: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 ya(){const t=x(n=>n.setUserMode);function s(n){t(n),P({type:"SETTINGS_SET",key:"userMode",value:n})}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 Wt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},wa={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Wt]},ja={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Wt]};function He(t){return t==="thorough"?ja:wa}function ut(t){const s=He(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const fe="wcagcheckr";function $(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function he(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 Na(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Sa(t){if(t.length===0)return null;const s=[...t].sort((n,a)=>n.capturedAt.localeCompare(a.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function Aa(t){const s=new Map;for(const n of t){const a=s.get(n.componentId);a?(a.entries.push(n),n.receipt&&a.anchoredCount++,n.capturedAt>a.latest.capturedAt&&(a.latest=n,a.pageUrl=n.pageUrl)):s.set(n.componentId,{componentId:n.componentId,pageUrl:n.pageUrl,entries:[n],latest:n,anchoredCount:n.receipt?1:0})}for(const n of s.values())n.entries.sort((a,r)=>r.capturedAt.localeCompare(a.capturedAt));return Array.from(s.values()).sort((n,a)=>a.latest.capturedAt.localeCompare(n.latest.capturedAt))}function ka(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 Ca(t){const s=t.totals,n=[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>',a=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${$(t.receipt.tsaName)}) — anchored ${$(he(t.receipt.anchoredAt))}</td></tr>
28
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");U!==null&&(await Ot(n,R,U||"(no reason given)",D),l(O=>O+1))}async function p(R){n&&(await Ft(n,R),l(D=>D+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((R,D)=>{var U;return R+(((U=D.announcements)==null?void 0:U.length)??0)},0),u=t.reduce((R,D)=>{var U;return R+(((U=D.focusEvents)==null?void 0:U.length)??0)},0),h=t.reduce((R,D)=>{var U;return R+(((U=D.focusEvents)==null?void 0:U.filter(O=>O.isFocusReset).length)??0)},0),f=rt(t,Ma),v=rt(t,Pa),j=f.length,C=v.length,S=((I=t[0])==null?void 0:I.readingOrderIssues)??[],x=((L=t[0])==null?void 0:L.tabOrderIssues)??[],b=S.filter(R=>!(ne(R.selector)in r)),y=S.filter(R=>ne(R.selector)in r),E=x.filter(R=>!(re(R.selector)in r)),_=x.filter(R=>re(R.selector)in r);if(d===0&&u===0&&j===0&&C===0&&b.length===0&&E.length===0&&y.length===0&&_.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 k=y.length+_.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 · ",C," form ·"," ",E.length," tab-order ·"," ",b.length," reading-order ·"," ",d," ",d===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"]}),k>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",k," dismissed"]})]}),E.length>0&&e.jsx(Ha,{issues:E,onDismiss:c}),b.length>0&&e.jsx(za,{issues:b,onDismiss:c}),k>0&&e.jsx(Ka,{dismissedReadingOrder:y,dismissedTabOrder:_,dismissals:r,onRestore:p}),j>0&&e.jsx(it,{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}),C>0&&e.jsx(it,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:v}),e.jsx(Wa,{delta:s}),t.map((R,D)=>{const U=R.announcements??[],O=R.focusEvents??[];return U.length===0&&O.length===0?null:e.jsx(Ba,{state:R.state,announcements:U,focusEvents:O},D)})]})}function Wa({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 rt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Ve(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 it({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 Ba({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:Ga(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 Ha({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 za({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 Ka({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=g.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 c=`tab-order::${l.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children: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(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const Fe="igtRuns";async function qa(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 xe(r,o.map(l=>({key:re(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 xe(r,o.map(l=>({key:ne(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Qa={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"}},Ja={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"}},Ya={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ot(t,s){const a=await H();if(!a)return;const n=s?Qa[t]:Ja[t];try{await Q(a,n)}catch{}}async function Xa(){const s=(await chrome.storage.local.get(Fe))[Fe];return s&&typeof s=="object"?s:{}}async function lt(t){await chrome.storage.local.set({[Fe]:t})}function Za(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 en(){const t=m(d=>d.componentId),s=m(d=>d.results),[a,n]=g.useState({}),[r,i]=g.useState(null);if(g.useEffect(()=>{Xa().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(d,u,h){var v;const f={...a,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((v=o[d])==null?void 0:v.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(f),lt(f),h.status==="pass"){const j=K.find(S=>S.id===d),C=j==null?void 0:j.steps.find(S=>S.id===u);C!=null&&C.autoDismissActivity&&qa(C.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[d];const h={...a,[t]:u};n(h),lt(h)}const p=K.find(d=>d.id===r);if(p){const d=o[p.id];return e.jsx(tn,{workflow:p,run:d,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),K.map(d=>{const u=o[d.id],h=u?ns(u,d):null;return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:"w-full text-left border border-slate-200 rounded p-2 bg-white hover:bg-slate-50 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),h&&e.jsxs("span",{className:"text-[10px] text-slate-500 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.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function tn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=g.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=Za(p,a);return c},[t,a]);function o(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),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((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ot(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Ya[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ot(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>n(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const sn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Te({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?sn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const ge="savedFlows";async function an(){const t=await chrome.storage.local.get(ge);return Array.isArray(t[ge])?t[ge]:[]}async function ct(t){await chrome.storage.local.set({[ge]:t})}function nn(){const[t,s]=g.useState([]),[a,n]=g.useState(!1),[r,i]=g.useState(null);g.useEffect(()=>{an().then(s)},[]);async function o(){const d=await H();if(!d){i("No audit-target tab found.");return}try{await Q(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await H();if(d)try{const u=await be(d,{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()},v=[f,...t];s(v),await ct(v),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await H();if(u){i(`Replaying "${d.name}"…`);try{const h=await be(u,{type:"FLOW_PLAY_REQUEST",steps:d.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(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==d);s(u),await ct(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(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function rn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(on).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function on(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function ln(){const t=m(l=>l.baselineList),s=m(l=>l.tier),a=St[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=g.useState(!1);if(g.useEffect(()=>{ye().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 P({type:"BASELINE_DELETE",componentId:l}),await ye()}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 c=rn(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[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(se,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(se,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(se,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(se,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(se,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(se,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(se,{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 cn={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 se({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${cn[t]}`,children:a})}const dn={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"},un={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},pn={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 Vt({onBack:t}){const s=m(u=>u.siteCrawlStatus),a=m(u=>u.siteCrawlProgress),n=m(u=>u.siteCrawlReport),r=m(u=>u.siteCrawlError),[i,o]=g.useState(""),[l,c]=g.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&&(m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),X({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function d(){P({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=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(hn,{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 hn({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-y0iEnnW8.js");return{renderSiteReportHtml:a}},__vite__mapDeps([0,1,2,3])).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 ${dn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${un[t.siteRisk]}`,children:yt[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=rs(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 ${pn[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 Ie="onboardingDismissed",$e=[{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 xn(){const[t,s]=g.useState(!1),[a,n]=g.useState(0);g.useEffect(()=>{chrome.storage.local.get(Ie).then(l=>{l[Ie]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ie]:!0}),s(!1),n(0)}const i=a===$e.length-1,o=$e[a];return e.jsxs(ie,{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," / ",$e.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 mn(){const t=m(n=>n.status),s=m(n=>n.errorMessage),a=m(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=m(c=>c.aiFailure),s=m(c=>c.clearAiFailure),[a,n]=g.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(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function dt(){const[t,s]=g.useState(!1);return g.useEffect(()=>z("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),m.getState().setStatus("idle"))}),[]),e.jsxs(ie,{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 fn(){var i;const[t,s]=g.useState(null);if(g.useEffect(()=>{is().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Je(),m.getState().startNewScan(),t.mode==="storybook-all"?X({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&X({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Je(),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 _e="storybook:hintDismissed";function bn(){const[t,s]=g.useState(!1),[a,n]=g.useState();g.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(_e))[_e])return;const o=await H();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[_e]:!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 vn(){var i;const t=m(o=>o.results),s=m(o=>o.baselineList),a=m(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 ${yn(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 yn(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 jn(){const t=m(l=>l.results),s=m(l=>l.componentId),[a,n]=g.useState([]);if(g.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=jt(r,a.length>0?{runs:a,workflows:K}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function wn(){const t=m(a=>a.setUserMode);function s(a){t(a),P({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 Wt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Nn={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Wt]},kn={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Wt]};function He(t){return t==="thorough"?kn:Nn}function ut(t){const s=He(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const fe="wcagcheckr";function $(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function he(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 Sn(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function An(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 Cn(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 En(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 Rn(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 (${$(t.receipt.tsaName)}) — anchored ${$(he(t.receipt.anchoredAt))}</td></tr>
29
29
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${$(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
30
  ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${$(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${$(fe)}; 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 ${ka(t.grade)}">${$(t.grade)}</span>
33
+ <span class="grade-badge ${En(t.grade)}">${$(t.grade)}</span>
34
34
  <div class="entry-headline">
35
35
  <div class="entry-time">${$(he(t.capturedAt))}</div>
36
36
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
@@ -41,18 +41,18 @@ document.getElementById('copy').addEventListener('click', () => {
41
41
  <tr><th>Page URL</th><td><code>${$(t.pageUrl)}</code></td></tr>
42
42
  <tr><th>Scope</th><td><code>${$(t.scope)}</code></td></tr>
43
43
  <tr><th>axe-core version</th><td>${$(t.axeVersion)}</td></tr>
44
- <tr><th>Severity breakdown</th><td class="sev-row">${n}</td></tr>
45
- ${a}
44
+ <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
45
+ ${n}
46
46
  </table>
47
- </article>`}function Ia(t){return`
47
+ </article>`}function Tn(t){return`
48
48
  <section class="component-section">
49
49
  <h2>
50
50
  <span class="component-id">${$(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
53
  <p class="component-url"><strong>Page audited:</strong> <code>${$(t.pageUrl)}</code></p>
54
- ${t.entries.map(Ca).join("")}
55
- </section>`}function Ea(t){const{entries:s,extensionVersion:n}=t,a=Aa(s),r=Sa(s),i=(t.axeVersions??Na(s)).join(", "),o=s.length,l=s.filter(d=>d.receipt).length,c=o-l,p=he(new Date().toISOString());return`<!doctype html>
54
+ ${t.entries.map(Rn).join("")}
55
+ </section>`}function In(t){const{entries:s,extensionVersion:a}=t,n=Cn(s),r=An(s),i=(t.axeVersions??Sn(s)).join(", "),o=s.length,l=s.filter(d=>d.receipt).length,c=o-l,p=he(new Date().toISOString());return`<!doctype html>
56
56
  <html lang="en">
57
57
  <head>
58
58
  <meta charset="utf-8" />
@@ -207,7 +207,7 @@ document.getElementById('copy').addEventListener('click', () => {
207
207
 
208
208
  <aside class="attestation">
209
209
  <h3>Attestation</h3>
210
- <p>The audit records summarized below were captured by the <strong>${$(fe)}</strong> Chrome extension, version <strong>${$(n)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${$(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>${$(fe)}</strong> Chrome extension, version <strong>${$(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${$(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
211
211
  <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
212
212
  <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
213
213
  </aside>
@@ -216,12 +216,12 @@ document.getElementById('copy').addEventListener('click', () => {
216
216
  <tr><th>Total audits recorded</th><td>${o}</td></tr>
217
217
  <tr><th>RFC 3161-anchored audits</th><td>${l}</td></tr>
218
218
  <tr><th>Local-only audits</th><td>${c}</td></tr>
219
- <tr><th>Distinct components / scopes</th><td>${a.length}</td></tr>
219
+ <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
220
220
  <tr><th>axe-core version(s) observed</th><td>${$(i||"n/a")}</td></tr>
221
- <tr><th>Tool</th><td>${$(fe)} ${$(n)}</td></tr>
221
+ <tr><th>Tool</th><td>${$(fe)} ${$(a)}</td></tr>
222
222
  </table>
223
223
 
224
- ${a.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':a.map(Ia).join("")}
224
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Tn).join("")}
225
225
 
226
226
  <section class="methodology">
227
227
  <h2>Methodology</h2>
@@ -245,16 +245,16 @@ document.getElementById('copy').addEventListener('click', () => {
245
245
  </section>
246
246
 
247
247
  <footer>
248
- <span>Generated ${$(p)} by ${$(fe)} ${$(n)}</span>
249
- <span>${o} audit${o===1?"":"s"} · ${l} anchored · ${a.length} component${a.length===1?"":"s"}</span>
248
+ <span>Generated ${$(p)} by ${$(fe)} ${$(a)}</span>
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 Ra(t){const s=Ea(t),n=new Blob([s],{type:"text/html;charset=utf-8"}),a=URL.createObjectURL(n);await chrome.tabs.create({url:a})}function Bt(){const[t,s]=g.useState(null),[n,a]=g.useState(null),[r,i]=g.useState(0),[o,l]=g.useState(!1),[c,p]=g.useState(""),[d,u]=g.useState(""),[h,f]=g.useState(""),[v,w]=g.useState(!1);if(g.useEffect(()=>{let y=!1;return s(null),a(null),jt().then(I=>{y||s(I)}).catch(I=>{y||a(I instanceof Error?I.message:String(I))}),()=>{y=!0}},[r]),t===null&&n===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(n!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",n]});const C=t.length,A=t.filter(y=>y.receipt).length;async function m(){if(!(!t||t.length===0)){w(!0);try{await Ra({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{w(!1)}}}async function b(){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},I=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),D=URL.createObjectURL(I),S=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,R=document.createElement("a");R.href=D,R.download=S,R.click(),setTimeout(()=>URL.revokeObjectURL(D),1e3)}return C===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:[C," ",C===1?"entry":"entries",A>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[A," RFC 3161-anchored"]})]}),A===0&&C>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 b(),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:c,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:d,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:v||C===0,onClick:m,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:v?"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 Ta(){const[t,s]=g.useState(null),[n,a]=g.useState(!1);if(g.useEffect(()=>{let c=!1;return jt().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[n]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(c=>c.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:()=>a(!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(c=>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 ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(ie,{open:n,onClose:()=>a(!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(Bt,{})})})]})}function $a(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Da={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."},_a={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."},La={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Ua={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ht(){const t=x(u=>u.tier),s=x(u=>u.trialDaysRemaining),n=x(u=>u.seatsUsed),a=x(u=>u.seatsTotal),r=x(u=>u.planCode),i=x(u=>u.licenseDaysRemaining),o=x(u=>u.pastDue),[l,c]=g.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:()=>c(!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 P({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ue,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?Ua:La,h=t==="team"&&n!==null&&a!==null?`${n} of ${a} seats used`:u.perks,f=t==="team"&&n!==null&&a!==null&&n>a,v=t==="team"&&n!==null&&a!==null&&n===a,w=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"}:v?{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 ${w.bg} border-b ${w.border} px-3 py-2 space-y-1 text-[11px] ${w.shadow}`,children:[e.jsxs("div",{className:w.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:w.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."}),v&&!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 P({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?Da:_a,d=t==="trial"?$a(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:d})]}),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:()=>c(!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 P({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(Ue,{open:l,onClose:()=>c(!1)})]})}const Fa={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"},Ma={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},pt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Oa={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"},ht={critical:0,serious:1,moderate:2,minor:3};function Pa(){const t=x(u=>u.setUserMode),s=x(u=>u.status),n=x(u=>u.setStatus),a=x(u=>u.errorMessage),r=x(u=>u.setError),[i,o]=g.useState(!1),[l,c]=g.useState(!1),p=g.useRef(s);g.useEffect(()=>{if(p.current==="running"&&s==="complete"){c(!0);const u=setTimeout(()=>c(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),g.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{x.getState().status==="running"&&(n("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,n,r]);function d(){t("dev"),P({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(Ht,{}),e.jsx(Dt,{}),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($t,{}),e.jsx("button",{type:"button",onClick:d,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(Ga,{}),s==="failed"&&a&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:a}),e.jsx("button",{type:"button",onClick:()=>{x.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(Vt,{onBack:()=>o(!1)}):e.jsx(Wa,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Va,{})]}),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 Ga(){const t=x(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void P({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 Va(){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 Wa({onPickCrawl:t}){const s=x(u=>u.status),n=x(u=>u.results),[a,r]=g.useState("quick"),[i,o]=g.useState("all"),l=s==="running",c=n.flatMap(u=>u.violations),p=n.length>0;function d(){X({type:"START_AUDIT",mode:"full-page",matrixOverride:He(a)}),x.getState().startNewScan(),K.polite(`${a==="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:d,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(Ha,{depth:a,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(Ba,{}),p&&e.jsx(za,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:a})]})}function Ba(){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 Ha({depth:t,onChange:s,disabled:n}){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(mt,{active:t==="quick",disabled:n,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${ut("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(mt,{active:t==="thorough",disabled:n,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${ut("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function mt({active:t,disabled:s,onClick:n,title:a,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:n,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:a}),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 za({violations:t,severityFilter:s,onSeverityFilterChange:n,scanDepth:a}){var A;const r=x(m=>m.status),i=x(m=>m.results),o=x(m=>m.freshThisSession),l=(A=i[0])==null?void 0:A.startedAt,c=wt(t),p=r==="running";function d(){X({type:"START_AUDIT",mode:"full-page",matrixOverride:He(a)}),x.getState().startNewScan(),K.polite("Re-scanning this page now.")}const u=s==="lawsuit-risk"?t.filter(m=>m.impact==="critical"||m.impact==="serious"):t,h=new Map;for(const m of u){const b=Ve(m.ruleId,m.target.selector);h.has(b)||h.set(b,m)}const f=Array.from(h.values()),v=new Map;for(const m of f){const b=v.get(m.ruleId)??[];b.push(m),v.set(m.ruleId,b)}const w=Array.from(v.entries()).sort((m,b)=>(ht[m[1][0].impact]??99)-(ht[b[1][0].impact]??99)),C=t.filter(m=>m.impact==="critical"||m.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:[l&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Ja,{iso:l})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void We(),disabled:p,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:d,disabled:p,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:p?"Scanning…":"↻ Scan again"})]})]}),p?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 ${Fa[c.risk]}`,children:[!o&&l&&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 ${Ma[c.letter]} text-white shrink-0`,"aria-label":`Grade ${c.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:c.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:`text-base font-semibold ${pt[c.risk]}`,children:yt[c.risk]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${pt[c.risk]}`,children:os[c.risk]}),e.jsxs("div",{className:"flex gap-3 mt-2 text-xs flex-wrap",children:[c.totals.critical>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.critical})," critical"]}),c.totals.serious>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.serious})," serious"]}),c.totals.moderate>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.moderate})," moderate"]}),c.totals.minor>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.minor})," minor"]}),c.totals.unique===0&&e.jsx("span",{children:"No automated issues found ✓"})]})]})]})]}),e.jsx(Qa,{}),e.jsx(Ta,{}),t.length>0&&e.jsx(qa,{filter:s,onChange:n,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[w.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."]}),w.map(([m,b])=>e.jsx(Ka,{ruleId:m,violations:b},m))]})]})}function qa({filter:t,onChange:s,totalCount:n,lawsuitRiskCount:a}){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:[n," 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:[a," critical/serious"]})]})]})]})}function Ka({ruleId:t,violations:s}){var l;const[n,a]=g.useState(!1),r=(l=s.find(c=>c.target.opacityContext))==null?void 0:l.target.opacityContext,i=ls(t,r),o=s[0].impact;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>a(!n),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":n,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Oa[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:i.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[s.length," ",s.length===1?"spot":"spots"," on this page · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:n?"▲":"▼"})]}),n&&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]})]})]})}const xe=[{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 Qa(){const t=x(d=>d.results),s=x(d=>d.componentId),[n,a]=g.useState(null),[r,i]=g.useState(!1),[o,l]=g.useState(null);async function c(d,u){if(t.length!==0){a(d);try{const h=await O({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const f=ft(d,s);await bt()?Pe(h.content,f):l({open:!0,format:d,content:h.content,filename:f})}else if(u)Oe(h.content);else{try{await navigator.clipboard.writeText(h.content),K.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const v=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
252
+ </html>`}async function $n(t){const s=In(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Bt(){const[t,s]=g.useState(null),[a,n]=g.useState(null),[r,i]=g.useState(0),[o,l]=g.useState(!1),[c,p]=g.useState(""),[d,u]=g.useState(""),[h,f]=g.useState(""),[v,j]=g.useState(!1);if(g.useEffect(()=>{let y=!1;return s(null),n(null),wt().then(E=>{y||s(E)}).catch(E=>{y||n(E instanceof Error?E.message:String(E))}),()=>{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 C=t.length,S=t.filter(y=>y.receipt).length;async function x(){if(!(!t||t.length===0)){j(!0);try{await $n({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:h.trim()||void 0}),l(!1)}finally{j(!1)}}}async function b(){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},E=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),_=URL.createObjectURL(E),k=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,T=document.createElement("a");T.href=_,T.download=k,T.click(),setTimeout(()=>URL.revokeObjectURL(_),1e3)}return C===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:[C," ",C===1?"entry":"entries",S>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[S," RFC 3161-anchored"]})]}),S===0&&C>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 b(),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:c,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:d,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:v||C===0,onClick:x,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:v?"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 _n(){const[t,s]=g.useState(null),[a,n]=g.useState(!1);if(g.useEffect(()=>{let c=!1;return wt().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!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(c=>c.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(c=>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 ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(ie,{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(Bt,{})})})]})}function Ln(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Dn={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."},Un={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."},On={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Fn={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ht(){const t=m(u=>u.tier),s=m(u=>u.trialDaysRemaining),a=m(u=>u.seatsUsed),n=m(u=>u.seatsTotal),r=m(u=>u.planCode),i=m(u=>u.licenseDaysRemaining),o=m(u=>u.pastDue),[l,c]=g.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:()=>c(!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 P({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ue,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?Fn:On,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,f=t==="team"&&a!==null&&n!==null&&a>n,v=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"}:v?{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."}),v&&!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 P({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const p=t==="trial"?Dn:Un,d=t==="trial"?Ln(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:d})]}),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:()=>c(!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 P({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(Ue,{open:l,onClose:()=>c(!1)})]})}const Mn={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},Pn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},pt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Gn={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"},ht={critical:0,serious:1,moderate:2,minor:3};function Vn(){const t=m(u=>u.setUserMode),s=m(u=>u.status),a=m(u=>u.setStatus),n=m(u=>u.errorMessage),r=m(u=>u.setError),[i,o]=g.useState(!1),[l,c]=g.useState(!1),p=g.useRef(s);g.useEffect(()=>{if(p.current==="running"&&s==="complete"){c(!0);const u=setTimeout(()=>c(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),g.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{m.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 d(){t("dev"),P({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(Ht,{}),e.jsx(_t,{}),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($t,{}),e.jsx("button",{type:"button",onClick:d,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(Wn,{}),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:()=>{m.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(Vt,{onBack:()=>o(!1)}):e.jsx(Hn,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Bn,{})]}),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 Wn(){const t=m(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 P({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 Bn(){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 Hn({onPickCrawl:t}){const s=m(u=>u.status),a=m(u=>u.results),[n,r]=g.useState("quick"),[i,o]=g.useState("all"),l=s==="running",c=a.flatMap(u=>u.violations),p=a.length>0;function d(){X({type:"START_AUDIT",mode:"full-page",matrixOverride:He(n)}),m.getState().startNewScan(),q.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:d,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(Kn,{depth:n,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(zn,{}),p&&e.jsx(qn,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function zn(){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 Kn({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(xt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${ut("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(xt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${ut("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function xt({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 qn({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var S;const r=m(x=>x.status),i=m(x=>x.results),o=m(x=>x.freshThisSession),l=(S=i[0])==null?void 0:S.startedAt,c=jt(t),p=r==="running";function d(){X({type:"START_AUDIT",mode:"full-page",matrixOverride:He(n)}),m.getState().startNewScan(),q.polite("Re-scanning this page now.")}const u=s==="lawsuit-risk"?t.filter(x=>x.impact==="critical"||x.impact==="serious"):t,h=new Map;for(const x of u){const b=Ve(x.ruleId,x.target.selector);h.has(b)||h.set(b,x)}const f=Array.from(h.values()),v=new Map;for(const x of f){const b=v.get(x.ruleId)??[];b.push(x),v.set(x.ruleId,b)}const j=Array.from(v.entries()).sort((x,b)=>(ht[x[1][0].impact]??99)-(ht[b[1][0].impact]??99)),C=t.filter(x=>x.impact==="critical"||x.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:[l&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Xn,{iso:l})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void We(),disabled:p,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:d,disabled:p,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:p?"Scanning…":"↻ Scan again"})]})]}),p?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 ${Mn[c.risk]}`,children:[!o&&l&&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 ${Pn[c.letter]} text-white shrink-0`,"aria-label":`Grade ${c.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:c.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:`text-base font-semibold ${pt[c.risk]}`,children:yt[c.risk]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${pt[c.risk]}`,children:os[c.risk]}),e.jsxs("div",{className:"flex gap-3 mt-2 text-xs flex-wrap",children:[c.totals.critical>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.critical})," critical"]}),c.totals.serious>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.serious})," serious"]}),c.totals.moderate>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.moderate})," moderate"]}),c.totals.minor>0&&e.jsxs("span",{children:[e.jsx("strong",{children:c.totals.minor})," minor"]}),c.totals.unique===0&&e.jsx("span",{children:"No automated issues found ✓"})]})]})]})]}),e.jsx(Yn,{}),e.jsx(_n,{}),t.length>0&&e.jsx(Qn,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[j.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."]}),j.map(([x,b])=>e.jsx(Jn,{ruleId:x,violations:b},x))]})]})}function Qn({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 Jn({ruleId:t,violations:s}){var l;const[a,n]=g.useState(!1),r=(l=s.find(c=>c.target.opacityContext))==null?void 0:l.target.opacityContext,i=ls(t,r),o=s[0].impact;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 ${Gn[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:i.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[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]})]})]})}const me=[{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 Yn(){const t=m(d=>d.results),s=m(d=>d.componentId),[a,n]=g.useState(null),[r,i]=g.useState(!1),[o,l]=g.useState(null);async function c(d,u){if(t.length!==0){n(d);try{const h=await M({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const f=ft(d,s);await bt()?Pe(h.content,f):l({open:!0,format:d,content:h.content,filename:f})}else if(u)Me(h.content);else{try{await navigator.clipboard.writeText(h.content),q.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const v=`<!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>`,w=new Blob([v],{type:"text/html"}),C=URL.createObjectURL(w);window.open(C,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(C),6e4)}}finally{a(null)}}}const p=r?xe:xe.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(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.isHtml),disabled:n!==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:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),n===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",xe.length-2," more report option",xe.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Gt,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Ja({iso:t}){const[,s]=g.useState(0);g.useEffect(()=>{const a=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(a)},[]);const n=Math.floor((Date.now()-new Date(t).getTime())/1e3);return n<5?e.jsx("span",{children:"just now"}):n<60?e.jsxs("span",{children:[n," seconds ago"]}):n<120?e.jsx("span",{children:"1 minute ago"}):n<3600?e.jsxs("span",{children:[Math.floor(n/60)," minutes ago"]}):n<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(n/3600)," hours ago"]})}const Ya=[{id:"1.1.1",title:"Non-text Content",level:"A",addedIn:"2.0",understandingSlug:"non-text-content",shortDescription:"All non-text content has a text alternative."},{id:"1.2.1",title:"Audio-only and Video-only (Prerecorded)",level:"A",addedIn:"2.0",understandingSlug:"audio-only-and-video-only-prerecorded",shortDescription:"Alternatives for prerecorded audio-only or video-only."},{id:"1.2.2",title:"Captions (Prerecorded)",level:"A",addedIn:"2.0",understandingSlug:"captions-prerecorded",shortDescription:"Captions for prerecorded audio in synchronized media."},{id:"1.2.3",title:"Audio Description or Media Alternative (Prerecorded)",level:"A",addedIn:"2.0",understandingSlug:"audio-description-or-media-alternative-prerecorded",shortDescription:"Alternative for time-based media (prerecorded)."},{id:"1.2.4",title:"Captions (Live)",level:"AA",addedIn:"2.0",understandingSlug:"captions-live",shortDescription:"Captions for live synchronized media."},{id:"1.2.5",title:"Audio Description (Prerecorded)",level:"AA",addedIn:"2.0",understandingSlug:"audio-description-prerecorded",shortDescription:"Audio description for prerecorded video in synchronized media."},{id:"1.2.6",title:"Sign Language (Prerecorded)",level:"AAA",addedIn:"2.0",understandingSlug:"sign-language-prerecorded",shortDescription:"Sign-language interpretation for prerecorded audio."},{id:"1.2.7",title:"Extended Audio Description (Prerecorded)",level:"AAA",addedIn:"2.0",understandingSlug:"extended-audio-description-prerecorded",shortDescription:"Extended audio description for prerecorded video."},{id:"1.2.8",title:"Media Alternative (Prerecorded)",level:"AAA",addedIn:"2.0",understandingSlug:"media-alternative-prerecorded",shortDescription:"Alternative for time-based media (prerecorded)."},{id:"1.2.9",title:"Audio-only (Live)",level:"AAA",addedIn:"2.0",understandingSlug:"audio-only-live",shortDescription:"Alternative for live audio-only content."},{id:"1.3.1",title:"Info and Relationships",level:"A",addedIn:"2.0",understandingSlug:"info-and-relationships",shortDescription:"Information and structural relationships are programmatically determinable."},{id:"1.3.2",title:"Meaningful Sequence",level:"A",addedIn:"2.0",understandingSlug:"meaningful-sequence",shortDescription:"Reading sequence is programmatically determinable."},{id:"1.3.3",title:"Sensory Characteristics",level:"A",addedIn:"2.0",understandingSlug:"sensory-characteristics",shortDescription:"Instructions don't rely solely on shape, color, size, or sound."},{id:"1.3.4",title:"Orientation",level:"AA",addedIn:"2.1",understandingSlug:"orientation",shortDescription:"Content doesn't restrict view to portrait or landscape."},{id:"1.3.5",title:"Identify Input Purpose",level:"AA",addedIn:"2.1",understandingSlug:"identify-input-purpose",shortDescription:"Purpose of input fields is programmatically identifiable."},{id:"1.3.6",title:"Identify Purpose",level:"AAA",addedIn:"2.1",understandingSlug:"identify-purpose",shortDescription:"Purpose of UI components, icons, and regions is identifiable."},{id:"1.4.1",title:"Use of Color",level:"A",addedIn:"2.0",understandingSlug:"use-of-color",shortDescription:"Color is not the only means of conveying information."},{id:"1.4.2",title:"Audio Control",level:"A",addedIn:"2.0",understandingSlug:"audio-control",shortDescription:"Mechanism to pause/stop auto-playing audio over 3s."},{id:"1.4.3",title:"Contrast (Minimum)",level:"AA",addedIn:"2.0",understandingSlug:"contrast-minimum",shortDescription:"Text has 4.5:1 contrast (3:1 for large text)."},{id:"1.4.4",title:"Resize Text",level:"AA",addedIn:"2.0",understandingSlug:"resize-text",shortDescription:"Text resizable to 200% without loss of content/function."},{id:"1.4.5",title:"Images of Text",level:"AA",addedIn:"2.0",understandingSlug:"images-of-text",shortDescription:"Text used in preference to images of text where possible."},{id:"1.4.6",title:"Contrast (Enhanced)",level:"AAA",addedIn:"2.0",understandingSlug:"contrast-enhanced",shortDescription:"Text has 7:1 contrast (4.5:1 for large text)."},{id:"1.4.7",title:"Low or No Background Audio",level:"AAA",addedIn:"2.0",understandingSlug:"low-or-no-background-audio",shortDescription:"Background audio at least 20dB lower than speech."},{id:"1.4.8",title:"Visual Presentation",level:"AAA",addedIn:"2.0",understandingSlug:"visual-presentation",shortDescription:"Configurable visual presentation for blocks of text."},{id:"1.4.9",title:"Images of Text (No Exception)",level:"AAA",addedIn:"2.0",understandingSlug:"images-of-text-no-exception",shortDescription:"Images of text used only for decoration / essential."},{id:"1.4.10",title:"Reflow",level:"AA",addedIn:"2.1",understandingSlug:"reflow",shortDescription:"Content reflows at 320 CSS px without 2D scrolling."},{id:"1.4.11",title:"Non-text Contrast",level:"AA",addedIn:"2.1",understandingSlug:"non-text-contrast",shortDescription:"UI components and graphical objects have 3:1 contrast."},{id:"1.4.12",title:"Text Spacing",level:"AA",addedIn:"2.1",understandingSlug:"text-spacing",shortDescription:"Text spacing overrides don't cause content loss."},{id:"1.4.13",title:"Content on Hover or Focus",level:"AA",addedIn:"2.1",understandingSlug:"content-on-hover-or-focus",shortDescription:"Hover/focus tooltips are dismissible, hoverable, persistent."},{id:"2.1.1",title:"Keyboard",level:"A",addedIn:"2.0",understandingSlug:"keyboard",shortDescription:"All functionality available from the keyboard."},{id:"2.1.2",title:"No Keyboard Trap",level:"A",addedIn:"2.0",understandingSlug:"no-keyboard-trap",shortDescription:"Keyboard focus can move away from any component."},{id:"2.1.3",title:"Keyboard (No Exception)",level:"AAA",addedIn:"2.0",understandingSlug:"keyboard-no-exception",shortDescription:"All functionality is keyboard-operable without timing."},{id:"2.1.4",title:"Character Key Shortcuts",level:"A",addedIn:"2.1",understandingSlug:"character-key-shortcuts",shortDescription:"Single-key shortcuts can be turned off or remapped."},{id:"2.2.1",title:"Timing Adjustable",level:"A",addedIn:"2.0",understandingSlug:"timing-adjustable",shortDescription:"User can turn off, adjust, or extend time limits."},{id:"2.2.2",title:"Pause, Stop, Hide",level:"A",addedIn:"2.0",understandingSlug:"pause-stop-hide",shortDescription:"Moving/blinking/scrolling content can be paused."},{id:"2.2.3",title:"No Timing",level:"AAA",addedIn:"2.0",understandingSlug:"no-timing",shortDescription:"No timing essential to content/function (with exceptions)."},{id:"2.2.4",title:"Interruptions",level:"AAA",addedIn:"2.0",understandingSlug:"interruptions",shortDescription:"User can postpone/suppress non-emergency interruptions."},{id:"2.2.5",title:"Re-authenticating",level:"AAA",addedIn:"2.0",understandingSlug:"re-authenticating",shortDescription:"Authenticated session can be resumed without data loss."},{id:"2.2.6",title:"Timeouts",level:"AAA",addedIn:"2.1",understandingSlug:"timeouts",shortDescription:"Inactivity timeouts warned in advance."},{id:"2.3.1",title:"Three Flashes or Below Threshold",level:"A",addedIn:"2.0",understandingSlug:"three-flashes-or-below-threshold",shortDescription:"No content flashes more than 3 times per second."},{id:"2.3.2",title:"Three Flashes",level:"AAA",addedIn:"2.0",understandingSlug:"three-flashes",shortDescription:"No content flashes more than 3 times per second (no exceptions)."},{id:"2.3.3",title:"Animation from Interactions",level:"AAA",addedIn:"2.1",understandingSlug:"animation-from-interactions",shortDescription:"Motion animation from interactions can be disabled."},{id:"2.4.1",title:"Bypass Blocks",level:"A",addedIn:"2.0",understandingSlug:"bypass-blocks",shortDescription:"Mechanism to skip blocks of repeated content."},{id:"2.4.2",title:"Page Titled",level:"A",addedIn:"2.0",understandingSlug:"page-titled",shortDescription:"Pages have titles that describe topic/purpose."},{id:"2.4.3",title:"Focus Order",level:"A",addedIn:"2.0",understandingSlug:"focus-order",shortDescription:"Components receive focus in a meaningful order."},{id:"2.4.4",title:"Link Purpose (In Context)",level:"A",addedIn:"2.0",understandingSlug:"link-purpose-in-context",shortDescription:"Link purpose is clear from the link text + context."},{id:"2.4.5",title:"Multiple Ways",level:"AA",addedIn:"2.0",understandingSlug:"multiple-ways",shortDescription:"Two or more ways to locate a page within a set."},{id:"2.4.6",title:"Headings and Labels",level:"AA",addedIn:"2.0",understandingSlug:"headings-and-labels",shortDescription:"Headings and labels describe topic or purpose."},{id:"2.4.7",title:"Focus Visible",level:"AA",addedIn:"2.0",understandingSlug:"focus-visible",shortDescription:"Keyboard focus indicator is visible."},{id:"2.4.8",title:"Location",level:"AAA",addedIn:"2.0",understandingSlug:"location",shortDescription:"Information about user's location within a set is available."},{id:"2.4.9",title:"Link Purpose (Link Only)",level:"AAA",addedIn:"2.0",understandingSlug:"link-purpose-link-only",shortDescription:"Link purpose clear from the link text alone."},{id:"2.4.10",title:"Section Headings",level:"AAA",addedIn:"2.0",understandingSlug:"section-headings",shortDescription:"Section headings are used to organize content."},{id:"2.4.11",title:"Focus Not Obscured (Minimum)",level:"AA",addedIn:"2.2",understandingSlug:"focus-not-obscured-minimum",shortDescription:"Focused component not entirely hidden by other content."},{id:"2.4.12",title:"Focus Not Obscured (Enhanced)",level:"AAA",addedIn:"2.2",understandingSlug:"focus-not-obscured-enhanced",shortDescription:"Focused component fully visible."},{id:"2.4.13",title:"Focus Appearance",level:"AAA",addedIn:"2.2",understandingSlug:"focus-appearance",shortDescription:"Focus indicator meets specific size/contrast requirements."},{id:"2.5.1",title:"Pointer Gestures",level:"A",addedIn:"2.1",understandingSlug:"pointer-gestures",shortDescription:"Multi-point or path-based gestures have single-pointer alternatives."},{id:"2.5.2",title:"Pointer Cancellation",level:"A",addedIn:"2.1",understandingSlug:"pointer-cancellation",shortDescription:"Pointer actions can be aborted or undone."},{id:"2.5.3",title:"Label in Name",level:"A",addedIn:"2.1",understandingSlug:"label-in-name",shortDescription:"Accessible name includes the visible label text."},{id:"2.5.4",title:"Motion Actuation",level:"A",addedIn:"2.1",understandingSlug:"motion-actuation",shortDescription:"Motion-triggered functions have UI alternatives + can be disabled."},{id:"2.5.5",title:"Target Size (Enhanced)",level:"AAA",addedIn:"2.1",understandingSlug:"target-size-enhanced",shortDescription:"Pointer target size at least 44×44 CSS px."},{id:"2.5.6",title:"Concurrent Input Mechanisms",level:"AAA",addedIn:"2.1",understandingSlug:"concurrent-input-mechanisms",shortDescription:"Content doesn't restrict input modality."},{id:"2.5.7",title:"Dragging Movements",level:"AA",addedIn:"2.2",understandingSlug:"dragging-movements",shortDescription:"Dragging actions have single-pointer alternatives."},{id:"2.5.8",title:"Target Size (Minimum)",level:"AA",addedIn:"2.2",understandingSlug:"target-size-minimum",shortDescription:"Pointer target size at least 24×24 CSS px."},{id:"3.1.1",title:"Language of Page",level:"A",addedIn:"2.0",understandingSlug:"language-of-page",shortDescription:"Default human language of the page is programmatically set."},{id:"3.1.2",title:"Language of Parts",level:"AA",addedIn:"2.0",understandingSlug:"language-of-parts",shortDescription:"Language of each passage is programmatically set."},{id:"3.1.3",title:"Unusual Words",level:"AAA",addedIn:"2.0",understandingSlug:"unusual-words",shortDescription:"Definitions provided for jargon, idioms, etc."},{id:"3.1.4",title:"Abbreviations",level:"AAA",addedIn:"2.0",understandingSlug:"abbreviations",shortDescription:"Expanded form or meaning of abbreviations is available."},{id:"3.1.5",title:"Reading Level",level:"AAA",addedIn:"2.0",understandingSlug:"reading-level",shortDescription:"Supplemental content provided for advanced reading levels."},{id:"3.1.6",title:"Pronunciation",level:"AAA",addedIn:"2.0",understandingSlug:"pronunciation",shortDescription:"Mechanism for pronunciation of words where meaning is ambiguous."},{id:"3.2.1",title:"On Focus",level:"A",addedIn:"2.0",understandingSlug:"on-focus",shortDescription:"Focus does not trigger an unexpected context change."},{id:"3.2.2",title:"On Input",level:"A",addedIn:"2.0",understandingSlug:"on-input",shortDescription:"Input does not trigger an unexpected context change."},{id:"3.2.3",title:"Consistent Navigation",level:"AA",addedIn:"2.0",understandingSlug:"consistent-navigation",shortDescription:"Navigation is consistent across a set of pages."},{id:"3.2.4",title:"Consistent Identification",level:"AA",addedIn:"2.0",understandingSlug:"consistent-identification",shortDescription:"Components with the same function are identified consistently."},{id:"3.2.5",title:"Change on Request",level:"AAA",addedIn:"2.0",understandingSlug:"change-on-request",shortDescription:"Changes of context only on user request."},{id:"3.2.6",title:"Consistent Help",level:"A",addedIn:"2.2",understandingSlug:"consistent-help",shortDescription:"Help mechanisms appear in consistent order across pages."},{id:"3.3.1",title:"Error Identification",level:"A",addedIn:"2.0",understandingSlug:"error-identification",shortDescription:"Form errors are identified and described in text."},{id:"3.3.2",title:"Labels or Instructions",level:"A",addedIn:"2.0",understandingSlug:"labels-or-instructions",shortDescription:"Form fields have labels or instructions."},{id:"3.3.3",title:"Error Suggestion",level:"AA",addedIn:"2.0",understandingSlug:"error-suggestion",shortDescription:"Error suggestions provided when known."},{id:"3.3.4",title:"Error Prevention (Legal, Financial, Data)",level:"AA",addedIn:"2.0",understandingSlug:"error-prevention-legal-financial-data",shortDescription:"Submissions are reversible, checked, or confirmed."},{id:"3.3.5",title:"Help",level:"AAA",addedIn:"2.0",understandingSlug:"help",shortDescription:"Context-sensitive help is available."},{id:"3.3.6",title:"Error Prevention (All)",level:"AAA",addedIn:"2.0",understandingSlug:"error-prevention-all",shortDescription:"All submissions reversible, checked, or confirmed."},{id:"3.3.7",title:"Redundant Entry",level:"A",addedIn:"2.2",understandingSlug:"redundant-entry",shortDescription:"Previously-entered information is auto-populated or selectable."},{id:"3.3.8",title:"Accessible Authentication (Minimum)",level:"AA",addedIn:"2.2",understandingSlug:"accessible-authentication-minimum",shortDescription:"Auth doesn't require cognitive function test."},{id:"3.3.9",title:"Accessible Authentication (Enhanced)",level:"AAA",addedIn:"2.2",understandingSlug:"accessible-authentication-enhanced",shortDescription:"Auth doesn't require cognitive function test (no exceptions)."},{id:"4.1.1",title:"Parsing",level:"A",addedIn:"2.0",removedIn:"2.2",understandingSlug:"parsing",shortDescription:"Markup is well-formed (obsoleted in WCAG 2.2)."},{id:"4.1.2",title:"Name, Role, Value",level:"A",addedIn:"2.0",understandingSlug:"name-role-value",shortDescription:"UI components have programmatically determinable name + role + state."},{id:"4.1.3",title:"Status Messages",level:"AA",addedIn:"2.1",understandingSlug:"status-messages",shortDescription:"Status messages programmatically announced without focus change."}];function Xa(t,s){const n={A:1,AA:2,AAA:3},a={"2.0":1,"2.1":2,"2.2":3};return Ya.filter(r=>a[r.addedIn]>a[t]||r.removedIn&&a[r.removedIn]<=a[t]?!1:n[r.level]<=n[s])}function Za(t,s){return`https://www.w3.org/WAI/WCAG${s.replace(".","")}/Understanding/${t.understandingSlug}`}function er(t,s){const n=new Set,a=[];for(const[r,i]of s)for(const o of i)for(const l of o.violations)l.wcagCriterion===t&&(n.add(l.ruleId),a.push({source:"axe",ruleOrStepId:l.ruleId,description:l.description||l.ruleId,pageUrl:r,selector:l.target.selector}));return{rulesFiring:n,failures:a}}function tr(t,s,n){const a=[];let r=0,i=0;for(const o of n){const l=o.steps.filter(c=>c.wcag===t);if(l.length!==0){r+=l.length;for(const[c,p]of s){const d=p[o.id];if(!d){i+=l.length;continue}for(const u of l){const h=d.steps[u.id];if(!h){i++;continue}h.status==="fail"?a.push({source:"igt",ruleOrStepId:`${o.id}.${u.id}`,description:u.question,pageUrl:c,notes:h.notes}):h.status==="skip"&&i++}}}}return{stepsCovering:r,failures:a,unanswered:i}}function sr(t,s){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0?"inconclusive":"pass"}function nr(t,s,n){switch(s){case"pass":return`${n.axeRulesFiringForCriterion+n.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${n.axeFailures.length} automated finding(s), ${n.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 ar(t,s){var c;const n=Xa(t.targetVersion,t.targetLevel),a=[];for(const p of n){const d=er(p.id,s.auditsByUrl),u=tr(p.id,s.igtRunsByUrl,s.workflows),h=d.rulesFiring.size===0&&u.stepsCovering===0,f={axeRulesFiringForCriterion:d.rulesFiring.size,axeFailures:d.failures,igtStepsCoveringCriterion:u.stepsCovering,igtFailures:u.failures,unmapped:h},v=(c=t.overrides)==null?void 0:c[p.id];let w,C,A=!1;v?(w=v.verdict,C=v.rationale,A=!0):(w=sr(f,u.unanswered),C=nr(p,w,f)),a.push({criterion:p,understandingUrl:Za(p,t.targetVersion),verdict:w,signals:f,overridden:A,rationale:C})}const r={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const p of a)p.verdict==="pass"?r.pass++:p.verdict==="fail"?r.fail++:p.verdict==="inconclusive"?r.inconclusive++:p.verdict==="not-applicable"?r.notApplicable++:p.verdict==="not-evaluated"&&r.notEvaluated++;function i(p){const d={A:1,AA:2,AAA:3},u=d[p];return a.every(h=>d[h.criterion.level]>u?!0:h.verdict==="pass"||h.verdict==="not-applicable")}let o=null;i("AAA")?o="AAA":i("AA")?o="AA":i("A")&&(o="A");const l=o===t.targetLevel||o==="AAA"&&t.targetLevel==="AA"||o==="AAA"&&t.targetLevel==="A"||o==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:a,summary:{totalCriteria:a.length,pass:r.pass,fail:r.fail,inconclusive:r.inconclusive,notApplicable:r.notApplicable,notEvaluated:r.notEvaluated,levelAchieved:o,meetsTarget:l}}}const rr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},xt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function N(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function _e(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 ir(t,s){const{inputs:n,rows:a,summary:r,generatedAt:i}=t,o=r.meetsTarget?`MEETS WCAG ${n.targetVersion} Level ${n.targetLevel}`:`DOES NOT MEET WCAG ${n.targetVersion} Level ${n.targetLevel}`,l=new Map;for(const p of a){const d=p.criterion.id.split(".").slice(0,2).join("."),u=l.get(d)??[];u.push(p),l.set(d,u)}const c=Array.from(l.entries()).sort(([p],[d])=>p.localeCompare(d,void 0,{numeric:!0})).map(([p,d])=>`
257
+ <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,j=new Blob([v],{type:"text/html"}),C=URL.createObjectURL(j);window.open(C,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(C),6e4)}}finally{n(null)}}}const p=r?me:me.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(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.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:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",me.length-2," more report option",me.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Gt,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Xn({iso:t}){const[,s]=g.useState(0);g.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 Zn(t,s){const a=new Set,n=[];let r=!1;for(const[i,o]of s)for(const l of o){for(const p of l.violations)p.wcagCriterion===t&&(a.add(p.ruleId),n.push({source:"axe",ruleOrStepId:p.ruleId,description:p.description||p.ruleId,pageUrl:i,selector:p.target.selector}));const c=l.axeRulesEvaluated;if(c){for(const p of c.passed)p.wcagCriterion===t&&a.add(p.ruleId);for(const p of c.inapplicable)p.wcagCriterion===t&&a.add(p.ruleId);for(const p of c.incomplete)p.wcagCriterion===t&&(a.add(p.ruleId),r=!0)}}return{rulesFiring:a,failures:n,hasIncomplete:r}}function er(t,s,a){const n=[];let r=0,i=0;for(const o of a){const l=o.steps.filter(c=>c.wcag===t);if(l.length!==0){r+=l.length;for(const[c,p]of s){const d=p[o.id];if(!d){i+=l.length;continue}for(const u of l){const h=d.steps[u.id];if(!h){i++;continue}h.status==="fail"?n.push({source:"igt",ruleOrStepId:`${o.id}.${u.id}`,description:u.question,pageUrl:c,notes:h.notes}):h.status==="skip"&&i++}}}}return{stepsCovering:r,failures:n,unanswered:i}}function tr(t,s,a){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":"pass"}function sr(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 ar(t,s){var c;const a=cs(t.targetVersion,t.targetLevel),n=[];for(const p of a){const d=Zn(p.id,s.auditsByUrl),u=er(p.id,s.igtRunsByUrl,s.workflows),h=d.rulesFiring.size===0&&u.stepsCovering===0,f={axeRulesFiringForCriterion:d.rulesFiring.size,axeFailures:d.failures,igtStepsCoveringCriterion:u.stepsCovering,igtFailures:u.failures,unmapped:h},v=(c=t.overrides)==null?void 0:c[p.id];let j,C,S=!1;v?(j=v.verdict,C=v.rationale,S=!0):(j=tr(f,u.unanswered,d.hasIncomplete),C=sr(p,j,f)),n.push({criterion:p,understandingUrl:ds(p,t.targetVersion),verdict:j,signals:f,overridden:S,rationale:C})}const r={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const p of n)p.verdict==="pass"?r.pass++:p.verdict==="fail"?r.fail++:p.verdict==="inconclusive"?r.inconclusive++:p.verdict==="not-applicable"?r.notApplicable++:p.verdict==="not-evaluated"&&r.notEvaluated++;function i(p){const d={A:1,AA:2,AAA:3},u=d[p];return n.every(h=>d[h.criterion.level]>u?!0:h.verdict==="pass"||h.verdict==="not-applicable")}let o=null;i("AAA")?o="AAA":i("AA")?o="AA":i("A")&&(o="A");const l=o===t.targetLevel||o==="AAA"&&t.targetLevel==="AA"||o==="AAA"&&t.targetLevel==="A"||o==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:n,summary:{totalCriteria:n.length,pass:r.pass,fail:r.fail,inconclusive:r.inconclusive,notApplicable:r.notApplicable,notEvaluated:r.notEvaluated,levelAchieved:o,meetsTarget:l}}}const nr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},mt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function N(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Le(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 rr(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 d=p.criterion.id.split(".").slice(0,2).join("."),u=l.get(d)??[];u.push(p),l.set(d,u)}const c=Array.from(l.entries()).sort(([p],[d])=>p.localeCompare(d,void 0,{numeric:!0})).map(([p,d])=>`
258
258
  <h3 class="guideline-h">Guideline ${N(p)}</h3>
259
259
  <table class="criteria-table">
260
260
  <thead>
@@ -264,11 +264,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
264
264
  </thead>
265
265
  <tbody>
266
266
  ${d.map(u=>`
267
- <tr class="${xt[u.verdict]}">
267
+ <tr class="${mt[u.verdict]}">
268
268
  <td><a href="${N(u.understandingUrl)}" target="_blank" rel="noopener">${N(u.criterion.id)}</a></td>
269
269
  <td>${N(u.criterion.title)}</td>
270
270
  <td>${N(u.criterion.level)}</td>
271
- <td><span class="verdict-badge ${xt[u.verdict]}">${rr[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
271
+ <td><span class="verdict-badge ${mt[u.verdict]}">${nr[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
272
272
  <td class="rationale">${N(u.rationale)}</td>
273
273
  </tr>
274
274
  ${u.signals.axeFailures.length>0||u.signals.igtFailures.length>0?`
@@ -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 ${N(n.targetVersion)} Level ${N(n.targetLevel)} Conformance Report — ${N(n.siteName)}</title>
303
+ <title>WCAG ${N(a.targetVersion)} Level ${N(a.targetLevel)} Conformance Report — ${N(a.siteName)}</title>
304
304
  <style>
305
305
  *, *::before, *::after { box-sizing: border-box; }
306
306
  body {
@@ -398,24 +398,24 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
398
398
  </head>
399
399
  <body>
400
400
  <section class="cover">
401
- <p class="eyebrow">WCAG ${N(n.targetVersion)} Conformance Evaluation Report</p>
402
- <h1>${N(n.siteName)}</h1>
403
- <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${N(n.siteUrl)}</code></p>
401
+ <p class="eyebrow">WCAG ${N(a.targetVersion)} Conformance Evaluation Report</p>
402
+ <h1>${N(a.siteName)}</h1>
403
+ <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${N(a.siteUrl)}</code></p>
404
404
  <div class="conformance-banner ${r.meetsTarget?"met":"not-met"}">
405
405
  ${N(o)}
406
406
  </div>
407
407
  <dl class="meta">
408
408
  <dt>Highest level fully satisfied</dt>
409
- <dd>${r.levelAchieved?`WCAG ${N(n.targetVersion)} Level ${N(r.levelAchieved)}`:"None (target level not met)"}</dd>
409
+ <dd>${r.levelAchieved?`WCAG ${N(a.targetVersion)} Level ${N(r.levelAchieved)}`:"None (target level not met)"}</dd>
410
410
  <dt>Target conformance level</dt>
411
- <dd>WCAG ${N(n.targetVersion)} Level ${N(n.targetLevel)}</dd>
411
+ <dd>WCAG ${N(a.targetVersion)} Level ${N(a.targetLevel)}</dd>
412
412
  <dt>Report generated</dt>
413
- <dd>${N(_e(i))}</dd>
413
+ <dd>${N(Le(i))}</dd>
414
414
  <dt>Evaluator</dt>
415
415
  <dd>
416
- ${N(n.evaluator.name)}
417
- ${n.evaluator.organization?`, ${N(n.evaluator.organization)}`:""}
418
- ${n.evaluator.qualifications?`<br><span style="color: #64748b">${N(n.evaluator.qualifications)}</span>`:""}
416
+ ${N(a.evaluator.name)}
417
+ ${a.evaluator.organization?`, ${N(a.evaluator.organization)}`:""}
418
+ ${a.evaluator.qualifications?`<br><span style="color: #64748b">${N(a.evaluator.qualifications)}</span>`:""}
419
419
  </dd>
420
420
  </dl>
421
421
  </section>
@@ -431,22 +431,22 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
431
431
 
432
432
  <h2>1 — Evaluation scope</h2>
433
433
  <dl class="meta">
434
- <dt>Website / application</dt><dd><strong>${N(n.siteName)}</strong> — <code>${N(n.siteUrl)}</code></dd>
435
- <dt>Conformance target</dt><dd>WCAG ${N(n.targetVersion)} Level ${N(n.targetLevel)}</dd>
434
+ <dt>Website / application</dt><dd><strong>${N(a.siteName)}</strong> — <code>${N(a.siteUrl)}</code></dd>
435
+ <dt>Conformance target</dt><dd>WCAG ${N(a.targetVersion)} Level ${N(a.targetLevel)}</dd>
436
436
  <dt>Accessibility-support baseline</dt>
437
- <dd>${N(n.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
438
- ${n.additionalStandards&&n.additionalStandards.length>0?`
437
+ <dd>${N(a.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
438
+ ${a.additionalStandards&&a.additionalStandards.length>0?`
439
439
  <dt>Additional standards evaluated against</dt>
440
- <dd>${n.additionalStandards.map(N).join(", ")}</dd>
440
+ <dd>${a.additionalStandards.map(N).join(", ")}</dd>
441
441
  `:""}
442
442
  </dl>
443
443
 
444
444
  <h2>2 — Sample of representative pages</h2>
445
- ${n.pageSample.length===0?"<p><em>No page sample recorded.</em></p>":`
445
+ ${a.pageSample.length===0?"<p><em>No page sample recorded.</em></p>":`
446
446
  <table class="sample-table">
447
447
  <thead><tr><th>URL</th><th>Page type</th><th>Selection</th><th>Data?</th></tr></thead>
448
448
  <tbody>
449
- ${n.pageSample.map(p=>`
449
+ ${a.pageSample.map(p=>`
450
450
  <tr>
451
451
  <td><a href="${N(p.url)}" target="_blank" rel="noopener"><code>${N(p.url)}</code></a></td>
452
452
  <td>${N(p.pageType)}</td>
@@ -475,7 +475,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
475
475
 
476
476
  <section class="attestation">
477
477
  <h3>Conformance claim</h3>
478
- <p>${r.meetsTarget?`Based on the evidence collected, <strong>${N(n.siteName)}</strong> meets the success criteria required for <strong>WCAG ${N(n.targetVersion)} Level ${N(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>${N(n.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${N(n.targetVersion)} Level ${N(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>
478
+ <p>${r.meetsTarget?`Based on the evidence collected, <strong>${N(a.siteName)}</strong> meets the success criteria required for <strong>WCAG ${N(a.targetVersion)} Level ${N(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>${N(a.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${N(a.targetVersion)} Level ${N(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
479
  <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
480
  </section>
481
481
 
@@ -485,7 +485,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
485
485
  <p style="font-size: 10pt;">The content of this report was hashed and the hash was anchored to a public RFC 3161 Time Stamping Authority, then counter-signed by the wcagcheckr server's ed25519 key. Any alteration to the conformance-bearing content above invalidates the hash; the receipt below is verifiable offline by anyone with the wcagcheckr-ci CLI.</p>
486
486
  <table class="anchor-table">
487
487
  <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${N(s.reportHash)}</code></td></tr>
488
- <tr><th>Anchored at</th><td>${N(_e(s.receipt.anchoredAt))}</td></tr>
488
+ <tr><th>Anchored at</th><td>${N(Le(s.receipt.anchoredAt))}</td></tr>
489
489
  <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${N(s.receipt.tsaName)}</td></tr>
490
490
  <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${N(s.receipt.serverKeyFingerprint)}</code></td></tr>
491
491
  ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${N(s.receipt.prevAuditHash)}</code></td></tr>`:""}
@@ -510,15 +510,15 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
510
510
 
511
511
  <section class="declaration">
512
512
  <h3>Evaluator declaration</h3>
513
- <p>I, <strong>${N(n.evaluator.name)}</strong>${n.evaluator.organization?` of <strong>${N(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: ${N(n.evaluator.qualifications)}.`:""} ${n.evaluator.contact?`I may be contacted at <code>${N(n.evaluator.contact)}</code>.`:""}</p>
513
+ <p>I, <strong>${N(a.evaluator.name)}</strong>${a.evaluator.organization?` of <strong>${N(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: ${N(a.evaluator.qualifications)}.`:""} ${a.evaluator.contact?`I may be contacted at <code>${N(a.evaluator.contact)}</code>.`:""}</p>
514
514
  <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
515
  </section>
516
516
 
517
517
  <footer class="report-footer">
518
- <span>Generated ${N(_e(i))} by wcagcheckr</span>
518
+ <span>Generated ${N(Le(i))} by wcagcheckr</span>
519
519
  <span>${r.totalCriteria} criteria · ${r.pass} pass · ${r.fail} fail · ${r.inconclusive} inconclusive</span>
520
520
  </footer>
521
521
  </body>
522
- </html>`}async function or(t,s){const n=ir(t,s),a=new Blob([n],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(a);await chrome.tabs.create({url:r})}const Le=vt("wcag-em-anchor"),lr="https://api.wcagcheckr.com",cr="wcagcheckr",dr=15e3;function zt(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 ur(t){const s=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}async function pr(t){return ur(cs(zt(t)))}function hr(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 mr(t,s){const n=await pr(t),a={auditHash:n,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${lr}/v1/products/${cr}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a),signal:AbortSignal.timeout(dr)});if(!i.ok)return Le.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return hr(o)?{reportHash:n,capturedAt:t.generatedAt,receipt:o}:(Le.warn("anchor returned malformed receipt",o),null)}catch(i){return Le.warn("anchor request failed",i),null}}function xr(t,s,n){return{schemaVersion:1,tool:{name:"wcagcheckr",version:n},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:zt(t)}}const gt="igtRuns",gr={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"},fr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function br(){const t=x(k=>k.results),[s,n]=g.useState(""),[a,r]=g.useState(""),[i,o]=g.useState("2.1"),[l,c]=g.useState("AA"),[p,d]=g.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[u,h]=g.useState(""),[f,v]=g.useState(""),[w,C]=g.useState(""),[A,m]=g.useState(""),[b,y]=g.useState(""),[I,D]=g.useState(""),[S,R]=g.useState({}),[j,T]=g.useState(!1),[_,E]=g.useState(null),[L,U]=g.useState(!1),[F,Y]=g.useState(null);g.useEffect(()=>{let k=!1;return chrome.storage.local.get(gt).then(G=>{if(k)return;const W=G[gt]??{};R(W),T(!0)}).catch(()=>{k||T(!0)}),()=>{k=!0}},[]),g.useEffect(()=>{var k;if(!s&&((k=t[0])!=null&&k.pageUrl))try{const G=new URL(t[0].pageUrl);n(G.hostname),r(G.origin)}catch{}},[t,s]);const V=g.useMemo(()=>{const k=new Map,G=new Map;for(const B of t){const Z=B.pageUrl??B.scope,J=k.get(Z)??[];J.push(B),k.set(Z,J)}const W=new Map;for(const B of t){const Z=B.pageUrl??B.scope;W.set(B.componentId,Z)}for(const[B,Z]of Object.entries(S)){const J=W.get(B);if(!J)continue;const oe=G.get(J)??{};Object.assign(oe,Z),G.set(J,oe)}return{auditsByUrl:k,igtRunsByUrl:G,workflows:q}},[t,S]),te=g.useMemo(()=>{const k=[],G=new Set;for(const W of V.auditsByUrl.keys())G.has(W)||(G.add(W),k.push({url:W,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const W of I.split(`
523
- `).map(B=>B.trim()).filter(Boolean))G.has(W)||(G.add(W),k.push({url:W,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return k},[V,I]),ze=g.useMemo(()=>({siteName:s||"Untitled site",siteUrl:a||"https://example.com",targetVersion:i,targetLevel:l,accessibilitySupportBaseline:p,additionalStandards:u.split(",").map(k=>k.trim()).filter(Boolean),pageSample:te,evaluator:{name:f||"(evaluator name pending)",organization:w||void 0,qualifications:A||void 0,contact:b||void 0}}),[s,a,i,l,p,u,te,f,w,A,b]),M=g.useMemo(()=>j?ar(ze,V):null,[ze,V,j]);async function qt(){M&&await or(M,_)}async function Kt(){if(M){U(!0),Y(null);try{const k=await mr(M);if(!k){Y("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}E(k)}finally{U(!1)}}}function Qt(){var oe,qe,Ke;if(!M||!_)return;const k=((Ke=(qe=(oe=chrome.runtime).getManifest)==null?void 0:qe.call(oe))==null?void 0:Ke.version)??"0.0.0",G=xr(M,_,k),W=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),B=URL.createObjectURL(W),Z=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,J=document.createElement("a");J.href=B,J.download=Z,J.click(),setTimeout(()=>URL.revokeObjectURL(B),1e3)}return g.useEffect(()=>{E(null),Y(null)},[s,a,i,l,p,u,f,w,A,b,I]),j?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."})]}),M&&M.summary.totalCriteria>0&&e.jsx(vr,{totalCriteria:M.summary.totalCriteria,pass:M.summary.pass,fail:M.summary.fail,inconclusive:M.summary.inconclusive,notEvaluated:M.summary.notEvaluated,levelAchieved:M.summary.levelAchieved,meetsTarget:M.summary.meetsTarget,targetVersion:i,targetLevel:l,auditedUrlCount:V.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:s,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:a,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",{className:"flex gap-2",children:[e.jsxs("label",{className:"flex-1",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Target version"}),e.jsxs("select",{value:i,onChange:k=>o(k.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs",children:[e.jsx("option",{value:"2.0",children:"WCAG 2.0"}),e.jsx("option",{value:"2.1",children:"WCAG 2.1"}),e.jsx("option",{value:"2.2",children:"WCAG 2.2"})]})]}),e.jsxs("label",{className:"flex-1",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Target level"}),e.jsxs("select",{value:l,onChange:k=>c(k.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs",children:[e.jsx("option",{value:"A",children:"Level A"}),e.jsx("option",{value:"AA",children:"Level AA"}),e.jsx("option",{value:"AAA",children:"Level AAA"})]})]})]}),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:p,onChange:k=>d(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:u,onChange:k=>h(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.",V.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:V.auditsByUrl.size})," URL",V.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:I,onChange:k=>D(k.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:f,onChange:k=>v(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:w,onChange:k=>C(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:A,onChange:k=>m(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=>y(k.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),M&&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 (",M.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:M.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 ${gr[k.verdict]}`,children:fr[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"}),_?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:[_.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",_.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.`}),F&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:F}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!M||!s||!f||L,onClick:()=>void Kt(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:L?"Anchoring…":_?"Re-anchor":"Anchor this report"}),_&&e.jsx("button",{type:"button",onClick:Qt,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:!M||!s||!f,onClick:()=>void qt(),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 vr({totalCriteria:t,pass:s,fail:n,inconclusive:a,notEvaluated:r,levelAchieved:i,meetsTarget:o,targetVersion:l,targetLevel:c,auditedUrlCount:p}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${l} Level ${c}`:`Does not currently meet WCAG ${l} Level ${c}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:i??"none"})," · ",t," criteria evaluated across ",p," audited URL",p===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",n," · Inconclusive ",a," · Not evaluated ",r]})]})}function kr(){const t=x(n=>n.view),s=x(n=>n.userMode);return g.useEffect(()=>{const n=ys(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=xs();kt({forceRefresh:!0}).catch(()=>{}),ye().catch(()=>{}),vs().catch(()=>{}),ws().catch(()=>{}),fs().catch(()=>{}),ds().then(l=>{x.getState().setAcknowledgedKeys(new Set(l.map(c=>c.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:c,setPinned:p,results:d}=x.getState();c&&(p(null),H().then(u=>{var h;u&&Q(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(h=d[0])==null?void 0:h.frameId).catch(()=>{})}))};return window.addEventListener("keydown",o),()=>{i(),n.disconnect(),r==null||r.disconnect(),window.removeEventListener("keydown",o)}},[]),s===null?e.jsxs(e.Fragment,{children:[e.jsx(ya,{}),e.jsx(Ce,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{}),e.jsx(dt,{}),e.jsx(Ce,{})]}):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(Ht,{}),e.jsx(Dt,{}),e.jsx(Ls,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Os,{}),e.jsx(Bs,{}),e.jsx(ga,{}),e.jsx(xa,{}),e.jsx(zs,{}),e.jsx(ha,{}),e.jsx(ma,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(wn,{}),t==="delta"&&e.jsx(En,{}),t==="activity"&&e.jsx(Gn,{}),t==="guided"&&e.jsx(Zn,{}),t==="flows"&&e.jsx(na,{}),t==="scorecard"&&e.jsx(ia,{}),t==="crawl"&&e.jsx(Vt,{}),t==="forensic"&&e.jsx(Bt,{}),t==="compliance"&&e.jsx(br,{})]})]}),e.jsx(va,{}),e.jsx(fa,{}),e.jsx(pa,{}),e.jsx(dt,{}),e.jsx(Ce,{})]})}class Cr extends pe.Component{constructor(){super(...arguments);Qe(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,a){console.error("[side-panel] render crashed",n,a.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{kr as A,Cr as E};
522
+ </html>`}async function ir(t,s){const a=rr(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const De=vt("wcag-em-anchor"),or="https://api.wcagcheckr.com",lr="wcagcheckr",cr=15e3;function zt(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 dr(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 ur(t){return dr(us(zt(t)))}function pr(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 hr(t,s){const a=await ur(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${or}/v1/products/${lr}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(cr)});if(!i.ok)return De.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return pr(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(De.warn("anchor returned malformed receipt",o),null)}catch(i){return De.warn("anchor request failed",i),null}}function xr(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:zt(t)}}const gt="igtRuns",mr={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"},gr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function fr(){const t=m(A=>A.results),[s,a]=g.useState(""),[n,r]=g.useState(""),[i,o]=g.useState("2.1"),[l,c]=g.useState("AA"),[p,d]=g.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[u,h]=g.useState(""),[f,v]=g.useState(""),[j,C]=g.useState(""),[S,x]=g.useState(""),[b,y]=g.useState(""),[E,_]=g.useState(""),[k,T]=g.useState({}),[w,I]=g.useState(!1),[L,R]=g.useState(null),[D,U]=g.useState(!1),[O,Y]=g.useState(null);g.useEffect(()=>{let A=!1;return chrome.storage.local.get(gt).then(G=>{if(A)return;const W=G[gt]??{};T(W),I(!0)}).catch(()=>{A||I(!0)}),()=>{A=!0}},[]),g.useEffect(()=>{var A;if(!s&&((A=t[0])!=null&&A.pageUrl))try{const G=new URL(t[0].pageUrl);a(G.hostname),r(G.origin)}catch{}},[t,s]);const V=g.useMemo(()=>{const A=new Map,G=new Map;for(const B of t){const Z=B.pageUrl??B.scope,J=A.get(Z)??[];J.push(B),A.set(Z,J)}const W=new Map;for(const B of t){const Z=B.pageUrl??B.scope;W.set(B.componentId,Z)}for(const[B,Z]of Object.entries(k)){const J=W.get(B);if(!J)continue;const oe=G.get(J)??{};Object.assign(oe,Z),G.set(J,oe)}return{auditsByUrl:A,igtRunsByUrl:G,workflows:K}},[t,k]),te=g.useMemo(()=>{const A=[],G=new Set;for(const W of V.auditsByUrl.keys())G.has(W)||(G.add(W),A.push({url:W,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const W of E.split(`
523
+ `).map(B=>B.trim()).filter(Boolean))G.has(W)||(G.add(W),A.push({url:W,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return A},[V,E]),ze=g.useMemo(()=>({siteName:s||"Untitled site",siteUrl:n||"https://example.com",targetVersion:i,targetLevel:l,accessibilitySupportBaseline:p,additionalStandards:u.split(",").map(A=>A.trim()).filter(Boolean),pageSample:te,evaluator:{name:f||"(evaluator name pending)",organization:j||void 0,qualifications:S||void 0,contact:b||void 0}}),[s,n,i,l,p,u,te,f,j,S,b]),F=g.useMemo(()=>w?ar(ze,V):null,[ze,V,w]);async function Kt(){F&&await ir(F,L)}async function qt(){if(F){U(!0),Y(null);try{const A=await hr(F);if(!A){Y("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}R(A)}finally{U(!1)}}}function Qt(){var oe,Ke,qe;if(!F||!L)return;const A=((qe=(Ke=(oe=chrome.runtime).getManifest)==null?void 0:Ke.call(oe))==null?void 0:qe.version)??"0.0.0",G=xr(F,L,A),W=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),B=URL.createObjectURL(W),Z=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,J=document.createElement("a");J.href=B,J.download=Z,J.click(),setTimeout(()=>URL.revokeObjectURL(B),1e3)}return g.useEffect(()=>{R(null),Y(null)},[s,n,i,l,p,u,f,j,S,b,E]),w?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(br,{totalCriteria:F.summary.totalCriteria,pass:F.summary.pass,fail:F.summary.fail,inconclusive:F.summary.inconclusive,notEvaluated:F.summary.notEvaluated,levelAchieved:F.summary.levelAchieved,meetsTarget:F.summary.meetsTarget,targetVersion:i,targetLevel:l,auditedUrlCount:V.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:s,onChange:A=>a(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:n,onChange:A=>r(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",{className:"flex gap-2",children:[e.jsxs("label",{className:"flex-1",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Target version"}),e.jsxs("select",{value:i,onChange:A=>o(A.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs",children:[e.jsx("option",{value:"2.0",children:"WCAG 2.0"}),e.jsx("option",{value:"2.1",children:"WCAG 2.1"}),e.jsx("option",{value:"2.2",children:"WCAG 2.2"})]})]}),e.jsxs("label",{className:"flex-1",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Target level"}),e.jsxs("select",{value:l,onChange:A=>c(A.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs",children:[e.jsx("option",{value:"A",children:"Level A"}),e.jsx("option",{value:"AA",children:"Level AA"}),e.jsx("option",{value:"AAA",children:"Level AAA"})]})]})]}),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:p,onChange:A=>d(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:u,onChange:A=>h(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.",V.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:V.auditsByUrl.size})," URL",V.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:E,onChange:A=>_(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:f,onChange:A=>v(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:j,onChange:A=>C(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:S,onChange:A=>x(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=>y(A.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(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 ${mr[A.verdict]}`,children:gr[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"}),L?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:[L.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",L.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.`}),O&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:O}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!F||!s||!f||D,onClick:()=>void qt(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:D?"Anchoring…":L?"Re-anchor":"Anchor this report"}),L&&e.jsx("button",{type:"button",onClick:Qt,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:!F||!s||!f,onClick:()=>void Kt(),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 br({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,levelAchieved:i,meetsTarget:o,targetVersion:l,targetLevel:c,auditedUrlCount:p}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${l} Level ${c}`:`Does not currently meet WCAG ${l} Level ${c}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:i??"none"})," · ",t," criteria evaluated across ",p," audited URL",p===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n," · Not evaluated ",r]})]})}function Sr(){const t=m(a=>a.view),s=m(a=>a.userMode);return g.useEffect(()=>{const a=ws(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=fs();At({forceRefresh:!0}).catch(()=>{}),ye().catch(()=>{}),js().catch(()=>{}),Ns().catch(()=>{}),vs().catch(()=>{}),ps().then(l=>{m.getState().setAcknowledgedKeys(new Set(l.map(c=>c.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:c,setPinned:p,results:d}=m.getState();c&&(p(null),H().then(u=>{var h;u&&Q(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(h=d[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(wn,{}),e.jsx(Ce,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Vn,{}),e.jsx(dt,{}),e.jsx(Ce,{})]}):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(Ht,{}),e.jsx(_t,{}),e.jsx(Os,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Gs,{}),e.jsx(zs,{}),e.jsx(bn,{}),e.jsx(fn,{}),e.jsx(qs,{}),e.jsx(mn,{}),e.jsx(gn,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(wa,{}),t==="delta"&&e.jsx(Ta,{}),t==="activity"&&e.jsx(Va,{}),t==="guided"&&e.jsx(en,{}),t==="flows"&&e.jsx(nn,{}),t==="scorecard"&&e.jsx(ln,{}),t==="crawl"&&e.jsx(Vt,{}),t==="forensic"&&e.jsx(Bt,{}),t==="compliance"&&e.jsx(fr,{})]})]}),e.jsx(jn,{}),e.jsx(vn,{}),e.jsx(xn,{}),e.jsx(dt,{}),e.jsx(Ce,{})]})}class Ar extends pe.Component{constructor(){super(...arguments);Qe(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{Sr as A,Ar as E};