@wcag-checkr/ci 1.0.0-rc.61 → 1.0.0-rc.62

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/forensic-log-CI0i5Tol.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-PELIq3oj.js","assets/site-report-renderer-BocuwvYR.js"])))=>i.map(i=>d[i]);
2
- var Yt=Object.defineProperty;var Xt=(t,s,a)=>s in t?Yt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ye=(t,s,a)=>Xt(t,typeof s!="symbol"?s+"":s,a);import{R as ge,i as te,r as x,j as e,M as ue,C as Ge,l as Zt,o as Be,t as He,m as jt,s as wt,k as _e}from"./styles-Cz69L6fQ.js";import{_ as ke}from"./preload-helper-D7HrI6pR.js";import{o as J,r as H,s as B,c as Nt,b as se,d as be}from"./crash-reporter-Dc5lvxvY.js";import{g as es,a as Q,u as ts,b as ss,c as as,d as ns,e as Xe,f as kt,l as rs,h as St,A as K,i as ze,s as is,O as os,j as ls,k as cs,m as Ze,n as ds,o as At,p as us,q as ps,r as hs,t as ms,T as xs,v as gs,w as fs}from"./forensic-log-CI0i5Tol.js";import{B as Le,i as Ct,b as Rt,T as Et}from"./state-PELIq3oj.js";const et=t=>{let s;const a=new Set,n=(p,l)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=l??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(f=>f(s,h))}},r=()=>s,c={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,c);return c},bs=t=>t?et(t):et,vs=t=>t;function ys(t,s=vs){const a=ge.useSyncExternalStore(t.subscribe,ge.useCallback(()=>s(t.getState()),[t,s]),ge.useCallback(()=>s(t.getInitialState()),[t,s]));return ge.useDebugValue(a),a}const tt=t=>{const s=bs(t),a=n=>ys(s,n);return Object.assign(a,s),a},js=t=>t?tt(t):tt,g=js(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(c=>c.id!==s?c:a==="seen"?{...c,seen:!0}:a==="dismissed"?{...c,dismissed:!0}:a==="acknowledged"?{...c,acknowledged:!0}:a==="clicked"?{...c,clicked:!0}:c).filter(c=>c.severity==="critical"?!c.acknowledged:!c.dismissed),i=r.filter(c=>!c.seen).length,o=r.some(c=>c.severity==="critical"&&!c.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),Se="sidePanel:lastAudit";function ws(){const t=[];return t.push(J("AUDIT_PROGRESS_EVENT",s=>{const a=g.getState().status==="running";g.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),g.getState().setStatus("running"),a||te.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(J("AUDIT_COMPLETE_EVENT",s=>{var i;g.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,c)=>o+c.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"}.`;te.polite(r),Ns({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(J("AUDIT_FAILED_EVENT",s=>{g.getState().setError(s.error.message)})),t.push(J("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=g.getState().aiProgress;g.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||te.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(J("AI_AUGMENTATION_FAILED_EVENT",s=>{g.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(J("SCORECARD_UPDATED_EVENT",()=>{Ae()})),t.push(J("LICENSE_CHANGED_EVENT",()=>{Tt()})),t.push(J("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&te.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(J("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),te.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(J("SITE_CRAWL_FAILED_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),te.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Ns(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Se]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function ks(){const s=(await chrome.storage.local.get(Se))[Se];s&&g.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ss(){await chrome.storage.local.remove(Se)}async function Ke(){g.getState().clearResults(),await Ss()}async function Ae(){const t=await H({type:"BASELINE_LIST"});g.getState().setBaselineList(t.items)}async function Tt(t){const s=await H({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});g.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),It()}async function It(){const{fetchMessages:t}=await ke(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ls);return{fetchMessages:n}},void 0),s=g.getState().userMode,a=await t(s);a&&g.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function As(){const s=(await H({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;g.getState().setUserMode(a)}function Cs(){return chrome.runtime.connect({name:"audit-keepalive"})}let Ce=null;async function Rs(){if(Ce===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Ce=t.id)}catch{}}function $t(){if(Ce===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Ce}).catch(()=>{})}function ae(t){$t(),B(t)}function Es({onClose:t}){const[s,a]=x.useState(""),[n,r]=x.useState(""),[i,o]=x.useState(!0),[c,d]=x.useState(""),[p,l]=x.useState(!1),[u,h]=x.useState(null);async function f(b){var w;if(b.preventDefault(),!(!s.trim()||!n.trim())){l(!0),h(null);try{const E=await H({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:c.trim()||void 0});E.success?(h({ok:!0,msg:`Sent (ref: ${E.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=E.error)==null?void 0:w.message)??"Failed to send"})}finally{l(!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:b=>a(b.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:b=>r(b.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:c,onChange:b=>d(b.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:b=>o(b.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 st({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 Re=Nt("messages-client"),Ts="https://api.wcagcheckr.com",_t="wcagcheckr",Is=1e4;function $s(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Lt(t,s){const a=await es();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":$s()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Ts}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Is)})}async function _s(t){try{const s=await Lt(`/v1/products/${_t}/messages`,{userMode:t??null});return s.ok?await s.json():(Re.warn("fetchMessages http",s.status),null)}catch(s){return Re.warn("fetchMessages failed",s),null}}async function le(t,s){try{const a=await Lt(`/v1/products/${_t}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Re.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Re.warn("ackMessage failed",a),!1}}const Ls=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:le,fetchMessages:_s},Symbol.toStringTag,{value:"Module"})),Us=["http:","https:"];function Ds(t){try{const s=new URL(t);return Us.includes(s.protocol)}catch{return!1}}function at(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 c=t.slice(a+1,i),d=t.slice(i+2,o);Ds(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:c},`l-${n++}`)):s.push(e.jsx(x.Fragment,{children:c},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Ut({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:at(d)},`p-${i++}`)),r=[]}function c(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:at(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){o(),c();continue}const l=/^[-*]\s+(.*)$/.exec(p);if(l){o(),n.push(l[1]);continue}c(),r.push(p)}return o(),c(),e.jsx("div",{className:"space-y-1.5",children:a})}const Fs={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Os={critical:"bg-rose-50 border-rose-200"};function Dt(){const t=g(h=>h.unreadMessageCount),s=g(h=>h.messages),a=g(h=>h.applyMessageAck),[n,r]=x.useState(!1),i=x.useRef(-1),[o,c]=x.useState(!1);x.useEffect(()=>{const h=s.filter(b=>!b.seen);if(h.length===0)return;const f=Math.max(...h.map(b=>b.id));if(f>i.current){i.current=f,c(!0);const b=setTimeout(()=>c(!1),1500);return()=>clearTimeout(b)}},[s]);async function d(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)a(f.id,"seen"),le(f.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function l(h){a(h.id,"dismissed"),await le(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),le(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(Ms,{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(Ps,{messages:s,onClose:()=>r(!1),onDismiss:l,onCtaClick:u})]})}function Ms({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 Ps({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=x.useRef(null);return x.useEffect(()=>{const i=c=>{r.current&&(r.current.contains(c.target)||s())},o=c=>{c.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:()=>{It()},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 ${Fs[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(Ut,{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 Ft(){const t=g(i=>i.messages),s=g(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await le(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),le(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Os.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(Ut,{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 pe=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Gs(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Vs(){var u,h;const t=g(f=>f.view),s=g(f=>f.setView),a=g(f=>f.setUserMode),n=g(f=>f.results),r=g(f=>f.status),[i,o]=x.useState(!1),c=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=Gs(c),p=n.length>0&&r!=="running";function l(){a("owner"),B({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:l,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(Dt,{}),e.jsx(st,{onClick:()=>void B({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(st,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:c??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void Ke(),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(Ws,{view:t,setView:s}),e.jsx(ue,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Es,{onClose:()=>o(!1)})})]})}function Ws({view:t,setView:s}){const a=x.useRef([]);function n(i){var d;const o=(i+pe.length)%pe.length,c=pe[o];c&&(s(c),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(pe.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:pe.map((i,o)=>{const c=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":c,tabIndex:c?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:c?"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 Bs({feature:t,upgradeUrl:s}){const[a,n]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ge,{open:a,onClose:()=>n(!1)})]})}const Hs="https://wcagcheckr.com/upgrade";function zs(){const[t,s]=x.useState("single-element"),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,c]=x.useState(null),[d,p]=x.useState(Le),[l,u]=x.useState(Le[0].id),h=g(A=>A.status),f=g(A=>A.tier),b=g(A=>A.results.length>0),w=h==="running";x.useEffect(()=>{Promise.all([H({type:"SETTINGS_GET",key:"matrixPresets"}),H({type:"SETTINGS_GET",key:"activePresetId"})]).then(([A,I])=>{const z=Array.isArray(A.data)?A.data:null;p(z&&z.length>0?z:Le),typeof I.data=="string"&&u(I.data)})},[]);function E(A){const I=d.find(z=>z.id===A);I&&(u(A),B({type:"SETTINGS_SET",key:"activePresetId",value:A}),B({type:"SETTINGS_SET",key:"stateMatrix",value:I.matrix}))}const R=Ct(f,"storybookAutoIterate");x.useEffect(()=>{const A=J("ELEMENT_PICKED_EVENT",(z,$)=>{n(!1);const U=$.frameId;S(U),i({selector:z.selector,frameId:U})}),I=J("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{A(),I()}},[]);async function m(){const A=await Q();A&&(n(!0),await se(A,{type:"PICKER_ACTIVATE_REQUEST",tabId:A}))}function v(){r&&(S(r.frameId),ae({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),g.getState().startNewScan())}function y(){if(!R){c("storybook:auto-iterate");return}S(),ae({type:"START_AUDIT",mode:"storybook-all"}),g.getState().startNewScan()}function N(){S(),ae({type:"START_AUDIT",mode:"all-frames"}),g.getState().startNewScan()}function T(){S(),ae({type:"START_AUDIT",mode:"full-page"}),g.getState().startNewScan()}function j(){B({type:"CANCEL_AUDIT"})}async function S(A){g.getState().setPinned(null);const I=await Q();if(I)try{await se(I,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:I},A)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:A=>s(A.target.value),disabled:w||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)",R?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:l,onChange:A=>E(A.target.value),disabled:w||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(A=>e.jsx("option",{value:A.id,children:A.name},A.id))}),t==="single-element"?e.jsx(Ks,{picking:a,picked:r,isRunning:w,onPick:m,onRun:v,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:T,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:N,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:j,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&b&&e.jsx("button",{type:"button",onClick:()=>void Ke(),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&&!w&&e.jsx(qs,{selector:r.selector,onRepick:m,onClear:()=>i(null)})]}),e.jsx(ue,{open:o!==null,onClose:()=>c(null),title:"Upgrade to continue",children:e.jsx(Bs,{feature:o??"",upgradeUrl:Hs})})]})}function Ks({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 qs({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 Qs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Js={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Ys(){const[t,s]=x.useState(null),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,c]=x.useState("off"),p=g(f=>f.results).flatMap(f=>f.violations);async function l(f){const b=await Q();b&&(c(f),f==="off"?await se(b,{type:"VISION_SIMULATOR_CLEAR",tabId:b}).catch(()=>{}):await se(b,{type:"VISION_SIMULATOR_APPLY",tabId:b,mode:f}).catch(()=>{}))}async function u(f){const b=await Q();if(b){if(t&&await se(b,{type:Qs[t],tabId:b}).catch(()=>{}),t===f){s(null);return}await se(b,{type:Js[f],tabId:b}).catch(()=>{}),s(f)}}async function h(){const f=await Q();if(f){if(a){await se(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 b=await be(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});n(!0),i(`Previewing ${b.visualFixCount} visual fix${b.visualFixCount===1?"":"es"} + ${b.annotationCount} annotation${b.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(he,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(he,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(he,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(he,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(he,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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 l(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 he({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Xs(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=g(p=>p.status),s=g(p=>p.progress),a=g(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,c=n?a.total:s.total,d=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":Xs(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void B({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":c,"aria-label":d,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const me={"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 ea(t){return/^wcag\d/.test(t.wcagCriterion)?[me["ada-iii"],me[508],me.eaa,me["en-301-549"],me.aoda]:[]}const ta={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 Ee({violation:t,alreadyAcknowledged:s}){const a=g(m=>m.pinnedMatchKey),n=g(m=>m.pinnedFound),r=g(m=>m.setPinned),i=g(m=>{var v;return(v=m.results[0])==null?void 0:v.frameId}),o=g(m=>{var v;return(v=m.results[0])==null?void 0:v.scope}),c=g(m=>m.results),d=g(m=>m.acknowledgedKeys.has(t.matchKey)),p=g(m=>m.markAcknowledged),l=g(m=>m.markUnacknowledged),u=s||d,h=a===t.matchKey,f=h&&!n;async function b(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 Q();if(!m)return;if(h){r(null);try{await se(m,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:m},i)}catch{}return}const v=await b(m);r(t.matchKey,v)}function E(m){m.stopPropagation(),t.currentState.breakpoint.width<=640&&$t(),(async()=>{const v=await Q();if(!v)return;try{await H({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:o,frameId:i})}catch{}const y=await b(v);r(t.matchKey,y)})()}async function R(m){m.stopPropagation();const v=await Q();if(!v)return;try{await H({type:"STATE_DRIVE_REQUEST",tabId:v,state:ra(),scope:o,frameId:i})}catch{B({type:"STATE_RESET_REQUEST",tabId:v})}const y=await b(v);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 ${ta[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(ia,{violation:t}),e.jsx(ca,{violation:t}),e.jsx(la,{violation:t}),e.jsx(oa,{text:t.target.failureSummary}),e.jsx(da,{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: ",sa(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:E,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),E(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:R,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),R(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(),l(t.matchKey),na(t,c)},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),aa(t,c)},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 sa(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 aa(t,s){await ss({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Ot(t.componentId,s)}async function na(t,s){await ts(t.componentId,t.matchKey),await Ot(t.componentId,s)}async function Ot(t,s){const a=s.flatMap(n=>n.violations);try{const n=await H({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});g.getState().setDelta(n.delta)}catch{}}function ra(){const t=Rt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Mt(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 ia({violation:t}){const s=Mt(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 oa({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 la({violation:t}){const s=ea(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 ca({violation:t}){const s=Mt(t),[a,n]=x.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 H({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),c=o.results.find(d=>d.matchKey===t.matchKey);n(c?{kind:"ready",suggestion:c}:{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 da({ruleId:t}){const s=as(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 ua=[{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 pa(t){const s=ua.map(i=>ha(i,t)),a=s.reduce((i,o)=>i+ma(o.letter),0)/Math.max(1,s.length),n=xa(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 ha(t,s){const a=new Set(t.axeRules),n=s.violations.filter(j=>a.has(j.ruleId)),r=s.manualRuns.filter(j=>t.igtWorkflowIds.includes(j.workflowId)),i=t.igtWorkflowIds.map(j=>s.workflows.find(S=>S.id===j)).filter(j=>j!=null);let o=i.length>0;for(const j of i){const S=r.find(I=>I.workflowId===j.id);if((S?Object.keys(S.steps).length:0)!==j.steps.length){o=!1;break}}const c=r.some(j=>Object.keys(j.steps).length>0),d=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(j=>d.includes(j.workflowId)),l=d.map(j=>s.workflows.find(S=>S.id===j)).filter(j=>j!=null);let u=d.length>0&&l.length===d.length;for(const j of l){const S=p.find(I=>I.workflowId===j.id);if((S?Object.keys(S.steps).length:0)!==j.steps.length){u=!1;break}}let h=null;if(u)for(const j of p)j.completedAt&&(h===null||j.completedAt>h)&&(h=j.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,b=d[0]??t.igtWorkflowIds[0]??null;if(u&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:f,primaryVerifierWorkflowId:b,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w=t.axeRules.length>0||t.heuristic!=null,E=t.igtWorkflowIds.length>0;let R=!1;if(w&&E?R=!s.auditRan&&!c:w?R=!s.auditRan:E?R=!c:R=!0,R)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:E||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:b,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 j of ns(n))m[j.impact]++;m.serious+=f;for(const j of r){const S=i.find(A=>A.id===j.workflowId);if(S)for(const A of S.steps){const I=j.steps[A.id];(I==null?void 0:I.status)==="fail"&&(A.severity==="required"?m.serious++:m.moderate++)}}const v=m.critical>0,y=m.serious>0;let N;m.critical>=5?N="F":m.critical>=1?N="D":m.serious>=1?N="C":m.moderate>=1?N="B":N="A";const T=E&&!o||d.length>0&&!u;return{id:t.id,label:t.label,letter:N,untested:!1,needsIgt:T,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:b,counts:m,caps:{cappedAtC:v,cappedAtB:y}}}function ma(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function xa(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const ga={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},fa={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function ba({violations:t,componentId:s}){var q,P,X,Z,D,ne,oe;const[a,n]=x.useState([]),[r,i]=x.useState([]),[o,c]=x.useState(new Set),[d,p]=x.useState(null),[l,u]=x.useState({}),[h,f]=x.useState(new Set),b=g(_=>_.status),w=g(_=>_.progress),E=g(_=>_.freshThisSession),R=g(_=>_.results),m=(q=R[0])==null?void 0:q.startedAt,v=((P=R[0])==null?void 0:P.pageUrl)??((X=R[0])==null?void 0:X.scope)??null;if(x.useEffect(()=>{if(!s){n([]);return}let _=!1;return chrome.storage.local.get("igtRuns").then(k=>{if(_)return;const M=((k==null?void 0:k.igtRuns)??{})[s]??{};n(Object.values(M))}),()=>{_=!0}},[s]),x.useEffect(()=>{if(!v){i([]);return}let _=!1;return Xe(v).then(k=>{_||i(k)}),()=>{_=!0}},[v]),b==="running")return e.jsx(Sa,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const y=pa({violations:t,auditRan:R.length>0,manualRuns:a,workflows:K,heuristicCounts:{tabOrder:((D=(Z=R[0])==null?void 0:Z.tabOrderIssues)==null?void 0:D.length)??0,readingOrder:((oe=(ne=R[0])==null?void 0:ne.readingOrderIssues)==null?void 0:oe.length)??0}}),N=g(_=>_.acknowledgedKeys),T=R.length>0?kt(R,{runs:a,workflows:K},"2.1","AA",N,r):void 0,j=R.length>0?rs(St({audits:R,igtRuns:a,workflows:K,acknowledgedMatchKeys:N,incompleteResolutions:r}),K):void 0,S=T?!T.canClaimConformance:!1,A=S&&y.overallLetter==="A"?"B":y.overallLetter;async function I(_){var ee;if(!v||!((ee=T==null?void 0:T.inconclusiveReasons)!=null&&ee[_]))return;const F=T.inconclusiveReasons[_].filter(W=>W.source==="axe-incomplete"&&W.elements&&W.elements.length>0);if(F.length===0)return;c(W=>new Set(W).add(_)),p(null);const M=[];let L=0;try{for(const V of F){const Y=await B({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:V.ruleOrStepId,pageUrl:V.pageUrl??v,wcagCriterion:_,elements:V.elements??[],targetLevel:"AA"});if(Y!=null&&Y.unavailableReason){p(Y.unavailableReason);break}Y!=null&&Y.resolutions&&(M.push(...Y.resolutions),L+=Y.totalCostUsd??0)}if(v){const V=await Xe(v);i(V)}const W={total:M.length,pass:M.filter(V=>V.verdict==="pass").length,fail:M.filter(V=>V.verdict==="fail").length,uncertain:M.filter(V=>V.verdict==="uncertain").length,costUsd:L,resolutions:M};u(V=>({...V,[_]:W}))}finally{c(W=>{const V=new Set(W);return V.delete(_),V})}}function z(_){f(k=>{const F=new Set(k);return F.has(_)?F.delete(_):F.add(_),F})}const $=(()=>{if(!S||y.overallLetter!=="A"||!T)return null;const _=T.untestedCriteria.length,k=T.inconclusiveCriteria.length,F=[];return _>0&&F.push(`${_} WCAG ${T.targetLevel} ${_===1?"criterion":"criteria"} still untested`),k>0&&F.push(`${k} WCAG ${T.targetLevel} ${k===1?"criterion":"criteria"} inconclusive`),`Capped at B — ${F.join(" + ")}. ${k>0?"Resolve axe-incomplete + IGT-skip items to claim conformance.":"Open Guided Tests to evaluate them."}`})();let U=0;for(const _ of K){const k=a.find(M=>M.workflowId===_.id);if(!k)continue;_.steps.every(M=>{const L=k.steps[M.id];return(L==null?void 0:L.status)==="pass"||(L==null?void 0:L.status)==="fail"||(L==null?void 0:L.status)==="skip"||(L==null?void 0:L.status)==="not-applicable"})&&U++}const G=t.length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!E&&m&&e.jsx(Aa,{scannedAt:m}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ga[A]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:A})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",y.subGrades.length," verification areas below. Untested areas count as F until verified."]}),$&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:$})]})]}),y.isLawsuitRisk&&e.jsx(ja,{areas:y.warningAreas}),e.jsx(wa,{grades:y.subGrades}),T&&e.jsx(va,{coverage:T,onResolveWithAi:I,resolving:o,resolveError:d,lastResolveResult:l,expandedResultFor:h,onToggleResultDetail:z}),j&&e.jsx(ya,{layers:j}),e.jsx(ka,{violationsRemaining:G,manualCompleted:U,manualTotal:K.length}),U>0||R.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:U})," 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:`${U/K.length*100}%`}})})]}):null]})}function va({coverage:t,onResolveWithAi:s,resolving:a,resolveError:n,lastResolveResult:r,expandedResultFor:i,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[d,p]=x.useState(c>0&&c<=3),l=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),u=t.canClaimConformance,h=[];return t.untestedCriteria.length>0&&h.push({kind:"untested",ids:t.untestedCriteria}),t.inconclusiveCriteria.length>0&&h.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),e.jsxs("div",{className:`border-t ${u?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${u?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",l,"%)"]}),u&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!u&&e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain",t.untestedCriteria.length>0?" untested":"",t.untestedCriteria.length>0&&t.inconclusiveCriteria.length>0?" or":"",t.inconclusiveCriteria.length>0?" inconclusive":"","."]}),!u&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!u&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!u&&h.length>0&&e.jsx("button",{type:"button",onClick:()=>p(f=>!f),className:"text-[11px] underline shrink-0 self-start",children:d?"hide":"show list"})]}),d&&!u&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[h.map(f=>e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-amber-900",children:[f.kind==="untested"?"Untested":"Inconclusive"," (",f.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:f.ids.map(b=>{var y;const w=f.kind==="inconclusive"?(y=t.inconclusiveReasons)==null?void 0:y[b]:void 0,E=w==null?void 0:w.some(N=>N.source==="axe-incomplete"&&N.elements&&N.elements.length>0),R=(a==null?void 0:a.has(b))??!1,m=r==null?void 0:r[b],v=(i==null?void 0:i.has(b))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",b]}),f.kind==="inconclusive"&&E&&s&&e.jsx("button",{type:"button",disabled:R,onClick:()=>s(b),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:R?"Resolving…":m?"✨ Resolve again →":"✨ Resolve with AI →"})]}),m&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",m.total," ",m.total===1?"verdict":"verdicts",":",m.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",m.pass," pass"]}),m.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",m.fail," fail"]}),m.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",m.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",m.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(b),className:"ml-auto text-[10px] underline text-brand-700",children:v?"hide reasoning":"show reasoning"})]}),m.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",m.uncertain," ",m.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),m.pass===m.total&&m.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),v&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:m.resolutions.map((N,T)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:N.verdict==="pass"?"text-emerald-700 font-semibold":N.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:N.verdict==="pass"?"✓":N.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:N.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:N.reasoning})]},T))})]}),w&&w.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:w.map((N,T)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[N.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," — "]}),N.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," skipped — "]}),N.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:N.ruleOrStepId})," — "]}),N.resolutionHint,N.elements&&N.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",N.elements.length===1?"element":`${N.elements.length} elements`,":"," ",N.elements.slice(0,3).map((j,S,A)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:j.selector}),S<A.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},S)),N.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",N.elements.length-3," more"]})]})]},T))}):f.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},b)})})]},f.kind)),n&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:n})]})]})}const nt={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function ya({layers:t}){const s=g(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,c=r.unevaluated.length,d=r.cleared,p=i>0&&o===0&&c===0,l=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:nt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${l}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:nt[n].hint}),n==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function ja({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 wa({grades:t}){const s=g(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${fa[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(Na,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Na({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?Pt(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 ka({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=g(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done: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,c)=>{const d=c===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${c+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},c)})})]})}function Sa({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 Aa({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 (",Pt(s)," old). Re-scan to grade the current page state."]})]})}function Pt(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 Ve="dismissedFindings";function Ie(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ce(t){return`reading-order::${t}`}function de(t){return`tab-order::${t}`}async function $e(){try{const t=await chrome.storage.local.get(Ve),s=t==null?void 0:t[Ve];if(s&&typeof s=="object")return s}catch{}return{}}async function qe(t){await chrome.storage.local.set({[Ve]:t})}async function Te(t){return(await $e())[Ie(t)]??{}}async function Gt(t,s,a,n){const r=await $e(),i=Ie(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await qe(r)}async function ve(t,s){if(s.length===0)return;const a=await $e(),n=Ie(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 qe(a)}async function Vt(t,s){const a=await $e(),n=Ie(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await qe(a))}const Ca=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Gt,addDismissals:ve,dismissalKeyForReadingOrder:ce,dismissalKeyForTabOrder:de,getDismissalsForUrl:Te,removeDismissal:Vt},Symbol.toStringTag,{value:"Module"}));function Wt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Bt(t){return`${ze(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Ra(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Bt(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 rt={critical:0,serious:1,moderate:2,minor:3};function Ea(){var b,w,E,R;const t=g(m=>m.results),s=g(m=>m.componentId),a=g(m=>m.setView),n=((b=t[0])==null?void 0:b.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=x.useState({}),[o,c]=x.useState(new Set);if(x.useEffect(()=>{if(!n)return;Te(n).then(i);const m=()=>{document.visibilityState==="visible"&&n&&Te(n).then(i)};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[n]),x.useEffect(()=>{if(!s){c(new Set);return}let m=!1;const v=async()=>{const N=await chrome.storage.local.get("igtRuns");if(m)return;const j=((N==null?void 0:N.igtRuns)??{})[s]??{},S=new Set;for(const A of K){const I=j[A.id];I&&Object.keys(I.steps).length===A.steps.length&&S.add(A.id)}c(S)};v();const y=()=>{document.visibilityState==="visible"&&v()};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 d=t.reduce((m,v)=>m+v.durationMs,0),p=t.reduce((m,v)=>m+v.violations.length,0),l=Ra(t);l.sort((m,v)=>{const y=rt[m.representative.impact]??99,N=rt[v.representative.impact]??99;return y!==N?y-N:v.states.length-m.states.length});const u=t.map(m=>Wt(m.state)).join(`
4
- `),h=o.has("keyboard")?0:(((E=t[0])==null?void 0:E.tabOrderIssues)??[]).filter(m=>!(de(m.selector)in r)).length,f=o.has("page-structure")?0:(((R=t[0])==null?void 0:R.readingOrderIssues)??[]).filter(m=>!(ce(m.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(ba,{violations:t.flatMap(m=>m.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"]})," · ",l.length," unique ",l.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),l.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:l.map(m=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ee,{violation:m.representative}),e.jsx(Ta,{states:m.states,totalStates:t.length})]},Bt(m.representative)))})]})}function Ta({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(Wt))),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 Ia={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 $a({ruleId:t,violations:s}){const[a,n]=x.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,c=s.length;return c===1?e.jsx(Ee,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Ia[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:["×",c]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(Ee,{violation:d},p))})]})}function _a(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 La={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Ht({open:t,onClose:s,format:a,content:n,filename:r}){const i=Zt(new Blob([n]).size);function o(){He(n,r),s()}function c(){Be(n),s()}return e.jsxs(ue,{open:t,onClose:s,title:La[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:c,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 it=7800;function Ua(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const l of a){const u=`${l.ruleId}::${l.target.selector}`,h=`:${l.currentState.pseudoState} · ${l.currentState.theme} · ${l.currentState.direction}`,f=r.find(b=>`${b.ruleId}::${b.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...l,_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 l of r)o.push(`### \`${l.ruleId}\` — ${l.impact}`),o.push(""),o.push(l.description),o.push(""),o.push(`- **WCAG:** ${l.wcagCriterion} (${l.wcagLevel})`),o.push(`- **Selector:** \`${l.target.selector}\``),o.push(`- **Found in state(s):** ${l._states.join(", ")}`),l.helpUrl&&o.push(`- **More info:** ${l.helpUrl}`),o.push(""),o.push("```html"),o.push(l.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const c=o.join(`
6
- `),d=new URLSearchParams({title:i,body:c});let p=`${n}/issues/new?${d.toString()}`;return p.length>it&&(p=p.slice(0,it)),{url:p,title:i,body:c}}const ot=7800;function Da(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const l of a){const u=`${l.ruleId}::${l.target.selector}`,h=`:${l.currentState.pseudoState} · ${l.currentState.theme} · ${l.currentState.direction}`,f=r.find(b=>`${b.ruleId}::${b.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...l,_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 l of r)o.push(`Rule: ${l.ruleId} (${l.impact})`),o.push(`WCAG: ${l.wcagCriterion} ${l.wcagLevel}`),o.push(`Description: ${l.description}`),o.push(`Selector: ${l.target.selector}`),o.push(`Found in state(s): ${l._states.join(", ")}`),l.helpUrl&&o.push(`More info: ${l.helpUrl}`),o.push(""),o.push(`HTML: ${l.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const c=o.join(`
7
- `),d=new URLSearchParams({summary:i,description:c});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>ot&&(p=p.slice(0,ot)),{url:p,summary:i,description:c}}function Fa(){const t=g(v=>v.delta),s=g(v=>v.componentId),a=g(v=>v.results),n=g(v=>v.tier),r=g(v=>v.baselineList),i=g(v=>v.siteCrawlReport),[o,c]=x.useState(""),[d,p]=x.useState(""),[l,u]=x.useState(null);x.useEffect(()=>{Promise.all([H({type:"SETTINGS_GET",key:"githubRepoUrl"}),H({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,y])=>{c(typeof v.data=="string"?v.data:""),p(typeof y.data=="string"?y.data:"")})},[]);const h=Ct(n,"exportJson"),f=Et[n].maxBaselines,b=r.some(v=>v.componentId===s),w=b||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 E(){if(!s||a.length===0)return;const v=a.flatMap(I=>I.violations),y=a.flatMap(I=>I.announcements??[]),N=a.flatMap(I=>I.focusEvents??[]),T=a[0],S=(await H({type:"SETTINGS_GET",key:"stateMatrix"})).data??Rt;await B({type:"BASELINE_SET",componentId:s,violations:v,announcements:y,focusEvents:N,snapshotMeta:{url:window.location.href,axeVersion:T.axeVersion,matrixConfig:S,capturedAt:new Date().toISOString()}});const A=await H({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:y,focusEvents:N,currentMatrix:S});g.getState().setDelta(A.delta),te.polite(`Baseline saved for ${s}.`)}async function R(){if(!s||!b||!window.confirm(`Remove the saved baseline for "${s}"?
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/forensic-log-CwwnrQMK.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-PELIq3oj.js","assets/site-report-renderer-BrlLZK3X.js"])))=>i.map(i=>d[i]);
2
+ var ss=Object.defineProperty;var as=(t,s,a)=>s in t?ss(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var st=(t,s,a)=>as(t,typeof s!="symbol"?s+"":s,a);import{R as ge,i as te,r as x,j as e,M as ue,C as ze,l as ns,o as Qe,t as Je,m as St,s as At,k as Fe}from"./styles-pWj24Nu1.js";import{_ as Se}from"./preload-helper-D7HrI6pR.js";import{o as X,r as z,s as H,c as Ct,b as se,d as be}from"./crash-reporter-Dc5lvxvY.js";import{g as rs,a as Y,u as is,b as os,c as ls,d as cs,e as Oe,f as Rt,l as ds,h as Et,A as Q,s as us,i as Ye,j as ps,O as hs,k as ms,m as xs,n as at,o as gs,p as Tt,q as fs,r as bs,t as vs,v as ys,T as js,w as ws,x as Ns}from"./forensic-log-CwwnrQMK.js";import{B as Me,i as It,b as $t,T as _t}from"./state-PELIq3oj.js";const nt=t=>{let s;const a=new Set,n=(p,l)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=l??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(b=>b(s,h))}},r=()=>s,c={setState:n,getState:r,getInitialState:()=>d,subscribe:p=>(a.add(p),()=>a.delete(p))},d=s=t(n,r,c);return c},ks=t=>t?nt(t):nt,Ss=t=>t;function As(t,s=Ss){const a=ge.useSyncExternalStore(t.subscribe,ge.useCallback(()=>s(t.getState()),[t,s]),ge.useCallback(()=>s(t.getInitialState()),[t,s]));return ge.useDebugValue(a),a}const rt=t=>{const s=ks(t),a=n=>As(s,n);return Object.assign(a,s),a},Cs=t=>t?rt(t):rt,g=Cs(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(c=>c.id!==s?c:a==="seen"?{...c,seen:!0}:a==="dismissed"?{...c,dismissed:!0}:a==="acknowledged"?{...c,acknowledged:!0}:a==="clicked"?{...c,clicked:!0}:c).filter(c=>c.severity==="critical"?!c.acknowledged:!c.dismissed),i=r.filter(c=>!c.seen).length,o=r.some(c=>c.severity==="critical"&&!c.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),Ae="sidePanel:lastAudit";function Rs(){const t=[];return t.push(X("AUDIT_PROGRESS_EVENT",s=>{const a=g.getState().status==="running";g.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),g.getState().setStatus("running"),a||te.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(X("AUDIT_COMPLETE_EVENT",s=>{var i;g.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,c)=>o+c.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"}.`;te.polite(r),Es({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(X("AUDIT_FAILED_EVENT",s=>{g.getState().setError(s.error.message)})),t.push(X("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=g.getState().aiProgress;g.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||te.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(X("AI_AUGMENTATION_FAILED_EVENT",s=>{g.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(X("SCORECARD_UPDATED_EVENT",()=>{Ce()})),t.push(X("LICENSE_CHANGED_EVENT",()=>{Lt()})),t.push(X("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&te.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(X("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),te.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(X("SITE_CRAWL_FAILED_EVENT",s=>{const a=g.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),te.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function Es(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Ae]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Ts(){const s=(await chrome.storage.local.get(Ae))[Ae];s&&g.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Is(){await chrome.storage.local.remove(Ae)}async function Xe(){g.getState().clearResults(),await Is()}async function Ce(){const t=await z({type:"BASELINE_LIST"});g.getState().setBaselineList(t.items)}async function Lt(t){const s=await z({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});g.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),Ut()}async function Ut(){const{fetchMessages:t}=await Se(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ps);return{fetchMessages:n}},void 0),s=g.getState().userMode,a=await t(s);a&&g.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function $s(){const s=(await z({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;g.getState().setUserMode(a)}function _s(){return chrome.runtime.connect({name:"audit-keepalive"})}let Re=null;async function Ls(){if(Re===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Re=t.id)}catch{}}function Dt(){if(Re===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Re}).catch(()=>{})}function ae(t){Dt(),H(t)}function Us({onClose:t}){const[s,a]=x.useState(""),[n,r]=x.useState(""),[i,o]=x.useState(!0),[c,d]=x.useState(""),[p,l]=x.useState(!1),[u,h]=x.useState(null);async function b(m){var N;if(m.preventDefault(),!(!s.trim()||!n.trim())){l(!0),h(null);try{const C=await z({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:c.trim()||void 0});C.success?(h({ok:!0,msg:`Sent (ref: ${C.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((N=C.error)==null?void 0:N.message)??"Failed to send"})}finally{l(!1)}}}return e.jsxs("form",{onSubmit:b,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:m=>a(m.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:m=>r(m.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:c,onChange:m=>d(m.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:m=>o(m.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function it({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 Ee=Ct("messages-client"),Ds="https://api.wcagcheckr.com",Ft="wcagcheckr",Fs=1e4;function Os(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Ot(t,s){const a=await rs();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Os()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Ds}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Fs)})}async function Ms(t){try{const s=await Ot(`/v1/products/${Ft}/messages`,{userMode:t??null});return s.ok?await s.json():(Ee.warn("fetchMessages http",s.status),null)}catch(s){return Ee.warn("fetchMessages failed",s),null}}async function le(t,s){try{const a=await Ot(`/v1/products/${Ft}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ee.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ee.warn("ackMessage failed",a),!1}}const Ps=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:le,fetchMessages:Ms},Symbol.toStringTag,{value:"Module"})),Gs=["http:","https:"];function Vs(t){try{const s=new URL(t);return Gs.includes(s.protocol)}catch{return!1}}function ot(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 c=t.slice(a+1,i),d=t.slice(i+2,o);Vs(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:c},`l-${n++}`)):s.push(e.jsx(x.Fragment,{children:c},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function Mt({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:ot(d)},`p-${i++}`)),r=[]}function c(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,p)=>e.jsx("li",{children:ot(d)},p))},`u-${i++}`)),n=[])}for(const d of s){const p=d.trimEnd();if(p===""){o(),c();continue}const l=/^[-*]\s+(.*)$/.exec(p);if(l){o(),n.push(l[1]);continue}c(),r.push(p)}return o(),c(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ws={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Bs={critical:"bg-rose-50 border-rose-200"};function Pt(){const t=g(h=>h.unreadMessageCount),s=g(h=>h.messages),a=g(h=>h.applyMessageAck),[n,r]=x.useState(!1),i=x.useRef(-1),[o,c]=x.useState(!1);x.useEffect(()=>{const h=s.filter(m=>!m.seen);if(h.length===0)return;const b=Math.max(...h.map(m=>m.id));if(b>i.current){i.current=b,c(!0);const m=setTimeout(()=>c(!1),1500);return()=>clearTimeout(m)}},[s]);async function d(){const h=s.filter(b=>!b.seen);if(h.length!==0)for(const b of h)a(b.id,"seen"),le(b.id,"seen")}function p(){const h=!n;r(h),h&&d()}async function l(h){a(h.id,"dismissed"),await le(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),le(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(Hs,{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(zs,{messages:s,onClose:()=>r(!1),onDismiss:l,onCtaClick:u})]})}function Hs({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 zs({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=x.useRef(null);return x.useEffect(()=>{const i=c=>{r.current&&(r.current.contains(c.target)||s())},o=c=>{c.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:()=>{Ut()},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 ${Ws[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(Mt,{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 Gt(){const t=g(i=>i.messages),s=g(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await le(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),le(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Bs.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(Mt,{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 pe=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ks(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function qs(){var u,h;const t=g(b=>b.view),s=g(b=>b.setView),a=g(b=>b.setUserMode),n=g(b=>b.results),r=g(b=>b.status),[i,o]=x.useState(!1),c=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),d=Ks(c),p=n.length>0&&r!=="running";function l(){a("owner"),H({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:l,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(Pt,{}),e.jsx(it,{onClick:()=>void H({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(it,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:c??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void Xe(),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(Qs,{view:t,setView:s}),e.jsx(ue,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(Us,{onClose:()=>o(!1)})})]})}function Qs({view:t,setView:s}){const a=x.useRef([]);function n(i){var d;const o=(i+pe.length)%pe.length,c=pe[o];c&&(s(c),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(pe.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:pe.map((i,o)=>{const c=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":c,tabIndex:c?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:c?"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 Js({feature:t,upgradeUrl:s}){const[a,n]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(ze,{open:a,onClose:()=>n(!1)})]})}const Ys="https://wcagcheckr.com/upgrade";function Xs(){const[t,s]=x.useState("single-element"),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,c]=x.useState(null),[d,p]=x.useState(Me),[l,u]=x.useState(Me[0].id),h=g(A=>A.status),b=g(A=>A.tier),m=g(A=>A.results.length>0),N=h==="running";x.useEffect(()=>{Promise.all([z({type:"SETTINGS_GET",key:"matrixPresets"}),z({type:"SETTINGS_GET",key:"activePresetId"})]).then(([A,I])=>{const K=Array.isArray(A.data)?A.data:null;p(K&&K.length>0?K:Me),typeof I.data=="string"&&u(I.data)})},[]);function C(A){const I=d.find(K=>K.id===A);I&&(u(A),H({type:"SETTINGS_SET",key:"activePresetId",value:A}),H({type:"SETTINGS_SET",key:"stateMatrix",value:I.matrix}))}const T=It(b,"storybookAutoIterate");x.useEffect(()=>{const A=X("ELEMENT_PICKED_EVENT",(K,$)=>{n(!1);const P=$.frameId;S(P),i({selector:K.selector,frameId:P})}),I=X("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{A(),I()}},[]);async function f(){const A=await Y();A&&(n(!0),await se(A,{type:"PICKER_ACTIVATE_REQUEST",tabId:A}))}function v(){r&&(S(r.frameId),ae({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),g.getState().startNewScan())}function y(){if(!T){c("storybook:auto-iterate");return}S(),ae({type:"START_AUDIT",mode:"storybook-all"}),g.getState().startNewScan()}function E(){S(),ae({type:"START_AUDIT",mode:"all-frames"}),g.getState().startNewScan()}function k(){S(),ae({type:"START_AUDIT",mode:"full-page"}),g.getState().startNewScan()}function w(){H({type:"CANCEL_AUDIT"})}async function S(A){g.getState().setPinned(null);const I=await Y();if(I)try{await se(I,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:I},A)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:A=>s(A.target.value),disabled:N||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)",T?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:l,onChange:A=>C(A.target.value),disabled:N||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(A=>e.jsx("option",{value:A.id,children:A.name},A.id))}),t==="single-element"?e.jsx(Zs,{picking:a,picked:r,isRunning:N,onPick:f,onRun:v,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:k,disabled:N,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:N?"Auditing…":"Scan page"}):t==="all-frames"?e.jsx("button",{onClick:E,disabled:N,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:N?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:N,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:N?"Auditing…":"Audit all stories"}),N&&e.jsx("button",{onClick:w,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!N&&m&&e.jsx("button",{type:"button",onClick:()=>void Xe(),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&&!N&&e.jsx(ea,{selector:r.selector,onRepick:f,onClear:()=>i(null)})]}),e.jsx(ue,{open:o!==null,onClose:()=>c(null),title:"Upgrade to continue",children:e.jsx(Js,{feature:o??"",upgradeUrl:Ys})})]})}function Zs({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 ea({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 ta={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},sa={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function aa(){const[t,s]=x.useState(null),[a,n]=x.useState(!1),[r,i]=x.useState(null),[o,c]=x.useState("off"),p=g(b=>b.results).flatMap(b=>b.violations);async function l(b){const m=await Y();m&&(c(b),b==="off"?await se(m,{type:"VISION_SIMULATOR_CLEAR",tabId:m}).catch(()=>{}):await se(m,{type:"VISION_SIMULATOR_APPLY",tabId:m,mode:b}).catch(()=>{}))}async function u(b){const m=await Y();if(m){if(t&&await se(m,{type:ta[t],tabId:m}).catch(()=>{}),t===b){s(null);return}await se(m,{type:sa[b],tabId:m}).catch(()=>{}),s(b)}}async function h(){const b=await Y();if(b){if(a){await se(b,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:b}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const m=await be(b,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:b,violations:p});n(!0),i(`Previewing ${m.visualFixCount} visual fix${m.visualFixCount===1?"":"es"} + ${m.annotationCount} annotation${m.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(he,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(he,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(he,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(he,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(he,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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:b=>void l(b.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 he({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function na(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 ra(){const t=g(p=>p.status),s=g(p=>p.progress),a=g(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,c=n?a.total:s.total,d=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":na(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void H({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":c,"aria-label":d,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const me={"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 ia(t){return/^wcag\d/.test(t.wcagCriterion)?[me["ada-iii"],me[508],me.eaa,me["en-301-549"],me.aoda]:[]}const oa={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 Te({violation:t,alreadyAcknowledged:s}){const a=g(f=>f.pinnedMatchKey),n=g(f=>f.pinnedFound),r=g(f=>f.setPinned),i=g(f=>{var v;return(v=f.results[0])==null?void 0:v.frameId}),o=g(f=>{var v;return(v=f.results[0])==null?void 0:v.scope}),c=g(f=>f.results),d=g(f=>f.acknowledgedKeys.has(t.matchKey)),p=g(f=>f.markAcknowledged),l=g(f=>f.markUnacknowledged),u=s||d,h=a===t.matchKey,b=h&&!n;async function m(f){try{return(await be(f,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:f,selector:t.target.selector},i)).found}catch{return!0}}async function N(){const f=await Y();if(!f)return;if(h){r(null);try{await se(f,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:f},i)}catch{}return}const v=await m(f);r(t.matchKey,v)}function C(f){f.stopPropagation(),t.currentState.breakpoint.width<=640&&Dt(),(async()=>{const v=await Y();if(!v)return;try{await z({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:o,frameId:i})}catch{}const y=await m(v);r(t.matchKey,y)})()}async function T(f){f.stopPropagation();const v=await Y();if(!v)return;try{await z({type:"STATE_DRIVE_REQUEST",tabId:v,state:ua(),scope:o,frameId:i})}catch{H({type:"STATE_RESET_REQUEST",tabId:v})}const y=await m(v);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:N,"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 ${oa[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(pa,{violation:t}),e.jsx(xa,{violation:t}),e.jsx(ma,{violation:t}),e.jsx(ha,{text:t.target.failureSummary}),e.jsx(ga,{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: ",la(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:C,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),C(f))},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:T,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),T(f))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),b&&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:f=>{f.stopPropagation(),l(t.matchKey),da(t,c)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.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:f=>{f.stopPropagation(),p(t.matchKey),ca(t,c)},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.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:f=>f.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function la(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 ca(t,s){await os({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Vt(t.componentId,s)}async function da(t,s){await is(t.componentId,t.matchKey),await Vt(t.componentId,s)}async function Vt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await z({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});g.getState().setDelta(n.delta)}catch{}}function ua(){const t=$t.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Wt(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 pa({violation:t}){const s=Wt(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 ha({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 ma({violation:t}){const s=ia(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 xa({violation:t}){const s=Wt(t),[a,n]=x.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 z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),c=o.results.find(d=>d.matchKey===t.matchKey);n(c?{kind:"ready",suggestion:c}:{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 ga({ruleId:t}){const s=ls(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 fa=[{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 ba(t){const s=fa.map(i=>va(i,t)),a=s.reduce((i,o)=>i+ya(o.letter),0)/Math.max(1,s.length),n=ja(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 va(t,s){const a=new Set(t.axeRules),n=s.violations.filter(w=>a.has(w.ruleId)),r=s.manualRuns.filter(w=>t.igtWorkflowIds.includes(w.workflowId)),i=t.igtWorkflowIds.map(w=>s.workflows.find(S=>S.id===w)).filter(w=>w!=null);let o=i.length>0;for(const w of i){const S=r.find(I=>I.workflowId===w.id);if((S?Object.keys(S.steps).length:0)!==w.steps.length){o=!1;break}}const c=r.some(w=>Object.keys(w.steps).length>0),d=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(w=>d.includes(w.workflowId)),l=d.map(w=>s.workflows.find(S=>S.id===w)).filter(w=>w!=null);let u=d.length>0&&l.length===d.length;for(const w of l){const S=p.find(I=>I.workflowId===w.id);if((S?Object.keys(S.steps).length:0)!==w.steps.length){u=!1;break}}let h=null;if(u)for(const w of p)w.completedAt&&(h===null||w.completedAt>h)&&(h=w.completedAt);const b=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,m=d[0]??t.igtWorkflowIds[0]??null;if(u&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:b,primaryVerifierWorkflowId:m,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const N=t.axeRules.length>0||t.heuristic!=null,C=t.igtWorkflowIds.length>0;let T=!1;if(N&&C?T=!s.auditRan&&!c:N?T=!s.auditRan:C?T=!c:T=!0,T)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:C||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const f={critical:0,serious:0,moderate:0,minor:0};for(const w of cs(n))f[w.impact]++;f.serious+=b;for(const w of r){const S=i.find(A=>A.id===w.workflowId);if(S)for(const A of S.steps){const I=w.steps[A.id];(I==null?void 0:I.status)==="fail"&&(A.severity==="required"?f.serious++:f.moderate++)}}const v=f.critical>0,y=f.serious>0;let E;f.critical>=5?E="F":f.critical>=1?E="D":f.serious>=1?E="C":f.moderate>=1?E="B":E="A";const k=C&&!o||d.length>0&&!u;return{id:t.id,label:t.label,letter:E,untested:!1,needsIgt:k,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:m,counts:f,caps:{cappedAtC:v,cappedAtB:y}}}function ya(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function ja(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const wa={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Na={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 ka({violations:t,componentId:s}){var V,Z,ee,U,ne,oe,ye;const[a,n]=x.useState([]),[r,i]=x.useState([]),[o,c]=x.useState(new Set),[d,p]=x.useState(null),[l,u]=x.useState({}),[h,b]=x.useState(new Set),m=g(j=>j.status),N=g(j=>j.progress),C=g(j=>j.freshThisSession),T=g(j=>j.results),f=(V=T[0])==null?void 0:V.startedAt,v=((Z=T[0])==null?void 0:Z.pageUrl)??((ee=T[0])==null?void 0:ee.scope)??null;if(x.useEffect(()=>{if(!s){n([]);return}let j=!1;return chrome.storage.local.get("igtRuns").then(_=>{if(j)return;const D=((_==null?void 0:_.igtRuns)??{})[s]??{};n(Object.values(D))}),()=>{j=!0}},[s]),x.useEffect(()=>{if(!v){i([]);return}let j=!1;return Oe(v).then(_=>{j||i(_)}),()=>{j=!0}},[v]),m==="running")return e.jsx(Ia,{current:N==null?void 0:N.current,total:N==null?void 0:N.total});const y=ba({violations:t,auditRan:T.length>0,manualRuns:a,workflows:Q,heuristicCounts:{tabOrder:((ne=(U=T[0])==null?void 0:U.tabOrderIssues)==null?void 0:ne.length)??0,readingOrder:((ye=(oe=T[0])==null?void 0:oe.readingOrderIssues)==null?void 0:ye.length)??0}}),E=g(j=>j.acknowledgedKeys),k=T.length>0?Rt(T,{runs:a,workflows:Q},"2.1","AA",E,r):void 0,w=T.length>0?ds(Et({audits:T,igtRuns:a,workflows:Q,acknowledgedMatchKeys:E,incompleteResolutions:r}),Q):void 0,S=k?!k.canClaimConformance:!1,A=S&&y.overallLetter==="A"?"B":y.overallLetter;async function I(j){var B;if(!v||!((B=k==null?void 0:k.inconclusiveReasons)!=null&&B[j]))return;const L=k.inconclusiveReasons[j].filter(q=>q.source==="axe-incomplete"&&q.elements&&q.elements.length>0);if(L.length===0)return;c(q=>new Set(q).add(j)),p(null);const D=[];let M=0;try{for(const W of L){const O=await H({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:W.ruleOrStepId,pageUrl:W.pageUrl??v,wcagCriterion:j,elements:W.elements??[],targetLevel:"AA"});if(O!=null&&O.unavailableReason){p(O.unavailableReason);break}O!=null&&O.resolutions&&(D.push(...O.resolutions),M+=O.totalCostUsd??0)}if(v){const W=await Oe(v);i(W)}const q={total:D.length,pass:D.filter(W=>W.verdict==="pass").length,fail:D.filter(W=>W.verdict==="fail").length,uncertain:D.filter(W=>W.verdict==="uncertain").length,costUsd:M,resolutions:D};u(W=>({...W,[j]:q}))}finally{c(q=>{const W=new Set(q);return W.delete(j),W})}}function K(j){b(_=>{const L=new Set(_);return L.has(j)?L.delete(j):L.add(j),L})}async function $(j){var W;if(!v||!((W=k==null?void 0:k.inconclusiveReasons)!=null&&W[j]))return;const L=k.inconclusiveReasons[j].filter(O=>O.source==="axe-incomplete"&&O.elements&&O.elements.length>0);if(L.length===0)return;const D=new Set(r.map(O=>`${O.pageUrl}::${O.ruleId}::${O.selector}`)),M=new Date().toISOString(),B=[];for(const O of L){const Le=O.pageUrl??v;for(const Ue of O.elements??[]){const ts=`${Le}::${O.ruleOrStepId}::${Ue.selector}`,tt=r.find(De=>De.pageUrl===Le&&De.ruleId===O.ruleOrStepId&&De.selector===Ue.selector);tt&&tt.verdict!=="uncertain"||(B.push({pageUrl:Le,ruleId:O.ruleOrStepId,selector:Ue.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${M.slice(0,10)}.`,resolvedAt:M,costUsd:0,wcagCriterion:j}),D.add(ts))}}if(B.length===0)return;await us(B);const q=await Oe(v);i(q),u(O=>({...O,[j]:{total:B.length,pass:B.length,fail:0,uncertain:0,costUsd:0,resolutions:B}}))}const P=(()=>{if(!S||y.overallLetter!=="A"||!k)return null;const j=k.untestedCriteria.length,_=k.inconclusiveCriteria.length,L=[];return j>0&&L.push(`${j} WCAG ${k.targetLevel} ${j===1?"criterion":"criteria"} still untested`),_>0&&L.push(`${_} WCAG ${k.targetLevel} ${_===1?"criterion":"criteria"} inconclusive`),`Capped at B — ${L.join(" + ")}. ${_>0?"Resolve axe-incomplete + IGT-skip items to claim conformance.":"Open Guided Tests to evaluate them."}`})();let G=0;for(const j of Q){const _=a.find(D=>D.workflowId===j.id);if(!_)continue;j.steps.every(D=>{const M=_.steps[D.id];return(M==null?void 0:M.status)==="pass"||(M==null?void 0:M.status)==="fail"||(M==null?void 0:M.status)==="skip"||(M==null?void 0:M.status)==="not-applicable"})&&G++}const J=t.filter(j=>!E.has(j.matchKey)).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!C&&f&&e.jsx($a,{scannedAt:f}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${wa[A]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:A})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",y.subGrades.length," verification areas below. Untested areas count as F until verified."]}),P&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:P})]})]}),y.isLawsuitRisk&&e.jsx(Ca,{areas:y.warningAreas}),e.jsx(Ra,{grades:y.subGrades}),k&&e.jsx(Sa,{coverage:k,onResolveWithAi:I,onMarkVisuallyVerified:$,resolving:o,resolveError:d,lastResolveResult:l,expandedResultFor:h,onToggleResultDetail:K}),w&&e.jsx(Aa,{layers:w}),e.jsx(Ta,{violationsRemaining:J,manualCompleted:G,manualTotal:Q.length}),G>0||T.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:G})," 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:`${G/Q.length*100}%`}})})]}):null]})}function Sa({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:c}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,l]=x.useState(d>0&&d<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,b=[];return t.failingCriteria.length>0&&b.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&b.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&b.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${h?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${h?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",u,"%)"]}),h&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!h&&(()=>{const m=[];t.failingCriteria.length>0&&m.push("failing"),t.inconclusiveCriteria.length>0&&m.push("inconclusive"),t.untestedCriteria.length>0&&m.push("untested");const N=m.length===0?"unresolved":m.length===1?m[0]:m.length===2?`${m[0]} or ${m[1]}`:`${m.slice(0,-1).join(", ")}, or ${m[m.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",N,"."]})})(),!h&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!h&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!h&&b.length>0&&e.jsx("button",{type:"button",onClick:()=>l(m=>!m),className:"text-[11px] underline shrink-0 self-start",children:p?"hide":"show list"})]}),p&&!h&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[b.map(m=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${m.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[m.kind==="untested"?"Untested":m.kind==="inconclusive"?"Inconclusive":"Failing"," (",m.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:m.ids.map(N=>{var E;const C=m.kind==="inconclusive"?(E=t.inconclusiveReasons)==null?void 0:E[N]:void 0,T=C==null?void 0:C.some(k=>k.source==="axe-incomplete"&&k.elements&&k.elements.length>0),f=(n==null?void 0:n.has(N))??!1,v=i==null?void 0:i[N],y=(o==null?void 0:o.has(N))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",N]}),m.kind==="inconclusive"&&T&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s&&e.jsx("button",{type:"button",disabled:f,onClick:()=>s(N),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:f?"Resolving…":v?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:f,onClick:()=>a(N),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),v&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",v.total," ",v.total===1?"verdict":"verdicts",":",v.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",v.pass," pass"]}),v.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",v.fail," fail"]}),v.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",v.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",v.costUsd.toFixed(4)]}),c&&e.jsx("button",{type:"button",onClick:()=>c(N),className:"ml-auto text-[10px] underline text-brand-700",children:y?"hide reasoning":"show reasoning"})]}),v.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",v.uncertain," ",v.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),v.pass===v.total&&v.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),y&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:v.resolutions.map((k,w)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:k.verdict==="pass"?"text-emerald-700 font-semibold":k.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:k.verdict==="pass"?"✓":k.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:k.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:k.reasoning})]},w))})]}),C&&C.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:C.map((k,w)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[k.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:k.ruleOrStepId})," — "]}),k.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:k.ruleOrStepId})," skipped — "]}),k.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:k.ruleOrStepId})," — "]}),k.resolutionHint,k.elements&&k.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",k.elements.length===1?"element":`${k.elements.length} elements`,":"," ",k.elements.slice(0,3).map((S,A,I)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:S.selector}),A<I.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},A)),k.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",k.elements.length-3," more"]})]})]},w))}):m.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},N)})})]},m.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const lt={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function Aa({layers:t}){const s=g(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,c=r.unevaluated.length,d=r.cleared,p=i>0&&o===0&&c===0,l=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:lt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${l}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),c>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",c," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:lt[n].hint}),n==="human"&&c>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function Ca({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 Ra({grades:t}){const s=g(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${Na[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(Ea,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Ea({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=Q.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?Bt(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 Ta({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=g(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done: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,c)=>{const d=c===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${c+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},c)})})]})}function Ia({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 $a({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 (",Bt(s)," old). Re-scan to grade the current page state."]})]})}function Bt(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 Ke="dismissedFindings";function $e(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ce(t){return`reading-order::${t}`}function de(t){return`tab-order::${t}`}async function _e(){try{const t=await chrome.storage.local.get(Ke),s=t==null?void 0:t[Ke];if(s&&typeof s=="object")return s}catch{}return{}}async function Ze(t){await chrome.storage.local.set({[Ke]:t})}async function Ie(t){return(await _e())[$e(t)]??{}}async function Ht(t,s,a,n){const r=await _e(),i=$e(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await Ze(r)}async function ve(t,s){if(s.length===0)return;const a=await _e(),n=$e(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 Ze(a)}async function zt(t,s){const a=await _e(),n=$e(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Ze(a))}const _a=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Ht,addDismissals:ve,dismissalKeyForReadingOrder:ce,dismissalKeyForTabOrder:de,getDismissalsForUrl:Ie,removeDismissal:zt},Symbol.toStringTag,{value:"Module"}));function Kt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function qt(t){return`${Ye(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function La(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=qt(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 ct={critical:0,serious:1,moderate:2,minor:3};function Ua(){var m,N,C,T;const t=g(f=>f.results),s=g(f=>f.componentId),a=g(f=>f.setView),n=((m=t[0])==null?void 0:m.pageUrl)??((N=t[0])==null?void 0:N.scope)??"",[r,i]=x.useState({}),[o,c]=x.useState(new Set);if(x.useEffect(()=>{if(!n)return;Ie(n).then(i);const f=()=>{document.visibilityState==="visible"&&n&&Ie(n).then(i)};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[n]),x.useEffect(()=>{if(!s){c(new Set);return}let f=!1;const v=async()=>{const E=await chrome.storage.local.get("igtRuns");if(f)return;const w=((E==null?void 0:E.igtRuns)??{})[s]??{},S=new Set;for(const A of Q){const I=w[A.id];I&&Object.keys(I.steps).length===A.steps.length&&S.add(A.id)}c(S)};v();const y=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",y),()=>{f=!0,document.removeEventListener("visibilitychange",y)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((f,v)=>f+v.durationMs,0),p=t.reduce((f,v)=>f+v.violations.length,0),l=La(t);l.sort((f,v)=>{const y=ct[f.representative.impact]??99,E=ct[v.representative.impact]??99;return y!==E?y-E:v.states.length-f.states.length});const u=t.map(f=>Kt(f.state)).join(`
4
+ `),h=o.has("keyboard")?0:(((C=t[0])==null?void 0:C.tabOrderIssues)??[]).filter(f=>!(de(f.selector)in r)).length,b=o.has("page-structure")?0:(((T=t[0])==null?void 0:T.readingOrderIssues)??[]).filter(f=>!(ce(f.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(ka,{violations:t.flatMap(f=>f.violations),componentId:s}),(h>0||b>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&&b>0&&" · ",b>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:b})," reading-order issue",b===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"]})," · ",l.length," unique ",l.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),l.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:l.map(f=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Te,{violation:f.representative}),e.jsx(Da,{states:f.states,totalStates:t.length})]},qt(f.representative)))})]})}function Da({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(Kt))),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 Fa={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 Oa({ruleId:t,violations:s}){const[a,n]=x.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,c=s.length;return c===1?e.jsx(Te,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Fa[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:["×",c]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,p)=>e.jsx(Te,{violation:d},p))})]})}function Ma(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 Pa={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Qt({open:t,onClose:s,format:a,content:n,filename:r}){const i=ns(new Blob([n]).size);function o(){Je(n,r),s()}function c(){Qe(n),s()}return e.jsxs(ue,{open:t,onClose:s,title:Pa[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:c,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 dt=7800;function Ga(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const l of a){const u=`${l.ruleId}::${l.target.selector}`,h=`:${l.currentState.pseudoState} · ${l.currentState.theme} · ${l.currentState.direction}`,b=r.find(m=>`${m.ruleId}::${m.target.selector}`===u);if(b){b._states.includes(h)||b._states.push(h);continue}r.push({...l,_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 l of r)o.push(`### \`${l.ruleId}\` — ${l.impact}`),o.push(""),o.push(l.description),o.push(""),o.push(`- **WCAG:** ${l.wcagCriterion} (${l.wcagLevel})`),o.push(`- **Selector:** \`${l.target.selector}\``),o.push(`- **Found in state(s):** ${l._states.join(", ")}`),l.helpUrl&&o.push(`- **More info:** ${l.helpUrl}`),o.push(""),o.push("```html"),o.push(l.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const c=o.join(`
6
+ `),d=new URLSearchParams({title:i,body:c});let p=`${n}/issues/new?${d.toString()}`;return p.length>dt&&(p=p.slice(0,dt)),{url:p,title:i,body:c}}const ut=7800;function Va(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const l of a){const u=`${l.ruleId}::${l.target.selector}`,h=`:${l.currentState.pseudoState} · ${l.currentState.theme} · ${l.currentState.direction}`,b=r.find(m=>`${m.ruleId}::${m.target.selector}`===u);if(b){b._states.includes(h)||b._states.push(h);continue}r.push({...l,_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 l of r)o.push(`Rule: ${l.ruleId} (${l.impact})`),o.push(`WCAG: ${l.wcagCriterion} ${l.wcagLevel}`),o.push(`Description: ${l.description}`),o.push(`Selector: ${l.target.selector}`),o.push(`Found in state(s): ${l._states.join(", ")}`),l.helpUrl&&o.push(`More info: ${l.helpUrl}`),o.push(""),o.push(`HTML: ${l.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const c=o.join(`
7
+ `),d=new URLSearchParams({summary:i,description:c});let p=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return p.length>ut&&(p=p.slice(0,ut)),{url:p,summary:i,description:c}}function Wa(){const t=g(v=>v.delta),s=g(v=>v.componentId),a=g(v=>v.results),n=g(v=>v.tier),r=g(v=>v.baselineList),i=g(v=>v.siteCrawlReport),[o,c]=x.useState(""),[d,p]=x.useState(""),[l,u]=x.useState(null);x.useEffect(()=>{Promise.all([z({type:"SETTINGS_GET",key:"githubRepoUrl"}),z({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,y])=>{c(typeof v.data=="string"?v.data:""),p(typeof y.data=="string"?y.data:"")})},[]);const h=It(n,"exportJson"),b=_t[n].maxBaselines,m=r.some(v=>v.componentId===s),N=m||r.length<b;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 v=a.flatMap(I=>I.violations),y=a.flatMap(I=>I.announcements??[]),E=a.flatMap(I=>I.focusEvents??[]),k=a[0],S=(await z({type:"SETTINGS_GET",key:"stateMatrix"})).data??$t;await H({type:"BASELINE_SET",componentId:s,violations:v,announcements:y,focusEvents:E,snapshotMeta:{url:window.location.href,axeVersion:k.axeVersion,matrixConfig:S,capturedAt:new Date().toISOString()}});const A=await z({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:y,focusEvents:E,currentMatrix:S});g.getState().setDelta(A.delta),te.polite(`Baseline saved for ${s}.`)}async function T(){if(!s||!m||!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 B({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(A=>A.violations),N=a.flatMap(A=>A.announcements??[]),T=a.flatMap(A=>A.focusEvents??[]),j=await H({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:N,focusEvents:T});g.getState().setDelta(j.delta);const S=await H({type:"BASELINE_LIST"});g.getState().setBaselineList(S.items),te.polite(`Baseline cleared for ${s}.`)}async function m(v,y=!1){var G,q;if(a.length===0)return;let N;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const P=await chrome.storage.local.get("igtRuns"),Z=((P==null?void 0:P.igtRuns)??{})[s]??{};N=Object.values(Z)}let T,j;if(v==="ai-prompt"){const P=((G=a[0])==null?void 0:G.pageUrl)??((q=a[0])==null?void 0:q.scope)??"";if(P){const{getDismissalsForUrl:X}=await ke(async()=>{const{getDismissalsForUrl:ne}=await Promise.resolve().then(()=>Ca);return{getDismissalsForUrl:ne}},void 0),Z=await X(P);T=Object.keys(Z);const{getResolutionsForPage:D}=await ke(async()=>{const{getResolutionsForPage:ne}=await import("./forensic-log-CI0i5Tol.js").then(oe=>oe.M);return{getResolutionsForPage:ne}},__vite__mapDeps([0,1,2]));j=await D(P)}}const S=await H({type:"EXPORT_REQUEST",format:v,results:a,delta:y?void 0:t??void 0,manualRuns:N,siteCrawlReport:v==="ai-prompt"?i??void 0:void 0,dismissedKeys:T,incompleteResolutions:j});if(v==="defense-bundle"||v==="evidence-bundle"){const P=jt(v,s);await wt()?He(S.content,P):u({open:!0,format:v,content:S.content,filename:P});return}if(v==="html-print"||v==="vpat"){Be(S.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText(S.content)}catch{}const X=`<!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 H({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(A=>A.violations),E=a.flatMap(A=>A.announcements??[]),k=a.flatMap(A=>A.focusEvents??[]),w=await z({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:E,focusEvents:k});g.getState().setDelta(w.delta);const S=await z({type:"BASELINE_LIST"});g.getState().setBaselineList(S.items),te.polite(`Baseline cleared for ${s}.`)}async function f(v,y=!1){var G,J;if(a.length===0)return;let E;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const V=await chrome.storage.local.get("igtRuns"),ee=((V==null?void 0:V.igtRuns)??{})[s]??{};E=Object.values(ee)}let k,w;if(v==="ai-prompt"){const V=((G=a[0])==null?void 0:G.pageUrl)??((J=a[0])==null?void 0:J.scope)??"";if(V){const{getDismissalsForUrl:Z}=await Se(async()=>{const{getDismissalsForUrl:ne}=await Promise.resolve().then(()=>_a);return{getDismissalsForUrl:ne}},void 0),ee=await Z(V);k=Object.keys(ee);const{getResolutionsForPage:U}=await Se(async()=>{const{getResolutionsForPage:ne}=await import("./forensic-log-CwwnrQMK.js").then(oe=>oe.M);return{getResolutionsForPage:ne}},__vite__mapDeps([0,1,2]));w=await U(V)}}const S=await z({type:"EXPORT_REQUEST",format:v,results:a,delta:y?void 0:t??void 0,manualRuns:E,siteCrawlReport:v==="ai-prompt"?i??void 0:void 0,dismissedKeys:k,incompleteResolutions:w});if(v==="defense-bundle"||v==="evidence-bundle"){const V=St(v,s);await At()?Je(S.content,V):u({open:!0,format:v,content:S.content,filename:V});return}if(v==="html-print"||v==="vpat"){Qe(S.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText(S.content)}catch{}const Z=`<!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;}
@@ -23,40 +23,40 @@ document.getElementById('copy').addEventListener('click', () => {
23
23
  navigator.clipboard.writeText(document.getElementById('content').textContent || '');
24
24
  });
25
25
  <\/script>
26
- </body></html>`,Z=new Blob([X],{type:"text/html"}),D=URL.createObjectURL(Z);window.open(D,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(D),6e4);return}const A=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",I=v==="junit"?"xml":v,z=new Blob([S.content],{type:A}),$=URL.createObjectURL(z),U=document.createElement("a");U.href=$,U.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${I}`,U.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:E,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"}),b&&e.jsx("button",{onClick:R,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(Ga,{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 v=Ue(t.new),y=Ue(t.persistent),N=Ue(t.fixed),T=[...v.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(xe,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>Ma(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>Pa(d,s,v.findings)}]:[]]}),e.jsx(xe,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(xe,{title:"Fixed",violations:N.findings,count:t.fixedCount,accent:"green"}),T.length>0&&e.jsx(xe,{title:"Needs review (does not affect grade)",violations:T,count:T.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(xe,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),l&&e.jsx(Ht,{open:l.open,onClose:()=>u(null),format:l.format,content:l.content,filename:l.filename})]})}const Oa={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ue(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 xe({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,c]=x.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Oa[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>c(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,p)=>e.jsx(Ee,{violation:d,alreadyAcknowledged:!0},p)):_a(s).map(d=>e.jsx($a,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Ma(t,s,a){if(a.length===0)return;const{url:n}=Ua(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Pa(t,s,a){if(a.length===0)return;const{url:n}=Da(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Ga({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=x.useState(!1),[i,o]=x.useState(!1);function c(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(re,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(re,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(re,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(re,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(re,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(re,{onClick:()=>c("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(re,{onClick:()=>c("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(re,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function re({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 lt="igtRuns";async function Va(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:{}}async function Wa(t,s){var o,c;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Va())[t];if(i)for(const d of K){const p=i[d.id];if(p)for(const l of d.steps){if(!l.autoDismissActivity||((c=(o=p.steps)==null?void 0:o[l.id])==null?void 0:c.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${l.id}" marked pass`;if(l.autoDismissActivity==="tab-order"){const f=a.tabOrderIssues??[];if(f.length===0)continue;await ve(n,f.map(b=>({key:de(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}else if(l.autoDismissActivity==="reading-order"){const f=a.readingOrderIssues??[];if(f.length===0)continue;await ve(n,f.map(b=>({key:ce(b.selector),reason:h,snippet:`${b.selector} — ${b.textSnippet||"(no text)"}`})))}}}}const Ba=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"]),Ha=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 za(t){return Ba.has(t.ruleId)}function Ka(t){return Ha.has(t.ruleId)}function qa(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Qa(){var S,A,I,z;const t=g($=>$.results),s=g($=>$.delta),a=g($=>$.componentId),n=((S=t[0])==null?void 0:S.pageUrl)??((A=t[0])==null?void 0:A.scope)??"",[r,i]=x.useState({}),[o,c]=x.useState(0);x.useEffect(()=>{if(!n)return;let $=!1;return(async()=>{if(a&&t.length>0)try{await Wa(a,t)}catch{}if($)return;const U=await Te(n);$||i(U)})(),()=>{$=!0}},[n,o,a,t]);async function d($,U){if(!n)return;const G=window.prompt(`Why is this finding a false positive?
26
+ </body></html>`,ee=new Blob([Z],{type:"text/html"}),U=URL.createObjectURL(ee);window.open(U,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(U),6e4);return}const A=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",I=v==="junit"?"xml":v,K=new Blob([S.content],{type:A}),$=URL.createObjectURL(K),P=document.createElement("a");P.href=$,P.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${I}`,P.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:!N,title:N?void 0:`Free tier limits you to ${b} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),m&&e.jsx("button",{onClick:T,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(Ka,{disabled:!h,onExport:f,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!N&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const v=Pe(t.new),y=Pe(t.persistent),E=Pe(t.fixed),k=[...v.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(xe,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>Ha(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>za(d,s,v.findings)}]:[]]}),e.jsx(xe,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(xe,{title:"Fixed",violations:E.findings,count:t.fixedCount,accent:"green"}),k.length>0&&e.jsx(xe,{title:"Needs review (does not affect grade)",violations:k,count:k.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(xe,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),l&&e.jsx(Qt,{open:l.open,onClose:()=>u(null),format:l.format,content:l.content,filename:l.filename})]})}const Ba={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Pe(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 xe({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,c]=x.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Ba[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>c(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,p)=>e.jsx(Te,{violation:d,alreadyAcknowledged:!0},p)):Ma(s).map(d=>e.jsx(Oa,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function Ha(t,s,a){if(a.length===0)return;const{url:n}=Ga(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function za(t,s,a){if(a.length===0)return;const{url:n}=Va(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Ka({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=x.useState(!1),[i,o]=x.useState(!1);function c(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(re,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(re,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(re,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(re,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(re,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(re,{onClick:()=>c("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(re,{onClick:()=>c("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(re,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function re({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 pt="igtRuns";async function qa(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(pt))[pt];return s&&typeof s=="object"?s:{}}async function Qa(t,s){var o,c;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await qa())[t];if(i)for(const d of Q){const p=i[d.id];if(p)for(const l of d.steps){if(!l.autoDismissActivity||((c=(o=p.steps)==null?void 0:o[l.id])==null?void 0:c.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${l.id}" marked pass`;if(l.autoDismissActivity==="tab-order"){const b=a.tabOrderIssues??[];if(b.length===0)continue;await ve(n,b.map(m=>({key:de(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}else if(l.autoDismissActivity==="reading-order"){const b=a.readingOrderIssues??[];if(b.length===0)continue;await ve(n,b.map(m=>({key:ce(m.selector),reason:h,snippet:`${m.selector} — ${m.textSnippet||"(no text)"}`})))}}}}const Ja=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"]),Ya=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 Xa(t){return Ja.has(t.ruleId)}function Za(t){return Ya.has(t.ruleId)}function en(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function tn(){var S,A,I,K;const t=g($=>$.results),s=g($=>$.delta),a=g($=>$.componentId),n=((S=t[0])==null?void 0:S.pageUrl)??((A=t[0])==null?void 0:A.scope)??"",[r,i]=x.useState({}),[o,c]=x.useState(0);x.useEffect(()=>{if(!n)return;let $=!1;return(async()=>{if(a&&t.length>0)try{await Qa(a,t)}catch{}if($)return;const P=await Ie(n);$||i(P)})(),()=>{$=!0}},[n,o,a,t]);async function d($,P){if(!n)return;const G=window.prompt(`Why is this finding a false positive?
27
27
 
28
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");G!==null&&(await Gt(n,$,G||"(no reason given)",U),c(q=>q+1))}async function p($){n&&(await Vt(n,$),c(U=>U+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 l=t.reduce(($,U)=>{var G;return $+(((G=U.announcements)==null?void 0:G.length)??0)},0),u=t.reduce(($,U)=>{var G;return $+(((G=U.focusEvents)==null?void 0:G.length)??0)},0),h=t.reduce(($,U)=>{var G;return $+(((G=U.focusEvents)==null?void 0:G.filter(q=>q.isFocusReset).length)??0)},0),f=ct(t,za),b=ct(t,Ka),w=f.length,E=b.length,R=((I=t[0])==null?void 0:I.readingOrderIssues)??[],m=((z=t[0])==null?void 0:z.tabOrderIssues)??[],v=R.filter($=>!(ce($.selector)in r)),y=R.filter($=>ce($.selector)in r),N=m.filter($=>!(de($.selector)in r)),T=m.filter($=>de($.selector)in r);if(l===0&&u===0&&w===0&&E===0&&v.length===0&&N.length===0&&y.length===0&&T.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const j=y.length+T.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[w," structural · ",E," form ·"," ",N.length," tab-order ·"," ",v.length," reading-order ·"," ",l," ",l===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"]}),j>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",j," dismissed"]})]}),N.length>0&&e.jsx(Xa,{issues:N,onDismiss:d}),v.length>0&&e.jsx(Za,{issues:v,onDismiss:d}),j>0&&e.jsx(en,{dismissedReadingOrder:y,dismissedTabOrder:T,dismissals:r,onRestore:p}),w>0&&e.jsx(dt,{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}),E>0&&e.jsx(dt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:b}),e.jsx(Ja,{delta:s}),t.map(($,U)=>{const G=$.announcements??[],q=$.focusEvents??[];return G.length===0&&q.length===0?null:e.jsx(Ya,{state:$.state,announcements:G,focusEvents:q},U)})]})}function Ja({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 ct(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ze(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 dt({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 Ya({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:qa(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 Xa({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 en({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(c=>{const d=`tab-order::${c.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:c.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:c.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(c=>{const d=`reading-order::${c.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:c.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:c.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const We="igtRuns";async function tn(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 ve(r,o.map(c=>({key:de(c.selector),reason:i,snippet:`${c.selector} — ${c.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await ve(r,o.map(c=>({key:ce(c.selector),reason:i,snippet:`${c.selector} — ${c.textSnippet||"(no text)"}`})))}}const sn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},an={outline:{type:"OUTLINE_HIDE_REQUEST"},"tab-order":{type:"TAB_ORDER_HIDE_REQUEST"},"reading-order":{type:"READING_ORDER_HIDE_REQUEST"},targets:{type:"TARGET_SIZE_HIDE_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_HIDE_REQUEST"}},nn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function ut(t,s){const a=await Q();if(!a)return;const n=s?sn[t]:an[t];try{await se(a,n)}catch{}}async function rn(){const s=(await chrome.storage.local.get(We))[We];return s&&typeof s=="object"?s:{}}async function pt(t){await chrome.storage.local.set({[We]:t})}function on(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 ln(){const t=g(l=>l.componentId),s=g(l=>l.results),[a,n]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{rn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function c(l,u,h){var b;const f={...a,[t]:{...o,[l]:{...o[l]??{componentId:t,workflowId:l,steps:{},completedAt:new Date().toISOString()},steps:{...((b=o[l])==null?void 0:b.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(f),pt(f),h.status==="pass"){const w=K.find(R=>R.id===l),E=w==null?void 0:w.steps.find(R=>R.id===u);E!=null&&E.autoDismissActivity&&tn(E.autoDismissActivity,s,u)}}function d(l){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[l];const h={...a,[t]:u};n(h),pt(h)}const p=K.find(l=>l.id===r);if(p){const l=o[p.id];return e.jsx(cn,{workflow:p,run:l,results:s,onAnswer:(u,h)=>c(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(l=>{const u=o[l.id],h=u?is(u,l):null,f=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",b={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[f];return e.jsxs("button",{type:"button",onClick:()=>i(l.id),className:`w-full text-left border rounded p-2 block transition-colors ${b}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:l.name}),f==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),f==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:l.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(l.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},l.id)})]})}function cn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=x.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=on(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const c=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),c>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:[c," step",c===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 ",c," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const l=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(l==null?void 0:l.status)==="pass"?"border-emerald-300 bg-emerald-50":(l==null?void 0:l.status)==="fail"?"border-rose-300 bg-rose-50":(l==null?void 0:l.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!l&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!l&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void ut(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",nn[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void ut(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(ye,{label:"Pass",active:(l==null?void 0:l.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:l==null?void 0:l.notes})}),e.jsx(ye,{label:"Fail",active:(l==null?void 0:l.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:l==null?void 0:l.notes})}),e.jsx(ye,{label:"N/A",active:(l==null?void 0:l.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:l==null?void 0:l.notes})}),e.jsx(ye,{label:"Skip",active:(l==null?void 0:l.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:l==null?void 0:l.notes})})]}),l&&e.jsx("textarea",{placeholder:"Notes (optional)",value:l.notes??"",onChange:u=>n(d.id,{status:l.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const dn={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 ye({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?dn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const we="savedFlows";async function un(){const t=await chrome.storage.local.get(we);return Array.isArray(t[we])?t[we]:[]}async function ht(t){await chrome.storage.local.set({[we]:t})}function pn(){const[t,s]=x.useState([]),[a,n]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{un().then(s)},[]);async function o(){const l=await Q();if(!l){i("No audit-target tab found.");return}try{await se(l,{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 c(){const l=await Q();if(l)try{const u=await be(l,{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()},b=[f,...t];s(b),await ht(b),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(l){const u=await Q();if(u){i(`Replaying "${l.name}"…`);try{const h=await be(u,{type:"FLOW_PLAY_REQUEST",steps:l.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(l){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==l);s(u),await ht(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:c,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(l=>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:l.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[l.steps.length," step",l.steps.length===1?"":"s"," ·"," ",new Date(l.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(l),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(l.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},l.id))})]})}function hn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(mn).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function mn(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function xn(){const t=g(c=>c.baselineList),s=g(c=>c.tier),a=Et[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=x.useState(!1);if(x.useEffect(()=>{Ae().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(c=>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"})]},c))});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(c){await B({type:"BASELINE_DELETE",componentId:c}),await Ae()}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(c=>{const d=hn(c.componentId),p=c.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:c.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[c.violationCount," ",c.violationCount===1?"violation":"violations"," ·"," ",new Date(c.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[c.seenOnUrlsCount&&c.seenOnUrlsCount>1&&e.jsxs(ie,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",c.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(ie,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(ie,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(ie,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(ie,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(ie,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(ie,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(c.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},c.componentId)})]})}const gn={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 ie({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${gn[t]}`,children:a})}const fn={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"},bn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},vn={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 zt({onBack:t}){const s=g(u=>u.siteCrawlStatus),a=g(u=>u.siteCrawlProgress),n=g(u=>u.siteCrawlReport),r=g(u=>u.siteCrawlError),[i,o]=x.useState(""),[c,d]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var f;const h=(f=u[0])==null?void 0:f.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(g.getState().setSiteCrawlStatus("running"),g.getState().setSiteCrawlReport(null),g.getState().setSiteCrawlError(null),ae({type:"START_SITE_CRAWL",startUrl:i,maxPages:c}))}function l(){B({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:c,onChange:u=>d(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:l,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(yn,{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 yn({report:t}){function s(){ke(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-BocuwvYR.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,0,1,2])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${fn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${bn[t.siteRisk]}`,children:os[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=ls(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 ${vn[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 De="onboardingDismissed",Fe=[{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 jn(){const[t,s]=x.useState(!1),[a,n]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(De).then(c=>{c[De]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[De]:!0}),s(!1),n(0)}const i=a===Fe.length-1,o=Fe[a];return e.jsxs(ue,{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," / ",Fe.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(c=>c-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(c=>c+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function wn(){const t=g(n=>n.status),s=g(n=>n.errorMessage),a=g(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Nn(){const t=g(d=>d.aiFailure),s=g(d=>d.clearAiFailure),[a,n]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",c=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})," ",c]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function mt(){const[t,s]=x.useState(!1);return x.useEffect(()=>J("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),g.getState().setStatus("idle"))}),[]),e.jsxs(ue,{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 kn(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{cs().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Ze(),g.getState().startNewScan(),t.mode==="storybook-all"?ae({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ae({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Ze(),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 Oe="storybook:hintDismissed";function Sn(){const[t,s]=x.useState(!1),[a,n]=x.useState();x.useEffect(()=>{(async()=>{var c;if((await chrome.storage.local.get(Oe))[Oe])return;const o=await Q();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const l=window;return{detected:typeof l.__STORYBOOK_PREVIEW__=="object",version:(u=l.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(l=>{var u;return(u=l.result)==null?void 0:u.detected});p&&(n((c=p.result)==null?void 0:c.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Oe]:!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 An(){var i;const t=g(o=>o.results),s=g(o=>o.baselineList),a=g(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Cn(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 Cn(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 c=Math.round(o/24);return c<7?`${c}d ago`:a.toLocaleDateString()}function Rn(){const t=g(c=>c.results),s=g(c=>c.componentId),[a,n]=x.useState([]);if(x.useEffect(()=>{if(!s){n([]);return}let c=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(c)return;const l=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(l))}),()=>{c=!0}},[s]),t.length===0)return null;const r=t.flatMap(c=>c.violations),i=ds(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 En(){const t=g(a=>a.setUserMode);function s(a){t(a),B({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 Tn=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],In={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function $n(t){const s=new Set(Tn),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:In[o]}}const Kt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},_n={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Kt]},Ln={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Kt]};function Qe(t){return t==="thorough"?Ln:_n}function xt(t){const s=Qe(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Ne="wcagcheckr";function O(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function fe(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 Un(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Dn(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 Fn(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 On(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 Mn(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 (${O(t.receipt.tsaName)}) — anchored ${O(fe(t.receipt.anchoredAt))}</td></tr>
29
- <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${O(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
- ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${O(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${O(Ne)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
28
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");G!==null&&(await Ht(n,$,G||"(no reason given)",P),c(J=>J+1))}async function p($){n&&(await zt(n,$),c(P=>P+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 l=t.reduce(($,P)=>{var G;return $+(((G=P.announcements)==null?void 0:G.length)??0)},0),u=t.reduce(($,P)=>{var G;return $+(((G=P.focusEvents)==null?void 0:G.length)??0)},0),h=t.reduce(($,P)=>{var G;return $+(((G=P.focusEvents)==null?void 0:G.filter(J=>J.isFocusReset).length)??0)},0),b=ht(t,Xa),m=ht(t,Za),N=b.length,C=m.length,T=((I=t[0])==null?void 0:I.readingOrderIssues)??[],f=((K=t[0])==null?void 0:K.tabOrderIssues)??[],v=T.filter($=>!(ce($.selector)in r)),y=T.filter($=>ce($.selector)in r),E=f.filter($=>!(de($.selector)in r)),k=f.filter($=>de($.selector)in r);if(l===0&&u===0&&N===0&&C===0&&v.length===0&&E.length===0&&y.length===0&&k.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const w=y.length+k.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:[N," structural · ",C," form ·"," ",E.length," tab-order ·"," ",v.length," reading-order ·"," ",l," ",l===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),w>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",w," dismissed"]})]}),E.length>0&&e.jsx(nn,{issues:E,onDismiss:d}),v.length>0&&e.jsx(rn,{issues:v,onDismiss:d}),w>0&&e.jsx(on,{dismissedReadingOrder:y,dismissedTabOrder:k,dismissals:r,onRestore:p}),N>0&&e.jsx(mt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:b}),C>0&&e.jsx(mt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:m}),e.jsx(sn,{delta:s}),t.map(($,P)=>{const G=$.announcements??[],J=$.focusEvents??[];return G.length===0&&J.length===0?null:e.jsx(an,{state:$.state,announcements:G,focusEvents:J},P)})]})}function sn({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 ht(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=Ye(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 mt({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 an({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:en(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 nn({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 rn({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function on({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(c=>{const d=`tab-order::${c.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:c.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:c.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(c=>{const d=`reading-order::${c.selector}`,p=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:c.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:c.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const qe="igtRuns";async function ln(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 ve(r,o.map(c=>({key:de(c.selector),reason:i,snippet:`${c.selector} — ${c.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await ve(r,o.map(c=>({key:ce(c.selector),reason:i,snippet:`${c.selector} — ${c.textSnippet||"(no text)"}`})))}}const cn={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"}},dn={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"}},un={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function xt(t,s){const a=await Y();if(!a)return;const n=s?cn[t]:dn[t];try{await se(a,n)}catch{}}async function pn(){const s=(await chrome.storage.local.get(qe))[qe];return s&&typeof s=="object"?s:{}}async function gt(t){await chrome.storage.local.set({[qe]:t})}function hn(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 mn(){const t=g(l=>l.componentId),s=g(l=>l.results),[a,n]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{pn().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 c(l,u,h){var m;const b={...a,[t]:{...o,[l]:{...o[l]??{componentId:t,workflowId:l,steps:{},completedAt:new Date().toISOString()},steps:{...((m=o[l])==null?void 0:m.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(b),gt(b),h.status==="pass"){const N=Q.find(T=>T.id===l),C=N==null?void 0:N.steps.find(T=>T.id===u);C!=null&&C.autoDismissActivity&&ln(C.autoDismissActivity,s,u)}}function d(l){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[l];const h={...a,[t]:u};n(h),gt(h)}const p=Q.find(l=>l.id===r);if(p){const l=o[p.id];return e.jsx(xn,{workflow:p,run:l,results:s,onAnswer:(u,h)=>c(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(l=>{const u=o[l.id],h=u?ps(u,l):null,b=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",m={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[b];return e.jsxs("button",{type:"button",onClick:()=>i(l.id),className:`w-full text-left border rounded p-2 block transition-colors ${m}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:l.name}),b==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),b==="in-progress"&&h&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[h.unanswered," unanswered"]})]}),h&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.notApplicable>0&&e.jsxs("span",{children:[" · ",h.notApplicable," N/A"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:l.blurb}),u&&e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),d(l.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},l.id)})]})}function xn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=x.useMemo(()=>{const d={};for(const p of t.steps)d[p.id]=hn(p,a);return d},[t,a]);function o(){for(const d of t.steps){const p=i[d.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const c=t.steps.filter(d=>{var p;return((p=i[d.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),c>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:[c," step",c===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 ",c," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,p)=>{const l=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(l==null?void 0:l.status)==="pass"?"border-emerald-300 bg-emerald-50":(l==null?void 0:l.status)==="fail"?"border-rose-300 bg-rose-50":(l==null?void 0:l.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const u=i[d.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!l&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!l&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void xt(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",un[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void xt(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(je,{label:"Pass",active:(l==null?void 0:l.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:l==null?void 0:l.notes})}),e.jsx(je,{label:"Fail",active:(l==null?void 0:l.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:l==null?void 0:l.notes})}),e.jsx(je,{label:"N/A",active:(l==null?void 0:l.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:l==null?void 0:l.notes})}),e.jsx(je,{label:"Skip",active:(l==null?void 0:l.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:l==null?void 0:l.notes})})]}),l&&e.jsx("textarea",{placeholder:"Notes (optional)",value:l.notes??"",onChange:u=>n(d.id,{status:l.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const gn={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 je({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?gn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Ne="savedFlows";async function fn(){const t=await chrome.storage.local.get(Ne);return Array.isArray(t[Ne])?t[Ne]:[]}async function ft(t){await chrome.storage.local.set({[Ne]:t})}function bn(){const[t,s]=x.useState([]),[a,n]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{fn().then(s)},[]);async function o(){const l=await Y();if(!l){i("No audit-target tab found.");return}try{await se(l,{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 c(){const l=await Y();if(l)try{const u=await be(l,{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 b={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},m=[b,...t];s(m),await ft(m),i(`Saved "${b.name}" with ${b.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function d(l){const u=await Y();if(u){i(`Replaying "${l.name}"…`);try{const h=await be(u,{type:"FLOW_PLAY_REQUEST",steps:l.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(l){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==l);s(u),await ft(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:c,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(l=>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:l.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[l.steps.length," step",l.steps.length===1?"":"s"," ·"," ",new Date(l.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(l),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(l.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},l.id))})]})}function vn(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(yn).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function yn(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function jn(){const t=g(c=>c.baselineList),s=g(c=>c.tier),a=_t[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=x.useState(!1);if(x.useEffect(()=>{Ce().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(c=>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"})]},c))});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(c){await H({type:"BASELINE_DELETE",componentId:c}),await Ce()}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(c=>{const d=vn(c.componentId),p=c.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:c.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[c.violationCount," ",c.violationCount===1?"violation":"violations"," ·"," ",new Date(c.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[c.seenOnUrlsCount&&c.seenOnUrlsCount>1&&e.jsxs(ie,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",c.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(ie,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(ie,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(ie,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(ie,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(ie,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(ie,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(c.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},c.componentId)})]})}const wn={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 ie({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${wn[t]}`,children:a})}const Nn={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"},kn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Sn={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 Jt({onBack:t}){const s=g(u=>u.siteCrawlStatus),a=g(u=>u.siteCrawlProgress),n=g(u=>u.siteCrawlReport),r=g(u=>u.siteCrawlError),[i,o]=x.useState(""),[c,d]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var b;const h=(b=u[0])==null?void 0:b.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(g.getState().setSiteCrawlStatus("running"),g.getState().setSiteCrawlReport(null),g.getState().setSiteCrawlError(null),ae({type:"START_SITE_CRAWL",startUrl:i,maxPages:c}))}function l(){H({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),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:c,onChange:u=>d(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:l,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(An,{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 An({report:t}){function s(){Se(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-BrlLZK3X.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,0,1,2])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Nn[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${kn[t.siteRisk]}`,children:hs[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=ms(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 ${Sn[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 Ge="onboardingDismissed",Ve=[{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 Cn(){const[t,s]=x.useState(!1),[a,n]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(Ge).then(c=>{c[Ge]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ge]:!0}),s(!1),n(0)}const i=a===Ve.length-1,o=Ve[a];return e.jsxs(ue,{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," / ",Ve.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(c=>c-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(c=>c+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Rn(){const t=g(n=>n.status),s=g(n=>n.errorMessage),a=g(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function En(){const t=g(d=>d.aiFailure),s=g(d=>d.clearAiFailure),[a,n]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",c=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})," ",c]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,p)=>e.jsx("li",{children:d},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function bt(){const[t,s]=x.useState(!1);return x.useEffect(()=>X("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),g.getState().setStatus("idle"))}),[]),e.jsxs(ue,{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 Tn(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{xs().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await at(),g.getState().startNewScan(),t.mode==="storybook-all"?ae({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ae({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await at(),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 We="storybook:hintDismissed";function In(){const[t,s]=x.useState(!1),[a,n]=x.useState();x.useEffect(()=>{(async()=>{var c;if((await chrome.storage.local.get(We))[We])return;const o=await Y();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const l=window;return{detected:typeof l.__STORYBOOK_PREVIEW__=="object",version:(u=l.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(l=>{var u;return(u=l.result)==null?void 0:u.detected});p&&(n((c=p.result)==null?void 0:c.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[We]:!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 $n(){var i;const t=g(o=>o.results),s=g(o=>o.baselineList),a=g(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${_n(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 _n(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 c=Math.round(o/24);return c<7?`${c}d ago`:a.toLocaleDateString()}function Ln(){const t=g(c=>c.results),s=g(c=>c.componentId),[a,n]=x.useState([]);if(x.useEffect(()=>{if(!s){n([]);return}let c=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(c)return;const l=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(l))}),()=>{c=!0}},[s]),t.length===0)return null;const r=t.flatMap(c=>c.violations),i=gs(r,a.length>0?{runs:a,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 Un(){const t=g(a=>a.setUserMode);function s(a){t(a),H({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 Dn=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],Fn={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function On(t){const s=new Set(Dn),a=new Map;for(const d of t)s.has(d.ruleId)&&a.set(d.ruleId,(a.get(d.ruleId)??0)+1);const n=Array.from(a.entries()).map(([d,p])=>({ruleId:d,instanceCount:p})).sort((d,p)=>p.instanceCount-d.instanceCount),r=n.length,i=Array.from(a.values()).reduce((d,p)=>d+p,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Fn[o]}}const Yt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Mn={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Yt]},Pn={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Yt]};function et(t){return t==="thorough"?Pn:Mn}function vt(t){const s=et(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const ke="wcagcheckr";function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function fe(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 Gn(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Vn(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 Wn(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 Bn(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 Hn(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 (${F(t.receipt.tsaName)}) — anchored ${F(fe(t.receipt.anchoredAt))}</td></tr>
29
+ <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${F(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${F(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${F(ke)}; 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 ${On(t.grade)}">${O(t.grade)}</span>
33
+ <span class="grade-badge ${Bn(t.grade)}">${F(t.grade)}</span>
34
34
  <div class="entry-headline">
35
- <div class="entry-time">${O(fe(t.capturedAt))}</div>
35
+ <div class="entry-time">${F(fe(t.capturedAt))}</div>
36
36
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
37
37
  </div>
38
38
  </header>
39
39
  <table class="entry-fields">
40
- <tr><th>Audit identity hash</th><td><code class="hash">${O(t.hash)}</code></td></tr>
41
- <tr><th>Page URL</th><td><code>${O(t.pageUrl)}</code></td></tr>
42
- <tr><th>Scope</th><td><code>${O(t.scope)}</code></td></tr>
43
- <tr><th>axe-core version</th><td>${O(t.axeVersion)}</td></tr>
40
+ <tr><th>Audit identity hash</th><td><code class="hash">${F(t.hash)}</code></td></tr>
41
+ <tr><th>Page URL</th><td><code>${F(t.pageUrl)}</code></td></tr>
42
+ <tr><th>Scope</th><td><code>${F(t.scope)}</code></td></tr>
43
+ <tr><th>axe-core version</th><td>${F(t.axeVersion)}</td></tr>
44
44
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
45
45
  ${n}
46
46
  </table>
47
- </article>`}function Pn(t){return`
47
+ </article>`}function zn(t){return`
48
48
  <section class="component-section">
49
49
  <h2>
50
- <span class="component-id">${O(t.componentId)}</span>
50
+ <span class="component-id">${F(t.componentId)}</span>
51
51
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
52
52
  </h2>
53
- <p class="component-url"><strong>Page audited:</strong> <code>${O(t.pageUrl)}</code></p>
54
- ${t.entries.map(Mn).join("")}
55
- </section>`}function Gn(t){const{entries:s,extensionVersion:a}=t,n=Fn(s),r=Dn(s),i=(t.axeVersions??Un(s)).join(", "),o=s.length,c=s.filter(l=>l.receipt).length,d=o-c,p=fe(new Date().toISOString());return`<!doctype html>
53
+ <p class="component-url"><strong>Page audited:</strong> <code>${F(t.pageUrl)}</code></p>
54
+ ${t.entries.map(Hn).join("")}
55
+ </section>`}function Kn(t){const{entries:s,extensionVersion:a}=t,n=Wn(s),r=Vn(s),i=(t.axeVersions??Gn(s)).join(", "),o=s.length,c=s.filter(l=>l.receipt).length,d=o-c,p=fe(new Date().toISOString());return`<!doctype html>
56
56
  <html lang="en">
57
57
  <head>
58
58
  <meta charset="utf-8" />
59
- <title>Pre-litigation accessibility audit report — ${O(t.matterReference??p)}</title>
59
+ <title>Pre-litigation accessibility audit report — ${F(t.matterReference??p)}</title>
60
60
  <style>
61
61
  *, *::before, *::after { box-sizing: border-box; }
62
62
  :root {
@@ -197,17 +197,17 @@ document.getElementById('copy').addEventListener('click', () => {
197
197
  <p class="eyebrow">Accessibility audit — pre-litigation report</p>
198
198
  <h1>Audit history &amp; chain-of-custody</h1>
199
199
  <dl class="cover-meta">
200
- ${t.matterReference?`<dt>Matter reference</dt><dd>${O(t.matterReference)}</dd>`:""}
201
- ${t.preparedBy?`<dt>Prepared by</dt><dd>${O(t.preparedBy)}</dd>`:""}
202
- ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${O(t.jurisdiction)}</dd>`:""}
203
- <dt>Report generated</dt><dd>${O(p)}</dd>
204
- <dt>Audit period</dt><dd>${r?`${O(fe(r.earliest))} — ${O(fe(r.latest))}`:"No audits recorded"}</dd>
200
+ ${t.matterReference?`<dt>Matter reference</dt><dd>${F(t.matterReference)}</dd>`:""}
201
+ ${t.preparedBy?`<dt>Prepared by</dt><dd>${F(t.preparedBy)}</dd>`:""}
202
+ ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${F(t.jurisdiction)}</dd>`:""}
203
+ <dt>Report generated</dt><dd>${F(p)}</dd>
204
+ <dt>Audit period</dt><dd>${r?`${F(fe(r.earliest))} — ${F(fe(r.latest))}`:"No audits recorded"}</dd>
205
205
  </dl>
206
206
  </section>
207
207
 
208
208
  <aside class="attestation">
209
209
  <h3>Attestation</h3>
210
- <p>The audit records summarized below were captured by the <strong>${O(Ne)}</strong> Chrome extension, version <strong>${O(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${O(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>${F(ke)}</strong> Chrome extension, version <strong>${F(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${F(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
211
211
  <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
212
212
  <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
213
213
  </aside>
@@ -217,11 +217,11 @@ document.getElementById('copy').addEventListener('click', () => {
217
217
  <tr><th>RFC 3161-anchored audits</th><td>${c}</td></tr>
218
218
  <tr><th>Local-only audits</th><td>${d}</td></tr>
219
219
  <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
220
- <tr><th>axe-core version(s) observed</th><td>${O(i||"n/a")}</td></tr>
221
- <tr><th>Tool</th><td>${O(Ne)} ${O(a)}</td></tr>
220
+ <tr><th>axe-core version(s) observed</th><td>${F(i||"n/a")}</td></tr>
221
+ <tr><th>Tool</th><td>${F(ke)} ${F(a)}</td></tr>
222
222
  </table>
223
223
 
224
- ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Pn).join("")}
224
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(zn).join("")}
225
225
 
226
226
  <section class="methodology">
227
227
  <h2>Methodology</h2>
@@ -245,17 +245,17 @@ document.getElementById('copy').addEventListener('click', () => {
245
245
  </section>
246
246
 
247
247
  <footer>
248
- <span>Generated ${O(p)} by ${O(Ne)} ${O(a)}</span>
248
+ <span>Generated ${F(p)} by ${F(ke)} ${F(a)}</span>
249
249
  <span>${o} audit${o===1?"":"s"} · ${c} anchored · ${n.length} component${n.length===1?"":"s"}</span>
250
250
  </footer>
251
251
  </body>
252
- </html>`}async function Vn(t){const s=Gn(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function qt(){const[t,s]=x.useState(null),[a,n]=x.useState(null),[r,i]=x.useState(0),[o,c]=x.useState(!1),[d,p]=x.useState(""),[l,u]=x.useState(""),[h,f]=x.useState(""),[b,w]=x.useState(!1);if(x.useEffect(()=>{let y=!1;return s(null),n(null),At().then(N=>{y||s(N)}).catch(N=>{y||n(N instanceof Error?N.message:String(N))}),()=>{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 E=t.length,R=t.filter(y=>y.receipt).length;async function m(){if(!(!t||t.length===0)){w(!0);try{await Vn({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:l.trim()||void 0,jurisdiction:h.trim()||void 0}),c(!1)}finally{w(!1)}}}async function v(){if(!t||t.length===0)return;const y={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},N=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),T=URL.createObjectURL(N),j=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,S=document.createElement("a");S.href=T,S.download=j,S.click(),setTimeout(()=>URL.revokeObjectURL(T),1e3)}return E===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:[E," ",E===1?"entry":"entries",R>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[R," RFC 3161-anchored"]})]}),R===0&&E>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:()=>c(y=>!y),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void v(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(y=>y+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:y=>p(y.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:l,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:()=>c(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:b||E===0,onClick:m,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:b?"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 Wn(){const[t,s]=x.useState(null),[a,n]=x.useState(!1);if(x.useEffect(()=>{let d=!1;return At().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),c=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),c>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[c," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(ue,{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(qt,{})})})]})}function Bn(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Hn={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."},zn={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."},Kn={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},qn={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Qt(){const t=g(u=>u.tier),s=g(u=>u.trialDaysRemaining),a=g(u=>u.seatsUsed),n=g(u=>u.seatsTotal),r=g(u=>u.planCode),i=g(u=>u.licenseDaysRemaining),o=g(u=>u.pastDue),[c,d]=x.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,h=u!==null&&u<=7,f=u===null?"":u===0?"expires today":u===1?"1 day left":`${u} days left`;return e.jsxs("aside",{"aria-label":"License status",className:h?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:h?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),f&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",f]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void B({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ge,{open:c,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?qn:Kn,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,f=t==="team"&&a!==null&&n!==null&&a>n,b=t==="team"&&a!==null&&n!==null&&a===n,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"}:b?{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."}),b&&!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 B({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?Hn:zn,l=t==="trial"?Bn(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:l})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void B({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(Ge,{open:c,onClose:()=>d(!1)})]})}const Qn={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"},Jn={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},gt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Yn={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"},ft={critical:0,serious:1,moderate:2,minor:3};function Xn(){const t=g(u=>u.setUserMode),s=g(u=>u.status),a=g(u=>u.setStatus),n=g(u=>u.errorMessage),r=g(u=>u.setError),[i,o]=x.useState(!1),[c,d]=x.useState(!1),p=x.useRef(s);x.useEffect(()=>{if(p.current==="running"&&s==="complete"){d(!0);const u=setTimeout(()=>d(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),x.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{g.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(u)},[s,a,r]);function l(){t("dev"),B({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(Qt,{}),e.jsx(Ft,{}),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(Dt,{}),e.jsx("button",{type:"button",onClick:l,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(Zn,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{g.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(zt,{onBack:()=>o(!1)}):e.jsx(tr,{onPickCrawl:()=>o(!0)}),c&&e.jsx(er,{})]}),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 Zn(){const t=g(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void B({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 er(){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 tr({onPickCrawl:t}){const s=g(u=>u.status),a=g(u=>u.results),[n,r]=x.useState("quick"),[i,o]=x.useState("all"),c=s==="running",d=a.flatMap(u=>u.violations),p=a.length>0;function l(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:Qe(n)}),g.getState().startNewScan(),te.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:l,disabled:c,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:c?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:c,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(ar,{depth:n,onChange:r,disabled:c})]}),!p&&!c&&e.jsx(sr,{}),p&&e.jsx(nr,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function sr(){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 ar({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(bt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${xt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(bt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${xt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function bt({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 nr({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var T;const r=g(j=>j.status),i=g(j=>j.results),o=g(j=>j.freshThisSession),c=g(j=>j.componentId),d=(T=i[0])==null?void 0:T.startedAt,p=$n(t),l=r==="running",[u,h]=x.useState([]);x.useEffect(()=>{if(!c){h([]);return}let j=!1;return chrome.storage.local.get("igtRuns").then(S=>{if(j)return;const I=((S==null?void 0:S.igtRuns)??{})[c]??{};h(Object.values(I))}),()=>{j=!0}},[c]);const f=g(j=>j.acknowledgedKeys),b=i.length>0?kt(i,{runs:u,workflows:K},"2.1","AA",f):void 0;function w(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:Qe(n)}),g.getState().startNewScan(),te.polite("Re-scanning this page now.")}const E=s==="lawsuit-risk"?t.filter(j=>j.impact==="critical"||j.impact==="serious"):t,R=new Map;for(const j of E){const S=ze(j.ruleId,j.target.selector);R.has(S)||R.set(S,j)}const m=Array.from(R.values()),v=new Map;for(const j of m){const S=v.get(j.ruleId)??[];S.push(j),v.set(j.ruleId,S)}const y=Array.from(v.entries()).sort((j,S)=>(ft[j[1][0].impact]??99)-(ft[S[1][0].impact]??99)),N=t.filter(j=>j.impact==="critical"||j.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(dr,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Ke(),disabled:l,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:w,disabled:l,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:l?"Scanning…":"↻ Scan again"})]})]}),l?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 ${Qn[p.tier]}`,children:[!o&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Jn[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${gt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${gt[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!l&&b&&!b.canClaimConformance&&e.jsx(rr,{coverage:b}),!l&&b&&b.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",b.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(cr,{}),e.jsx(Wn,{}),t.length>0&&e.jsx(ir,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:N}),e.jsxs("div",{className:"space-y-2",children:[y.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),y.map(([j,S])=>e.jsx(or,{ruleId:j,violations:S},j))]})]})}function rr({coverage:t}){const s=g(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),B({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function ir({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 or({ruleId:t,violations:s}){var u;const[a,n]=x.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=us(t,r),o=s[0].impact,c=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&c.description?c.description:i.whatsWrong,l=c.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Yn[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,f)=>e.jsx(lr,{violation:h},f))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function lr({violation:t}){const s=g(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=x.useState(null);async function r(i){i.stopPropagation();const o=await Q();if(o)try{const c=await be(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(c.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const je=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function cr(){const t=g(l=>l.results),s=g(l=>l.componentId),[a,n]=x.useState(null),[r,i]=x.useState(!1),[o,c]=x.useState(null);async function d(l,u){if(t.length!==0){n(l);try{const h=await H({type:"EXPORT_REQUEST",format:l,results:t});if(l==="defense-bundle"||l==="evidence-bundle"){const f=jt(l,s);await wt()?He(h.content,f):c({open:!0,format:l,content:h.content,filename:f})}else if(u)Be(h.content);else{try{await navigator.clipboard.writeText(h.content),te.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const b=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
252
+ </html>`}async function qn(t){const s=Kn(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Xt(){const[t,s]=x.useState(null),[a,n]=x.useState(null),[r,i]=x.useState(0),[o,c]=x.useState(!1),[d,p]=x.useState(""),[l,u]=x.useState(""),[h,b]=x.useState(""),[m,N]=x.useState(!1);if(x.useEffect(()=>{let y=!1;return s(null),n(null),Tt().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,T=t.filter(y=>y.receipt).length;async function f(){if(!(!t||t.length===0)){N(!0);try{await qn({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:l.trim()||void 0,jurisdiction:h.trim()||void 0}),c(!1)}finally{N(!1)}}}async function v(){if(!t||t.length===0)return;const y={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},E=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),k=URL.createObjectURL(E),w=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,S=document.createElement("a");S.href=k,S.download=w,S.click(),setTimeout(()=>URL.revokeObjectURL(k),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",T>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[T," RFC 3161-anchored"]})]}),T===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:()=>c(y=>!y),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void v(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(y=>y+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:y=>p(y.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:l,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=>b(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:()=>c(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:m||C===0,onClick:f,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:m?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(y=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${y.grade==="A"?"bg-emerald-100 text-emerald-700":y.grade==="B"?"bg-lime-100 text-lime-700":y.grade==="C"?"bg-yellow-100 text-yellow-700":y.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:y.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:y.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${y.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:y.receipt?`Anchored to ${y.receipt.tsaName} at ${y.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:y.receipt?`RFC 3161 (${y.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:y.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:y.capturedAt}),(y.totals.critical>0||y.totals.serious>0)&&e.jsxs("span",{children:[y.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[y.totals.critical," crit"]}),y.totals.critical>0&&y.totals.serious>0&&" · ",y.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[y.totals.serious," sev"]})]}),e.jsxs("span",{children:[y.statesAudited," ",y.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:y.hash,children:[y.hash.slice(0,12),"…"]})]})]},`${y.componentId}::${y.capturedAt}`))})]})}function Qn(){const[t,s]=x.useState(null),[a,n]=x.useState(!1);if(x.useEffect(()=>{let d=!1;return Tt().then(p=>{d||s(p)}).catch(()=>{d||s([])}),()=>{d=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),c=t.filter(d=>d.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),c>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[c," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(d=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${d.grade==="A"?"bg-emerald-100 text-emerald-700":d.grade==="B"?"bg-lime-100 text-lime-700":d.grade==="C"?"bg-yellow-100 text-yellow-700":d.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:d.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:d.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:d.pageUrl}),d.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${d.receipt.tsaName}`,children:"✓ anchored"})]},`${d.componentId}::${d.capturedAt}`))}),e.jsx(ue,{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(Xt,{})})})]})}function Jn(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Yn={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."},Xn={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."},Zn={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},er={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Zt(){const t=g(u=>u.tier),s=g(u=>u.trialDaysRemaining),a=g(u=>u.seatsUsed),n=g(u=>u.seatsTotal),r=g(u=>u.planCode),i=g(u=>u.licenseDaysRemaining),o=g(u=>u.pastDue),[c,d]=x.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,h=u!==null&&u<=7,b=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"}),b&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",b]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(ze,{open:c,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?er:Zn,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,b=t==="team"&&a!==null&&n!==null&&a>n,m=t==="team"&&a!==null&&n!==null&&a===n,N=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"}:b?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:m?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${N.bg} border-b ${N.border} px-3 py-2 space-y-1 text-[11px] ${N.shadow}`,children:[e.jsxs("div",{className:N.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:N.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."}),b&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),m&&!b&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:N.link,children:"Manage license →"})})]})}const p=t==="trial"?Yn:Xn,l=t==="trial"?Jn(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:l})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void H({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(ze,{open:c,onClose:()=>d(!1)})]})}const tr={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"},sr={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},yt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},ar={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"},jt={critical:0,serious:1,moderate:2,minor:3};function nr(){const t=g(u=>u.setUserMode),s=g(u=>u.status),a=g(u=>u.setStatus),n=g(u=>u.errorMessage),r=g(u=>u.setError),[i,o]=x.useState(!1),[c,d]=x.useState(!1),p=x.useRef(s);x.useEffect(()=>{if(p.current==="running"&&s==="complete"){d(!0);const u=setTimeout(()=>d(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),x.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{g.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(u)},[s,a,r]);function l(){t("dev"),H({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(Zt,{}),e.jsx(Gt,{}),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(Pt,{}),e.jsx("button",{type:"button",onClick:l,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(rr,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{g.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(Jt,{onBack:()=>o(!1)}):e.jsx(or,{onPickCrawl:()=>o(!0)}),c&&e.jsx(ir,{})]}),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 rr(){const t=g(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void H({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function ir(){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 or({onPickCrawl:t}){const s=g(u=>u.status),a=g(u=>u.results),[n,r]=x.useState("quick"),[i,o]=x.useState("all"),c=s==="running",d=a.flatMap(u=>u.violations),p=a.length>0;function l(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:et(n)}),g.getState().startNewScan(),te.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:l,disabled:c,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:c?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:c,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(cr,{depth:n,onChange:r,disabled:c})]}),!p&&!c&&e.jsx(lr,{}),p&&e.jsx(dr,{violations:d,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function lr(){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 cr({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(wt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${vt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(wt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${vt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function wt({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 dr({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var k;const r=g(w=>w.status),i=g(w=>w.results),o=g(w=>w.freshThisSession),c=g(w=>w.componentId),d=(k=i[0])==null?void 0:k.startedAt,p=On(t),l=r==="running",[u,h]=x.useState([]);x.useEffect(()=>{if(!c){h([]);return}let w=!1;return chrome.storage.local.get("igtRuns").then(S=>{if(w)return;const I=((S==null?void 0:S.igtRuns)??{})[c]??{};h(Object.values(I))}),()=>{w=!0}},[c]);const b=g(w=>w.acknowledgedKeys),m=i.length>0?Rt(i,{runs:u,workflows:Q},"2.1","AA",b):void 0;function N(){ae({type:"START_AUDIT",mode:"full-page",matrixOverride:et(n)}),g.getState().startNewScan(),te.polite("Re-scanning this page now.")}const C=s==="lawsuit-risk"?t.filter(w=>w.impact==="critical"||w.impact==="serious"):t,T=new Map;for(const w of C){const S=Ye(w.ruleId,w.target.selector);T.has(S)||T.set(S,w)}const f=Array.from(T.values()),v=new Map;for(const w of f){const S=v.get(w.ruleId)??[];S.push(w),v.set(w.ruleId,S)}const y=Array.from(v.entries()).sort((w,S)=>(jt[w[1][0].impact]??99)-(jt[S[1][0].impact]??99)),E=t.filter(w=>w.impact==="critical"||w.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[d&&e.jsxs("span",{children:["Last scanned: ",e.jsx(gr,{iso:d})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Xe(),disabled:l,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:N,disabled:l,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:l?"Scanning…":"↻ Scan again"})]})]}),l?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 ${tr[p.tier]}`,children:[!o&&d&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${sr[p.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${p.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${yt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${yt[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",p.flaggedInstanceCount>p.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:p.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!l&&m&&!m.canClaimConformance&&e.jsx(ur,{coverage:m}),!l&&m&&m.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",m.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(xr,{}),e.jsx(Qn,{}),t.length>0&&e.jsx(pr,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:E}),e.jsxs("div",{className:"space-y-2",children:[y.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),y.map(([w,S])=>e.jsx(hr,{ruleId:w,violations:S},w))]})]})}function ur({coverage:t}){const s=g(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),H({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function pr({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 hr({ruleId:t,violations:s}){var u;const[a,n]=x.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=fs(t,r),o=s[0].impact,c=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&c.description?c.description:i.whatsWrong,l=c.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ar[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((h,b)=>e.jsx(mr,{violation:h},b))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function mr({violation:t}){const s=g(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=x.useState(null);async function r(i){i.stopPropagation();const o=await Y();if(o)try{const c=await be(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(c.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const we=[{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 xr(){const t=g(l=>l.results),s=g(l=>l.componentId),[a,n]=x.useState(null),[r,i]=x.useState(!1),[o,c]=x.useState(null);async function d(l,u){if(t.length!==0){n(l);try{const h=await z({type:"EXPORT_REQUEST",format:l,results:t});if(l==="defense-bundle"||l==="evidence-bundle"){const b=St(l,s);await At()?Je(h.content,b):c({open:!0,format:l,content:h.content,filename:b})}else if(u)Qe(h.content);else{try{await navigator.clipboard.writeText(h.content),te.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const m=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
253
253
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
254
254
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
255
255
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
256
256
  <div class="banner"><strong>✓ Copied to clipboard.</strong> Paste this into ChatGPT, Claude, or your favorite AI assistant. The AI will walk you through fixes for your specific situation.</div>
257
- <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,w=new Blob([b],{type:"text/html"}),E=URL.createObjectURL(w);window.open(E,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(E),6e4)}}finally{n(null)}}}const p=r?je:je.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(l=>e.jsx("button",{type:"button",onClick:()=>void d(l.id,l.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:l.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:l.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:l.desc})]}),a===l.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},l.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",je.length-2," more report option",je.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Ht,{open:o.open,onClose:()=>c(null),format:o.format,content:o.content,filename:o.filename})]})}function dr({iso:t}){const[,s]=x.useState(0);x.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function ur(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,c]of s)for(const d of c){for(const l of d.violations)if(l.wcagCriterion===t){if(a!=null&&a.has(l.matchKey)){n.add(l.ruleId);continue}if(l.needsReview){n.add(l.ruleId),i=!0;continue}n.add(l.ruleId),r.push({source:"axe",ruleOrStepId:l.ruleId,description:l.description||l.ruleId,pageUrl:o,selector:l.target.selector})}const p=d.axeRulesEvaluated;if(p){for(const l of p.passed)l.wcagCriterion===t&&n.add(l.ruleId);for(const l of p.inapplicable)l.wcagCriterion===t&&n.add(l.ruleId);for(const l of p.incomplete)l.wcagCriterion===t&&(n.add(l.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function pr(t,s,a){const n=[];let r=0,i=0,o=0,c=0;for(const p of a){const l=p.steps.filter(u=>u.wcag===t);if(l.length!==0){r+=l.length;for(const[u,h]of s){const f=h[p.id];if(!f){i+=l.length;continue}for(const b of l){const w=f.steps[b.id];if(!w){i++;continue}w.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${p.id}.${b.id}`,description:b.question,pageUrl:u,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(o++,c++):o++}}}}const d=o>0&&c===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function hr(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function mr(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 xr(t,s){var u;const a=[];for(const h of s.auditsByUrl.values())a.push(...h);const n=[];for(const h of s.igtRunsByUrl.values())n.push(...Object.values(h));const r=St({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set}),i=ps(t.targetVersion,t.targetLevel),o=[];for(const h of i){const f=ur(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),b=pr(h.id,s.igtRunsByUrl,s.workflows),w=f.rulesFiring.size===0&&b.stepsCovering===0,E={axeRulesFiringForCriterion:f.rulesFiring.size,axeFailures:f.failures,igtStepsCoveringCriterion:b.stepsCovering,igtFailures:b.failures,unmapped:w},R=(u=t.overrides)==null?void 0:u[h.id];let m,v,y=!1;if(R)m=R.verdict,v=R.rationale,y=!0;else{const N=r.get(h.id);N?m=N.state:m=hr(E,b.unanswered,f.hasIncomplete,b.allNotApplicable),v=mr(h,m,E)}o.push({criterion:h,understandingUrl:hs(h,t.targetVersion),verdict:m,signals:E,overridden:y,rationale:v})}const c={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of o)h.verdict==="pass"?c.pass++:h.verdict==="fail"?c.fail++:h.verdict==="inconclusive"?c.inconclusive++:h.verdict==="not-applicable"?c.notApplicable++:h.verdict==="not-evaluated"&&c.notEvaluated++;function d(h){const f={A:1,AA:2,AAA:3},b=f[h];return o.every(w=>f[w.criterion.level]>b?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let p=null;d("AAA")?p="AAA":d("AA")?p="AA":d("A")&&(p="A");const l=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:c.pass,fail:c.fail,inconclusive:c.inconclusive,notApplicable:c.notApplicable,notEvaluated:c.notEvaluated,levelAchieved:p,meetsTarget:l}}}const gr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},vt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function C(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Me(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 fr(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}`,c=new Map;for(const p of n){const l=p.criterion.id.split(".").slice(0,2).join("."),u=c.get(l)??[];u.push(p),c.set(l,u)}const d=Array.from(c.entries()).sort(([p],[l])=>p.localeCompare(l,void 0,{numeric:!0})).map(([p,l])=>`
258
- <h3 class="guideline-h">Guideline ${C(p)}</h3>
257
+ <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,N=new Blob([m],{type:"text/html"}),C=URL.createObjectURL(N);window.open(C,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(C),6e4)}}finally{n(null)}}}const p=r?we:we.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(l=>e.jsx("button",{type:"button",onClick:()=>void d(l.id,l.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:l.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:l.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:l.desc})]}),a===l.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},l.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",we.length-2," more report option",we.length-2===1?"":"s"," ↓"]}),o&&e.jsx(Qt,{open:o.open,onClose:()=>c(null),format:o.format,content:o.content,filename:o.filename})]})}function gr({iso:t}){const[,s]=x.useState(0);x.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function fr(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,c]of s)for(const d of c){for(const l of d.violations)if(l.wcagCriterion===t){if(a!=null&&a.has(l.matchKey)){n.add(l.ruleId);continue}if(l.needsReview){n.add(l.ruleId),i=!0;continue}n.add(l.ruleId),r.push({source:"axe",ruleOrStepId:l.ruleId,description:l.description||l.ruleId,pageUrl:o,selector:l.target.selector})}const p=d.axeRulesEvaluated;if(p){for(const l of p.passed)l.wcagCriterion===t&&n.add(l.ruleId);for(const l of p.inapplicable)l.wcagCriterion===t&&n.add(l.ruleId);for(const l of p.incomplete)l.wcagCriterion===t&&(n.add(l.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function br(t,s,a){const n=[];let r=0,i=0,o=0,c=0;for(const p of a){const l=p.steps.filter(u=>u.wcag===t);if(l.length!==0){r+=l.length;for(const[u,h]of s){const b=h[p.id];if(!b){i+=l.length;continue}for(const m of l){const N=b.steps[m.id];if(!N){i++;continue}N.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${p.id}.${m.id}`,description:m.question,pageUrl:u,notes:N.notes})):N.status==="skip"?i++:N.status==="not-applicable"?(o++,c++):o++}}}}const d=o>0&&c===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function vr(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function yr(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 jr(t,s){var u;const a=[];for(const h of s.auditsByUrl.values())a.push(...h);const n=[];for(const h of s.igtRunsByUrl.values())n.push(...Object.values(h));const r=Et({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set}),i=bs(t.targetVersion,t.targetLevel),o=[];for(const h of i){const b=fr(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),m=br(h.id,s.igtRunsByUrl,s.workflows),N=b.rulesFiring.size===0&&m.stepsCovering===0,C={axeRulesFiringForCriterion:b.rulesFiring.size,axeFailures:b.failures,igtStepsCoveringCriterion:m.stepsCovering,igtFailures:m.failures,unmapped:N},T=(u=t.overrides)==null?void 0:u[h.id];let f,v,y=!1;if(T)f=T.verdict,v=T.rationale,y=!0;else{const E=r.get(h.id);E?f=E.state:f=vr(C,m.unanswered,b.hasIncomplete,m.allNotApplicable),v=yr(h,f,C)}o.push({criterion:h,understandingUrl:vs(h,t.targetVersion),verdict:f,signals:C,overridden:y,rationale:v})}const c={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of o)h.verdict==="pass"?c.pass++:h.verdict==="fail"?c.fail++:h.verdict==="inconclusive"?c.inconclusive++:h.verdict==="not-applicable"?c.notApplicable++:h.verdict==="not-evaluated"&&c.notEvaluated++;function d(h){const b={A:1,AA:2,AAA:3},m=b[h];return o.every(N=>b[N.criterion.level]>m?!0:N.verdict==="pass"||N.verdict==="not-applicable")}let p=null;d("AAA")?p="AAA":d("AA")?p="AA":d("A")&&(p="A");const l=p===t.targetLevel||p==="AAA"&&t.targetLevel==="AA"||p==="AAA"&&t.targetLevel==="A"||p==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:c.pass,fail:c.fail,inconclusive:c.inconclusive,notApplicable:c.notApplicable,notEvaluated:c.notEvaluated,levelAchieved:p,meetsTarget:l}}}const wr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Nt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function R(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Be(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 Nr(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}`,c=new Map;for(const p of n){const l=p.criterion.id.split(".").slice(0,2).join("."),u=c.get(l)??[];u.push(p),c.set(l,u)}const d=Array.from(c.entries()).sort(([p],[l])=>p.localeCompare(l,void 0,{numeric:!0})).map(([p,l])=>`
258
+ <h3 class="guideline-h">Guideline ${R(p)}</h3>
259
259
  <table class="criteria-table">
260
260
  <thead>
261
261
  <tr>
@@ -264,12 +264,12 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
264
264
  </thead>
265
265
  <tbody>
266
266
  ${l.map(u=>`
267
- <tr class="${vt[u.verdict]}">
268
- <td><a href="${C(u.understandingUrl)}" target="_blank" rel="noopener">${C(u.criterion.id)}</a></td>
269
- <td>${C(u.criterion.title)}</td>
270
- <td>${C(u.criterion.level)}</td>
271
- <td><span class="verdict-badge ${vt[u.verdict]}">${gr[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
272
- <td class="rationale">${C(u.rationale)}</td>
267
+ <tr class="${Nt[u.verdict]}">
268
+ <td><a href="${R(u.understandingUrl)}" target="_blank" rel="noopener">${R(u.criterion.id)}</a></td>
269
+ <td>${R(u.criterion.title)}</td>
270
+ <td>${R(u.criterion.level)}</td>
271
+ <td><span class="verdict-badge ${Nt[u.verdict]}">${wr[u.verdict]}</span>${u.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
272
+ <td class="rationale">${R(u.rationale)}</td>
273
273
  </tr>
274
274
  ${u.signals.axeFailures.length>0||u.signals.igtFailures.length>0?`
275
275
  <tr class="evidence-row">
@@ -280,11 +280,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
280
280
  <ul>
281
281
  ${[...u.signals.axeFailures,...u.signals.igtFailures].slice(0,20).map(h=>`
282
282
  <li>
283
- <code>${C(h.ruleOrStepId)}</code>
284
- ${h.pageUrl?` on <a href="${C(h.pageUrl)}" target="_blank" rel="noopener"><code>${C(h.pageUrl)}</code></a>`:""}
285
- — ${C(h.description)}
286
- ${h.selector?`<br><span class="ev-selector"><code>${C(h.selector)}</code></span>`:""}
287
- ${h.notes?`<br><em>${C(h.notes)}</em>`:""}
283
+ <code>${R(h.ruleOrStepId)}</code>
284
+ ${h.pageUrl?` on <a href="${R(h.pageUrl)}" target="_blank" rel="noopener"><code>${R(h.pageUrl)}</code></a>`:""}
285
+ — ${R(h.description)}
286
+ ${h.selector?`<br><span class="ev-selector"><code>${R(h.selector)}</code></span>`:""}
287
+ ${h.notes?`<br><em>${R(h.notes)}</em>`:""}
288
288
  </li>
289
289
  `).join("")}
290
290
  ${u.signals.axeFailures.length+u.signals.igtFailures.length>20?`<li class="ev-more">…and ${u.signals.axeFailures.length+u.signals.igtFailures.length-20} more.</li>`:""}
@@ -300,7 +300,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
300
300
  <html lang="en">
301
301
  <head>
302
302
  <meta charset="utf-8" />
303
- <title>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)} Conformance Report — ${C(a.siteName)}</title>
303
+ <title>WCAG ${R(a.targetVersion)} Level ${R(a.targetLevel)} Conformance Report — ${R(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 ${C(a.targetVersion)} Conformance Evaluation Report</p>
402
- <h1>${C(a.siteName)}</h1>
403
- <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${C(a.siteUrl)}</code></p>
401
+ <p class="eyebrow">WCAG ${R(a.targetVersion)} Conformance Evaluation Report</p>
402
+ <h1>${R(a.siteName)}</h1>
403
+ <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${R(a.siteUrl)}</code></p>
404
404
  <div class="conformance-banner ${r.meetsTarget?"met":"not-met"}">
405
- ${C(o)}
405
+ ${R(o)}
406
406
  </div>
407
407
  <dl class="meta">
408
408
  <dt>Highest level fully satisfied</dt>
409
- <dd>${r.levelAchieved?`WCAG ${C(a.targetVersion)} Level ${C(r.levelAchieved)}`:"None (target level not met)"}</dd>
409
+ <dd>${r.levelAchieved?`WCAG ${R(a.targetVersion)} Level ${R(r.levelAchieved)}`:"None (target level not met)"}</dd>
410
410
  <dt>Target conformance level</dt>
411
- <dd>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)}</dd>
411
+ <dd>WCAG ${R(a.targetVersion)} Level ${R(a.targetLevel)}</dd>
412
412
  <dt>Report generated</dt>
413
- <dd>${C(Me(i))}</dd>
413
+ <dd>${R(Be(i))}</dd>
414
414
  <dt>Evaluator</dt>
415
415
  <dd>
416
- ${C(a.evaluator.name)}
417
- ${a.evaluator.organization?`, ${C(a.evaluator.organization)}`:""}
418
- ${a.evaluator.qualifications?`<br><span style="color: #64748b">${C(a.evaluator.qualifications)}</span>`:""}
416
+ ${R(a.evaluator.name)}
417
+ ${a.evaluator.organization?`, ${R(a.evaluator.organization)}`:""}
418
+ ${a.evaluator.qualifications?`<br><span style="color: #64748b">${R(a.evaluator.qualifications)}</span>`:""}
419
419
  </dd>
420
420
  </dl>
421
421
  </section>
@@ -431,13 +431,13 @@ 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>${C(a.siteName)}</strong> — <code>${C(a.siteUrl)}</code></dd>
435
- <dt>Conformance target</dt><dd>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)}</dd>
434
+ <dt>Website / application</dt><dd><strong>${R(a.siteName)}</strong> — <code>${R(a.siteUrl)}</code></dd>
435
+ <dt>Conformance target</dt><dd>WCAG ${R(a.targetVersion)} Level ${R(a.targetLevel)}</dd>
436
436
  <dt>Accessibility-support baseline</dt>
437
- <dd>${C(a.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
437
+ <dd>${R(a.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
438
438
  ${a.additionalStandards&&a.additionalStandards.length>0?`
439
439
  <dt>Additional standards evaluated against</dt>
440
- <dd>${a.additionalStandards.map(C).join(", ")}</dd>
440
+ <dd>${a.additionalStandards.map(R).join(", ")}</dd>
441
441
  `:""}
442
442
  </dl>
443
443
 
@@ -448,9 +448,9 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
448
448
  <tbody>
449
449
  ${a.pageSample.map(p=>`
450
450
  <tr>
451
- <td><a href="${C(p.url)}" target="_blank" rel="noopener"><code>${C(p.url)}</code></a></td>
452
- <td>${C(p.pageType)}</td>
453
- <td>${C(p.selectionType)}</td>
451
+ <td><a href="${R(p.url)}" target="_blank" rel="noopener"><code>${R(p.url)}</code></a></td>
452
+ <td>${R(p.pageType)}</td>
453
+ <td>${R(p.selectionType)}</td>
454
454
  <td>${p.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
455
455
  </tr>
456
456
  `).join("")}
@@ -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>${C(a.siteName)}</strong> meets the success criteria required for <strong>WCAG ${C(a.targetVersion)} Level ${C(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>${C(a.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${C(a.targetVersion)} Level ${C(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>
478
+ <p>${r.meetsTarget?`Based on the evidence collected, <strong>${R(a.siteName)}</strong> meets the success criteria required for <strong>WCAG ${R(a.targetVersion)} Level ${R(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>${R(a.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${R(a.targetVersion)} Level ${R(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
 
@@ -484,11 +484,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
484
484
  <h3>Forensic anchor — report integrity proof</h3>
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
- <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${C(s.reportHash)}</code></td></tr>
488
- <tr><th>Anchored at</th><td>${C(Me(s.receipt.anchoredAt))}</td></tr>
489
- <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${C(s.receipt.tsaName)}</td></tr>
490
- <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${C(s.receipt.serverKeyFingerprint)}</code></td></tr>
491
- ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${C(s.receipt.prevAuditHash)}</code></td></tr>`:""}
487
+ <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${R(s.reportHash)}</code></td></tr>
488
+ <tr><th>Anchored at</th><td>${R(Be(s.receipt.anchoredAt))}</td></tr>
489
+ <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${R(s.receipt.tsaName)}</td></tr>
490
+ <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${R(s.receipt.serverKeyFingerprint)}</code></td></tr>
491
+ ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${R(s.receipt.prevAuditHash)}</code></td></tr>`:""}
492
492
  </table>
493
493
  <p style="font-size: 9pt; color: #64748b; margin-top: 8pt;">
494
494
  To verify: download the verification bundle JSON from the wcagcheckr Compliance tab,
@@ -499,7 +499,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
499
499
  <!-- Machine-readable receipt — verifier can extract from the printed PDF
500
500
  if the JSON bundle was lost. Inert in browsers; serves only as
501
501
  structured-data preservation. -->
502
- <script type="application/json" id="wcagcheckr-anchor-receipt">${C(JSON.stringify(s))}<\/script>
502
+ <script type="application/json" id="wcagcheckr-anchor-receipt">${R(JSON.stringify(s))}<\/script>
503
503
  </section>
504
504
  `:`
505
505
  <section class="anchor-block anchor-missing">
@@ -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>${C(a.evaluator.name)}</strong>${a.evaluator.organization?` of <strong>${C(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: ${C(a.evaluator.qualifications)}.`:""} ${a.evaluator.contact?`I may be contacted at <code>${C(a.evaluator.contact)}</code>.`:""}</p>
513
+ <p>I, <strong>${R(a.evaluator.name)}</strong>${a.evaluator.organization?` of <strong>${R(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: ${R(a.evaluator.qualifications)}.`:""} ${a.evaluator.contact?`I may be contacted at <code>${R(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 ${C(Me(i))} by wcagcheckr</span>
518
+ <span>Generated ${R(Be(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 br(t,s){const a=fr(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const Pe=Nt("wcag-em-anchor"),vr="https://api.wcagcheckr.com",yr="wcagcheckr",jr=15e3;function Jt(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 wr(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 Nr(t){return wr(ms(Jt(t)))}function kr(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 Sr(t,s){const a=await Nr(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${vr}/v1/products/${yr}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(jr)});if(!i.ok)return Pe.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return kr(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Pe.warn("anchor returned malformed receipt",o),null)}catch(i){return Pe.warn("anchor request failed",i),null}}function Ar(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Jt(t)}}const yt="igtRuns",Cr={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"},Rr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Er(){const t=g(k=>k.results),s=g(k=>k.acknowledgedKeys),[a,n]=x.useState(""),[r,i]=x.useState(""),o=gs,c=xs,[d,p]=x.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[l,u]=x.useState(""),[h,f]=x.useState(""),[b,w]=x.useState(""),[E,R]=x.useState(""),[m,v]=x.useState(""),[y,N]=x.useState(""),[T,j]=x.useState({}),[S,A]=x.useState(!1),[I,z]=x.useState(null),[$,U]=x.useState(!1),[G,q]=x.useState(null);x.useEffect(()=>{let k=!1;return chrome.storage.local.get(yt).then(F=>{if(k)return;const M=F[yt]??{};j(M),A(!0)}).catch(()=>{k||A(!0)}),()=>{k=!0}},[]),x.useEffect(()=>{var k;if(!a&&((k=t[0])!=null&&k.pageUrl))try{const F=new URL(t[0].pageUrl);n(F.hostname),i(F.origin)}catch{}},[t,a]);const P=x.useMemo(()=>{const k=new Map,F=new Map;for(const L of t){const ee=L.pageUrl??L.scope,W=k.get(ee)??[];W.push(L),k.set(ee,W)}const M=new Map;for(const L of t){const ee=L.pageUrl??L.scope;M.set(L.componentId,ee)}for(const[L,ee]of Object.entries(T)){const W=M.get(L);if(!W)continue;const V=F.get(W)??{};Object.assign(V,ee),F.set(W,V)}return{auditsByUrl:k,igtRunsByUrl:F,workflows:K,acknowledgedMatchKeys:s}},[t,T,s]),X=x.useMemo(()=>{const k=[],F=new Set;for(const M of P.auditsByUrl.keys())F.has(M)||(F.add(M),k.push({url:M,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const M of y.split(`
523
- `).map(L=>L.trim()).filter(Boolean))F.has(M)||(F.add(M),k.push({url:M,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return k},[P,y]),Z=x.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:c,accessibilitySupportBaseline:d,additionalStandards:l.split(",").map(k=>k.trim()).filter(Boolean),pageSample:X,evaluator:{name:h||"(evaluator name pending)",organization:b||void 0,qualifications:E||void 0,contact:m||void 0}}),[a,r,o,c,d,l,X,h,b,E,m]),D=x.useMemo(()=>S?xr(Z,P):null,[Z,P,S]);async function ne(){D&&await br(D,I)}async function oe(){if(D){U(!0),q(null);try{const k=await Sr(D);if(!k){q("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}z(k)}finally{U(!1)}}}function _(){var V,Y,Je;if(!D||!I)return;const k=((Je=(Y=(V=chrome.runtime).getManifest)==null?void 0:Y.call(V))==null?void 0:Je.version)??"0.0.0",F=Ar(D,I,k),M=new Blob([JSON.stringify(F,null,2)],{type:"application/json"}),L=URL.createObjectURL(M),ee=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,W=document.createElement("a");W.href=L,W.download=ee,W.click(),setTimeout(()=>URL.revokeObjectURL(L),1e3)}return x.useEffect(()=>{z(null),q(null)},[a,r,d,l,h,b,E,m,y]),S?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."})]}),D&&D.summary.totalCriteria>0&&e.jsx(Tr,{totalCriteria:D.summary.totalCriteria,pass:D.summary.pass,fail:D.summary.fail,inconclusive:D.summary.inconclusive,notEvaluated:D.summary.notEvaluated,notApplicable:D.summary.notApplicable,levelAchieved:D.summary.levelAchieved,meetsTarget:D.summary.meetsTarget,targetVersion:o,targetLevel:c,auditedUrlCount:P.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:k=>n(k.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:k=>i(k.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",c]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:k=>p(k.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:l,onChange:k=>u(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.",P.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:P.auditsByUrl.size})," URL",P.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:y,onChange:k=>N(k.target.value),rows:3,placeholder:`https://app.example.com/checkout
524
- https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:k=>f(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:b,onChange:k=>w(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:E,onChange:k=>R(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:m,onChange:k=>v(k.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),D&&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 (",D.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:D.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 ${Cr[k.verdict]}`,children:Rr[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"}),I?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:[I.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",I.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.`}),G&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:G}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!D||!a||!h||$,onClick:()=>void oe(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:$?"Anchoring…":I?"Re-anchor":"Anchor this report"}),I&&e.jsx("button",{type:"button",onClick:_,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:!D||!a||!h,onClick:()=>void ne(),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 Tr({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:c,targetVersion:d,targetLevel:p,auditedUrlCount:l}){return e.jsxs("div",{className:`border rounded p-2 ${c?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${c?"text-emerald-900":"text-amber-900"}`,children:c?`Currently meeting WCAG ${d} Level ${p}`:`Does not currently meet WCAG ${d} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",l," audited URL",l===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}function Fr(){const t=g(a=>a.view),s=g(a=>a.userMode);return x.useEffect(()=>{const a=Cs(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=ws();Tt({forceRefresh:!0}).catch(()=>{}),Ae().catch(()=>{}),As().catch(()=>{}),Rs().catch(()=>{}),ks().catch(()=>{}),fs().then(c=>{g.getState().setAcknowledgedKeys(new Set(c.map(d=>d.matchKey)))}).catch(()=>{});const o=c=>{if(c.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:p,results:l}=g.getState();d&&(p(null),Q().then(u=>{var h;u&&se(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(h=l[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(En,{}),e.jsx(_e,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Xn,{}),e.jsx(mt,{}),e.jsx(_e,{})]}):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(Qt,{}),e.jsx(Ft,{}),e.jsx(Vs,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(zs,{}),e.jsx(Ys,{}),e.jsx(Sn,{}),e.jsx(kn,{}),e.jsx(Zs,{}),e.jsx(wn,{}),e.jsx(Nn,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Ea,{}),t==="delta"&&e.jsx(Fa,{}),t==="activity"&&e.jsx(Qa,{}),t==="guided"&&e.jsx(ln,{}),t==="flows"&&e.jsx(pn,{}),t==="scorecard"&&e.jsx(xn,{}),t==="crawl"&&e.jsx(zt,{}),t==="forensic"&&e.jsx(qt,{}),t==="compliance"&&e.jsx(Er,{})]})]}),e.jsx(Rn,{}),e.jsx(An,{}),e.jsx(jn,{}),e.jsx(mt,{}),e.jsx(_e,{})]})}class Or extends ge.Component{constructor(){super(...arguments);Ye(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{Fr as A,Or as E};
522
+ </html>`}async function kr(t,s){const a=Nr(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const He=Ct("wcag-em-anchor"),Sr="https://api.wcagcheckr.com",Ar="wcagcheckr",Cr=15e3;function es(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 Rr(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 Er(t){return Rr(ys(es(t)))}function Tr(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 Ir(t,s){const a=await Er(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Sr}/v1/products/${Ar}/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 He.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return Tr(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(He.warn("anchor returned malformed receipt",o),null)}catch(i){return He.warn("anchor request failed",i),null}}function $r(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:es(t)}}const kt="igtRuns",_r={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"},Lr={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Ur(){const t=g(j=>j.results),s=g(j=>j.acknowledgedKeys),[a,n]=x.useState(""),[r,i]=x.useState(""),o=ws,c=js,[d,p]=x.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[l,u]=x.useState(""),[h,b]=x.useState(""),[m,N]=x.useState(""),[C,T]=x.useState(""),[f,v]=x.useState(""),[y,E]=x.useState(""),[k,w]=x.useState({}),[S,A]=x.useState(!1),[I,K]=x.useState(null),[$,P]=x.useState(!1),[G,J]=x.useState(null);x.useEffect(()=>{let j=!1;return chrome.storage.local.get(kt).then(_=>{if(j)return;const L=_[kt]??{};w(L),A(!0)}).catch(()=>{j||A(!0)}),()=>{j=!0}},[]),x.useEffect(()=>{var j;if(!a&&((j=t[0])!=null&&j.pageUrl))try{const _=new URL(t[0].pageUrl);n(_.hostname),i(_.origin)}catch{}},[t,a]);const V=x.useMemo(()=>{const j=new Map,_=new Map;for(const D of t){const M=D.pageUrl??D.scope,B=j.get(M)??[];B.push(D),j.set(M,B)}const L=new Map;for(const D of t){const M=D.pageUrl??D.scope;L.set(D.componentId,M)}for(const[D,M]of Object.entries(k)){const B=L.get(D);if(!B)continue;const q=_.get(B)??{};Object.assign(q,M),_.set(B,q)}return{auditsByUrl:j,igtRunsByUrl:_,workflows:Q,acknowledgedMatchKeys:s}},[t,k,s]),Z=x.useMemo(()=>{const j=[],_=new Set;for(const L of V.auditsByUrl.keys())_.has(L)||(_.add(L),j.push({url:L,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const L of y.split(`
523
+ `).map(D=>D.trim()).filter(Boolean))_.has(L)||(_.add(L),j.push({url:L,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return j},[V,y]),ee=x.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:c,accessibilitySupportBaseline:d,additionalStandards:l.split(",").map(j=>j.trim()).filter(Boolean),pageSample:Z,evaluator:{name:h||"(evaluator name pending)",organization:m||void 0,qualifications:C||void 0,contact:f||void 0}}),[a,r,o,c,d,l,Z,h,m,C,f]),U=x.useMemo(()=>S?jr(ee,V):null,[ee,V,S]);async function ne(){U&&await kr(U,I)}async function oe(){if(U){P(!0),J(null);try{const j=await Ir(U);if(!j){J("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}K(j)}finally{P(!1)}}}function ye(){var q,W,O;if(!U||!I)return;const j=((O=(W=(q=chrome.runtime).getManifest)==null?void 0:W.call(q))==null?void 0:O.version)??"0.0.0",_=$r(U,I,j),L=new Blob([JSON.stringify(_,null,2)],{type:"application/json"}),D=URL.createObjectURL(L),M=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,B=document.createElement("a");B.href=D,B.download=M,B.click(),setTimeout(()=>URL.revokeObjectURL(D),1e3)}return x.useEffect(()=>{K(null),J(null)},[a,r,d,l,h,m,C,f,y]),S?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."})]}),U&&U.summary.totalCriteria>0&&e.jsx(Dr,{totalCriteria:U.summary.totalCriteria,pass:U.summary.pass,fail:U.summary.fail,inconclusive:U.summary.inconclusive,notEvaluated:U.summary.notEvaluated,notApplicable:U.summary.notApplicable,levelAchieved:U.summary.levelAchieved,meetsTarget:U.summary.meetsTarget,targetVersion:o,targetLevel:c,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:a,onChange:j=>n(j.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:j=>i(j.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",c]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:j=>p(j.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:l,onChange:j=>u(j.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:y,onChange:j=>E(j.target.value),rows:3,placeholder:`https://app.example.com/checkout
524
+ https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:h,onChange:j=>b(j.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:m,onChange:j=>N(j.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:C,onChange:j=>T(j.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:f,onChange:j=>v(j.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),U&&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 (",U.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:U.rows.map(j=>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:[j.criterion.id," · ",j.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:j.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${_r[j.verdict]}`,children:Lr[j.verdict]})]},j.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"}),I?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:[I.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",I.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.`}),G&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:G}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!U||!a||!h||$,onClick:()=>void oe(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:$?"Anchoring…":I?"Re-anchor":"Anchor this report"}),I&&e.jsx("button",{type:"button",onClick:ye,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:!U||!a||!h,onClick:()=>void ne(),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 Dr({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:c,targetVersion:d,targetLevel:p,auditedUrlCount:l}){return e.jsxs("div",{className:`border rounded p-2 ${c?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${c?"text-emerald-900":"text-amber-900"}`,children:c?`Currently meeting WCAG ${d} Level ${p}`:`Does not currently meet WCAG ${d} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",l," audited URL",l===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}function Wr(){const t=g(a=>a.view),s=g(a=>a.userMode);return x.useEffect(()=>{const a=_s(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=Rs();Lt({forceRefresh:!0}).catch(()=>{}),Ce().catch(()=>{}),$s().catch(()=>{}),Ls().catch(()=>{}),Ts().catch(()=>{}),Ns().then(c=>{g.getState().setAcknowledgedKeys(new Set(c.map(d=>d.matchKey)))}).catch(()=>{});const o=c=>{if(c.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:p,results:l}=g.getState();d&&(p(null),Y().then(u=>{var h;u&&se(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(h=l[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(Un,{}),e.jsx(Fe,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(nr,{}),e.jsx(bt,{}),e.jsx(Fe,{})]}):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(Zt,{}),e.jsx(Gt,{}),e.jsx(qs,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Xs,{}),e.jsx(aa,{}),e.jsx(In,{}),e.jsx(Tn,{}),e.jsx(ra,{}),e.jsx(Rn,{}),e.jsx(En,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Ua,{}),t==="delta"&&e.jsx(Wa,{}),t==="activity"&&e.jsx(tn,{}),t==="guided"&&e.jsx(mn,{}),t==="flows"&&e.jsx(bn,{}),t==="scorecard"&&e.jsx(jn,{}),t==="crawl"&&e.jsx(Jt,{}),t==="forensic"&&e.jsx(Xt,{}),t==="compliance"&&e.jsx(Ur,{})]})]}),e.jsx(Ln,{}),e.jsx($n,{}),e.jsx(Cn,{}),e.jsx(bt,{}),e.jsx(Fe,{})]})}class Br extends ge.Component{constructor(){super(...arguments);st(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{Wr as A,Br as E};