@wcag-checkr/ci 1.0.0-rc.140 → 1.0.0-rc.142

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,21 +1,27 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-DChWCNTL.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-CzL3uuvq.js","assets/scheduled-audit-runner-3nAUxKGr.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
2
- var Bs=Object.defineProperty;var Hs=(t,s,a)=>s in t?Bs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var kt=(t,s,a)=>Hs(t,typeof s!="symbol"?s+"":s,a);import{R as Ce,i as re,r as m,j as e,M as ve,C as st,l as zs,o as dt,t as ut,m as ns,s as rs,k as Ee}from"./styles-BQMwoCaE.js";import{s as Ks,g as qs,a as ae,b as Qs,u as Ys,c as Js,d as Xs,e as Zs,f as pt,h as is,A as se,l as ht,i as ea,j as De,k as ls,m as ta,n as mt,o as sa,p as aa,N as na,q as ra,O as ia,r as la,t as oa,v as ca,w as St,x as da,y as os,z as ua,B as pa,C as ha,D as ma,E as xa,F as ga,T as fa,G as ba,H as va,I as ya,J as cs,K as wa,L as At,M as Ct,P as Ke,Q as ja,R as It,S as Na,U as ka,V as Sa,W as Aa,X as Ca,Y as Ia}from"./scheduled-audit-runner-3nAUxKGr.js";import{_ as xt}from"./diff-DA41zYPc.js";import{o as oe,r as Z,s as te,c as ds,b as le,d as xe}from"./crash-reporter-Dc5lvxvY.js";import{B as qe,i as us,f as ps,T as hs}from"./ai-usage-log-DBBVxutJ.js";const Rt=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,h))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,o);return o},Ra=t=>t?Rt(t):Rt,Ea=t=>t;function Ta(t,s=Ea){const a=Ce.useSyncExternalStore(t.subscribe,Ce.useCallback(()=>s(t.getState()),[t,s]),Ce.useCallback(()=>s(t.getInitialState()),[t,s]));return Ce.useDebugValue(a),a}const Et=t=>{const s=Ra(t),a=n=>Ta(s,n);return Object.assign(a,s),a},$a=t=>t?Et(t):Et,b=$a(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}),Ks(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(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),Me="sidePanel:lastAudit";function Ua(){const t=[];return t.push(oe("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||re.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(oe("AUDIT_COMPLETE_EVENT",s=>{var i;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.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"}.`;re.polite(r),La({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(oe("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(oe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||re.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(oe("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(oe("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(oe("LICENSE_CHANGED_EVENT",()=>{ms()})),t.push(oe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&re.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(oe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),re.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(oe("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),re.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function La(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Me]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Da(){const s=(await chrome.storage.local.get(Me))[Me];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function _a(){await chrome.storage.local.remove(Me)}async function Be(){b.getState().clearResults(),await _a()}async function Fe(){const t=await Z({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function ms(t){const s=await Z({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),xs()}async function xs(){const{fetchMessages:t}=await xt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ha);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Oa(){const s=(await Z({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function Ma(){return chrome.runtime.connect({name:"audit-keepalive"})}let Pe=null;async function Fa(){if(Pe===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Pe=t.id)}catch{}}function gs(){if(Pe===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Pe}).catch(()=>{})}function ue(t){gs(),te(t)}function Pa({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,l]=m.useState(!0),[o,c]=m.useState(""),[p,d]=m.useState(!1),[u,h]=m.useState(null);async function x(g){var w;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),h(null);try{const A=await Z({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});A.success?(h({ok:!0,msg:`Sent (ref: ${A.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=A.error)==null?void 0:w.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,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:g=>a(g.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:g=>r(g.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:o,onChange:g=>c(g.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:g=>l(g.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 Tt({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 Ge=ds("messages-client"),Ga="https://api.wcagcheckr.com",fs="wcagcheckr",Va=1e4;function Wa(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function bs(t,s){const a=await qs();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Wa()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Ga}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Va)})}async function Ba(t){try{const s=await bs(`/v1/products/${fs}/messages`,{userMode:t??null});return s.ok?await s.json():(Ge.warn("fetchMessages http",s.status),null)}catch(s){return Ge.warn("fetchMessages failed",s),null}}async function ge(t,s){try{const a=await bs(`/v1/products/${fs}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ge.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ge.warn("ackMessage failed",a),!1}}const Ha=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:Ba},Symbol.toStringTag,{value:"Module"})),za=["http:","https:"];function Ka(t){try{const s=new URL(t);return za.includes(s.protocol)}catch{return!1}}function $t(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 l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Ka(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:o},`l-${n++}`)),a=l+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(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function vs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:$t(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:$t(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){l(),n.push(d[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const qa={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Qa={critical:"bg-rose-50 border-rose-200"};function ys(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[l,o]=m.useState(!1);m.useEffect(()=>{const h=s.filter(g=>!g.seen);if(h.length===0)return;const x=Math.max(...h.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const h=s.filter(x=>!x.seen);if(h.length!==0)for(const x of h)a(x.id,"seen"),ge(x.id,"seen")}function p(){const h=!n;r(h),h&&c()}async function d(h){a(h.id,"dismissed"),await ge(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),ge(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Ya,{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(Ja,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function Ya({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 Ja({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{xs()},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 ${qa[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(vs,{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 ws(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ge(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ge(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Qa.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(vs,{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 ye=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","forensic","compliance"];function Xa(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Za(){var u,h;const t=b(x=>x.view),s=b(x=>x.setView),a=b(x=>x.setUserMode),n=b(x=>x.results),r=b(x=>x.status),[i,l]=m.useState(!1),o=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),c=Xa(o),p=n.length>0&&r!=="running";function d(){a("owner"),te({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(ys,{}),e.jsx(Tt,{onClick:()=>void te({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Tt,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:o??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Be(),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(en,{view:t,setView:s}),e.jsx(ve,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(Pa,{onClose:()=>l(!1)})})]})}function en({view:t,setView:s}){const a=m.useRef([]);function n(i){var c;const l=(i+ye.length)%ye.length,o=ye[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ye.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ye.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"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 tn({feature:t,upgradeUrl:s}){const[a,n]=m.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(st,{open:a,onClose:()=>n(!1)})]})}const sn="https://wcagcheckr.com/upgrade";function an(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState(null),[c,p]=m.useState(qe),[d,u]=m.useState(qe[0].id),h=b(L=>L.status),x=b(L=>L.tier),g=b(L=>L.results.length>0),w=h==="running";m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"matrixPresets"}),Z({type:"SETTINGS_GET",key:"activePresetId"})]).then(([L,S])=>{const M=Array.isArray(L.data)?L.data:null;p(M&&M.length>0?M:qe),typeof S.data=="string"&&u(S.data)})},[]);function A(L){const S=c.find(M=>M.id===L);S&&(u(L),te({type:"SETTINGS_SET",key:"activePresetId",value:L}),te({type:"SETTINGS_SET",key:"stateMatrix",value:S.matrix}))}const T=us(x,"storybookAutoIterate");m.useEffect(()=>{const L=oe("ELEMENT_PICKED_EVENT",(M,F)=>{n(!1);const Q=F.frameId;U(Q),i({selector:M.selector,frameId:Q})}),S=oe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{L(),S()}},[]);async function N(){const L=await ae();L&&(n(!0),await le(L,{type:"PICKER_ACTIVATE_REQUEST",tabId:L}))}function k(){r&&(U(r.frameId),ue({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function v(){if(!T){o("storybook:auto-iterate");return}U(),ue({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function C(){U(),ue({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function j(){U(),ue({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function E(){U(),ue({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function D(){U(),ue({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function y(){te({type:"CANCEL_AUDIT"})}async function U(L){b.getState().setPinned(null);const S=await ae();if(S)try{await le(S,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:S},L)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:L=>s(L.target.value),disabled: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:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",T?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:L=>A(L.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:c.map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))}),t==="single-element"?e.jsx(nn,{picking:a,picked:r,isRunning:w,onPick:N,onRun:k,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:j,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==="quick-scan"?e.jsx("button",{onClick:E,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:w?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:D,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:w?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:C,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:v,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:y,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&g&&e.jsx("button",{type:"button",onClick:()=>void Be(),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(rn,{selector:r.selector,onRepick:N,onClear:()=>i(null)})]}),e.jsx(ve,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(tn,{feature:l??"",upgradeUrl:sn})})]})}function nn({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 rn({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 ln={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},on={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function cn(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState("off"),p=b(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await ae();g&&(o(x),x==="off"?await le(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await le(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await ae();if(g){if(t&&await le(g,{type:ln[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await le(g,{type:on[x],tabId:g}).catch(()=>{}),s(x)}}async function h(){const x=await ae();if(x){if(a){await le(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const g=await xe(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.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(we,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(we,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(we,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(we,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(we,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function we({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function dn(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 un(){const t=b(c=>c.status),s=b(c=>c.progress),a=b(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":dn(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Ut,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Ut,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function Ut({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}const je={"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 pn(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const hn={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 Ve({violation:t,alreadyAcknowledged:s}){const a=b(N=>N.pinnedMatchKey),n=b(N=>N.pinnedFound),r=b(N=>N.setPinned),i=b(N=>{var k;return(k=N.results[0])==null?void 0:k.frameId}),l=b(N=>{var k;return(k=N.results[0])==null?void 0:k.scope}),o=b(N=>N.results),c=b(N=>N.acknowledgedKeys.has(t.matchKey)),p=b(N=>N.markAcknowledged),d=b(N=>N.markUnacknowledged),u=s||c,h=a===t.matchKey,x=h&&!n;async function g(N){try{return(await xe(N,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:N,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const N=await ae();if(!N)return;if(h){r(null);try{await le(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},i)}catch{}return}const k=await g(N);r(t.matchKey,k)}function A(N){N.stopPropagation(),t.currentState.breakpoint.width<=640&&gs(),(async()=>{const k=await ae();if(!k)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:k,state:t.currentState,scope:l,frameId:i})}catch{}const v=await g(k);r(t.matchKey,v)})()}async function T(N){N.stopPropagation();const k=await ae();if(!k)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:k,state:fn(),scope:l,frameId:i})}catch{te({type:"STATE_RESET_REQUEST",tabId:k})}const v=await g(k);r(t.matchKey,v)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,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 ${hn[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(bn,{violation:t}),e.jsx(wn,{violation:t}),e.jsx(yn,{violation:t}),e.jsx(vn,{text:t.target.failureSummary}),e.jsx(jn,{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: ",mn(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:A,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),A(N))},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:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),T(N))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),x&&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:N=>{N.stopPropagation(),d(t.matchKey),gn(t,o)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.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:N=>{N.stopPropagation(),p(t.matchKey),xn(t,o)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.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:N=>N.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function mn(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 xn(t,s){await Js({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await js(t.componentId,s)}async function gn(t,s){await Ys(t.componentId,t.matchKey),await js(t.componentId,s)}async function js(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Z({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function fn(){const t=ps.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Ns(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 bn({violation:t}){const s=Ns(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 vn({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 yn({violation:t}){const s=pn(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 wn({violation:t}){const s=Ns(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return Qs(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(c=>c.matchKey===t.matchKey);o?(await Xs(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.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,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background: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})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function jn({ruleId:t}){const s=Zs(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 at=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function gt(t){const s=at.map(r=>kn(r,t)),a=Nn(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function Nn(t){const s=t.filter(l=>l==="A").length,a=t.filter(l=>l==="C").length,n=t.filter(l=>l==="D").length,r=t.filter(l=>l==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function kn(t,s){const a=new Set(t.axeRules),n=s.violations.filter(S=>a.has(S.ruleId)),r=s.manualRuns.filter(S=>t.igtWorkflowIds.includes(S.workflowId)),i=t.igtWorkflowIds.map(S=>s.workflows.find(M=>M.id===S)).filter(S=>S!=null);let l=i.length>0;for(const S of i){const M=r.find(Q=>Q.workflowId===S.id);if((M?Object.keys(M.steps).length:0)!==S.steps.length){l=!1;break}}const o=r.some(S=>Object.keys(S.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(S=>c.includes(S.workflowId)),d=c.map(S=>s.workflows.find(M=>M.id===S)).filter(S=>S!=null);let u=c.length>0&&d.length===c.length;for(const S of d){const M=p.find(Q=>Q.workflowId===S.id);if((M?Object.keys(M.steps).length:0)!==S.steps.length){u=!1;break}}let h=null;if(u)for(const S of p)S.completedAt&&(h===null||S.completedAt>h)&&(h=S.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,w=s.interactiveAuditVerdicts,A=[];w&&(t.id==="tab-order"&&w.focusOrder&&A.push({verdict:w.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(w.keyboardTrap&&A.push({verdict:w.keyboardTrap,criterionId:"2.1.2"}),w.focusVisible&&A.push({verdict:w.focusVisible,criterionId:"2.4.7"})));const T=A.some(S=>S.verdict==="fail");if(A.length>0&&A.every(S=>S.verdict==="pass")&&c.length>0&&!u)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:A.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:A.map(S=>S.criterionId)};if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const k=t.axeRules.length>0||t.heuristic!=null,v=t.igtWorkflowIds.length>0;if(k?!s.auditRan:!o)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:v||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j={critical:0,serious:0,moderate:0,minor:0};for(const S of pt(n))j[S.impact]++;A.length>0&&A.every(S=>S.verdict==="pass")||(j.serious+=x),T&&(j.serious+=A.filter(S=>S.verdict==="fail").length);for(const S of r){const M=i.find(F=>F.id===S.workflowId);if(M)for(const F of M.steps){const Q=S.steps[F.id];(Q==null?void 0:Q.status)==="fail"&&(F.severity==="required"?j.serious++:j.moderate++)}}const D=j.critical>0,y=j.serious>0;let U;j.critical>=5?U="F":j.critical>=1?U="D":j.serious>=1?U="C":j.moderate>=1?U="B":U="A";const L=U!=="A"&&(v&&!l||c.length>0&&!u);return{id:t.id,label:t.label,letter:U,untested:!1,needsIgt:L,igtCompleted:l,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:j,caps:{cappedAtC:D,cappedAtB:y}}}const nt="dismissedFindings";function He(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function fe(t){return`reading-order::${t}`}function be(t){return`tab-order::${t}`}async function ze(){try{const t=await chrome.storage.local.get(nt),s=t==null?void 0:t[nt];if(s&&typeof s=="object")return s}catch{}return{}}async function ft(t){await chrome.storage.local.set({[nt]:t})}async function We(t){return(await ze())[He(t)]??{}}async function ks(t,s,a,n){const r=await ze(),i=He(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await ft(r)}async function Re(t,s){if(s.length===0)return;const a=await ze(),n=He(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await ft(a)}async function Ss(t,s){const a=await ze(),n=He(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await ft(a))}const Ol=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:ks,addDismissals:Re,dismissalKeyForReadingOrder:fe,dismissalKeyForTabOrder:be,getDismissalsForUrl:We,removeDismissal:Ss},Symbol.toStringTag,{value:"Module"}));function As(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Cs(t){return`${ht(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Sn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Cs(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 Lt={critical:0,serious:1,moderate:2,minor:3};function An(){var N,k,v,C;const t=b(j=>j.results),s=b(j=>j.componentId),a=b(j=>j.setView),n=((N=t[0])==null?void 0:N.pageUrl)??((k=t[0])==null?void 0:k.scope)??"",[r,i]=m.useState({}),[l,o]=m.useState(new Set),[c,p]=m.useState({});if(m.useEffect(()=>{if(!s){p({});return}let j=!1;const E=async()=>{const y=await is(s);if(j)return;const U={};for(const L of y)L.criterionId==="2.4.3"?U.focusOrder=L.verdict:L.criterionId==="2.1.2"?U.keyboardTrap=L.verdict:L.criterionId==="2.4.7"?U.focusVisible=L.verdict:L.criterionId==="1.3.2"&&(U.readingOrder=L.verdict);p(U)};E();const D=y=>{y.interactiveAuditResults&&E()};return chrome.storage.local.onChanged.addListener(D),()=>{j=!0,chrome.storage.local.onChanged.removeListener(D)}},[s]),m.useEffect(()=>{if(!n)return;We(n).then(i);const j=()=>{document.visibilityState==="visible"&&n&&We(n).then(i)};return document.addEventListener("visibilitychange",j),()=>document.removeEventListener("visibilitychange",j)},[n]),m.useEffect(()=>{if(!s){o(new Set);return}let j=!1;const E=async()=>{const y=await chrome.storage.local.get("igtRuns");if(j)return;const L=((y==null?void 0:y.igtRuns)??{})[s]??{},S=new Set;for(const M of se){const F=L[M.id];F&&Object.keys(F.steps).length===M.steps.length&&S.add(M.id)}o(S)};E();const D=()=>{document.visibilityState==="visible"&&E()};return document.addEventListener("visibilitychange",D),()=>{j=!0,document.removeEventListener("visibilitychange",D)}},[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((j,E)=>j+E.durationMs,0),u=t.reduce((j,E)=>j+E.violations.length,0),h=Sn(t);h.sort((j,E)=>{const D=Lt[j.representative.impact]??99,y=Lt[E.representative.impact]??99;return D!==y?D-y:E.states.length-j.states.length});const x=t.map(j=>As(j.state)).join(`
4
- `),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",w=l.has("keyboard")||g?0:(((v=t[0])==null?void 0:v.tabOrderIssues)??[]).filter(j=>!(be(j.selector)in r)).length,A=c.readingOrder!==void 0,T=l.has("page-structure")||A?0:(((C=t[0])==null?void 0:C.readingOrderIssues)??[]).filter(j=>!(fe(j.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(En,{violations:t.flatMap(j=>j.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(w>0||T>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:[w>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:w})," tab-order issue",w===1?"":"s"," (WCAG 2.4.3)"]}),w>0&&T>0&&" · ",T>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:T})," reading-order issue",T===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:x,"aria-label":`${t.length} states tested: ${x.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",h.length," unique ",h.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",u," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(In,{groups:h,totalStates:t.length,violations:t.flatMap(j=>j.violations),interactiveVerdicts:c})]})}const Cn={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 In({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=gt({violations:a,auditRan:!0,manualRuns:[],workflows:se,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,l=new Set;for(const c of at){for(const p of c.axeRules)l.add(p);i.set(c.id,[])}const o=[];for(const c of t){let p=!1;for(const d of at)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),p=!0;break}p||o.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const p=i.get(c.id)??[];return e.jsx(Dt,{subGrade:c,groups:p,totalStates:s},c.id)}),o.length>0&&e.jsx(Dt,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:o,totalStates:s})]})}function Dt({subGrade:t,groups:s,totalStates:a}){const[n,r]=m.useState(!1),[i,l]=m.useState("idle"),[o,c]=m.useState(null),[p,d]=m.useState(0),u=s.length>0,h=Cn[t.letter],x=s.filter(A=>A.representative.ruleId==="color-contrast"||A.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function w(A){A.stopPropagation(),l("loading"),c(null);try{const T=x.map(k=>{const v=k.representative.target.outerHTML,C=k.representative.target.failureSummary,j=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(C),E=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(C);if(!j||!E)return null;const D=k.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:k.representative.matchKey,foreground:j[1],background:E[1],fontSize:16,fontWeight:400,targetLevel:D,_html:v}}).filter(k=>k!==null);if(T.length===0){l("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const N=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:k,...v})=>v)});if(N.unavailableReason&&N.results.length===0){l("error"),c(N.unavailableReason);return}await ea(N.results),l("done"),d(k=>k+1),n||r(!0)}catch(T){l("error"),c(T instanceof Error?T.message:String(T))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(A=>!A),"aria-expanded":n,disabled:!u,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${h}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:u?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:A=>void w(A),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),w(A))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${x.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${x.length}`:`✨ Suggest for all ${x.length}`}),u&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&o&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:o}),n&&u&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(A=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ve,{violation:A.representative}),e.jsx(Tn,{states:A.states,totalStates:a})]},`${Cs(A.representative)}::${p}`))})]})}const Rn={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 En({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=b(p=>p.setView),l=gt({violations:t,auditRan:!0,manualRuns:a,workflows:se,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=pt(t).length;return e.jsx("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${Rn[l]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:l})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function Tn({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(As))),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 $n={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Un={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function Ln({violations:t,componentId:s}){var he,pe,de,I,J,ne,ee;const[a,n]=m.useState([]),[r,i]=m.useState([]),[l,o]=m.useState(new Set),[c,p]=m.useState(null),[d,u]=m.useState({}),[h,x]=m.useState(new Set),g=b(f=>f.status),w=b(f=>f.progress),A=b(f=>f.freshThisSession),T=b(f=>f.results),N=(he=T[0])==null?void 0:he.startedAt,k=((pe=T[0])==null?void 0:pe.pageUrl)??((de=T[0])==null?void 0:de.scope)??null;if(m.useEffect(()=>{if(!s){n([]);return}let f=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(f)return;const G=((O==null?void 0:O.igtRuns)??{})[s]??{};n(Object.values(G))}),()=>{f=!0}},[s]),m.useEffect(()=>{if(!k){i([]);return}let f=!1;return De(k).then(O=>{f||i(O)}),()=>{f=!0}},[k]),g==="running")return e.jsx(Gn,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const v=gt({violations:t,auditRan:T.length>0,manualRuns:a,workflows:se,heuristicCounts:{tabOrder:((J=(I=T[0])==null?void 0:I.tabOrderIssues)==null?void 0:J.length)??0,readingOrder:((ee=(ne=T[0])==null?void 0:ne.readingOrderIssues)==null?void 0:ee.length)??0}}),C=b(f=>f.acknowledgedKeys),j=T.length>0?ls(T,{runs:a,workflows:se},"2.1","AA",C,r):void 0,E=T.length>0?ta(mt({audits:T,igtRuns:a,workflows:se,acknowledgedMatchKeys:C,incompleteResolutions:r}),se):void 0,D=j?j.failingCriteria.length>0||j.inconclusiveCriteria.length>0:!1,y=D&&v.overallLetter==="A"?"B":v.overallLetter;async function U(f){var q;if(!k||!((q=j==null?void 0:j.inconclusiveReasons)!=null&&q[f]))return;const P=j.inconclusiveReasons[f].filter(V=>V.source==="axe-incomplete"&&V.elements&&V.elements.length>0);if(P.length===0)return;o(V=>new Set(V).add(f)),p(null);const G=[];let H=0;try{for(const B of P){const R=await te({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:B.ruleOrStepId,pageUrl:B.pageUrl??k,wcagCriterion:f,elements:B.elements??[],targetLevel:"AA"});if(R!=null&&R.unavailableReason){p(R.unavailableReason);break}R!=null&&R.resolutions&&(G.push(...R.resolutions),H+=R.totalCostUsd??0)}if(k){const B=await De(k);i(B)}const V={total:G.length,pass:G.filter(B=>B.verdict==="pass").length,fail:G.filter(B=>B.verdict==="fail").length,uncertain:G.filter(B=>B.verdict==="uncertain").length,costUsd:H,resolutions:G};u(B=>({...B,[f]:V}))}finally{o(V=>{const B=new Set(V);return B.delete(f),B})}}function L(f){x(O=>{const P=new Set(O);return P.has(f)?P.delete(f):P.add(f),P})}async function S(f){var R,z;if(!k)return;const O=((R=j==null?void 0:j.inconclusiveReasons)==null?void 0:R[f])??[],P=((z=j==null?void 0:j.failingReasons)==null?void 0:z[f])??[],G=[],H=new Set;for(const _ of O){if(_.source!=="axe-incomplete"||!_.elements)continue;const W=_.pageUrl??k;for(const Y of _.elements){const X=`${W}::${_.ruleOrStepId}::${Y.selector}`;H.has(X)||(H.add(X),G.push({ruleId:_.ruleOrStepId,pageUrl:W,selector:Y.selector}))}}for(const _ of P){if(_.source!=="ai"||!_.selector)continue;const W=_.ruleOrStepId.startsWith("ai-resolved::")?_.ruleOrStepId.slice(13):_.ruleOrStepId,Y=_.pageUrl??k,X=`${Y}::${W}::${_.selector}`;H.has(X)||(H.add(X),G.push({ruleId:W,pageUrl:Y,selector:_.selector}))}if(G.length===0)return;const q=new Date().toISOString(),V=[];for(const _ of G){const W=r.find(Y=>Y.pageUrl===_.pageUrl&&Y.ruleId===_.ruleId&&Y.selector===_.selector);W&&W.verdict==="pass"&&W.reasoning.startsWith("Marked as visually verified")||V.push({pageUrl:_.pageUrl,ruleId:_.ruleId,selector:_.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${q.slice(0,10)}.`,resolvedAt:q,costUsd:0,wcagCriterion:f})}if(V.length===0)return;await sa(V);const B=await De(k);i(B),u(_=>({..._,[f]:{total:V.length,pass:V.length,fail:0,uncertain:0,costUsd:0,resolutions:V}}))}const M=(()=>{if(!D||v.overallLetter!=="A"||!j)return null;const f=j.inconclusiveCriteria.length,O=j.failingCriteria.length,P=[];O>0&&P.push(`${O} WCAG ${j.targetLevel} ${O===1?"criterion":"criteria"} failing`),f>0&&P.push(`${f} WCAG ${j.targetLevel} ${f===1?"criterion":"criteria"} inconclusive`);const G=O>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${P.join(" + ")}. ${G}`})();let F=0;for(const f of se){const O=a.find(G=>G.workflowId===f.id);if(!O)continue;f.steps.every(G=>{const H=O.steps[G.id];return(H==null?void 0:H.status)==="pass"||(H==null?void 0:H.status)==="fail"||(H==null?void 0:H.status)==="skip"||(H==null?void 0:H.status)==="not-applicable"})&&F++}const Q=pt(t.filter(f=>!C.has(f.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!A&&N&&e.jsx(Vn,{scannedAt:N}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${$n[y]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:y})}),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 ",v.subGrades.length," verification areas below. Untested areas count as F until verified."]}),M&&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:M})]})]}),v.isLawsuitRisk&&e.jsx(On,{areas:v.warningAreas}),e.jsx(Mn,{grades:v.subGrades}),j&&e.jsx(Dn,{coverage:j,onResolveWithAi:U,onMarkVisuallyVerified:S,resolving:l,resolveError:c,lastResolveResult:d,expandedResultFor:h,onToggleResultDetail:L}),E&&e.jsx(_n,{layers:E}),e.jsx(Pn,{violationsRemaining:Q,manualCompleted:F,manualTotal:se.length}),F>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:F})," of ",e.jsx("strong",{children:se.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:`${F/se.length*100}%`}})})]}):null]})}function Dn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=m.useState(c>0&&c<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.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 g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const w=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",w,"."]})})(),!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&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),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:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(w=>{var E,D;const A=g.kind==="inconclusive"?(E=t.inconclusiveReasons)==null?void 0:E[w]:void 0,T=g.kind==="failing"?(D=t.failingReasons)==null?void 0:D[w]:void 0,N=A==null?void 0:A.some(y=>y.source==="axe-incomplete"&&y.elements&&y.elements.length>0),k=T==null?void 0:T.some(y=>y.source==="ai"),v=(n==null?void 0:n.has(w))??!1,C=i==null?void 0:i[w],j=(l==null?void 0:l.has(w))??!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:["· ",w]}),(g.kind==="inconclusive"&&N||g.kind==="failing"&&k)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:v,onClick:()=>s(w),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:v?"Resolving…":C?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:v,onClick:()=>a(w),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:g.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),C&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",C.total," ",C.total===1?"verdict":"verdicts",":",C.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",C.pass," pass"]}),C.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",C.fail," fail"]}),C.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",C.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",C.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(w),className:"ml-auto text-[10px] underline text-brand-700",children:j?"hide reasoning":"show reasoning"})]}),C.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",C.uncertain," ",C.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),C.pass===C.total&&C.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),j&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:C.resolutions.map((y,U)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:y.verdict==="pass"?"text-emerald-700 font-semibold":y.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:y.verdict==="pass"?"✓":y.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:y.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:y.reasoning})]},U))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((y,U)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[y.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),y.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:y.selector}),y.notes&&e.jsx("span",{className:"text-rose-700",children:y.notes})]},U))}),A&&A.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:A.map((y,U)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[y.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," skipped — "]}),y.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.resolutionHint,y.elements&&y.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",y.elements.length===1?"element":`${y.elements.length} elements`,":"," ",y.elements.slice(0,3).map((L,S,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),S<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},S)),y.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",y.elements.length-3," more"]})]})]},U))}):g.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.)"})]},w)})})]},g.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 _t={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 _n({layers:t}){const s=b(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,l=r.blocked.length,o=r.unevaluated.length,c=r.cleared,p=i>0&&l===0&&o===0,d=p?"text-emerald-700":l>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":l>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":l>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:_t[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),l>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",l," blocked"]}),o>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",o," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:_t[n].hint}),n==="human"&&o>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 On({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 Mn({grades:t}){const s=b(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 ${Un[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(Fn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Fn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=se.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?Is(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",n?` ${n} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function Pn({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(l=>l.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(l=>!l.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((l,o)=>{const c=o===i,p=l.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${o+1}.`}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[l.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label})]},o)})})]})}function Gn({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 Vn({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",Is(s)," old). Re-scan to grade the current page state."]})]})}function Is(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}function Wn(){const t=b(a=>a.results),s=b(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(Ln,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(Bn,{})]})}function Bn(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(Ne,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(Ne,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(Ne,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(Ne,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(Ne,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function Ne({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Hn={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 zn({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(Ve,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Hn[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:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Ve,{violation:c},p))})]})}function Kn(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 qn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Rs({open:t,onClose:s,format:a,content:n,filename:r}){const i=zs(new Blob([n]).size);function l(){ut(n,r),s()}function o(){dt(n),s()}return e.jsxs(ve,{open:t,onClose:s,title:qn[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:o,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Ot=7800;function Qn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
6
- `),c=new URLSearchParams({title:i,body:o});let p=`${n}/issues/new?${c.toString()}`;return p.length>Ot&&(p=p.slice(0,Ot)),{url:p,title:i,body:o}}const Mt=7800;function Yn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`Component: ${s??"unknown"}`),l.push(""),l.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`Rule: ${d.ruleId} (${d.impact})`),l.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),l.push(`Description: ${d.description}`),l.push(`Selector: ${d.target.selector}`),l.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&l.push(`More info: ${d.helpUrl}`),l.push(""),l.push(`HTML: ${d.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const o=l.join(`
7
- `),c=new URLSearchParams({summary:i,description:o});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>Mt&&(p=p.slice(0,Mt)),{url:p,summary:i,description:o}}const Ft=7800;function Jn(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),i=[];for(const u of a){const h=`${u.ruleId}::${u.target.selector}`,x=`:${u.currentState.pseudoState} · ${u.currentState.theme} · ${u.currentState.direction}`,g=i.find(w=>`${w.ruleId}::${w.target.selector}`===h);if(g){g._states.includes(x)||g._states.push(x);continue}i.push({...u,_states:[x]})}const l=`a11y: ${i.length} new violation${i.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const u of i)o.push(`### \`${u.ruleId}\` — ${u.impact}`),o.push(""),o.push(u.description),o.push(""),o.push(`- **WCAG:** ${u.wcagCriterion} (${u.wcagLevel})`),o.push(`- **Selector:** \`${u.target.selector}\``),o.push(`- **Found in state(s):** ${u._states.join(", ")}`),u.helpUrl&&o.push(`- **More info:** ${u.helpUrl}`),o.push(""),o.push("```html"),o.push(u.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(`
8
- `),p=new URLSearchParams({"[Title]":l,"[Description]":c});let d=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return d.length>Ft&&(d=d.slice(0,Ft)),{url:d,title:l,description:c}}const Pt=7800;function Xn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only inherited debt not included)._");const o=l.join(`
9
- `),c=new URLSearchParams({"issue[title]":i,"issue[description]":o});let p=`${n}/-/issues/new?${c.toString()}`;return p.length>Pt&&(p=p.slice(0,Pt)),{url:p,title:i,description:o}}const Gt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Zn=["wcag-component-auditor","wcag-forensic-log"];async function er(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Gt);s=Object.keys(n).length,await chrome.storage.local.remove(Gt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Zn)try{await tr(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function tr(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const rt="accessibilityStatementInputs:v1";async function sr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:null}async function ar(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[rt]:t})}function nr({open:t,onClose:s,results:a}){const[n,r]=m.useState("eaa"),[i,l]=m.useState(""),[o,c]=m.useState(""),[p,d]=m.useState("partial"),[u,h]=m.useState(""),[x,g]=m.useState(""),[w,A]=m.useState(""),[T,N]=m.useState(""),[k,v]=m.useState("English"),[C,j]=m.useState("wcagcheckr (self-evaluation)"),[E,D]=m.useState("2.1"),[y,U]=m.useState("AA"),[L,S]=m.useState(!1),[M,F]=m.useState(null),Q=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var J,ne,ee,f;const I=await sr();if(I&&(I.framing&&r(I.framing),I.organizationName&&l(I.organizationName),I.siteUrl&&c(I.siteUrl),I.conformanceStatus&&d(I.conformanceStatus),(J=I.contact)!=null&&J.email&&h(I.contact.email),(ne=I.contact)!=null&&ne.phone&&g(I.contact.phone),(ee=I.contact)!=null&&ee.formUrl&&A(I.contact.formUrl),I.countryCode&&N(I.countryCode),I.language&&v(I.language),I.auditedBy&&j(I.auditedBy),I.wcagVersion&&D(I.wcagVersion),I.wcagLevel&&U(I.wcagLevel)),!(I!=null&&I.siteUrl)&&((f=a[0])!=null&&f.pageUrl))try{const O=new URL(a[0].pageUrl);c(`${O.protocol}//${O.host}/`)}catch{}I!=null&&I.conformanceStatus||d(aa(a)),setTimeout(()=>{var O;return(O=Q.current)==null?void 0:O.focus()},50)})()},[t,a]),!t)return null;function he(){var ee;const I=new Date().toISOString().slice(0,10),J=(ee=a[0])!=null&&ee.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):I,ne={};return u.trim()&&(ne.email=u.trim()),x.trim()&&(ne.phone=x.trim()),w.trim()&&(ne.formUrl=w.trim()),{framing:n,organizationName:i.trim(),siteUrl:o.trim(),conformanceStatus:p,preparedAt:I,evaluatedAt:J,contact:ne,countryCode:T||null,language:k.trim()||"English",auditedBy:C.trim()||"wcagcheckr (self-evaluation)",wcagVersion:E,wcagLevel:y}}function pe(I){if(!I.organizationName)return"Organization name is required.";if(!I.siteUrl)return"Site URL is required.";try{new URL(I.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!I.contact.email&&!I.contact.phone&&!I.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function de(I){F(null);const J=he(),ne=pe(J);if(ne){F(ne);return}S(!0);try{await ar(J);const ee=await Z({type:"EXPORT_REQUEST",format:I==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:J}),f=(ee==null?void 0:ee.content)??"";if(!f||f.startsWith("# Accessibility statement — error")){F(f||"Export failed — no response.");return}try{await navigator.clipboard.writeText(f)}catch{}const O=new Blob([f],{type:I==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),P=URL.createObjectURL(O);window.open(P,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(P),6e4),s()}catch(ee){F(ee instanceof Error?ee.message:String(ee))}finally{S(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:n==="eaa",onChange:()=>r("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:n==="wad",onChange:()=>r("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:Q,type:"text",value:i,onChange:I=>l(I.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:o,onChange:I=>c(I.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:p,onChange:I=>d(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:E,onChange:I=>D(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:y,onChange:I=>U(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:u,onChange:I=>h(I.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:I=>g(I.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:w,onChange:I=>A(I.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:T,onChange:I=>N(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(na).map(([I,J])=>e.jsxs("option",{value:I,children:[I," — ",J.name.replace(/^[A-Z]+\s*—\s*/,"")]},I))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:k,onChange:I=>v(I.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:C,onChange:I=>j(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),M&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:M})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void de("markdown"),disabled:L,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:L?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void de("html"),disabled:L,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:L?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:L,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function rr(){const t=b(f=>f.delta),s=b(f=>f.componentId),a=b(f=>f.results),n=b(f=>f.tier),r=b(f=>f.baselineList),i=b(f=>f.siteCrawlReport),[l,o]=m.useState(""),[c,p]=m.useState(""),[d,u]=m.useState(""),[h,x]=m.useState(""),[g,w]=m.useState(!1),[A,T]=m.useState(!1),[N,k]=m.useState(null),[v,C]=m.useState(null),[j,E]=m.useState(!1),[D,y]=m.useState(!1),[U,L]=m.useState(null),[S,M]=m.useState(!1);m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"githubRepoUrl"}),Z({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),Z({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),Z({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([f,O,P,G])=>{o(typeof f.data=="string"?f.data:""),p(typeof O.data=="string"?O.data:""),u(typeof P.data=="string"?P.data:""),x(typeof G.data=="string"?G.data:"")})},[]),m.useEffect(()=>oe("BADGE_CLICKED_EVENT",O=>{const P=`viol-row-${O.violationId}`,G=document.getElementById(P);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-rose-500"),setTimeout(()=>G.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const f=await ae();f&&(D&&await le(f,{type:"BADGES_HIDE_REQUEST",tabId:f}).catch(()=>{}),S&&await le(f,{type:"HEATMAP_HIDE_REQUEST",tabId:f}).catch(()=>{}))})()},[]);async function F(){const f=await ae();if(!f){re.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(D){await le(f,{type:"BADGES_HIDE_REQUEST",tabId:f}).catch(()=>{}),y(!1),L(null);return}const O={critical:4,serious:3,moderate:2,minor:1},P=new Map;for(const V of a)for(const B of V.violations)P.has(B.matchKey)||P.set(B.matchKey,B);const H=Array.from(P.values()).sort((V,B)=>O[B.impact]-O[V.impact]).map((V,B)=>({id:V.matchKey,index:B+1,selector:V.target.selector,impact:V.impact,ruleId:V.ruleId,wcagCriterion:V.wcagCriterion}));if(H.length===0){re.polite("No violations to badge.");return}const q=await xe(f,{type:"BADGES_SHOW_REQUEST",tabId:f,violations:H}).catch(()=>null);q&&(y(!0),L({rendered:q.rendered,requested:q.requested,clustered:q.clustered}),re.polite(`${q.rendered} violation badges shown on the page.`))}async function Q(){const f=await ae();if(!f){re.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(S){await le(f,{type:"HEATMAP_HIDE_REQUEST",tabId:f}).catch(()=>{}),M(!1);return}const O=new Map;for(const H of a)for(const q of H.violations)O.has(q.matchKey)||O.set(q.matchKey,q);const P=Array.from(O.values()).map(H=>({selector:H.target.selector,impact:H.impact}));if(P.length===0){re.polite("No violations to heatmap.");return}const G=await xe(f,{type:"HEATMAP_SHOW_REQUEST",tabId:f,violations:P}).catch(()=>null);G&&(M(!0),re.polite(`Heatmap shown with ${G.rendered} violation blobs.`))}const he=us(n,"exportJson"),pe=hs[n].maxBaselines,de=r.some(f=>f.componentId===s),I=de||r.length<pe;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 J(){if(!s||a.length===0)return;const f=a.flatMap(B=>B.violations),O=a.flatMap(B=>B.announcements??[]),P=a.flatMap(B=>B.focusEvents??[]),G=a[0],q=(await Z({type:"SETTINGS_GET",key:"stateMatrix"})).data??ps;await te({type:"BASELINE_SET",componentId:s,violations:f,announcements:O,focusEvents:P,snapshotMeta:{url:window.location.href,axeVersion:G.axeVersion,matrixConfig:q,capturedAt:new Date().toISOString()}});const V=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:f,announcements:O,focusEvents:P,currentMatrix:q});b.getState().setDelta(V.delta),re.polite(`Baseline saved for ${s}.`)}async function ne(){if(!s||!de||!window.confirm(`Remove the saved baseline for "${s}"?
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-BRg9o8WW.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-CzL3uuvq.js","assets/scheduled-audit-runner-3nAUxKGr.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
2
+ var zs=Object.defineProperty;var Ks=(t,s,a)=>s in t?zs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var kt=(t,s,a)=>Ks(t,typeof s!="symbol"?s+"":s,a);import{R as Ce,i as re,r as m,j as e,M as ve,C as st,l as qs,o as dt,t as ut,m as rs,s as is,k as Ee}from"./styles-BQMwoCaE.js";import{s as Qs,g as Ys,a as ae,b as Js,u as Xs,c as Zs,d as ea,e as ta,f as pt,h as ls,A as se,l as ht,i as sa,j as De,k as os,m as aa,n as mt,o as na,p as ra,N as ia,q as la,O as oa,r as ca,t as da,v as ua,w as St,x as pa,y as cs,z as ha,B as ma,C as xa,D as ga,E as fa,F as ba,T as va,G as ya,H as wa,I as ja,J as ds,K as Na,L as At,M as Ct,P as Ke,Q as ka,R as It,S as Sa,U as Aa,V as Ca,W as Ia,X as Ra,Y as Ea}from"./scheduled-audit-runner-3nAUxKGr.js";import{_ as xt}from"./diff-DA41zYPc.js";import{o as oe,r as Z,s as te,c as us,b as le,d as xe}from"./crash-reporter-Dc5lvxvY.js";import{B as qe,i as ps,f as hs,T as ms}from"./ai-usage-log-DBBVxutJ.js";const Rt=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,h))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,o);return o},Ta=t=>t?Rt(t):Rt,$a=t=>t;function Ua(t,s=$a){const a=Ce.useSyncExternalStore(t.subscribe,Ce.useCallback(()=>s(t.getState()),[t,s]),Ce.useCallback(()=>s(t.getInitialState()),[t,s]));return Ce.useDebugValue(a),a}const Et=t=>{const s=Ta(t),a=n=>Ua(s,n);return Object.assign(a,s),a},La=t=>t?Et(t):Et,b=La(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}),Qs(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(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),Me="sidePanel:lastAudit";function Da(){const t=[];return t.push(oe("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||re.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(oe("AUDIT_COMPLETE_EVENT",s=>{var i;b.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.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"}.`;re.polite(r),_a({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(oe("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(oe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||re.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(oe("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(oe("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(oe("LICENSE_CHANGED_EVENT",()=>{xs()})),t.push(oe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&re.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(oe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),re.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(oe("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),re.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function _a(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Me]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function Oa(){const s=(await chrome.storage.local.get(Me))[Me];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function Ma(){await chrome.storage.local.remove(Me)}async function Be(){b.getState().clearResults(),await Ma()}async function Fe(){const t=await Z({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function xs(t){const s=await Z({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),gs()}async function gs(){const{fetchMessages:t}=await xt(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ka);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function Fa(){const s=(await Z({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function Pa(){return chrome.runtime.connect({name:"audit-keepalive"})}let Pe=null;async function Ga(){if(Pe===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Pe=t.id)}catch{}}function fs(){if(Pe===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Pe}).catch(()=>{})}function ue(t){fs(),te(t)}function Va({onClose:t}){const[s,a]=m.useState(""),[n,r]=m.useState(""),[i,l]=m.useState(!0),[o,c]=m.useState(""),[p,d]=m.useState(!1),[u,h]=m.useState(null);async function x(g){var w;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),h(null);try{const A=await Z({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});A.success?(h({ok:!0,msg:`Sent (ref: ${A.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((w=A.error)==null?void 0:w.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,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:g=>a(g.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:g=>r(g.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:o,onChange:g=>c(g.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:g=>l(g.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 Tt({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 Ge=us("messages-client"),Wa="https://api.wcagcheckr.com",bs="wcagcheckr",Ba=1e4;function Ha(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function vs(t,s){const a=await Ys();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ha()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Wa}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Ba)})}async function za(t){try{const s=await vs(`/v1/products/${bs}/messages`,{userMode:t??null});return s.ok?await s.json():(Ge.warn("fetchMessages http",s.status),null)}catch(s){return Ge.warn("fetchMessages failed",s),null}}async function ge(t,s){try{const a=await vs(`/v1/products/${bs}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Ge.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Ge.warn("ackMessage failed",a),!1}}const Ka=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ge,fetchMessages:za},Symbol.toStringTag,{value:"Module"})),qa=["http:","https:"];function Qa(t){try{const s=new URL(t);return qa.includes(s.protocol)}catch{return!1}}function $t(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 l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Qa(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(m.Fragment,{children:o},`l-${n++}`)),a=l+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(m.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function ys({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:$t(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:$t(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){l(),n.push(d[1]);continue}o(),r.push(p)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const Ya={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Ja={critical:"bg-rose-50 border-rose-200"};function ws(){const t=b(h=>h.unreadMessageCount),s=b(h=>h.messages),a=b(h=>h.applyMessageAck),[n,r]=m.useState(!1),i=m.useRef(-1),[l,o]=m.useState(!1);m.useEffect(()=>{const h=s.filter(g=>!g.seen);if(h.length===0)return;const x=Math.max(...h.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const h=s.filter(x=>!x.seen);if(h.length!==0)for(const x of h)a(x.id,"seen"),ge(x.id,"seen")}function p(){const h=!n;r(h),h&&c()}async function d(h){a(h.id,"dismissed"),await ge(h.id,"dismissed")}async function u(h){h.ctaUrl&&(a(h.id,"clicked"),ge(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Xa,{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(Za,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}function Xa({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 Za({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=m.useRef(null);return m.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{gs()},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 ${Ya[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(ys,{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 js(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ge(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ge(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Ja.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(ys,{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 ye=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","risk","forensic","compliance"];function en(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function tn(){var u,h;const t=b(x=>x.view),s=b(x=>x.setView),a=b(x=>x.setUserMode),n=b(x=>x.results),r=b(x=>x.status),[i,l]=m.useState(!1),o=((u=n[0])==null?void 0:u.pageUrl)??((h=n[0])==null?void 0:h.scope),c=en(o),p=n.length>0&&r!=="running";function d(){a("owner"),te({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(ws,{}),e.jsx(Tt,{onClick:()=>void te({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Tt,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:o??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Be(),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(sn,{view:t,setView:s}),e.jsx(ve,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(Va,{onClose:()=>l(!1)})})]})}function sn({view:t,setView:s}){const a=m.useRef([]);function n(i){var c;const l=(i+ye.length)%ye.length,o=ye[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ye.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ye.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"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 an({feature:t,upgradeUrl:s}){const[a,n]=m.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(st,{open:a,onClose:()=>n(!1)})]})}const nn="https://wcagcheckr.com/upgrade";function rn(){const[t,s]=m.useState("single-element"),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState(null),[c,p]=m.useState(qe),[d,u]=m.useState(qe[0].id),h=b(L=>L.status),x=b(L=>L.tier),g=b(L=>L.results.length>0),w=h==="running";m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"matrixPresets"}),Z({type:"SETTINGS_GET",key:"activePresetId"})]).then(([L,S])=>{const M=Array.isArray(L.data)?L.data:null;p(M&&M.length>0?M:qe),typeof S.data=="string"&&u(S.data)})},[]);function A(L){const S=c.find(M=>M.id===L);S&&(u(L),te({type:"SETTINGS_SET",key:"activePresetId",value:L}),te({type:"SETTINGS_SET",key:"stateMatrix",value:S.matrix}))}const T=ps(x,"storybookAutoIterate");m.useEffect(()=>{const L=oe("ELEMENT_PICKED_EVENT",(M,F)=>{n(!1);const Q=F.frameId;U(Q),i({selector:M.selector,frameId:Q})}),S=oe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{L(),S()}},[]);async function j(){const L=await ae();L&&(n(!0),await le(L,{type:"PICKER_ACTIVATE_REQUEST",tabId:L}))}function k(){r&&(U(r.frameId),ue({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function v(){if(!T){o("storybook:auto-iterate");return}U(),ue({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function C(){U(),ue({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function N(){U(),ue({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function E(){U(),ue({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function D(){U(),ue({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function y(){te({type:"CANCEL_AUDIT"})}async function U(L){b.getState().setPinned(null);const S=await ae();if(S)try{await le(S,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:S},L)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:L=>s(L.target.value),disabled: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:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",T?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:L=>A(L.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:c.map(L=>e.jsx("option",{value:L.id,children:L.name},L.id))}),t==="single-element"?e.jsx(ln,{picking:a,picked:r,isRunning:w,onPick:j,onRun:k,onClearPick:()=>i(null)}):t==="full-page"?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…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:E,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:w?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:D,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:w?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:C,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:v,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:y,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&g&&e.jsx("button",{type:"button",onClick:()=>void Be(),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(on,{selector:r.selector,onRepick:j,onClear:()=>i(null)})]}),e.jsx(ve,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(an,{feature:l??"",upgradeUrl:nn})})]})}function ln({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 on({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 cn={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},dn={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function un(){const[t,s]=m.useState(null),[a,n]=m.useState(!1),[r,i]=m.useState(null),[l,o]=m.useState("off"),p=b(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await ae();g&&(o(x),x==="off"?await le(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await le(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await ae();if(g){if(t&&await le(g,{type:cn[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await le(g,{type:dn[x],tabId:g}).catch(()=>{}),s(x)}}async function h(){const x=await ae();if(x){if(a){await le(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const g=await xe(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:p});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.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(we,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(we,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(we,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(we,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(we,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick: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:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function we({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function pn(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 hn(){const t=b(c=>c.status),s=b(c=>c.progress),a=b(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":pn(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Ut,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Ut,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function Ut({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}function Ns(){return typeof chrome<"u"&&typeof chrome.devtools<"u"}async function Lt(t){if(!Ns())return!1;const s=chrome.devtools;return await new Promise(a=>{const r=`(function(){
3
+ try {
4
+ var el = document.querySelector(${JSON.stringify(t)});
5
+ if (el) { inspect(el); return true; }
6
+ return false;
7
+ } catch (err) { return false; }
8
+ })()`;s.inspectedWindow.eval(r,(i,l)=>{a(l?!1:i===!0)})})}const je={"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 mn(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const xn={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 Ve({violation:t,alreadyAcknowledged:s}){const a=b(j=>j.pinnedMatchKey),n=b(j=>j.pinnedFound),r=b(j=>j.setPinned),i=b(j=>{var k;return(k=j.results[0])==null?void 0:k.frameId}),l=b(j=>{var k;return(k=j.results[0])==null?void 0:k.scope}),o=b(j=>j.results),c=b(j=>j.acknowledgedKeys.has(t.matchKey)),p=b(j=>j.markAcknowledged),d=b(j=>j.markUnacknowledged),u=s||c,h=a===t.matchKey,x=h&&!n;async function g(j){try{return(await xe(j,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:j,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const j=await ae();if(!j)return;if(h){r(null);try{await le(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},i)}catch{}return}const k=await g(j);r(t.matchKey,k)}function A(j){j.stopPropagation(),t.currentState.breakpoint.width<=640&&fs(),(async()=>{const k=await ae();if(!k)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:k,state:t.currentState,scope:l,frameId:i})}catch{}const v=await g(k);r(t.matchKey,v)})()}async function T(j){j.stopPropagation();const k=await ae();if(!k)return;try{await Z({type:"STATE_DRIVE_REQUEST",tabId:k,state:vn(),scope:l,frameId:i})}catch{te({type:"STATE_RESET_REQUEST",tabId:k})}const v=await g(k);r(t.matchKey,v)}return e.jsxs("button",{type:"button",id:`viol-row-${t.matchKey}`,onClick:w,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
9
+ ${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 ${xn[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(yn,{violation:t}),e.jsx(Nn,{violation:t}),e.jsx(jn,{violation:t}),e.jsx(wn,{text:t.target.failureSummary}),e.jsx(kn,{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: ",gn(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:A,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),A(j))},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:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T(j))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),Ns()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:j=>{j.preventDefault(),j.stopPropagation(),Lt(t.target.selector)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),Lt(t.target.selector))},title:"Focus this element in the DevTools Elements tab",className:"text-brand-600 hover:underline cursor-pointer","data-testid":"reveal-in-elements",children:"Reveal in Elements"})]}),x&&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:j=>{j.stopPropagation(),d(t.matchKey),bn(t,o)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),j.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:j=>{j.stopPropagation(),p(t.matchKey),fn(t,o)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),j.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:j=>j.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function gn(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 fn(t,s){await Zs({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await ks(t.componentId,s)}async function bn(t,s){await Xs(t.componentId,t.matchKey),await ks(t.componentId,s)}async function ks(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Z({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function vn(){const t=hs.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function Ss(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 yn({violation:t}){const s=Ss(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 wn({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 jn({violation:t}){const s=mn(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 Nn({violation:t}){const s=Ss(t),[a,n]=m.useState({kind:"idle"});if(m.useEffect(()=>{let i=!1;return Js(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(c=>c.matchKey===t.matchKey);o?(await ea(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.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,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background: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})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function kn({ruleId:t}){const s=ta(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 at=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function gt(t){const s=at.map(r=>An(r,t)),a=Sn(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function Sn(t){const s=t.filter(l=>l==="A").length,a=t.filter(l=>l==="C").length,n=t.filter(l=>l==="D").length,r=t.filter(l=>l==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function An(t,s){const a=new Set(t.axeRules),n=s.violations.filter(S=>a.has(S.ruleId)),r=s.manualRuns.filter(S=>t.igtWorkflowIds.includes(S.workflowId)),i=t.igtWorkflowIds.map(S=>s.workflows.find(M=>M.id===S)).filter(S=>S!=null);let l=i.length>0;for(const S of i){const M=r.find(Q=>Q.workflowId===S.id);if((M?Object.keys(M.steps).length:0)!==S.steps.length){l=!1;break}}const o=r.some(S=>Object.keys(S.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(S=>c.includes(S.workflowId)),d=c.map(S=>s.workflows.find(M=>M.id===S)).filter(S=>S!=null);let u=c.length>0&&d.length===c.length;for(const S of d){const M=p.find(Q=>Q.workflowId===S.id);if((M?Object.keys(M.steps).length:0)!==S.steps.length){u=!1;break}}let h=null;if(u)for(const S of p)S.completedAt&&(h===null||S.completedAt>h)&&(h=S.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,w=s.interactiveAuditVerdicts,A=[];w&&(t.id==="tab-order"&&w.focusOrder&&A.push({verdict:w.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(w.keyboardTrap&&A.push({verdict:w.keyboardTrap,criterionId:"2.1.2"}),w.focusVisible&&A.push({verdict:w.focusVisible,criterionId:"2.4.7"})));const T=A.some(S=>S.verdict==="fail");if(A.length>0&&A.every(S=>S.verdict==="pass")&&c.length>0&&!u)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:A.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:A.map(S=>S.criterionId)};if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const k=t.axeRules.length>0||t.heuristic!=null,v=t.igtWorkflowIds.length>0;if(k?!s.auditRan:!o)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:v||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const N={critical:0,serious:0,moderate:0,minor:0};for(const S of pt(n))N[S.impact]++;A.length>0&&A.every(S=>S.verdict==="pass")||(N.serious+=x),T&&(N.serious+=A.filter(S=>S.verdict==="fail").length);for(const S of r){const M=i.find(F=>F.id===S.workflowId);if(M)for(const F of M.steps){const Q=S.steps[F.id];(Q==null?void 0:Q.status)==="fail"&&(F.severity==="required"?N.serious++:N.moderate++)}}const D=N.critical>0,y=N.serious>0;let U;N.critical>=5?U="F":N.critical>=1?U="D":N.serious>=1?U="C":N.moderate>=1?U="B":U="A";const L=U!=="A"&&(v&&!l||c.length>0&&!u);return{id:t.id,label:t.label,letter:U,untested:!1,needsIgt:L,igtCompleted:l,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:N,caps:{cappedAtC:D,cappedAtB:y}}}const nt="dismissedFindings";function He(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function fe(t){return`reading-order::${t}`}function be(t){return`tab-order::${t}`}async function ze(){try{const t=await chrome.storage.local.get(nt),s=t==null?void 0:t[nt];if(s&&typeof s=="object")return s}catch{}return{}}async function ft(t){await chrome.storage.local.set({[nt]:t})}async function We(t){return(await ze())[He(t)]??{}}async function As(t,s,a,n){const r=await ze(),i=He(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await ft(r)}async function Re(t,s){if(s.length===0)return;const a=await ze(),n=He(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await ft(a)}async function Cs(t,s){const a=await ze(),n=He(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await ft(a))}const Fl=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:As,addDismissals:Re,dismissalKeyForReadingOrder:fe,dismissalKeyForTabOrder:be,getDismissalsForUrl:We,removeDismissal:Cs},Symbol.toStringTag,{value:"Module"}));function Is(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Rs(t){return`${ht(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Cn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Rs(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 Dt={critical:0,serious:1,moderate:2,minor:3};function In(){var j,k,v,C;const t=b(N=>N.results),s=b(N=>N.componentId),a=b(N=>N.setView),n=((j=t[0])==null?void 0:j.pageUrl)??((k=t[0])==null?void 0:k.scope)??"",[r,i]=m.useState({}),[l,o]=m.useState(new Set),[c,p]=m.useState({});if(m.useEffect(()=>{if(!s){p({});return}let N=!1;const E=async()=>{const y=await ls(s);if(N)return;const U={};for(const L of y)L.criterionId==="2.4.3"?U.focusOrder=L.verdict:L.criterionId==="2.1.2"?U.keyboardTrap=L.verdict:L.criterionId==="2.4.7"?U.focusVisible=L.verdict:L.criterionId==="1.3.2"&&(U.readingOrder=L.verdict);p(U)};E();const D=y=>{y.interactiveAuditResults&&E()};return chrome.storage.local.onChanged.addListener(D),()=>{N=!0,chrome.storage.local.onChanged.removeListener(D)}},[s]),m.useEffect(()=>{if(!n)return;We(n).then(i);const N=()=>{document.visibilityState==="visible"&&n&&We(n).then(i)};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[n]),m.useEffect(()=>{if(!s){o(new Set);return}let N=!1;const E=async()=>{const y=await chrome.storage.local.get("igtRuns");if(N)return;const L=((y==null?void 0:y.igtRuns)??{})[s]??{},S=new Set;for(const M of se){const F=L[M.id];F&&Object.keys(F.steps).length===M.steps.length&&S.add(M.id)}o(S)};E();const D=()=>{document.visibilityState==="visible"&&E()};return document.addEventListener("visibilitychange",D),()=>{N=!0,document.removeEventListener("visibilitychange",D)}},[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((N,E)=>N+E.durationMs,0),u=t.reduce((N,E)=>N+E.violations.length,0),h=Cn(t);h.sort((N,E)=>{const D=Dt[N.representative.impact]??99,y=Dt[E.representative.impact]??99;return D!==y?D-y:E.states.length-N.states.length});const x=t.map(N=>Is(N.state)).join(`
10
+ `),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",w=l.has("keyboard")||g?0:(((v=t[0])==null?void 0:v.tabOrderIssues)??[]).filter(N=>!(be(N.selector)in r)).length,A=c.readingOrder!==void 0,T=l.has("page-structure")||A?0:(((C=t[0])==null?void 0:C.readingOrderIssues)??[]).filter(N=>!(fe(N.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx($n,{violations:t.flatMap(N=>N.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(w>0||T>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:[w>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:w})," tab-order issue",w===1?"":"s"," (WCAG 2.4.3)"]}),w>0&&T>0&&" · ",T>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:T})," reading-order issue",T===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:x,"aria-label":`${t.length} states tested: ${x.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",h.length," unique ",h.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",u," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(En,{groups:h,totalStates:t.length,violations:t.flatMap(N=>N.violations),interactiveVerdicts:c})]})}const Rn={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 En({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=gt({violations:a,auditRan:!0,manualRuns:[],workflows:se,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,l=new Set;for(const c of at){for(const p of c.axeRules)l.add(p);i.set(c.id,[])}const o=[];for(const c of t){let p=!1;for(const d of at)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),p=!0;break}p||o.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const p=i.get(c.id)??[];return e.jsx(_t,{subGrade:c,groups:p,totalStates:s},c.id)}),o.length>0&&e.jsx(_t,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:o,totalStates:s})]})}function _t({subGrade:t,groups:s,totalStates:a}){const[n,r]=m.useState(!1),[i,l]=m.useState("idle"),[o,c]=m.useState(null),[p,d]=m.useState(0),u=s.length>0,h=Rn[t.letter],x=s.filter(A=>A.representative.ruleId==="color-contrast"||A.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function w(A){A.stopPropagation(),l("loading"),c(null);try{const T=x.map(k=>{const v=k.representative.target.outerHTML,C=k.representative.target.failureSummary,N=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(C),E=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(C);if(!N||!E)return null;const D=k.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:k.representative.matchKey,foreground:N[1],background:E[1],fontSize:16,fontWeight:400,targetLevel:D,_html:v}}).filter(k=>k!==null);if(T.length===0){l("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const j=await Z({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:k,...v})=>v)});if(j.unavailableReason&&j.results.length===0){l("error"),c(j.unavailableReason);return}await sa(j.results),l("done"),d(k=>k+1),n||r(!0)}catch(T){l("error"),c(T instanceof Error?T.message:String(T))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(A=>!A),"aria-expanded":n,disabled:!u,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${h}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:u?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:A=>void w(A),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),w(A))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${x.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${x.length}`:`✨ Suggest for all ${x.length}`}),u&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&o&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:o}),n&&u&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(A=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ve,{violation:A.representative}),e.jsx(Un,{states:A.states,totalStates:a})]},`${Rs(A.representative)}::${p}`))})]})}const Tn={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 $n({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=b(p=>p.setView),l=gt({violations:t,auditRan:!0,manualRuns:a,workflows:se,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=pt(t).length;return e.jsx("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${Tn[l]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:l})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function Un({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(Is))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
11
+ `);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 Ln={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Dn={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 _n({violations:t,componentId:s}){var he,pe,de,I,J,ne,ee;const[a,n]=m.useState([]),[r,i]=m.useState([]),[l,o]=m.useState(new Set),[c,p]=m.useState(null),[d,u]=m.useState({}),[h,x]=m.useState(new Set),g=b(f=>f.status),w=b(f=>f.progress),A=b(f=>f.freshThisSession),T=b(f=>f.results),j=(he=T[0])==null?void 0:he.startedAt,k=((pe=T[0])==null?void 0:pe.pageUrl)??((de=T[0])==null?void 0:de.scope)??null;if(m.useEffect(()=>{if(!s){n([]);return}let f=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(f)return;const G=((O==null?void 0:O.igtRuns)??{})[s]??{};n(Object.values(G))}),()=>{f=!0}},[s]),m.useEffect(()=>{if(!k){i([]);return}let f=!1;return De(k).then(O=>{f||i(O)}),()=>{f=!0}},[k]),g==="running")return e.jsx(Wn,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const v=gt({violations:t,auditRan:T.length>0,manualRuns:a,workflows:se,heuristicCounts:{tabOrder:((J=(I=T[0])==null?void 0:I.tabOrderIssues)==null?void 0:J.length)??0,readingOrder:((ee=(ne=T[0])==null?void 0:ne.readingOrderIssues)==null?void 0:ee.length)??0}}),C=b(f=>f.acknowledgedKeys),N=T.length>0?os(T,{runs:a,workflows:se},"2.1","AA",C,r):void 0,E=T.length>0?aa(mt({audits:T,igtRuns:a,workflows:se,acknowledgedMatchKeys:C,incompleteResolutions:r}),se):void 0,D=N?N.failingCriteria.length>0||N.inconclusiveCriteria.length>0:!1,y=D&&v.overallLetter==="A"?"B":v.overallLetter;async function U(f){var q;if(!k||!((q=N==null?void 0:N.inconclusiveReasons)!=null&&q[f]))return;const P=N.inconclusiveReasons[f].filter(V=>V.source==="axe-incomplete"&&V.elements&&V.elements.length>0);if(P.length===0)return;o(V=>new Set(V).add(f)),p(null);const G=[];let H=0;try{for(const B of P){const R=await te({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:B.ruleOrStepId,pageUrl:B.pageUrl??k,wcagCriterion:f,elements:B.elements??[],targetLevel:"AA"});if(R!=null&&R.unavailableReason){p(R.unavailableReason);break}R!=null&&R.resolutions&&(G.push(...R.resolutions),H+=R.totalCostUsd??0)}if(k){const B=await De(k);i(B)}const V={total:G.length,pass:G.filter(B=>B.verdict==="pass").length,fail:G.filter(B=>B.verdict==="fail").length,uncertain:G.filter(B=>B.verdict==="uncertain").length,costUsd:H,resolutions:G};u(B=>({...B,[f]:V}))}finally{o(V=>{const B=new Set(V);return B.delete(f),B})}}function L(f){x(O=>{const P=new Set(O);return P.has(f)?P.delete(f):P.add(f),P})}async function S(f){var R,z;if(!k)return;const O=((R=N==null?void 0:N.inconclusiveReasons)==null?void 0:R[f])??[],P=((z=N==null?void 0:N.failingReasons)==null?void 0:z[f])??[],G=[],H=new Set;for(const _ of O){if(_.source!=="axe-incomplete"||!_.elements)continue;const W=_.pageUrl??k;for(const Y of _.elements){const X=`${W}::${_.ruleOrStepId}::${Y.selector}`;H.has(X)||(H.add(X),G.push({ruleId:_.ruleOrStepId,pageUrl:W,selector:Y.selector}))}}for(const _ of P){if(_.source!=="ai"||!_.selector)continue;const W=_.ruleOrStepId.startsWith("ai-resolved::")?_.ruleOrStepId.slice(13):_.ruleOrStepId,Y=_.pageUrl??k,X=`${Y}::${W}::${_.selector}`;H.has(X)||(H.add(X),G.push({ruleId:W,pageUrl:Y,selector:_.selector}))}if(G.length===0)return;const q=new Date().toISOString(),V=[];for(const _ of G){const W=r.find(Y=>Y.pageUrl===_.pageUrl&&Y.ruleId===_.ruleId&&Y.selector===_.selector);W&&W.verdict==="pass"&&W.reasoning.startsWith("Marked as visually verified")||V.push({pageUrl:_.pageUrl,ruleId:_.ruleId,selector:_.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${q.slice(0,10)}.`,resolvedAt:q,costUsd:0,wcagCriterion:f})}if(V.length===0)return;await na(V);const B=await De(k);i(B),u(_=>({..._,[f]:{total:V.length,pass:V.length,fail:0,uncertain:0,costUsd:0,resolutions:V}}))}const M=(()=>{if(!D||v.overallLetter!=="A"||!N)return null;const f=N.inconclusiveCriteria.length,O=N.failingCriteria.length,P=[];O>0&&P.push(`${O} WCAG ${N.targetLevel} ${O===1?"criterion":"criteria"} failing`),f>0&&P.push(`${f} WCAG ${N.targetLevel} ${f===1?"criterion":"criteria"} inconclusive`);const G=O>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${P.join(" + ")}. ${G}`})();let F=0;for(const f of se){const O=a.find(G=>G.workflowId===f.id);if(!O)continue;f.steps.every(G=>{const H=O.steps[G.id];return(H==null?void 0:H.status)==="pass"||(H==null?void 0:H.status)==="fail"||(H==null?void 0:H.status)==="skip"||(H==null?void 0:H.status)==="not-applicable"})&&F++}const Q=pt(t.filter(f=>!C.has(f.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!A&&j&&e.jsx(Bn,{scannedAt:j}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Ln[y]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:y})}),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 ",v.subGrades.length," verification areas below. Untested areas count as F until verified."]}),M&&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:M})]})]}),v.isLawsuitRisk&&e.jsx(Fn,{areas:v.warningAreas}),e.jsx(Pn,{grades:v.subGrades}),N&&e.jsx(On,{coverage:N,onResolveWithAi:U,onMarkVisuallyVerified:S,resolving:l,resolveError:c,lastResolveResult:d,expandedResultFor:h,onToggleResultDetail:L}),E&&e.jsx(Mn,{layers:E}),e.jsx(Vn,{violationsRemaining:Q,manualCompleted:F,manualTotal:se.length}),F>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:F})," of ",e.jsx("strong",{children:se.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:`${F/se.length*100}%`}})})]}):null]})}function On({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=m.useState(c>0&&c<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),h=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.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 g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const w=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",w,"."]})})(),!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&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),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:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(w=>{var E,D;const A=g.kind==="inconclusive"?(E=t.inconclusiveReasons)==null?void 0:E[w]:void 0,T=g.kind==="failing"?(D=t.failingReasons)==null?void 0:D[w]:void 0,j=A==null?void 0:A.some(y=>y.source==="axe-incomplete"&&y.elements&&y.elements.length>0),k=T==null?void 0:T.some(y=>y.source==="ai"),v=(n==null?void 0:n.has(w))??!1,C=i==null?void 0:i[w],N=(l==null?void 0:l.has(w))??!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:["· ",w]}),(g.kind==="inconclusive"&&j||g.kind==="failing"&&k)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:v,onClick:()=>s(w),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:v?"Resolving…":C?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:v,onClick:()=>a(w),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:g.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),C&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",C.total," ",C.total===1?"verdict":"verdicts",":",C.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",C.pass," pass"]}),C.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",C.fail," fail"]}),C.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",C.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",C.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(w),className:"ml-auto text-[10px] underline text-brand-700",children:N?"hide reasoning":"show reasoning"})]}),C.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",C.uncertain," ",C.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),C.pass===C.total&&C.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),N&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:C.resolutions.map((y,U)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:y.verdict==="pass"?"text-emerald-700 font-semibold":y.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:y.verdict==="pass"?"✓":y.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:y.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:y.reasoning})]},U))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((y,U)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[y.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),y.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," fail — "]}),y.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:y.selector}),y.notes&&e.jsx("span",{className:"text-rose-700",children:y.notes})]},U))}),A&&A.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:A.map((y,U)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[y.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," skipped — "]}),y.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:y.ruleOrStepId})," — "]}),y.resolutionHint,y.elements&&y.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",y.elements.length===1?"element":`${y.elements.length} elements`,":"," ",y.elements.slice(0,3).map((L,S,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:L.selector}),S<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},S)),y.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",y.elements.length-3," more"]})]})]},U))}):g.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.)"})]},w)})})]},g.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 Ot={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 Mn({layers:t}){const s=b(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,l=r.blocked.length,o=r.unevaluated.length,c=r.cleared,p=i>0&&l===0&&o===0,d=p?"text-emerald-700":l>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":l>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":l>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:Ot[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),l>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",l," blocked"]}),o>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",o," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Ot[n].hint}),n==="human"&&o>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 Fn({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 Pn({grades:t}){const s=b(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 ${Dn[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(Gn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Gn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=se.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?Es(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 Vn({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(l=>l.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(l=>!l.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((l,o)=>{const c=o===i,p=l.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${o+1}.`}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[l.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label})]},o)})})]})}function Wn({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function Bn({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",Es(s)," old). Re-scan to grade the current page state."]})]})}function Es(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}function Hn(){const t=b(a=>a.results),s=b(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(_n,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(zn,{})]})}function zn(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(Ne,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(Ne,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(Ne,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(Ne,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(Ne,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function Ne({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Kn={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 qn({ruleId:t,violations:s}){const[a,n]=m.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(Ve,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Kn[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:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Ve,{violation:c},p))})]})}function Qn(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 Yn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready","deposition-packet":"Deposition packet ready 🔒"};function Ts({open:t,onClose:s,format:a,content:n,filename:r}){const i=qs(new Blob([n]).size);function l(){ut(n,r),s()}function o(){dt(n),s()}return e.jsxs(ve,{open:t,onClose:s,title:Yn[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:o,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Mt=7800;function Jn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
12
+ `),c=new URLSearchParams({title:i,body:o});let p=`${n}/issues/new?${c.toString()}`;return p.length>Mt&&(p=p.slice(0,Mt)),{url:p,title:i,body:o}}const Ft=7800;function Xn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`Component: ${s??"unknown"}`),l.push(""),l.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`Rule: ${d.ruleId} (${d.impact})`),l.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),l.push(`Description: ${d.description}`),l.push(`Selector: ${d.target.selector}`),l.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&l.push(`More info: ${d.helpUrl}`),l.push(""),l.push(`HTML: ${d.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const o=l.join(`
13
+ `),c=new URLSearchParams({summary:i,description:o});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>Ft&&(p=p.slice(0,Ft)),{url:p,summary:i,description:o}}const Pt=7800;function Zn(t,s,a,n="Bug"){const r=t.replace(/\/$/,""),i=[];for(const u of a){const h=`${u.ruleId}::${u.target.selector}`,x=`:${u.currentState.pseudoState} · ${u.currentState.theme} · ${u.currentState.direction}`,g=i.find(w=>`${w.ruleId}::${w.target.selector}`===h);if(g){g._states.includes(x)||g._states.push(x);continue}i.push({...u,_states:[x]})}const l=`a11y: ${i.length} new violation${i.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const u of i)o.push(`### \`${u.ruleId}\` — ${u.impact}`),o.push(""),o.push(u.description),o.push(""),o.push(`- **WCAG:** ${u.wcagCriterion} (${u.wcagLevel})`),o.push(`- **Selector:** \`${u.target.selector}\``),o.push(`- **Found in state(s):** ${u._states.join(", ")}`),u.helpUrl&&o.push(`- **More info:** ${u.helpUrl}`),o.push(""),o.push("```html"),o.push(u.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(`
14
+ `),p=new URLSearchParams({"[Title]":l,"[Description]":c});let d=`${r}/_workitems/create/${encodeURIComponent(n)}?${p.toString()}`;return d.length>Pt&&(d=d.slice(0,Pt)),{url:d,title:l,description:c}}const Gt=7800;function er(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(h)||x._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
15
+ `),c=new URLSearchParams({"issue[title]":i,"issue[description]":o});let p=`${n}/-/issues/new?${c.toString()}`;return p.length>Gt&&(p=p.slice(0,Gt)),{url:p,title:i,description:o}}const Vt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],tr=["wcag-component-auditor","wcag-forensic-log"];async function sr(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Vt);s=Object.keys(n).length,await chrome.storage.local.remove(Vt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of tr)try{await ar(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function ar(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const rt="accessibilityStatementInputs:v1";async function nr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:null}async function rr(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[rt]:t})}function ir({open:t,onClose:s,results:a}){const[n,r]=m.useState("eaa"),[i,l]=m.useState(""),[o,c]=m.useState(""),[p,d]=m.useState("partial"),[u,h]=m.useState(""),[x,g]=m.useState(""),[w,A]=m.useState(""),[T,j]=m.useState(""),[k,v]=m.useState("English"),[C,N]=m.useState("wcagcheckr (self-evaluation)"),[E,D]=m.useState("2.1"),[y,U]=m.useState("AA"),[L,S]=m.useState(!1),[M,F]=m.useState(null),Q=m.useRef(null);if(m.useEffect(()=>{t&&(async()=>{var J,ne,ee,f;const I=await nr();if(I&&(I.framing&&r(I.framing),I.organizationName&&l(I.organizationName),I.siteUrl&&c(I.siteUrl),I.conformanceStatus&&d(I.conformanceStatus),(J=I.contact)!=null&&J.email&&h(I.contact.email),(ne=I.contact)!=null&&ne.phone&&g(I.contact.phone),(ee=I.contact)!=null&&ee.formUrl&&A(I.contact.formUrl),I.countryCode&&j(I.countryCode),I.language&&v(I.language),I.auditedBy&&N(I.auditedBy),I.wcagVersion&&D(I.wcagVersion),I.wcagLevel&&U(I.wcagLevel)),!(I!=null&&I.siteUrl)&&((f=a[0])!=null&&f.pageUrl))try{const O=new URL(a[0].pageUrl);c(`${O.protocol}//${O.host}/`)}catch{}I!=null&&I.conformanceStatus||d(ra(a)),setTimeout(()=>{var O;return(O=Q.current)==null?void 0:O.focus()},50)})()},[t,a]),!t)return null;function he(){var ee;const I=new Date().toISOString().slice(0,10),J=(ee=a[0])!=null&&ee.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):I,ne={};return u.trim()&&(ne.email=u.trim()),x.trim()&&(ne.phone=x.trim()),w.trim()&&(ne.formUrl=w.trim()),{framing:n,organizationName:i.trim(),siteUrl:o.trim(),conformanceStatus:p,preparedAt:I,evaluatedAt:J,contact:ne,countryCode:T||null,language:k.trim()||"English",auditedBy:C.trim()||"wcagcheckr (self-evaluation)",wcagVersion:E,wcagLevel:y}}function pe(I){if(!I.organizationName)return"Organization name is required.";if(!I.siteUrl)return"Site URL is required.";try{new URL(I.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!I.contact.email&&!I.contact.phone&&!I.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function de(I){F(null);const J=he(),ne=pe(J);if(ne){F(ne);return}S(!0);try{await rr(J);const ee=await Z({type:"EXPORT_REQUEST",format:I==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:J}),f=(ee==null?void 0:ee.content)??"";if(!f||f.startsWith("# Accessibility statement — error")){F(f||"Export failed — no response.");return}try{await navigator.clipboard.writeText(f)}catch{}const O=new Blob([f],{type:I==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),P=URL.createObjectURL(O);window.open(P,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(P),6e4),s()}catch(ee){F(ee instanceof Error?ee.message:String(ee))}finally{S(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:n==="eaa",onChange:()=>r("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:n==="wad",onChange:()=>r("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:Q,type:"text",value:i,onChange:I=>l(I.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:o,onChange:I=>c(I.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:p,onChange:I=>d(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:E,onChange:I=>D(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:y,onChange:I=>U(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:u,onChange:I=>h(I.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:I=>g(I.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:w,onChange:I=>A(I.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:T,onChange:I=>j(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(ia).map(([I,J])=>e.jsxs("option",{value:I,children:[I," — ",J.name.replace(/^[A-Z]+\s*—\s*/,"")]},I))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:k,onChange:I=>v(I.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:C,onChange:I=>N(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),M&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:M})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void de("markdown"),disabled:L,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:L?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void de("html"),disabled:L,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:L?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:L,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function lr(){const t=b(f=>f.delta),s=b(f=>f.componentId),a=b(f=>f.results),n=b(f=>f.tier),r=b(f=>f.baselineList),i=b(f=>f.siteCrawlReport),[l,o]=m.useState(""),[c,p]=m.useState(""),[d,u]=m.useState(""),[h,x]=m.useState(""),[g,w]=m.useState(!1),[A,T]=m.useState(!1),[j,k]=m.useState(null),[v,C]=m.useState(null),[N,E]=m.useState(!1),[D,y]=m.useState(!1),[U,L]=m.useState(null),[S,M]=m.useState(!1);m.useEffect(()=>{Promise.all([Z({type:"SETTINGS_GET",key:"githubRepoUrl"}),Z({type:"SETTINGS_GET",key:"jiraInstanceUrl"}),Z({type:"SETTINGS_GET",key:"azureDevOpsProjectUrl"}),Z({type:"SETTINGS_GET",key:"gitlabProjectUrl"})]).then(([f,O,P,G])=>{o(typeof f.data=="string"?f.data:""),p(typeof O.data=="string"?O.data:""),u(typeof P.data=="string"?P.data:""),x(typeof G.data=="string"?G.data:"")})},[]),m.useEffect(()=>oe("BADGE_CLICKED_EVENT",O=>{const P=`viol-row-${O.violationId}`,G=document.getElementById(P);G&&(G.scrollIntoView({behavior:"smooth",block:"center"}),G.classList.add("ring-2","ring-rose-500"),setTimeout(()=>G.classList.remove("ring-2","ring-rose-500"),1500))}),[]),m.useEffect(()=>()=>{(async()=>{const f=await ae();f&&(D&&await le(f,{type:"BADGES_HIDE_REQUEST",tabId:f}).catch(()=>{}),S&&await le(f,{type:"HEATMAP_HIDE_REQUEST",tabId:f}).catch(()=>{}))})()},[]);async function F(){const f=await ae();if(!f){re.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(D){await le(f,{type:"BADGES_HIDE_REQUEST",tabId:f}).catch(()=>{}),y(!1),L(null);return}const O={critical:4,serious:3,moderate:2,minor:1},P=new Map;for(const V of a)for(const B of V.violations)P.has(B.matchKey)||P.set(B.matchKey,B);const H=Array.from(P.values()).sort((V,B)=>O[B.impact]-O[V.impact]).map((V,B)=>({id:V.matchKey,index:B+1,selector:V.target.selector,impact:V.impact,ruleId:V.ruleId,wcagCriterion:V.wcagCriterion}));if(H.length===0){re.polite("No violations to badge.");return}const q=await xe(f,{type:"BADGES_SHOW_REQUEST",tabId:f,violations:H}).catch(()=>null);q&&(y(!0),L({rendered:q.rendered,requested:q.requested,clustered:q.clustered}),re.polite(`${q.rendered} violation badges shown on the page.`))}async function Q(){const f=await ae();if(!f){re.polite("Cannot identify audit tab; reload and re-run the audit.");return}if(S){await le(f,{type:"HEATMAP_HIDE_REQUEST",tabId:f}).catch(()=>{}),M(!1);return}const O=new Map;for(const H of a)for(const q of H.violations)O.has(q.matchKey)||O.set(q.matchKey,q);const P=Array.from(O.values()).map(H=>({selector:H.target.selector,impact:H.impact}));if(P.length===0){re.polite("No violations to heatmap.");return}const G=await xe(f,{type:"HEATMAP_SHOW_REQUEST",tabId:f,violations:P}).catch(()=>null);G&&(M(!0),re.polite(`Heatmap shown with ${G.rendered} violation blobs.`))}const he=ps(n,"exportJson"),pe=ms[n].maxBaselines,de=r.some(f=>f.componentId===s),I=de||r.length<pe;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 J(){if(!s||a.length===0)return;const f=a.flatMap(B=>B.violations),O=a.flatMap(B=>B.announcements??[]),P=a.flatMap(B=>B.focusEvents??[]),G=a[0],q=(await Z({type:"SETTINGS_GET",key:"stateMatrix"})).data??hs;await te({type:"BASELINE_SET",componentId:s,violations:f,announcements:O,focusEvents:P,snapshotMeta:{url:window.location.href,axeVersion:G.axeVersion,matrixConfig:q,capturedAt:new Date().toISOString()}});const V=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:f,announcements:O,focusEvents:P,currentMatrix:q});b.getState().setDelta(V.delta),re.polite(`Baseline saved for ${s}.`)}async function ne(){if(!s||!de||!window.confirm(`Remove the saved baseline for "${s}"?
10
16
 
11
- Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await te({type:"BASELINE_DELETE",componentId:s});const O=a.flatMap(V=>V.violations),P=a.flatMap(V=>V.announcements??[]),G=a.flatMap(V=>V.focusEvents??[]),H=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:O,announcements:P,focusEvents:G});b.getState().setDelta(H.delta);const q=await Z({type:"BASELINE_LIST"});b.getState().setBaselineList(q.items),re.polite(`Baseline cleared for ${s}.`)}async function ee(f,O=!1){if(a.length===0)return;if(f==="ai-prompt"){const{copyAiFixerPrompt:W}=await xt(async()=>{const{copyAiFixerPrompt:Y}=await import("./copy-ai-fixer-prompt-DChWCNTL.js");return{copyAiFixerPrompt:Y}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:O?void 0:t,siteCrawlReport:i});return}let P;if((f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet")&&s){const W=await chrome.storage.local.get("igtRuns"),X=((W==null?void 0:W.igtRuns)??{})[s]??{};P=Object.values(X)}const q=await Z({type:"EXPORT_REQUEST",format:f,results:a,delta:O?void 0:t??void 0,manualRuns:P,dismissedKeys:void 0,incompleteResolutions:void 0});if(f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet"){const W=ns(f,s);await rs()?ut(q.content,W):C({open:!0,format:f,content:q.content,filename:W});return}if(f==="html-print"||f==="vpat"||f==="methodology-doc"||f==="conformance-crosswalk"){dt(q.content);return}const V=f==="json"?"application/json":f==="sarif"?"application/sarif+json":f==="ticket-bundle"?"text/markdown":"application/xml",B=f==="junit"?"xml":f==="ticket-bundle"?"md":f,R=new Blob([q.content],{type:V}),z=URL.createObjectURL(R),_=document.createElement("a");_.href=z,_.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${B}`,_.click(),URL.revokeObjectURL(z)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("button",{onClick:J,disabled:!I,title:I?void 0:`Free tier limits you to ${pe} 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"}),de&&e.jsx("button",{onClick:ne,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>w(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void F(),"aria-pressed":D,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:D?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:D?"Hide badges":"Show badges 🎯"}),D&&U&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[U.rendered," of ",U.requested," rendered",U.clustered>0?` · ${U.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void Q(),"aria-pressed":S,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:S?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:S?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(ur,{disabled:!he,onExport:ee,onAccessibilityStatement:()=>E(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!I&&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 f=Qe(t.new),O=Qe(t.persistent),P=Qe(t.fixed),G=[...f.review,...O.review];return e.jsxs(e.Fragment,{children:[e.jsx(ke,{title:"New",violations:f.findings,count:f.findings.length,accent:"red",actions:[...l&&f.findings.length>0?[{label:"File GitHub issue",onClick:()=>lr(l,s,f.findings)}]:[],...c&&f.findings.length>0?[{label:"File Jira issue",onClick:()=>or(c,s,f.findings)}]:[],...d&&f.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>cr(d,s,f.findings)}]:[],...h&&f.findings.length>0?[{label:"File GitLab issue",onClick:()=>dr(h,s,f.findings)}]:[]]}),e.jsx(ke,{title:"Persistent",violations:O.findings,count:O.findings.length,accent:"slate"}),e.jsx(ke,{title:"Fixed",violations:P.findings,count:t.fixedCount,accent:"green"}),G.length>0&&e.jsx(ke,{title:"Needs review (does not affect grade)",violations:G,count:G.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ke,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),v&&e.jsx(Rs,{open:v.open,onClose:()=>C(null),format:v.format,content:v.content,filename:v.filename}),e.jsx(nr,{open:j,onClose:()=>E(!1),results:a}),g&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),N&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",N.chromeStorageKeysCleared," chrome.storage key",N.chromeStorageKeysCleared===1?"":"s"," + ",N.indexedDbsCleared.length," database",N.indexedDbsCleared.length===1?"":"s",".",N.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",N.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:N?e.jsx("button",{type:"button",onClick:()=>{w(!1),k(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:A,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{T(!0);try{const f=await er();k(f),await Be(),re.polite("Audit data reset. Ready for a fresh scan.")}catch(f){k({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[f instanceof Error?f.message:String(f)]})}finally{T(!1)}},disabled:A,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:A?"Resetting…":"Reset everything"})]})})]})})]})}const ir={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Qe(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 ke({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=m.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 ${ir[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(Ve,{violation:c,alreadyAcknowledged:!0},p)):Kn(s).map(c=>e.jsx(zn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function lr(t,s,a){if(a.length===0)return;const{url:n}=Qn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function or(t,s,a){if(a.length===0)return;const{url:n}=Yn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function cr(t,s,a){if(a.length===0)return;const{url:n}=Jn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function dr(t,s,a){if(a.length===0)return;const{url:n}=Xn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ur({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=m.useState(!1),[l,o]=m.useState(!1);function c(p){i(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(p=>!p),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:p=>o(p.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ce,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ce,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ce,{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(ce,{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(ce,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ce,{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(ce,{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(ce,{onClick:()=>c("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ce,{onClick:()=>c("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ce,{onClick:()=>c("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ce,{onClick:()=>c("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>{i(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function ce({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const Vt="igtRuns";async function pr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Vt))[Vt];return s&&typeof s=="object"?s:{}}async function hr(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await pr())[t];if(i)for(const c of se){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:be(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const mr=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"]),xr=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 gr(t){return mr.has(t.ruleId)}function fr(t){return xr.has(t.ruleId)}function br(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function vr(){var D,y,U,L;const t=b(S=>S.results),s=b(S=>S.delta),a=b(S=>S.componentId),n=((D=t[0])==null?void 0:D.pageUrl)??((y=t[0])==null?void 0:y.scope)??"",[r,i]=m.useState({}),[l,o]=m.useState(0);m.useEffect(()=>{if(!n)return;let S=!1;return(async()=>{if(a&&t.length>0)try{await hr(a,t)}catch{}if(S)return;const M=await We(n);S||i(M)})(),()=>{S=!0}},[n,l,a,t]);async function c(S,M){if(!n)return;const F=window.prompt(`Why is this finding a false positive?
17
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await te({type:"BASELINE_DELETE",componentId:s});const O=a.flatMap(V=>V.violations),P=a.flatMap(V=>V.announcements??[]),G=a.flatMap(V=>V.focusEvents??[]),H=await Z({type:"BASELINE_COMPARE",componentId:s,currentViolations:O,announcements:P,focusEvents:G});b.getState().setDelta(H.delta);const q=await Z({type:"BASELINE_LIST"});b.getState().setBaselineList(q.items),re.polite(`Baseline cleared for ${s}.`)}async function ee(f,O=!1){if(a.length===0)return;if(f==="ai-prompt"){const{copyAiFixerPrompt:W}=await xt(async()=>{const{copyAiFixerPrompt:Y}=await import("./copy-ai-fixer-prompt-BRg9o8WW.js");return{copyAiFixerPrompt:Y}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:O?void 0:t,siteCrawlReport:i});return}let P;if((f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet")&&s){const W=await chrome.storage.local.get("igtRuns"),X=((W==null?void 0:W.igtRuns)??{})[s]??{};P=Object.values(X)}const q=await Z({type:"EXPORT_REQUEST",format:f,results:a,delta:O?void 0:t??void 0,manualRuns:P,dismissedKeys:void 0,incompleteResolutions:void 0});if(f==="defense-bundle"||f==="evidence-bundle"||f==="deposition-packet"){const W=rs(f,s);await is()?ut(q.content,W):C({open:!0,format:f,content:q.content,filename:W});return}if(f==="html-print"||f==="vpat"||f==="methodology-doc"||f==="conformance-crosswalk"){dt(q.content);return}const V=f==="json"?"application/json":f==="sarif"?"application/sarif+json":f==="ticket-bundle"?"text/markdown":"application/xml",B=f==="junit"?"xml":f==="ticket-bundle"?"md":f,R=new Blob([q.content],{type:V}),z=URL.createObjectURL(R),_=document.createElement("a");_.href=z,_.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${B}`,_.click(),URL.revokeObjectURL(z)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("button",{onClick:J,disabled:!I,title:I?void 0:`Free tier limits you to ${pe} 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"}),de&&e.jsx("button",{onClick:ne,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>w(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx("button",{type:"button",onClick:()=>void F(),"aria-pressed":D,title:"Overlay numbered, color-coded badges on every violating element in the page. Click a badge to scroll its row into view here.",className:D?"text-xs px-2 py-1 bg-rose-600 hover:bg-rose-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:D?"Hide badges":"Show badges 🎯"}),D&&U&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:[U.rendered," of ",U.requested," rendered",U.clustered>0?` · ${U.clustered} clusters`:""]}),e.jsx("button",{type:"button",onClick:()=>void Q(),"aria-pressed":S,title:"Overlay a density heatmap on the page. Red blobs at each violation rect; overlapping blobs glow brighter to show problem clusters.",className:S?"text-xs px-2 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded":"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:S?"Hide heatmap":"Show heatmap 🔥"}),e.jsx(hr,{disabled:!he,onExport:ee,onAccessibilityStatement:()=>E(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!I&&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 f=Qe(t.new),O=Qe(t.persistent),P=Qe(t.fixed),G=[...f.review,...O.review];return e.jsxs(e.Fragment,{children:[e.jsx(ke,{title:"New",violations:f.findings,count:f.findings.length,accent:"red",actions:[...l&&f.findings.length>0?[{label:"File GitHub issue",onClick:()=>cr(l,s,f.findings)}]:[],...c&&f.findings.length>0?[{label:"File Jira issue",onClick:()=>dr(c,s,f.findings)}]:[],...d&&f.findings.length>0?[{label:"File Azure DevOps work item",onClick:()=>ur(d,s,f.findings)}]:[],...h&&f.findings.length>0?[{label:"File GitLab issue",onClick:()=>pr(h,s,f.findings)}]:[]]}),e.jsx(ke,{title:"Persistent",violations:O.findings,count:O.findings.length,accent:"slate"}),e.jsx(ke,{title:"Fixed",violations:P.findings,count:t.fixedCount,accent:"green"}),G.length>0&&e.jsx(ke,{title:"Needs review (does not affect grade)",violations:G,count:G.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ke,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),v&&e.jsx(Ts,{open:v.open,onClose:()=>C(null),format:v.format,content:v.content,filename:v.filename}),e.jsx(ir,{open:N,onClose:()=>E(!1),results:a}),g&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),j&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",j.chromeStorageKeysCleared," chrome.storage key",j.chromeStorageKeysCleared===1?"":"s"," + ",j.indexedDbsCleared.length," database",j.indexedDbsCleared.length===1?"":"s",".",j.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",j.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:j?e.jsx("button",{type:"button",onClick:()=>{w(!1),k(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w(!1),disabled:A,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{T(!0);try{const f=await sr();k(f),await Be(),re.polite("Audit data reset. Ready for a fresh scan.")}catch(f){k({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[f instanceof Error?f.message:String(f)]})}finally{T(!1)}},disabled:A,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:A?"Resetting…":"Reset everything"})]})})]})})]})}const or={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Qe(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 ke({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=m.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 ${or[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(Ve,{violation:c,alreadyAcknowledged:!0},p)):Qn(s).map(c=>e.jsx(qn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function cr(t,s,a){if(a.length===0)return;const{url:n}=Jn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function dr(t,s,a){if(a.length===0)return;const{url:n}=Xn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function ur(t,s,a){if(a.length===0)return;const{url:n}=Zn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function pr(t,s,a){if(a.length===0)return;const{url:n}=er(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function hr({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=m.useState(!1),[l,o]=m.useState(!1);function c(p){i(!1),s(p,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(p=>!p),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:p=>o(p.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ce,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ce,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ce,{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(ce,{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(ce,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ce,{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(ce,{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(ce,{onClick:()=>c("deposition-packet"),title:"Forensic-grade upgrade of defense bundle. Anchors the audit hash via RFC 3161 trusted timestamp + ed25519 server signature, prepends a chain-of-custody cover sheet, appends verification instructions and a sworn-declaration template. The artifact to hand to opposing counsel.",children:"Deposition packet 🔒"}),e.jsx(ce,{onClick:()=>c("methodology-doc"),title:"Standalone methodology document explaining how wcagcheckr audits — multi-state matrix, axe-core rule coverage, WCAG criteria requiring manual review, audit process. Pairs with the deposition packet for legal use; usable standalone as a publishable 'how we audit' document.",children:"Methodology doc 📘"}),e.jsx(ce,{onClick:()=>c("conformance-crosswalk"),title:"Cross-jurisdiction conformance crosswalk: per WCAG criterion, shows the mapping to EN 301 549 (EU), Section 508 (US federal), ADA Title III (US private-sector), EAA (Directive 2019/882), and AODA (Ontario). Highlights criteria violated in this audit.",children:"Conformance crosswalk 🗺"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx(ce,{onClick:()=>c("ticket-bundle"),title:"One markdown document with N self-contained ticket sections — one per unique violation. Copy + paste each section into Linear / Asana / Trello / Jira / GitHub Issues. Tickets deduped by logical group; critical-first ordering.",children:"Ticket bundle (markdown) 🎫"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ce,{onClick:()=>{i(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function ce({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const Wt="igtRuns";async function mr(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Wt))[Wt];return s&&typeof s=="object"?s:{}}async function xr(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await mr())[t];if(i)for(const c of se){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=p.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const h=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:be(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:h,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const gr=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"]),fr=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 br(t){return gr.has(t.ruleId)}function vr(t){return fr.has(t.ruleId)}function yr(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function wr(){var D,y,U,L;const t=b(S=>S.results),s=b(S=>S.delta),a=b(S=>S.componentId),n=((D=t[0])==null?void 0:D.pageUrl)??((y=t[0])==null?void 0:y.scope)??"",[r,i]=m.useState({}),[l,o]=m.useState(0);m.useEffect(()=>{if(!n)return;let S=!1;return(async()=>{if(a&&t.length>0)try{await xr(a,t)}catch{}if(S)return;const M=await We(n);S||i(M)})(),()=>{S=!0}},[n,l,a,t]);async function c(S,M){if(!n)return;const F=window.prompt(`Why is this finding a false positive?
12
18
 
13
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");F!==null&&(await ks(n,S,F||"(no reason given)",M),o(Q=>Q+1))}async function p(S){n&&(await Ss(n,S),o(M=>M+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((S,M)=>{var F;return S+(((F=M.announcements)==null?void 0:F.length)??0)},0),u=t.reduce((S,M)=>{var F;return S+(((F=M.focusEvents)==null?void 0:F.length)??0)},0),h=t.reduce((S,M)=>{var F;return S+(((F=M.focusEvents)==null?void 0:F.filter(Q=>Q.isFocusReset).length)??0)},0),x=Wt(t,gr),g=Wt(t,fr),w=x.length,A=g.length,T=((U=t[0])==null?void 0:U.readingOrderIssues)??[],N=((L=t[0])==null?void 0:L.tabOrderIssues)??[],k=T.filter(S=>!(fe(S.selector)in r)),v=T.filter(S=>fe(S.selector)in r),C=N.filter(S=>!(be(S.selector)in r)),j=N.filter(S=>be(S.selector)in r);if(d===0&&u===0&&w===0&&A===0&&k.length===0&&C.length===0&&v.length===0&&j.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 E=v.length+j.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 · ",A," form ·"," ",C.length," tab-order ·"," ",k.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),E>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",E," dismissed"]})]}),C.length>0&&e.jsx(jr,{issues:C,onDismiss:c}),k.length>0&&e.jsx(Nr,{issues:k,onDismiss:c}),E>0&&e.jsx(kr,{dismissedReadingOrder:v,dismissedTabOrder:j,dismissals:r,onRestore:p}),w>0&&e.jsx(Bt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),A>0&&e.jsx(Bt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(yr,{delta:s}),t.map((S,M)=>{const F=S.announcements??[],Q=S.focusEvents??[];return F.length===0&&Q.length===0?null:e.jsx(wr,{state:S.state,announcements:F,focusEvents:Q},M)})]})}function yr({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 Wt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ht(r.ruleId,r.target.selector),l=a.get(i);l?l.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 Bt({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 wr({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:br(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 jr({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 Nr({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 kr({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=m.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>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 (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(o=>{const c=`tab-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const it="igtRuns";async function Sr(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 l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:be(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const Ar={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"}},Cr={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"}},Ir={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Ht(t,s){const a=await ae();if(!a)return;const n=s?Ar[t]:Cr[t];try{await le(a,n)}catch{}}async function Rr(){const s=(await chrome.storage.local.get(it))[it];return s&&typeof s=="object"?s:{}}async function zt(t){await chrome.storage.local.set({[it]:t})}function Er(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 Tr(){const t=b(d=>d.componentId),s=b(d=>d.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{Rr().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const l=a[t]??{};function o(d,u,h){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(x),zt(x),h.status==="pass"){const w=se.find(T=>T.id===d),A=w==null?void 0:w.steps.find(T=>T.id===u);A!=null&&A.autoDismissActivity&&Sr(A.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[d];const h={...a,[t]:u};n(h),zt(h)}const p=se.find(d=>d.id===r);if(p){const d=l[p.id];return e.jsx($r,{workflow:p,run:d,results:s,onAnswer:(u,h)=>o(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."}),se.map(d=>{const u=l[d.id],h=u?ra(u,d):null,x=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",g={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"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,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:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="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:d.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function $r({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=Er(p,a);return c},[t,a]);function l(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),o>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:[o," step",o===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Ht(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Ir[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Ht(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>n(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Ur={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Te({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?Ur[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const _e="savedFlows";async function Lr(){const t=await chrome.storage.local.get(_e);return Array.isArray(t[_e])?t[_e]:[]}async function Kt(t){await chrome.storage.local.set({[_e]:t})}function Dr(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{Lr().then(s)},[]);async function l(){const d=await ae();if(!d){i("No audit-target tab found.");return}try{await le(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function o(){const d=await ae();if(d)try{const u=await xe(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Kt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await ae();if(u){i(`Replaying "${d.name}"…`);try{const h=await xe(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==d);s(u),await Kt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function _r(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),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(Or).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function Or(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Mr(){const t=b(o=>o.baselineList),s=b(o=>o.tier),a=hs[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=m.useState(!1);if(m.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>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"})]},o))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function l(o){await te({type:"BASELINE_DELETE",componentId:o}),await Fe()}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(o=>{const c=_r(o.componentId),p=o.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:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(me,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(me,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(me,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(me,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(me,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(me,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(me,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Fr={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 me({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Fr[t]}`,children:a})}const Pr={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"},Gr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Vr={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Es({onBack:t}){const s=b(u=>u.siteCrawlStatus),a=b(u=>u.siteCrawlProgress),n=b(u=>u.siteCrawlReport),r=b(u=>u.siteCrawlError),[i,l]=m.useState(""),[o,c]=m.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const h=(x=u[0])==null?void 0:x.url;h&&/^https?:\/\//.test(h)&&i===""&&l(h)});function p(){i&&(o>=5&&!window.confirm(`Each of the ${o} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${o*5} minutes. Proceed?`)||(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),ue({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){te({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=>l(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:o,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your full single-page audit pipeline (matrix + analyzers + AI)."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Wr,{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 Wr({report:t}){function s(){xt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-CzL3uuvq.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=m.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Pr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Gr[t.siteRisk]}`,children:ia[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.jsx("button",{type:"button",onClick:r,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),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(i=>{const l=la(i.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 ${Vr[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.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.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void Br(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function Br(t){try{const s=await oa(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){b.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}b.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Ye="onboardingDismissed",Je=[{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 Hr(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Ye).then(o=>{o[Ye]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1),n(0)}const i=a===Je.length-1,l=Je[a];return e.jsxs(ve,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Je.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-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(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function zr(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Kr(){const t=b(c=>c.aiFailure),s=b(c=>c.clearAiFailure),[a,n]=m.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",l="⚠",o=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:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function qt(){const[t,s]=m.useState(!1);return m.useEffect(()=>oe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(ve,{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 qr(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{ca().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await St(),b.getState().startNewScan(),t.mode==="storybook-all"?ue({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ue({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await St(),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 Xe="storybook:hintDismissed";function Qr(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Xe))[Xe])return;const l=await ae();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Xe]:!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 Yr(){var i;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.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 ${Jr(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 Jr(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 l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function Xr(){const t=b(o=>o.results),s=b(o=>o.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=da(r,a.length>0?{runs:a,workflows:se}:void 0),l=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."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Zr(){const t=b(a=>a.setUserMode);function s(a){t(a),te({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 ei=["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"],ti={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 si(t){const s=new Set(ei),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,p])=>({ruleId:c,instanceCount:p})).sort((c,p)=>p.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,p)=>c+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:ti[l]}}const Ts={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},ai={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Ts]},ni={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Ts]};function bt(t){return t==="thorough"?ni:ai}function Qt(t){const s=bt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Oe="wcagcheckr";function K(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ie(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 ri(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function ii(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 li(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 oi(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 ci(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 (${K(t.receipt.tsaName)}) — anchored ${K(Ie(t.receipt.anchoredAt))}</td></tr>
19
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");F!==null&&(await As(n,S,F||"(no reason given)",M),o(Q=>Q+1))}async function p(S){n&&(await Cs(n,S),o(M=>M+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((S,M)=>{var F;return S+(((F=M.announcements)==null?void 0:F.length)??0)},0),u=t.reduce((S,M)=>{var F;return S+(((F=M.focusEvents)==null?void 0:F.length)??0)},0),h=t.reduce((S,M)=>{var F;return S+(((F=M.focusEvents)==null?void 0:F.filter(Q=>Q.isFocusReset).length)??0)},0),x=Bt(t,br),g=Bt(t,vr),w=x.length,A=g.length,T=((U=t[0])==null?void 0:U.readingOrderIssues)??[],j=((L=t[0])==null?void 0:L.tabOrderIssues)??[],k=T.filter(S=>!(fe(S.selector)in r)),v=T.filter(S=>fe(S.selector)in r),C=j.filter(S=>!(be(S.selector)in r)),N=j.filter(S=>be(S.selector)in r);if(d===0&&u===0&&w===0&&A===0&&k.length===0&&C.length===0&&v.length===0&&N.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 E=v.length+N.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 · ",A," form ·"," ",C.length," tab-order ·"," ",k.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",h>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",h," focus reset",h===1?"":"s"]}),E>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",E," dismissed"]})]}),C.length>0&&e.jsx(kr,{issues:C,onDismiss:c}),k.length>0&&e.jsx(Sr,{issues:k,onDismiss:c}),E>0&&e.jsx(Ar,{dismissedReadingOrder:v,dismissedTabOrder:N,dismissals:r,onRestore:p}),w>0&&e.jsx(Ht,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),A>0&&e.jsx(Ht,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(jr,{delta:s}),t.map((S,M)=>{const F=S.announcements??[],Q=S.focusEvents??[];return F.length===0&&Q.length===0?null:e.jsx(Nr,{state:S.state,announcements:F,focusEvents:Q},M)})]})}function jr({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 Bt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ht(r.ruleId,r.target.selector),l=a.get(i);l?l.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 Ht({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 Nr({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:yr(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 kr({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 Sr({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 Ar({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=m.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>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 (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(o=>{const c=`tab-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const it="igtRuns";async function Cr(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 l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:be(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const Ir={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"}},Rr={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"}},Er={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function zt(t,s){const a=await ae();if(!a)return;const n=s?Ir[t]:Rr[t];try{await le(a,n)}catch{}}async function Tr(){const s=(await chrome.storage.local.get(it))[it];return s&&typeof s=="object"?s:{}}async function Kt(t){await chrome.storage.local.set({[it]:t})}function $r(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 Ur(){const t=b(d=>d.componentId),s=b(d=>d.results),[a,n]=m.useState({}),[r,i]=m.useState(null);if(m.useEffect(()=>{Tr().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const l=a[t]??{};function o(d,u,h){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(n(x),Kt(x),h.status==="pass"){const w=se.find(T=>T.id===d),A=w==null?void 0:w.steps.find(T=>T.id===u);A!=null&&A.autoDismissActivity&&Cr(A.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...l};delete u[d];const h={...a,[t]:u};n(h),Kt(h)}const p=se.find(d=>d.id===r);if(p){const d=l[p.id];return e.jsx(Lr,{workflow:p,run:d,results:s,onAnswer:(u,h)=>o(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."}),se.map(d=>{const u=l[d.id],h=u?la(u,d):null,x=u?h!=null&&h.failed&&h.failed>0?"failed":h!=null&&h.unanswered&&h.unanswered>0?"in-progress":"done":"unstarted",g={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"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,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:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="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:d.blurb}),u&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function Lr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=m.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=$r(p,a);return c},[t,a]);function l(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const o=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),o>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:[o," step",o===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void zt(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Er[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void zt(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>n(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Dr={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Te({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?Dr[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const _e="savedFlows";async function _r(){const t=await chrome.storage.local.get(_e);return Array.isArray(t[_e])?t[_e]:[]}async function qt(t){await chrome.storage.local.set({[_e]:t})}function Or(){const[t,s]=m.useState([]),[a,n]=m.useState(!1),[r,i]=m.useState(null);m.useEffect(()=>{_r().then(s)},[]);async function l(){const d=await ae();if(!d){i("No audit-target tab found.");return}try{await le(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function o(){const d=await ae();if(d)try{const u=await xe(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await qt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await ae();if(u){i(`Replaying "${d.name}"…`);try{const h=await xe(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==d);s(u),await qt(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:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function Mr(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),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(Fr).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function Fr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function Pr(){const t=b(o=>o.baselineList),s=b(o=>o.tier),a=ms[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=m.useState(!1);if(m.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>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"})]},o))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function l(o){await te({type:"BASELINE_DELETE",componentId:o}),await Fe()}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(o=>{const c=Mr(o.componentId),p=o.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:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(me,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(me,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(me,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(me,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(me,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(me,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(me,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const Gr={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 me({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${Gr[t]}`,children:a})}const Vr={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"},Wr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Br={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 $s({onBack:t}){const s=b(u=>u.siteCrawlStatus),a=b(u=>u.siteCrawlProgress),n=b(u=>u.siteCrawlReport),r=b(u=>u.siteCrawlError),[i,l]=m.useState(""),[o,c]=m.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const h=(x=u[0])==null?void 0:x.url;h&&/^https?:\/\//.test(h)&&i===""&&l(h)});function p(){i&&(o>=5&&!window.confirm(`Each of the ${o} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${o*5} minutes. Proceed?`)||(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),ue({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){te({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=>l(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:o,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your full single-page audit pipeline (matrix + analyzers + AI)."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Hr,{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 Hr({report:t}){function s(){xt(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-CzL3uuvq.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=m.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${Vr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${Wr[t.siteRisk]}`,children:oa[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.jsx("button",{type:"button",onClick:r,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),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(i=>{const l=ca(i.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 ${Br[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.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.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void zr(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function zr(t){try{const s=await da(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){b.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}b.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const Ye="onboardingDismissed",Je=[{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 Kr(){const[t,s]=m.useState(!1),[a,n]=m.useState(0);m.useEffect(()=>{chrome.storage.local.get(Ye).then(o=>{o[Ye]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1),n(0)}const i=a===Je.length-1,l=Je[a];return e.jsxs(ve,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Je.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-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(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function qr(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Qr(){const t=b(c=>c.aiFailure),s=b(c=>c.clearAiFailure),[a,n]=m.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",l="⚠",o=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:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Qt(){const[t,s]=m.useState(!1);return m.useEffect(()=>oe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(ve,{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 Yr(){var i;const[t,s]=m.useState(null);if(m.useEffect(()=>{ua().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await St(),b.getState().startNewScan(),t.mode==="storybook-all"?ue({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ue({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await St(),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 Xe="storybook:hintDismissed";function Jr(){const[t,s]=m.useState(!1),[a,n]=m.useState();m.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Xe))[Xe])return;const l=await ae();if(l)try{const p=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((o=p.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Xe]:!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 Xr(){var i;const t=b(l=>l.results),s=b(l=>l.baselineList),a=b(l=>l.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 ${Zr(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 Zr(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 l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function ei(){const t=b(o=>o.results),s=b(o=>o.componentId),[a,n]=m.useState([]);if(m.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=pa(r,a.length>0?{runs:a,workflows:se}:void 0),l=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."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function ti(){const t=b(a=>a.setUserMode);function s(a){t(a),te({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 si=["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"],ai={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 ni(t){const s=new Set(si),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,p])=>({ruleId:c,instanceCount:p})).sort((c,p)=>p.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,p)=>c+p,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:ai[l]}}const Us={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},ri={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Us]},ii={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Us]};function bt(t){return t==="thorough"?ii:ri}function Yt(t){const s=bt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Oe="wcagcheckr";function K(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ie(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 li(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function oi(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 ci(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 di(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 ui(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 (${K(t.receipt.tsaName)}) — anchored ${K(Ie(t.receipt.anchoredAt))}</td></tr>
14
20
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${K(t.receipt.serverKeyFingerprint)}</code></td></tr>
15
21
  ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${K(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${K(Oe)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
16
22
  <article class="entry">
17
23
  <header class="entry-header">
18
- <span class="grade-badge ${oi(t.grade)}">${K(t.grade)}</span>
24
+ <span class="grade-badge ${di(t.grade)}">${K(t.grade)}</span>
19
25
  <div class="entry-headline">
20
26
  <div class="entry-time">${K(Ie(t.capturedAt))}</div>
21
27
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
@@ -29,15 +35,15 @@ Future audits will treat every detected violation as new (no delta filtering). T
29
35
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
30
36
  ${n}
31
37
  </table>
32
- </article>`}function di(t){return`
38
+ </article>`}function pi(t){return`
33
39
  <section class="component-section">
34
40
  <h2>
35
41
  <span class="component-id">${K(t.componentId)}</span>
36
42
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
37
43
  </h2>
38
44
  <p class="component-url"><strong>Page audited:</strong> <code>${K(t.pageUrl)}</code></p>
39
- ${t.entries.map(ci).join("")}
40
- </section>`}function ui(t){const{entries:s,extensionVersion:a}=t,n=li(s),r=ii(s),i=(t.axeVersions??ri(s)).join(", "),l=s.length,o=s.filter(d=>d.receipt).length,c=l-o,p=Ie(new Date().toISOString());return`<!doctype html>
45
+ ${t.entries.map(ui).join("")}
46
+ </section>`}function hi(t){const{entries:s,extensionVersion:a}=t,n=ci(s),r=oi(s),i=(t.axeVersions??li(s)).join(", "),l=s.length,o=s.filter(d=>d.receipt).length,c=l-o,p=Ie(new Date().toISOString());return`<!doctype html>
41
47
  <html lang="en">
42
48
  <head>
43
49
  <meta charset="utf-8" />
@@ -206,7 +212,7 @@ Future audits will treat every detected violation as new (no delta filtering). T
206
212
  <tr><th>Tool</th><td>${K(Oe)} ${K(a)}</td></tr>
207
213
  </table>
208
214
 
209
- ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(di).join("")}
215
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(pi).join("")}
210
216
 
211
217
  <section class="methodology">
212
218
  <h2>Methodology</h2>
@@ -234,12 +240,12 @@ Future audits will treat every detected violation as new (no delta filtering). T
234
240
  <span>${l} audit${l===1?"":"s"} · ${o} anchored · ${n.length} component${n.length===1?"":"s"}</span>
235
241
  </footer>
236
242
  </body>
237
- </html>`}async function pi(t){const s=ui(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function $s(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[l,o]=m.useState(!1),[c,p]=m.useState(""),[d,u]=m.useState(""),[h,x]=m.useState(""),[g,w]=m.useState(!1);if(m.useEffect(()=>{let v=!1;return s(null),n(null),os().then(C=>{v||s(C)}).catch(C=>{v||n(C instanceof Error?C.message:String(C))}),()=>{v=!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 A=t.length,T=t.filter(v=>v.receipt).length;async function N(){if(!(!t||t.length===0)){w(!0);try{await pi({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:h.trim()||void 0}),o(!1)}finally{w(!1)}}}async function k(){if(!t||t.length===0)return;const v={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},C=new Blob([JSON.stringify(v,null,2)],{type:"application/json"}),j=URL.createObjectURL(C),E=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,D=document.createElement("a");D.href=j,D.download=E,D.click(),setTimeout(()=>URL.revokeObjectURL(j),1e3)}return A===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:[A," ",A===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&&A>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:()=>o(v=>!v),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(v=>v+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:v=>p(v.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:d,onChange:v=>u(v.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:v=>x(v.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:()=>o(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||A===0,onClick:N,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"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(v=>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 ${v.grade==="A"?"bg-emerald-100 text-emerald-700":v.grade==="B"?"bg-lime-100 text-lime-700":v.grade==="C"?"bg-yellow-100 text-yellow-700":v.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:v.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:v.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${v.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:v.receipt?`Anchored to ${v.receipt.tsaName} at ${v.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:v.receipt?`RFC 3161 (${v.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:v.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:v.capturedAt}),(v.totals.critical>0||v.totals.serious>0)&&e.jsxs("span",{children:[v.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[v.totals.critical," crit"]}),v.totals.critical>0&&v.totals.serious>0&&" · ",v.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[v.totals.serious," sev"]})]}),e.jsxs("span",{children:[v.statesAudited," ",v.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:v.hash,children:[v.hash.slice(0,12),"…"]})]})]},`${v.componentId}::${v.capturedAt}`))})]})}function hi(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let c=!1;return os().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],l=t.slice(0,3),o=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),o>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[o," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(ve,{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($s,{})})})]})}function mi(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const xi={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."},gi={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."},fi={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},bi={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Us(){const t=b(u=>u.tier),s=b(u=>u.trialDaysRemaining),a=b(u=>u.seatsUsed),n=b(u=>u.seatsTotal),r=b(u=>u.planCode),i=b(u=>u.licenseDaysRemaining),l=b(u=>u.pastDue),[o,c]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,h=u!==null&&u<=7,x=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"}),x&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void te({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(st,{open:o,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?bi:fi,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,w=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-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]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),g&&!x&&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 te({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?xi:gi,d=t==="trial"?mi(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void te({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(st,{open:o,onClose:()=>c(!1)})]})}const vi={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"},yi={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"},wi={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 ji(){const t=b(u=>u.setUserMode),s=b(u=>u.status),a=b(u=>u.setStatus),n=b(u=>u.errorMessage),r=b(u=>u.setError),[i,l]=m.useState(!1),[o,c]=m.useState(!1),p=m.useRef(s);m.useEffect(()=>{if(p.current==="running"&&s==="complete"){c(!0);const u=setTimeout(()=>c(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{b.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(u)},[s,a,r]);function d(){t("dev"),te({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(Us,{}),e.jsx(ws,{}),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(ys,{}),e.jsx("button",{type:"button",onClick:d,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(Ni,{}),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:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(Es,{onBack:()=>l(!1)}):e.jsx(Si,{onPickCrawl:()=>l(!0)}),o&&e.jsx(ki,{})]}),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 Ni(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void te({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 ki(){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 Si({onPickCrawl:t}){const s=b(u=>u.status),a=b(u=>u.results),[n,r]=m.useState("quick"),[i,l]=m.useState("all"),o=s==="running",c=a.flatMap(u=>u.violations),p=a.length>0;function d(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),re.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:o,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:o?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:o,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(Ci,{depth:n,onChange:r,disabled:o})]}),!p&&!o&&e.jsx(Ai,{}),p&&e.jsx(Ii,{violations:c,severityFilter:i,onSeverityFilterChange:l,scanDepth:n})]})}function Ai(){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 Ci({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(Xt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Qt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Xt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Qt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Xt({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:i})]})}function Ii({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var j;const r=b(E=>E.status),i=b(E=>E.results),l=b(E=>E.freshThisSession),o=b(E=>E.componentId),c=(j=i[0])==null?void 0:j.startedAt,p=si(t),d=r==="running",[u,h]=m.useState([]);m.useEffect(()=>{if(!o){h([]);return}let E=!1;return chrome.storage.local.get("igtRuns").then(D=>{if(E)return;const U=((D==null?void 0:D.igtRuns)??{})[o]??{};h(Object.values(U))}),()=>{E=!0}},[o]);const x=b(E=>E.acknowledgedKeys),g=i.length>0?ls(i,{runs:u,workflows:se},"2.1","AA",x):void 0;function w(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),re.polite("Re-scanning this page now.")}const A=s==="lawsuit-risk"?t.filter(E=>E.impact==="critical"||E.impact==="serious"):t,T=new Map;for(const E of A){const D=ht(E.ruleId,E.target.selector);T.has(D)||T.set(D,E)}const N=Array.from(T.values()),k=new Map;for(const E of N){const D=k.get(E.ruleId)??[];D.push(E),k.set(E.ruleId,D)}const v=Array.from(k.entries()).sort((E,D)=>(Jt[E[1][0].impact]??99)-(Jt[D[1][0].impact]??99)),C=t.filter(E=>E.impact==="critical"||E.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:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(Li,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Be(),disabled:d,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:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?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 ${vi[p.tier]}`,children:[!l&&c&&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 ${yi[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."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(Ri,{coverage:g}),!d&&g&&g.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 ",g.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(Ui,{}),e.jsx(hi,{}),t.length>0&&e.jsx(Ei,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[v.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."]}),v.map(([E,D])=>e.jsx(Ti,{ruleId:E,violations:D},E))]})]})}function Ri({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),te({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 Ei({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 Ti({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=ua(t,r),l=s[0].impact,o=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&o.description?o.description:i.whatsWrong,d=o.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 ${wi[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",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,x)=>e.jsx($i,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function $i({violation:t}){const s=b(i=>{var l;return(l=i.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(i){i.stopPropagation();const l=await ae();if(l)try{const o=await xe(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(o.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 $e=[{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 Ui(){const t=b(d=>d.results),s=b(d=>d.componentId),[a,n]=m.useState(null),[r,i]=m.useState(!1),[l,o]=m.useState(null);async function c(d,u){if(t.length!==0){n(d);try{const h=await Z({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=ns(d,s);await rs()?ut(h.content,x):o({open:!0,format:d,content:h.content,filename:x})}else if(u)dt(h.content);else{try{await navigator.clipboard.writeText(h.content),re.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
243
+ </html>`}async function mi(t){const s=hi(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Ls(){const[t,s]=m.useState(null),[a,n]=m.useState(null),[r,i]=m.useState(0),[l,o]=m.useState(!1),[c,p]=m.useState(""),[d,u]=m.useState(""),[h,x]=m.useState(""),[g,w]=m.useState(!1);if(m.useEffect(()=>{let v=!1;return s(null),n(null),cs().then(C=>{v||s(C)}).catch(C=>{v||n(C instanceof Error?C.message:String(C))}),()=>{v=!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 A=t.length,T=t.filter(v=>v.receipt).length;async function j(){if(!(!t||t.length===0)){w(!0);try{await mi({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:h.trim()||void 0}),o(!1)}finally{w(!1)}}}async function k(){if(!t||t.length===0)return;const v={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},C=new Blob([JSON.stringify(v,null,2)],{type:"application/json"}),N=URL.createObjectURL(C),E=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,D=document.createElement("a");D.href=N,D.download=E,D.click(),setTimeout(()=>URL.revokeObjectURL(N),1e3)}return A===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:[A," ",A===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&&A>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:()=>o(v=>!v),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(v=>v+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:v=>p(v.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:d,onChange:v=>u(v.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:v=>x(v.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:()=>o(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||A===0,onClick:j,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"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(v=>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 ${v.grade==="A"?"bg-emerald-100 text-emerald-700":v.grade==="B"?"bg-lime-100 text-lime-700":v.grade==="C"?"bg-yellow-100 text-yellow-700":v.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:v.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:v.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${v.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:v.receipt?`Anchored to ${v.receipt.tsaName} at ${v.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:v.receipt?`RFC 3161 (${v.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:v.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:v.capturedAt}),(v.totals.critical>0||v.totals.serious>0)&&e.jsxs("span",{children:[v.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[v.totals.critical," crit"]}),v.totals.critical>0&&v.totals.serious>0&&" · ",v.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[v.totals.serious," sev"]})]}),e.jsxs("span",{children:[v.statesAudited," ",v.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:v.hash,children:[v.hash.slice(0,12),"…"]})]})]},`${v.componentId}::${v.capturedAt}`))})]})}function xi(){const[t,s]=m.useState(null),[a,n]=m.useState(!1);if(m.useEffect(()=>{let c=!1;return cs().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],l=t.slice(0,3),o=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),o>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[o," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(ve,{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(Ls,{})})})]})}function gi(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const fi={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."},bi={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."},vi={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},yi={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ds(){const t=b(u=>u.tier),s=b(u=>u.trialDaysRemaining),a=b(u=>u.seatsUsed),n=b(u=>u.seatsTotal),r=b(u=>u.planCode),i=b(u=>u.licenseDaysRemaining),l=b(u=>u.pastDue),[o,c]=m.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,h=u!==null&&u<=7,x=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"}),x&&e.jsxs("span",{className:h?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:h?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:h?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void te({type:"OPEN_SETTINGS"}),className:h?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(st,{open:o,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?yi:vi,h=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:u.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,w=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-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]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),g&&!x&&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 te({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?fi:bi,d=t==="trial"?gi(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:p.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:p.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:p.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void te({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(st,{open:o,onClose:()=>c(!1)})]})}const wi={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"},ji={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Jt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Ni={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"},Xt={critical:0,serious:1,moderate:2,minor:3};function ki(){const t=b(u=>u.setUserMode),s=b(u=>u.status),a=b(u=>u.setStatus),n=b(u=>u.errorMessage),r=b(u=>u.setError),[i,l]=m.useState(!1),[o,c]=m.useState(!1),p=m.useRef(s);m.useEffect(()=>{if(p.current==="running"&&s==="complete"){c(!0);const u=setTimeout(()=>c(!1),3500);return p.current=s,()=>clearTimeout(u)}p.current=s},[s]),m.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{b.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(u)},[s,a,r]);function d(){t("dev"),te({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(Ds,{}),e.jsx(js,{}),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(ws,{}),e.jsx("button",{type:"button",onClick:d,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(Si,{}),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:()=>{b.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx($s,{onBack:()=>l(!1)}):e.jsx(Ci,{onPickCrawl:()=>l(!0)}),o&&e.jsx(Ai,{})]}),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 Si(){const t=b(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void te({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 Ai(){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 Ci({onPickCrawl:t}){const s=b(u=>u.status),a=b(u=>u.results),[n,r]=m.useState("quick"),[i,l]=m.useState("all"),o=s==="running",c=a.flatMap(u=>u.violations),p=a.length>0;function d(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),re.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:o,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:o?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:o,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(Ri,{depth:n,onChange:r,disabled:o})]}),!p&&!o&&e.jsx(Ii,{}),p&&e.jsx(Ei,{violations:c,severityFilter:i,onSeverityFilterChange:l,scanDepth:n})]})}function Ii(){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 Ri({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(Zt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Yt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Zt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Yt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Zt({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 Ei({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var N;const r=b(E=>E.status),i=b(E=>E.results),l=b(E=>E.freshThisSession),o=b(E=>E.componentId),c=(N=i[0])==null?void 0:N.startedAt,p=ni(t),d=r==="running",[u,h]=m.useState([]);m.useEffect(()=>{if(!o){h([]);return}let E=!1;return chrome.storage.local.get("igtRuns").then(D=>{if(E)return;const U=((D==null?void 0:D.igtRuns)??{})[o]??{};h(Object.values(U))}),()=>{E=!0}},[o]);const x=b(E=>E.acknowledgedKeys),g=i.length>0?os(i,{runs:u,workflows:se},"2.1","AA",x):void 0;function w(){ue({type:"START_AUDIT",mode:"full-page",matrixOverride:bt(n)}),b.getState().startNewScan(),re.polite("Re-scanning this page now.")}const A=s==="lawsuit-risk"?t.filter(E=>E.impact==="critical"||E.impact==="serious"):t,T=new Map;for(const E of A){const D=ht(E.ruleId,E.target.selector);T.has(D)||T.set(D,E)}const j=Array.from(T.values()),k=new Map;for(const E of j){const D=k.get(E.ruleId)??[];D.push(E),k.set(E.ruleId,D)}const v=Array.from(k.entries()).sort((E,D)=>(Xt[E[1][0].impact]??99)-(Xt[D[1][0].impact]??99)),C=t.filter(E=>E.impact==="critical"||E.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:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(_i,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Be(),disabled:d,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:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?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 ${wi[p.tier]}`,children:[!l&&c&&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 ${ji[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 ${Jt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Jt[p.tier]}`,children:p.headline}),p.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:p.flaggedRuleCount})," ",p.flaggedRuleCount===1?"issue type":"issue types"," flagged",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."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(Ti,{coverage:g}),!d&&g&&g.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 ",g.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(Di,{}),e.jsx(xi,{}),t.length>0&&e.jsx($i,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:C}),e.jsxs("div",{className:"space-y-2",children:[v.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."]}),v.map(([E,D])=>e.jsx(Ui,{ruleId:E,violations:D},E))]})]})}function Ti({coverage:t}){const s=b(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),te({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 $i({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 Ui({ruleId:t,violations:s}){var u;const[a,n]=m.useState(!1),r=(u=s.find(h=>h.target.opacityContext))==null?void 0:u.target.opacityContext,i=ha(t,r),l=s[0].impact,o=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&o.description?o.description:i.whatsWrong,d=o.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 ${Ni[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",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,x)=>e.jsx(Li,{violation:h},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Li({violation:t}){const s=b(i=>{var l;return(l=i.results[0])==null?void 0:l.frameId}),[a,n]=m.useState(null);async function r(i){i.stopPropagation();const l=await ae();if(l)try{const o=await xe(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(o.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 $e=[{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 Di(){const t=b(d=>d.results),s=b(d=>d.componentId),[a,n]=m.useState(null),[r,i]=m.useState(!1),[l,o]=m.useState(null);async function c(d,u){if(t.length!==0){n(d);try{const h=await Z({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=rs(d,s);await is()?ut(h.content,x):o({open:!0,format:d,content:h.content,filename:x})}else if(u)dt(h.content);else{try{await navigator.clipboard.writeText(h.content),re.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
238
244
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
239
245
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
240
246
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
241
247
  <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>
242
- <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,w=new Blob([g],{type:"text/html"}),A=URL.createObjectURL(w);window.open(A,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(A),6e4)}}finally{n(null)}}}const p=r?$e:$e.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),l&&e.jsx(Rs,{open:l.open,onClose:()=>o(null),format:l.format,content:l.content,filename:l.filename})]})}function Li({iso:t}){const[,s]=m.useState(0);m.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 Di(t,s,a){const n=new Set,r=[];let i=!1;for(const[l,o]of s)for(const c of o){for(const d of c.violations)if(d.wcagCriterion===t){if(a!=null&&a.has(d.matchKey)){n.add(d.ruleId);continue}if(d.needsReview){n.add(d.ruleId),i=!0;continue}n.add(d.ruleId),r.push({source:"axe",ruleOrStepId:d.ruleId,description:d.description||d.ruleId,pageUrl:l,selector:d.target.selector})}const p=c.axeRulesEvaluated;if(p){for(const d of p.passed)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of p.inapplicable)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of p.incomplete)d.wcagCriterion===t&&(n.add(d.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function _i(t,s,a){const n=[];let r=0,i=0,l=0,o=0;for(const p of a){const d=p.steps.filter(u=>u.wcag===t);if(d.length!==0){r+=d.length;for(const[u,h]of s){const x=h[p.id];if(!x){i+=d.length;continue}for(const g of d){const w=x.steps[g.id];if(!w){i++;continue}w.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${p.id}.${g.id}`,description:g.question,pageUrl:u,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(l++,o++):l++}}}}const c=l>0&&o===l;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function Oi(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 Mi(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 Fi(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=mt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=pa(t.targetVersion,t.targetLevel),l=[];for(const h of i){const x=Di(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=_i(h.id,s.igtRunsByUrl,s.workflows),w=x.rulesFiring.size===0&&g.stepsCovering===0,A={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:w},T=(u=t.overrides)==null?void 0:u[h.id];let N,k,v=!1;if(T)N=T.verdict,k=T.rationale,v=!0;else{const C=r.get(h.id);C?N=C.state:N=Oi(A,g.unanswered,x.hasIncomplete,g.allNotApplicable),k=Mi(h,N,A)}l.push({criterion:h,understandingUrl:ha(h,t.targetVersion),verdict:N,signals:A,overridden:v,rationale:k})}const o={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of l)h.verdict==="pass"?o.pass++:h.verdict==="fail"?o.fail++:h.verdict==="inconclusive"?o.inconclusive++:h.verdict==="not-applicable"?o.notApplicable++:h.verdict==="not-evaluated"&&o.notEvaluated++;function c(h){const x={A:1,AA:2,AAA:3},g=x[h];return l.every(w=>x[w.criterion.level]>g?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let p=null;c("AAA")?p="AAA":c("AA")?p="AA":c("A")&&(p="A");const d=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:l,summary:{totalCriteria:l.length,pass:o.pass,fail:o.fail,inconclusive:o.inconclusive,notApplicable:o.notApplicable,notEvaluated:o.notEvaluated,levelAchieved:p,meetsTarget:d}}}const Pi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Zt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function $(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Se(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 Gi(t,s,a,n){const{inputs:r,rows:i,summary:l,generatedAt:o}=t,c=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,p=new Map;for(const u of i){const h=u.criterion.id.split(".").slice(0,2).join("."),x=p.get(h)??[];x.push(u),p.set(h,x)}const d=Array.from(p.entries()).sort(([u],[h])=>u.localeCompare(h,void 0,{numeric:!0})).map(([u,h])=>`
248
+ <pre>${h.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,w=new Blob([g],{type:"text/html"}),A=URL.createObjectURL(w);window.open(A,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(A),6e4)}}finally{n(null)}}}const p=r?$e:$e.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),l&&e.jsx(Ts,{open:l.open,onClose:()=>o(null),format:l.format,content:l.content,filename:l.filename})]})}function _i({iso:t}){const[,s]=m.useState(0);m.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 Oi(t,s,a){const n=new Set,r=[];let i=!1;for(const[l,o]of s)for(const c of o){for(const d of c.violations)if(d.wcagCriterion===t){if(a!=null&&a.has(d.matchKey)){n.add(d.ruleId);continue}if(d.needsReview){n.add(d.ruleId),i=!0;continue}n.add(d.ruleId),r.push({source:"axe",ruleOrStepId:d.ruleId,description:d.description||d.ruleId,pageUrl:l,selector:d.target.selector})}const p=c.axeRulesEvaluated;if(p){for(const d of p.passed)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of p.inapplicable)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of p.incomplete)d.wcagCriterion===t&&(n.add(d.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Mi(t,s,a){const n=[];let r=0,i=0,l=0,o=0;for(const p of a){const d=p.steps.filter(u=>u.wcag===t);if(d.length!==0){r+=d.length;for(const[u,h]of s){const x=h[p.id];if(!x){i+=d.length;continue}for(const g of d){const w=x.steps[g.id];if(!w){i++;continue}w.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${p.id}.${g.id}`,description:g.question,pageUrl:u,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(l++,o++):l++}}}}const c=l>0&&o===l;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function Fi(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 Pi(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 Gi(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=mt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=ma(t.targetVersion,t.targetLevel),l=[];for(const h of i){const x=Oi(h.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=Mi(h.id,s.igtRunsByUrl,s.workflows),w=x.rulesFiring.size===0&&g.stepsCovering===0,A={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:w},T=(u=t.overrides)==null?void 0:u[h.id];let j,k,v=!1;if(T)j=T.verdict,k=T.rationale,v=!0;else{const C=r.get(h.id);C?j=C.state:j=Fi(A,g.unanswered,x.hasIncomplete,g.allNotApplicable),k=Pi(h,j,A)}l.push({criterion:h,understandingUrl:xa(h,t.targetVersion),verdict:j,signals:A,overridden:v,rationale:k})}const o={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const h of l)h.verdict==="pass"?o.pass++:h.verdict==="fail"?o.fail++:h.verdict==="inconclusive"?o.inconclusive++:h.verdict==="not-applicable"?o.notApplicable++:h.verdict==="not-evaluated"&&o.notEvaluated++;function c(h){const x={A:1,AA:2,AAA:3},g=x[h];return l.every(w=>x[w.criterion.level]>g?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let p=null;c("AAA")?p="AAA":c("AA")?p="AA":c("A")&&(p="A");const d=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:l,summary:{totalCriteria:l.length,pass:o.pass,fail:o.fail,inconclusive:o.inconclusive,notApplicable:o.notApplicable,notEvaluated:o.notEvaluated,levelAchieved:p,meetsTarget:d}}}const Vi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},es={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function $(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Se(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 Wi(t,s,a,n){const{inputs:r,rows:i,summary:l,generatedAt:o}=t,c=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,p=new Map;for(const u of i){const h=u.criterion.id.split(".").slice(0,2).join("."),x=p.get(h)??[];x.push(u),p.set(h,x)}const d=Array.from(p.entries()).sort(([u],[h])=>u.localeCompare(h,void 0,{numeric:!0})).map(([u,h])=>`
243
249
  <h3 class="guideline-h">Guideline ${$(u)}</h3>
244
250
  <table class="criteria-table">
245
251
  <thead>
@@ -249,11 +255,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
249
255
  </thead>
250
256
  <tbody>
251
257
  ${h.map(x=>`
252
- <tr class="${Zt[x.verdict]}">
258
+ <tr class="${es[x.verdict]}">
253
259
  <td><a href="${$(x.understandingUrl)}" target="_blank" rel="noopener">${$(x.criterion.id)}</a></td>
254
260
  <td>${$(x.criterion.title)}</td>
255
261
  <td>${$(x.criterion.level)}</td>
256
- <td><span class="verdict-badge ${Zt[x.verdict]}">${Pi[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
262
+ <td><span class="verdict-badge ${es[x.verdict]}">${Vi[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
257
263
  <td class="rationale">${$(x.rationale)}</td>
258
264
  </tr>
259
265
  ${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
@@ -541,6 +547,6 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
541
547
  <span>${l.totalCriteria} criteria · ${l.pass} pass · ${l.fail} fail · ${l.inconclusive} inconclusive</span>
542
548
  </footer>
543
549
  </body>
544
- </html>`}async function Vi(t,s,a,n){const r=Gi(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(i);await chrome.tabs.create({url:l})}const Ze=ds("wcag-em-anchor"),Wi="https://api.wcagcheckr.com",Bi="wcagcheckr",Hi=15e3;function Ls(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function zi(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 Ki(t){return zi(ma(Ls(t)))}function qi(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 Qi(t,s){const a=await Ki(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Wi}/v1/products/${Bi}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Hi)});if(!i.ok)return Ze.warn(`anchor HTTP ${i.status}`),null;const l=await i.json();return qi(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Ze.warn("anchor returned malformed receipt",l),null)}catch(i){return Ze.warn("anchor request failed",i),null}}function Yi(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ls(t)}}const lt="auditAttestations",ot="auditAttestation:defaultSigner";function vt(t,s){return`${t}::${s}`}async function yt(){try{const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ds(t){await chrome.storage.local.set({[lt]:t})}async function Ji(t){const s=await yt();s[vt(t.componentId,t.auditCapturedAt)]=t,await Ds(s)}async function _s(t,s){return(await yt())[vt(t,s)]??null}async function Xi(t,s){const a=await yt();delete a[vt(t,s)],await Ds(a)}async function Zi(){try{const s=(await chrome.storage.local.get(ot))[ot];return s&&typeof s=="object"?s:null}catch{return null}}async function el(t){await chrome.storage.local.set({[ot]:t})}function tl(t,s){return t.auditCapturedAt!==s}function sl(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function al(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,l]=m.useState(!1),[o,c]=m.useState(""),[p,d]=m.useState(""),[u,h]=m.useState(""),[x,g]=m.useState(""),[w,A]=m.useState("");m.useEffect(()=>{let C=!1;return Promise.all([_s(t.componentId,t.auditCapturedAt),Zi()]).then(([j,E])=>{C||(a(j),j?(c(j.signerName),d(j.signerEmail),h(j.signerOrganization??""),g(j.signerQualifications??""),A(j.claim)):E&&(c(E.signerName),d(E.signerEmail),h(E.signerOrganization??""),g(E.signerQualifications??"")),A(D=>D||sl({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{C=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!o.trim()||!p.trim())return;const C={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:o.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:x.trim()||void 0,claim:w.trim(),scope:t.scope};await Ji(C),await el({signerName:C.signerName,signerEmail:C.signerEmail,signerOrganization:C.signerOrganization,signerQualifications:C.signerQualifications}),a(C),l(!1)}async function N(){await Xi(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const k=s&&tl(s,t.auditCapturedAt);if(s&&!k&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void N(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&k&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const v=o.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:o,onChange:C=>c(C.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:C=>d(C.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:u,onChange:C=>h(C.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:x,onChange:C=>g(C.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:w,onChange:C=>A(C.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>void T(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const ct="spotAuditReviews";function Os(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function wt(){try{const s=(await chrome.storage.local.get(ct))[ct];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ms(t){await chrome.storage.local.set({[ct]:t})}async function nl(t){const s=await wt();s[t.key]=t,await Ms(s)}async function rl(t){const s=await wt();delete s[t],await Ms(s)}async function Fs(){const t=await wt();return Object.values(t)}function Ps(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,i=0;for(const l of t){const o=a.get(l);o&&(n++,o.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function il(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function ll(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const l=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,o=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${l}::${i.selector}`):void 0;n.push({key:Os({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:o})}return n}const ol={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},cl={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function dl({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>ll(t,s),[t,s]),[n,r]=m.useState([]),[i,l]=m.useState(!0),[o,c]=m.useState(null),[p,d]=m.useState(5),[u,h]=m.useState(!1);m.useEffect(()=>{let v=!1;return Fs().then(C=>{v||(r(C),l(!1))}),()=>{v=!0}},[]);const x=m.useMemo(()=>a.map(v=>v.key),[a]),g=m.useMemo(()=>Ps(x,n),[x,n]),A=(u?x:o||n.filter(v=>x.includes(v.key)).map(v=>v.key)).map(v=>a.find(C=>C.key===v)).filter(v=>!!v);async function T(v,C,j){const E={key:v.key,criterionId:v.criterionId,ruleOrStepId:v.ruleOrStepId,pageUrl:v.pageUrl,selector:v.selector,verdict:C,correction:(j==null?void 0:j.trim())||void 0,reviewedAt:new Date().toISOString()};await nl(E),r(D=>[E,...D.filter(y=>y.key!==E.key)])}async function N(v){await rl(v.key),r(C=>C.filter(j=>j.key!==v.key))}function k(){c(il(x,p)),h(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(Ue,{label:"AI determinations",value:g.total}),e.jsx(Ue,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Ue,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Ue,{label:"Disagreed",value:g.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:p,onChange:v=>d(Math.max(1,Math.min(a.length,Number(v.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(v=>!v),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:u?"Hide list":`Show all (${a.length})`}),o&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):A.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:A.map(v=>e.jsx(ul,{row:v,review:n.find(C=>C.key===v.key)??null,onAgree:()=>void T(v,"agreed"),onDisagree:C=>void T(v,"disagreed",C),onClear:()=>void N(v)},v.key))})]})}function Ue({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function ul(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[i,l]=m.useState((a==null?void 0:a.correction)??""),o=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${o==="agreed"?"border-emerald-300 bg-emerald-50/50":o==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${ol[s.outcome]}`,children:cl[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),o&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&o==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>l(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Ae(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,l]=m.useState(!1),[o,c]=m.useState(null);m.useEffect(()=>{let u=!1;return xa(t.componentId,t.criterionId).then(h=>{u||(a(h),r(!1))}),()=>{u=!0}},[t.componentId,t.criterionId]);async function p(){l(!0),c(null);try{const h=await te({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});h.ok?h.result&&a(h.result):c(h.error??"Audit failed.")}catch(u){c(u instanceof Error?u.message:String(u))}finally{l(!1)}}async function d(){await ga(t.componentId,t.criterionId),a(null)}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!o&&e.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),o&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:o}),e.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:["AI: ",s.verdict]}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug",children:s.reasoning}),(()=>{const u=(s.steps??[]).filter(h=>h.action!=="initial").length;return u===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",u," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(h=>h.action!=="initial").map(h=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",h.focused.role||h.focused.tag,"]"]})," ",h.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:h.focused.selector})]},h.ordinal))})]})})(),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function pl(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ae().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const es="igtRuns",hl={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"},ml={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function xl(){var q,V,B;const t=b(R=>R.results),s=b(R=>R.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),l=ba,o=fa,[c,p]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,u]=m.useState(""),[h,x]=m.useState(""),[g,w]=m.useState(""),[A,T]=m.useState(""),[N,k]=m.useState(""),[v,C]=m.useState(""),[j,E]=m.useState({}),[D,y]=m.useState(!1),[U,L]=m.useState([]),[S,M]=m.useState([]),[F,Q]=m.useState(null),[he,pe]=m.useState(!1),[de,I]=m.useState(null);m.useEffect(()=>{let R=!1;return chrome.storage.local.get(es).then(z=>{if(R)return;const _=z[es]??{};E(_),y(!0)}).catch(()=>{R||y(!0)}),()=>{R=!0}},[]),m.useEffect(()=>{var Y;const R=(Y=t[0])==null?void 0:Y.componentId;if(!R)return;let z=!1;const _=()=>{is(R).then(X=>{z||M(X.map(ie=>({criterionId:ie.criterionId,ruleId:`ai-interactive::${ie.criterionId}`,pageUrl:ie.pageUrl,verdict:ie.verdict,reasoning:ie.reasoning})))})};_();const W=X=>{X.interactiveAuditResults&&_()};return chrome.storage.local.onChanged.addListener(W),()=>{z=!0,chrome.storage.local.onChanged.removeListener(W)}},[t]),m.useEffect(()=>{var R;if(!a&&((R=t[0])!=null&&R.pageUrl))try{const z=new URL(t[0].pageUrl);n(z.hostname),i(z.origin)}catch{}},[t,a]),m.useEffect(()=>{const R=new Set;for(const _ of t)R.add(_.pageUrl??_.scope);if(R.size===0){L([]);return}let z=!1;return Promise.all(Array.from(R).map(_=>De(_))).then(_=>{z||L(_.flat())}).catch(()=>{}),()=>{z=!0}},[t]);const J=m.useMemo(()=>{const R=new Map,z=new Map;for(const W of t){const Y=W.pageUrl??W.scope,X=R.get(Y)??[];X.push(W),R.set(Y,X)}const _=new Map;for(const W of t){const Y=W.pageUrl??W.scope;_.set(W.componentId,Y)}for(const[W,Y]of Object.entries(j)){const X=_.get(W);if(!X)continue;const ie=z.get(X)??{};Object.assign(ie,Y),z.set(X,ie)}return{auditsByUrl:R,igtRunsByUrl:z,workflows:se,acknowledgedMatchKeys:s,incompleteResolutions:U,interactiveAuditResults:S}},[t,j,s,U,S]),ne=m.useMemo(()=>{const R=[],z=new Set;for(const _ of J.auditsByUrl.keys())z.has(_)||(z.add(_),R.push({url:_,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const _ of v.split(`
545
- `).map(W=>W.trim()).filter(Boolean))z.has(_)||(z.add(_),R.push({url:_,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return R},[J,v]),ee=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:o,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(R=>R.trim()).filter(Boolean),pageSample:ne,evaluator:{name:h||"(evaluator name pending)",organization:g||void 0,qualifications:A||void 0,contact:N||void 0}}),[a,r,l,o,c,d,ne,h,g,A,N]),f=m.useMemo(()=>D?Fi(ee,J):null,[ee,J,D]),O=m.useMemo(()=>{const R=Array.from(J.auditsByUrl.values()).flat(),z=Object.values(j).flatMap(_=>Object.values(_));return mt({audits:R,igtRuns:z,workflows:se,acknowledgedMatchKeys:s,incompleteResolutions:U,interactiveAuditResults:S})},[J,j,s,U,S]);async function P(){if(!f)return;const R=t[0],z=R!=null&&R.componentId&&(R!=null&&R.startedAt)?await _s(R.componentId,R.startedAt):null,_=await Fs(),W=[];for(const X of O.values())for(const ie of X.evidence)ie.source==="ai"&&W.push(Os({criterionId:X.criterionId,ruleOrStepId:ie.ruleOrStepId,pageUrl:ie.pageUrl,selector:ie.selector}));const Y=Ps(W,_);await Vi(f,F,z,Y)}async function G(){if(f){pe(!0),I(null);try{const R=await Qi(f);if(!R){I("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}Q(R)}finally{pe(!1)}}}function H(){var ie,jt,Nt;if(!f||!F)return;const R=((Nt=(jt=(ie=chrome.runtime).getManifest)==null?void 0:jt.call(ie))==null?void 0:Nt.version)??"0.0.0",z=Yi(f,F,R),_=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),W=URL.createObjectURL(_),Y=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,X=document.createElement("a");X.href=W,X.download=Y,X.click(),setTimeout(()=>URL.revokeObjectURL(W),1e3)}return m.useEffect(()=>{Q(null),I(null)},[a,r,c,d,h,g,A,N,v]),D?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),f&&f.summary.totalCriteria>0&&e.jsx(gl,{totalCriteria:f.summary.totalCriteria,pass:f.summary.pass,fail:f.summary.fail,inconclusive:f.summary.inconclusive,notEvaluated:f.summary.notEvaluated,notApplicable:f.summary.notApplicable,levelAchieved:f.summary.levelAchieved,meetsTarget:f.summary.meetsTarget,targetVersion:l,targetLevel:o,auditedUrlCount:J.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:R=>n(R.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:R=>i(R.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 ",l," Level ",o]}),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:c,onChange:R=>p(R.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:d,onChange:R=>u(R.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.",J.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:J.auditsByUrl.size})," URL",J.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:v,onChange:R=>C(R.target.value),rows:3,placeholder:`https://app.example.com/checkout
546
- 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:R=>x(R.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:g,onChange:R=>w(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:A,onChange:R=>T(R.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:N,onChange:R=>k(R.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),f&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",f.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:f.rows.map(R=>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:[R.criterion.id," · ",R.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:R.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${hl[R.verdict]}`,children:ml[R.verdict]})]},R.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"}),F?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:[F.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",F.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.`}),de&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:de}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!f||!a||!h||he,onClick:()=>void G(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:he?"Anchoring…":F?"Re-anchor":"Anchor this report"}),F&&e.jsx("button",{type:"button",onClick:H,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),f&&((q=t[0])==null?void 0:q.componentId)&&e.jsx(pl,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),f&&e.jsx(dl,{verdicts:O,incompleteResolutions:U}),f&&((V=t[0])==null?void 0:V.componentId)&&((B=t[0])==null?void 0:B.startedAt)&&e.jsx(al,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:o,evaluatedCount:f.summary.pass+f.summary.fail+f.summary.inconclusive+f.summary.notApplicable,totalCount:f.summary.totalCriteria,canClaimConformance:f.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!f||!a||!h,onClick:()=>void P(),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 gl({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:l,meetsTarget:o,targetVersion:c,targetLevel:p,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${c} Level ${p}`:`Does not currently meet WCAG ${c} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",d," audited URL",d===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]})]})}const fl={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function bl(t){if(!t)return"never";const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function vl(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+ja[t.cadence]*6e4-Date.now();if(n<0)return"imminent";const r=Math.floor(n/6e4);return r<60?`in ${r} min`:`in ${Math.floor(r/60)}h`}function yl(){return crypto.randomUUID()}function wl(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[l,o]=m.useState("daily"),[c,p]=m.useState(null),[d,u]=m.useState(!1),[h,x]=m.useState(va),[g,w]=m.useState("idle"),[A,T]=m.useState(!1),[N,k]=m.useState(null);async function v(){n(!0);try{const y=await cs();y.sort((U,L)=>U.enabled!==L.enabled?U.enabled?-1:1:L.createdAt.localeCompare(U.createdAt)),s(y)}finally{n(!1)}}m.useEffect(()=>{v(),(async()=>{const y=await ya();x(y)})()},[]);async function C(y){if(k(null),y.webhookEnabled&&y.webhookUrl.trim().length>0)try{if(new URL(y.webhookUrl).protocol!=="https:"){k("Webhook URL must use https://");return}}catch{k("Webhook URL is not a valid https:// URL.");return}w("saving"),await wa(y),x(y),w("saved"),setTimeout(()=>w("idle"),1500)}async function j(){p(null);const y=r.trim();if(!y){p("URL is required.");return}try{new URL(y)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}u(!0);try{const U={id:yl(),url:y,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await At(U),await Ct(U),i(""),o("daily"),await v(),await Ke()}finally{u(!1)}}async function E(y){const U={...y,enabled:!y.enabled};await At(U),U.enabled?await Ct(U):await It(y.id),await v(),await Ke()}async function D(y){window.confirm(`Remove the scheduled audit for ${y.url}? Run history for this schedule will also be deleted.`)&&(await It(y.id),await Na(y.id),await ka(y.id),await v(),await Ke())}return e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Scheduled audits"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Re-audit a URL on a cadence. Each scheduled run opens a background tab, runs the audit, compares to the saved baseline, and records the result. New violations vs. baseline trigger alerts when configured below."})]}),e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>T(y=>!y),"aria-expanded":A,className:"w-full flex items-center justify-between px-3 py-2 text-left font-medium hover:bg-slate-50",children:[e.jsxs("span",{children:["Alert preferences",h.emailEnabled||h.webhookEnabled?e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"on"}):e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"off"})]}),e.jsx("span",{className:"text-slate-500","aria-hidden":"true",children:A?"▾":"▸"})]}),A&&e.jsxs("div",{className:"px-3 pb-3 space-y-2.5 border-t border-slate-100 pt-3",children:[e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Alerts fire when a scheduled audit finds NEW violations vs. the saved baseline. Email goes to your license-registered address (server-enforced). Webhook is your own URL."}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-email-enabled",type:"checkbox",checked:h.emailEnabled,onChange:y=>void C({...h,emailEnabled:y.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Email alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"Sends to your team-license email address only."})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-webhook-enabled",type:"checkbox",checked:h.webhookEnabled,onChange:y=>void C({...h,webhookEnabled:y.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Webhook alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"POSTs the alert payload as JSON to your URL."})]})]}),h.webhookEnabled&&e.jsxs("div",{className:"ml-5 space-y-1",children:[e.jsx("label",{htmlFor:"alert-webhook-url",className:"block text-[11px] font-medium",children:"Webhook URL (https:// only)"}),e.jsx("input",{id:"alert-webhook-url",type:"url",value:h.webhookUrl,onChange:y=>x({...h,webhookUrl:y.target.value}),onBlur:()=>void C(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),N&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:N})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:h.minImpact,onChange:y=>void C({...h,minImpact:y.target.value}),className:"w-full border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"minor",children:"Minor (alert on everything)"}),e.jsx("option",{value:"moderate",children:"Moderate"}),e.jsx("option",{value:"serious",children:"Serious (recommended)"}),e.jsx("option",{value:"critical",children:"Critical only"})]})]}),g==="saved"&&e.jsx("p",{className:"text-[11px] text-emerald-700",role:"status",children:"✓ Saved"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-url",className:"block font-medium mb-1",children:"URL to audit"}),e.jsx("input",{id:"sched-url",type:"url",value:r,onChange:y=>i(y.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:y=>o(y.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void j(),disabled:d||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:d?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(y=>e.jsx("li",{className:`border rounded p-2.5 ${y.enabled?"border-slate-200 bg-white":"border-slate-200 bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 break-all",children:y.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[fl[y.cadence]," · last run ",bl(y.lastRunAt)," ·"," ","next ",vl(y)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[y.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",y.lastTotalViolations??0," violation",(y.lastTotalViolations??0)===1?"":"s"]}),y.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:y.lastError??"",children:"✗ failed"}),y.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),y.lastResult==="pending"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700",children:"pending first run"}),(y.lastNewViolationCount??0)>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-900",title:"New violations vs. saved baseline",children:["⚠ ",y.lastNewViolationCount," new vs baseline"]}),!y.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void E(y),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:y.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void D(y),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},y.id))})]})}const ts={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Gs(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function jl(t){let s=0,a=0,n=0,r=0,i=0,l=0,o=0,c=0;for(const p of t){if(!p.enabled){a++;continue}s++;const d=Gs(p);d==="clean"?n++:d==="new-violations"?r++:d==="failed"?i++:d==="pending"&&l++,o+=p.lastNewViolationCount??0,c+=p.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:l,totalNewViolations:o,totalViolationsAcrossSchedules:c}}function Nl(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const l=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-l}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:Gs(a)}))}function kl(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,i)=>i.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function Vs(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let o=s-1;o>=0;o--){const c=new Date(r.getTime()-o*864e5);i.push({date:c.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const l=new Map(i.map(o=>[o.date,o]));for(const o of t){const c=o.ranAt.slice(0,10),p=l.get(c);p&&(p.runs++,p.totalViolations+=o.totalViolations,p.newViolations+=o.newVsBaselineViolations)}return i}function Sl(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return Vs(r,a,n)}function Al(t,s=new Date){const a=[];for(const n of t){if(!n.enabled)continue;n.lastResult==="failed"&&a.push({kind:"failed-run",scheduleId:n.id,url:n.url,detail:n.lastError??"audit failed"});const r=ts[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const l=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${l}h (expected every ${ts[n.cadence]}min)`})}}(n.lastNewViolationCount??0)>10&&a.push({kind:"large-regression",scheduleId:n.id,url:n.url,detail:`${n.lastNewViolationCount} new violations vs baseline`})}return a}function ss(t){const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function Ws(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function as({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(o=>o.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((o,c)=>{const p=c*r,d=s-o.totalViolations/n*(s-4)-2;return`${p.toFixed(1)},${d.toFixed(1)}`}),l=t.map((o,c)=>{const p=c*r,d=s-o.newViolations/n*(s-4)-2;return`${p.toFixed(1)},${d.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:l.join(" ")})]})}function Le({state:t,count:s}){const a={clean:"bg-emerald-100 text-emerald-800","new-violations":"bg-rose-100 text-rose-900",failed:"bg-amber-100 text-amber-900",pending:"bg-slate-100 text-slate-700"},n={clean:"clean","new-violations":"new violations",failed:"failed",pending:"pending"};return e.jsxs("div",{className:`px-2 py-1 rounded text-[11px] ${a[t]}`,children:[e.jsx("strong",{children:s})," ",n[t]]})}function Cl({item:t}){const s={"failed-run":"✗ Failed","stale-schedule":"⏳ Stale","large-regression":"⚠ Regression"},a={"failed-run":"text-rose-700","stale-schedule":"text-amber-700","large-regression":"text-rose-700"};return e.jsxs("li",{className:"border-l-2 border-slate-200 pl-2 py-1",children:[e.jsx("div",{className:`text-[11px] font-medium ${a[t.kind]}`,children:s[t.kind]}),e.jsx("div",{className:"text-[11px] font-mono break-all",children:Ws(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function Il(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{(async()=>{i(!0);try{const[u,h]=await Promise.all([cs(),Sa()]);s(u),n(h)}finally{i(!1)}})()},[]);const l=jl(t),o=Nl(t,5),c=kl(t,a,10),p=Vs(a,30),d=Al(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",l.enabledSchedules," enabled",l.pausedSchedules>0?` · ${l.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Le,{state:"clean",count:l.cleanCount}),e.jsx(Le,{state:"new-violations",count:l.newViolationsCount}),e.jsx(Le,{state:"failed",count:l.failedCount}),e.jsx(Le,{state:"pending",count:l.pendingCount})]}),l.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[l.totalNewViolations," new WCAG violation",l.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(as,{buckets:p}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",l.enabledSchedules," schedule",l.enabledSchedules===1?"":"s"]})]})]})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",d.length]}),e.jsx("ul",{className:"space-y-1.5",children:d.map((u,h)=>e.jsx(Cl,{item:u},`${u.kind}-${u.scheduleId}-${h}`))})]}),o.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:o.map(u=>{const h=Sl(u.scheduleId,a,14),x=h.some(g=>g.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:u.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[u.lastTotalViolations," total · ",u.cadence," ·"," ","last run ",u.lastRunAt?ss(u.lastRunAt):"never"]})]}),x&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(as,{buckets:h,height:20,width:56})}),u.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",u.lastNewViolationCount," new"]})]},u.scheduleId)})})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:c.map((u,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:ss(u.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:Ws(u.scheduleUrl)}),u.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:u.error,children:"failed"}):u.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",u.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${u.scheduleId}-${u.ranAt}-${h}`))})]})]})}const et="onboarding:dismissed",tt="onboarding:exportTried";function Rl(){const t=b(k=>k.tier),s=b(k=>k.results),a=b(k=>k.baselineList),[n,r]=m.useState(!1),[i,l]=m.useState(!1),[o,c]=m.useState(!1),[p,d]=m.useState(!1);m.useEffect(()=>{(async()=>{const k=await chrome.storage.local.get([et,tt]);r(k[et]===!0),c(k[tt]===!0);const v=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],C=await Promise.all(v.map(j=>Z({type:"SETTINGS_GET",key:j})));d(C.some(j=>typeof j.data=="string"&&j.data.length>0)),l(!0)})()},[]);const u=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:o?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],h=u.filter(k=>!k.optional),x=u.filter(k=>k.state==="done").length,g=h.filter(k=>k.state==="done").length,w=x===u.length,A=g===h.length;if(!i||n||A)return null;async function T(){r(!0),await chrome.storage.local.set({[et]:!0})}async function N(){const k=!o;c(k),await chrome.storage.local.set({[tt]:k})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded p-2.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",x," of ",u.length," done"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Quick checklist to get you started. ",w?"All steps complete — nice!":"Auto-checks as you go."]})]}),e.jsx("button",{type:"button",onClick:()=>void T(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none -mt-1",children:"✕"})]}),e.jsx("ul",{className:"space-y-1",children:u.map(k=>e.jsx("li",{className:"flex items-start gap-1.5",children:k.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:k.state==="done",onChange:()=>void N(),className:"mt-0.5","aria-label":k.label}),e.jsx("span",{className:k.state==="done"?"line-through text-amber-700":"text-amber-900",children:k.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:k.state==="done"?"✓":"○"}),e.jsxs("span",{className:k.state==="done"?"line-through text-amber-700":"text-amber-900",children:[k.label,k.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},k.id))})]})}function El(){const[t,s]=m.useState(""),[a,n]=m.useState(!1),[r,i]=m.useState(null);async function l(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const o=await te({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(o!=null&&o.validated)){const c=o!=null&&o.seatClaim&&"reason"in o.seatClaim?o.seatClaim.reason:null,p=o!=null&&o.seatClaim&&"hint"in o.seatClaim?o.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${p??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${o!=null&&o.seatClaim&&"message"in o.seatClaim?o.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(o){i(o instanceof Error?o.message:String(o))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:o=>s(o.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Ml(){const t=b(l=>l.view),s=b(l=>l.userMode),a=b(l=>l.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const i=n&&Ia(a);return m.useEffect(()=>{const l=Ma(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),p=Ua();ms({forceRefresh:!0}).catch(()=>{}),Fe().catch(()=>{}),Oa().catch(()=>{}),Fa().catch(()=>{}),Da().catch(()=>{}),Aa().then(u=>{b.getState().setAcknowledgedKeys(new Set(u.map(h=>h.matchKey)))}).catch(()=>{}),Ca().then(u=>{u&&b.setState({siteCrawlReport:u})}).catch(()=>{});const d=u=>{if(u.key!=="Escape")return;const{pinnedMatchKey:h,setPinned:x,results:g}=b.getState();h&&(x(null),ae().then(w=>{var A;w&&le(w,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:w},(A=g[0])==null?void 0:A.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{p(),l.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(El,{}),e.jsx(Ee,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Zr,{}),e.jsx(Ee,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(ji,{}),e.jsx(qt,{}),e.jsx(Ee,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(Us,{}),e.jsx(ws,{}),e.jsx(Za,{}),e.jsx(Rl,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(an,{}),e.jsx(cn,{}),e.jsx(Qr,{}),e.jsx(qr,{}),e.jsx(un,{}),e.jsx(zr,{}),e.jsx(Kr,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(An,{}),t==="report"&&e.jsx(Wn,{}),t==="delta"&&e.jsx(rr,{}),t==="activity"&&e.jsx(vr,{}),t==="guided"&&e.jsx(Tr,{}),t==="flows"&&e.jsx(Dr,{}),t==="scorecard"&&e.jsx(Mr,{}),t==="crawl"&&e.jsx(Es,{}),t==="forensic"&&e.jsx($s,{}),t==="compliance"&&e.jsx(xl,{}),t==="schedules"&&e.jsx(wl,{}),t==="risk"&&e.jsx(Il,{})]})]}),e.jsx(Xr,{}),e.jsx(Yr,{}),e.jsx(Hr,{}),e.jsx(qt,{}),e.jsx(Ee,{})]})}class Fl extends Ce.Component{constructor(){super(...arguments);kt(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{Ml as A,Fl as E,Ol as d};
550
+ </html>`}async function Bi(t,s,a,n){const r=Wi(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(i);await chrome.tabs.create({url:l})}const Ze=us("wcag-em-anchor"),Hi="https://api.wcagcheckr.com",zi="wcagcheckr",Ki=15e3;function _s(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 qi(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 Qi(t){return qi(ga(_s(t)))}function Yi(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 Ji(t,s){const a=await Qi(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Hi}/v1/products/${zi}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Ki)});if(!i.ok)return Ze.warn(`anchor HTTP ${i.status}`),null;const l=await i.json();return Yi(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Ze.warn("anchor returned malformed receipt",l),null)}catch(i){return Ze.warn("anchor request failed",i),null}}function Xi(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:_s(t)}}const lt="auditAttestations",ot="auditAttestation:defaultSigner";function vt(t,s){return`${t}::${s}`}async function yt(){try{const s=(await chrome.storage.local.get(lt))[lt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Os(t){await chrome.storage.local.set({[lt]:t})}async function Zi(t){const s=await yt();s[vt(t.componentId,t.auditCapturedAt)]=t,await Os(s)}async function Ms(t,s){return(await yt())[vt(t,s)]??null}async function el(t,s){const a=await yt();delete a[vt(t,s)],await Os(a)}async function tl(){try{const s=(await chrome.storage.local.get(ot))[ot];return s&&typeof s=="object"?s:null}catch{return null}}async function sl(t){await chrome.storage.local.set({[ot]:t})}function al(t,s){return t.auditCapturedAt!==s}function nl(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function rl(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,l]=m.useState(!1),[o,c]=m.useState(""),[p,d]=m.useState(""),[u,h]=m.useState(""),[x,g]=m.useState(""),[w,A]=m.useState("");m.useEffect(()=>{let C=!1;return Promise.all([Ms(t.componentId,t.auditCapturedAt),tl()]).then(([N,E])=>{C||(a(N),N?(c(N.signerName),d(N.signerEmail),h(N.signerOrganization??""),g(N.signerQualifications??""),A(N.claim)):E&&(c(E.signerName),d(E.signerEmail),h(E.signerOrganization??""),g(E.signerQualifications??"")),A(D=>D||nl({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{C=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!o.trim()||!p.trim())return;const C={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:o.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:x.trim()||void 0,claim:w.trim(),scope:t.scope};await Zi(C),await sl({signerName:C.signerName,signerEmail:C.signerEmail,signerOrganization:C.signerOrganization,signerQualifications:C.signerQualifications}),a(C),l(!1)}async function j(){await el(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const k=s&&al(s,t.auditCapturedAt);if(s&&!k&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void j(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&k&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const v=o.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:o,onChange:C=>c(C.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:p,onChange:C=>d(C.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:u,onChange:C=>h(C.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:x,onChange:C=>g(C.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:w,onChange:C=>A(C.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>void T(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const ct="spotAuditReviews";function Fs(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function wt(){try{const s=(await chrome.storage.local.get(ct))[ct];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ps(t){await chrome.storage.local.set({[ct]:t})}async function il(t){const s=await wt();s[t.key]=t,await Ps(s)}async function ll(t){const s=await wt();delete s[t],await Ps(s)}async function Gs(){const t=await wt();return Object.values(t)}function Vs(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,i=0;for(const l of t){const o=a.get(l);o&&(n++,o.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function ol(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function cl(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const l=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,o=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${l}::${i.selector}`):void 0;n.push({key:Fs({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:o})}return n}const dl={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},ul={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function pl({verdicts:t,incompleteResolutions:s}){const a=m.useMemo(()=>cl(t,s),[t,s]),[n,r]=m.useState([]),[i,l]=m.useState(!0),[o,c]=m.useState(null),[p,d]=m.useState(5),[u,h]=m.useState(!1);m.useEffect(()=>{let v=!1;return Gs().then(C=>{v||(r(C),l(!1))}),()=>{v=!0}},[]);const x=m.useMemo(()=>a.map(v=>v.key),[a]),g=m.useMemo(()=>Vs(x,n),[x,n]),A=(u?x:o||n.filter(v=>x.includes(v.key)).map(v=>v.key)).map(v=>a.find(C=>C.key===v)).filter(v=>!!v);async function T(v,C,N){const E={key:v.key,criterionId:v.criterionId,ruleOrStepId:v.ruleOrStepId,pageUrl:v.pageUrl,selector:v.selector,verdict:C,correction:(N==null?void 0:N.trim())||void 0,reviewedAt:new Date().toISOString()};await il(E),r(D=>[E,...D.filter(y=>y.key!==E.key)])}async function j(v){await ll(v.key),r(C=>C.filter(N=>N.key!==v.key))}function k(){c(ol(x,p)),h(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(Ue,{label:"AI determinations",value:g.total}),e.jsx(Ue,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Ue,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Ue,{label:"Disagreed",value:g.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:p,onChange:v=>d(Math.max(1,Math.min(a.length,Number(v.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{h(v=>!v),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:u?"Hide list":`Show all (${a.length})`}),o&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):A.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:A.map(v=>e.jsx(hl,{row:v,review:n.find(C=>C.key===v.key)??null,onAgree:()=>void T(v,"agreed"),onDisagree:C=>void T(v,"disagreed",C),onClear:()=>void j(v)},v.key))})]})}function Ue({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function hl(t){const{row:s,review:a}=t,[n,r]=m.useState(!1),[i,l]=m.useState((a==null?void 0:a.correction)??""),o=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${o==="agreed"?"border-emerald-300 bg-emerald-50/50":o==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${dl[s.outcome]}`,children:ul[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),o&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&o==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>l(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Ae(t){const[s,a]=m.useState(null),[n,r]=m.useState(!0),[i,l]=m.useState(!1),[o,c]=m.useState(null);m.useEffect(()=>{let u=!1;return fa(t.componentId,t.criterionId).then(h=>{u||(a(h),r(!1))}),()=>{u=!0}},[t.componentId,t.criterionId]);async function p(){l(!0),c(null);try{const h=await te({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});h.ok?h.result&&a(h.result):c(h.error??"Audit failed.")}catch(u){c(u instanceof Error?u.message:String(u))}finally{l(!1)}}async function d(){await ba(t.componentId,t.criterionId),a(null)}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!o&&e.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),o&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:o}),e.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:["AI: ",s.verdict]}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug",children:s.reasoning}),(()=>{const u=(s.steps??[]).filter(h=>h.action!=="initial").length;return u===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",u," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(h=>h.action!=="initial").map(h=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",h.focused.role||h.focused.tag,"]"]})," ",h.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:h.focused.selector})]},h.ordinal))})]})})(),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function ml(t){const[s,a]=m.useState(null);return m.useEffect(()=>{let n=!1;return ae().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(Ae,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const ts="igtRuns",xl={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"},gl={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function fl(){var q,V,B;const t=b(R=>R.results),s=b(R=>R.acknowledgedKeys),[a,n]=m.useState(""),[r,i]=m.useState(""),l=ya,o=va,[c,p]=m.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,u]=m.useState(""),[h,x]=m.useState(""),[g,w]=m.useState(""),[A,T]=m.useState(""),[j,k]=m.useState(""),[v,C]=m.useState(""),[N,E]=m.useState({}),[D,y]=m.useState(!1),[U,L]=m.useState([]),[S,M]=m.useState([]),[F,Q]=m.useState(null),[he,pe]=m.useState(!1),[de,I]=m.useState(null);m.useEffect(()=>{let R=!1;return chrome.storage.local.get(ts).then(z=>{if(R)return;const _=z[ts]??{};E(_),y(!0)}).catch(()=>{R||y(!0)}),()=>{R=!0}},[]),m.useEffect(()=>{var Y;const R=(Y=t[0])==null?void 0:Y.componentId;if(!R)return;let z=!1;const _=()=>{ls(R).then(X=>{z||M(X.map(ie=>({criterionId:ie.criterionId,ruleId:`ai-interactive::${ie.criterionId}`,pageUrl:ie.pageUrl,verdict:ie.verdict,reasoning:ie.reasoning})))})};_();const W=X=>{X.interactiveAuditResults&&_()};return chrome.storage.local.onChanged.addListener(W),()=>{z=!0,chrome.storage.local.onChanged.removeListener(W)}},[t]),m.useEffect(()=>{var R;if(!a&&((R=t[0])!=null&&R.pageUrl))try{const z=new URL(t[0].pageUrl);n(z.hostname),i(z.origin)}catch{}},[t,a]),m.useEffect(()=>{const R=new Set;for(const _ of t)R.add(_.pageUrl??_.scope);if(R.size===0){L([]);return}let z=!1;return Promise.all(Array.from(R).map(_=>De(_))).then(_=>{z||L(_.flat())}).catch(()=>{}),()=>{z=!0}},[t]);const J=m.useMemo(()=>{const R=new Map,z=new Map;for(const W of t){const Y=W.pageUrl??W.scope,X=R.get(Y)??[];X.push(W),R.set(Y,X)}const _=new Map;for(const W of t){const Y=W.pageUrl??W.scope;_.set(W.componentId,Y)}for(const[W,Y]of Object.entries(N)){const X=_.get(W);if(!X)continue;const ie=z.get(X)??{};Object.assign(ie,Y),z.set(X,ie)}return{auditsByUrl:R,igtRunsByUrl:z,workflows:se,acknowledgedMatchKeys:s,incompleteResolutions:U,interactiveAuditResults:S}},[t,N,s,U,S]),ne=m.useMemo(()=>{const R=[],z=new Set;for(const _ of J.auditsByUrl.keys())z.has(_)||(z.add(_),R.push({url:_,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const _ of v.split(`
551
+ `).map(W=>W.trim()).filter(Boolean))z.has(_)||(z.add(_),R.push({url:_,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return R},[J,v]),ee=m.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:o,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(R=>R.trim()).filter(Boolean),pageSample:ne,evaluator:{name:h||"(evaluator name pending)",organization:g||void 0,qualifications:A||void 0,contact:j||void 0}}),[a,r,l,o,c,d,ne,h,g,A,j]),f=m.useMemo(()=>D?Gi(ee,J):null,[ee,J,D]),O=m.useMemo(()=>{const R=Array.from(J.auditsByUrl.values()).flat(),z=Object.values(N).flatMap(_=>Object.values(_));return mt({audits:R,igtRuns:z,workflows:se,acknowledgedMatchKeys:s,incompleteResolutions:U,interactiveAuditResults:S})},[J,N,s,U,S]);async function P(){if(!f)return;const R=t[0],z=R!=null&&R.componentId&&(R!=null&&R.startedAt)?await Ms(R.componentId,R.startedAt):null,_=await Gs(),W=[];for(const X of O.values())for(const ie of X.evidence)ie.source==="ai"&&W.push(Fs({criterionId:X.criterionId,ruleOrStepId:ie.ruleOrStepId,pageUrl:ie.pageUrl,selector:ie.selector}));const Y=Vs(W,_);await Bi(f,F,z,Y)}async function G(){if(f){pe(!0),I(null);try{const R=await Ji(f);if(!R){I("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}Q(R)}finally{pe(!1)}}}function H(){var ie,jt,Nt;if(!f||!F)return;const R=((Nt=(jt=(ie=chrome.runtime).getManifest)==null?void 0:jt.call(ie))==null?void 0:Nt.version)??"0.0.0",z=Xi(f,F,R),_=new Blob([JSON.stringify(z,null,2)],{type:"application/json"}),W=URL.createObjectURL(_),Y=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,X=document.createElement("a");X.href=W,X.download=Y,X.click(),setTimeout(()=>URL.revokeObjectURL(W),1e3)}return m.useEffect(()=>{Q(null),I(null)},[a,r,c,d,h,g,A,j,v]),D?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),f&&f.summary.totalCriteria>0&&e.jsx(bl,{totalCriteria:f.summary.totalCriteria,pass:f.summary.pass,fail:f.summary.fail,inconclusive:f.summary.inconclusive,notEvaluated:f.summary.notEvaluated,notApplicable:f.summary.notApplicable,levelAchieved:f.summary.levelAchieved,meetsTarget:f.summary.meetsTarget,targetVersion:l,targetLevel:o,auditedUrlCount:J.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:R=>n(R.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:R=>i(R.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 ",l," Level ",o]}),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:c,onChange:R=>p(R.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:d,onChange:R=>u(R.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.",J.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:J.auditsByUrl.size})," URL",J.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:v,onChange:R=>C(R.target.value),rows:3,placeholder:`https://app.example.com/checkout
552
+ 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:R=>x(R.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:g,onChange:R=>w(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:A,onChange:R=>T(R.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:j,onChange:R=>k(R.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),f&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",f.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:f.rows.map(R=>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:[R.criterion.id," · ",R.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:R.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${xl[R.verdict]}`,children:gl[R.verdict]})]},R.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"}),F?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:[F.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",F.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.`}),de&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:de}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!f||!a||!h||he,onClick:()=>void G(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:he?"Anchoring…":F?"Re-anchor":"Anchor this report"}),F&&e.jsx("button",{type:"button",onClick:H,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),f&&((q=t[0])==null?void 0:q.componentId)&&e.jsx(ml,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),f&&e.jsx(pl,{verdicts:O,incompleteResolutions:U}),f&&((V=t[0])==null?void 0:V.componentId)&&((B=t[0])==null?void 0:B.startedAt)&&e.jsx(rl,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:o,evaluatedCount:f.summary.pass+f.summary.fail+f.summary.inconclusive+f.summary.notApplicable,totalCount:f.summary.totalCriteria,canClaimConformance:f.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!f||!a||!h,onClick:()=>void P(),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 bl({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:l,meetsTarget:o,targetVersion:c,targetLevel:p,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${c} Level ${p}`:`Does not currently meet WCAG ${c} Level ${p}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",d," audited URL",d===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]})]})}const vl={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function yl(t){if(!t)return"never";const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function wl(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+ka[t.cadence]*6e4-Date.now();if(n<0)return"imminent";const r=Math.floor(n/6e4);return r<60?`in ${r} min`:`in ${Math.floor(r/60)}h`}function jl(){return crypto.randomUUID()}function Nl(){const[t,s]=m.useState([]),[a,n]=m.useState(!0),[r,i]=m.useState(""),[l,o]=m.useState("daily"),[c,p]=m.useState(null),[d,u]=m.useState(!1),[h,x]=m.useState(wa),[g,w]=m.useState("idle"),[A,T]=m.useState(!1),[j,k]=m.useState(null);async function v(){n(!0);try{const y=await ds();y.sort((U,L)=>U.enabled!==L.enabled?U.enabled?-1:1:L.createdAt.localeCompare(U.createdAt)),s(y)}finally{n(!1)}}m.useEffect(()=>{v(),(async()=>{const y=await ja();x(y)})()},[]);async function C(y){if(k(null),y.webhookEnabled&&y.webhookUrl.trim().length>0)try{if(new URL(y.webhookUrl).protocol!=="https:"){k("Webhook URL must use https://");return}}catch{k("Webhook URL is not a valid https:// URL.");return}w("saving"),await Na(y),x(y),w("saved"),setTimeout(()=>w("idle"),1500)}async function N(){p(null);const y=r.trim();if(!y){p("URL is required.");return}try{new URL(y)}catch{p("Must be a valid URL (e.g. https://example.com/).");return}u(!0);try{const U={id:jl(),url:y,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await At(U),await Ct(U),i(""),o("daily"),await v(),await Ke()}finally{u(!1)}}async function E(y){const U={...y,enabled:!y.enabled};await At(U),U.enabled?await Ct(U):await It(y.id),await v(),await Ke()}async function D(y){window.confirm(`Remove the scheduled audit for ${y.url}? Run history for this schedule will also be deleted.`)&&(await It(y.id),await Sa(y.id),await Aa(y.id),await v(),await Ke())}return e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Scheduled audits"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Re-audit a URL on a cadence. Each scheduled run opens a background tab, runs the audit, compares to the saved baseline, and records the result. New violations vs. baseline trigger alerts when configured below."})]}),e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>T(y=>!y),"aria-expanded":A,className:"w-full flex items-center justify-between px-3 py-2 text-left font-medium hover:bg-slate-50",children:[e.jsxs("span",{children:["Alert preferences",h.emailEnabled||h.webhookEnabled?e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"on"}):e.jsx("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:"off"})]}),e.jsx("span",{className:"text-slate-500","aria-hidden":"true",children:A?"▾":"▸"})]}),A&&e.jsxs("div",{className:"px-3 pb-3 space-y-2.5 border-t border-slate-100 pt-3",children:[e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:"Alerts fire when a scheduled audit finds NEW violations vs. the saved baseline. Email goes to your license-registered address (server-enforced). Webhook is your own URL."}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-email-enabled",type:"checkbox",checked:h.emailEnabled,onChange:y=>void C({...h,emailEnabled:y.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Email alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"Sends to your team-license email address only."})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{id:"alert-webhook-enabled",type:"checkbox",checked:h.webhookEnabled,onChange:y=>void C({...h,webhookEnabled:y.target.checked}),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Webhook alerts"}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:"POSTs the alert payload as JSON to your URL."})]})]}),h.webhookEnabled&&e.jsxs("div",{className:"ml-5 space-y-1",children:[e.jsx("label",{htmlFor:"alert-webhook-url",className:"block text-[11px] font-medium",children:"Webhook URL (https:// only)"}),e.jsx("input",{id:"alert-webhook-url",type:"url",value:h.webhookUrl,onChange:y=>x({...h,webhookUrl:y.target.value}),onBlur:()=>void C(h),placeholder:"https://hooks.your-domain.com/wcagcheckr",className:"w-full border border-slate-300 rounded px-2 py-1 font-mono text-[11px]"}),j&&e.jsx("p",{className:"text-rose-700 text-[11px]",role:"alert",children:j})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"alert-min-impact",className:"block text-[11px] font-medium mb-1",children:"Minimum impact to alert on"}),e.jsxs("select",{id:"alert-min-impact",value:h.minImpact,onChange:y=>void C({...h,minImpact:y.target.value}),className:"w-full border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"minor",children:"Minor (alert on everything)"}),e.jsx("option",{value:"moderate",children:"Moderate"}),e.jsx("option",{value:"serious",children:"Serious (recommended)"}),e.jsx("option",{value:"critical",children:"Critical only"})]})]}),g==="saved"&&e.jsx("p",{className:"text-[11px] text-emerald-700",role:"status",children:"✓ Saved"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-url",className:"block font-medium mb-1",children:"URL to audit"}),e.jsx("input",{id:"sched-url",type:"url",value:r,onChange:y=>i(y.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:y=>o(y.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void N(),disabled:d||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:d?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(y=>e.jsx("li",{className:`border rounded p-2.5 ${y.enabled?"border-slate-200 bg-white":"border-slate-200 bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 break-all",children:y.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[vl[y.cadence]," · last run ",yl(y.lastRunAt)," ·"," ","next ",wl(y)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[y.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",y.lastTotalViolations??0," violation",(y.lastTotalViolations??0)===1?"":"s"]}),y.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:y.lastError??"",children:"✗ failed"}),y.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),y.lastResult==="pending"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700",children:"pending first run"}),(y.lastNewViolationCount??0)>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-900",title:"New violations vs. saved baseline",children:["⚠ ",y.lastNewViolationCount," new vs baseline"]}),!y.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void E(y),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:y.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void D(y),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},y.id))})]})}const ss={hourly:60,"every-4-hours":240,daily:1440,weekly:10080};function Ws(t){return t.enabled?(t.lastNewViolationCount??0)>0?"new-violations":t.lastResult==="failed"?"failed":t.lastResult==="ok"?"clean":"pending":"paused"}function kl(t){let s=0,a=0,n=0,r=0,i=0,l=0,o=0,c=0;for(const p of t){if(!p.enabled){a++;continue}s++;const d=Ws(p);d==="clean"?n++:d==="new-violations"?r++:d==="failed"?i++:d==="pending"&&l++,o+=p.lastNewViolationCount??0,c+=p.lastTotalViolations??0}return{totalSchedules:t.length,enabledSchedules:s,pausedSchedules:a,cleanCount:n,newViolationsCount:r,failedCount:i,pendingCount:l,totalNewViolations:o,totalViolationsAcrossSchedules:c}}function Sl(t,s=5){return t.filter(a=>a.enabled&&a.lastResult==="ok").sort((a,n)=>{const r=a.lastNewViolationCount??0,i=n.lastNewViolationCount??0;if(r!==i)return i-r;const l=a.lastTotalViolations??0;return(n.lastTotalViolations??0)-l}).slice(0,s).map(a=>({scheduleId:a.id,url:a.url,cadence:a.cadence,lastRunAt:a.lastRunAt??null,lastTotalViolations:a.lastTotalViolations??0,lastNewViolationCount:a.lastNewViolationCount??0,state:Ws(a)}))}function Al(t,s,a=10){const n=new Map;for(const r of t)n.set(r.id,r.url);return[...s].sort((r,i)=>i.ranAt.localeCompare(r.ranAt)).slice(0,a).map(r=>({scheduleId:r.scheduleId,scheduleUrl:n.get(r.scheduleId)??"(deleted schedule)",ranAt:r.ranAt,totalViolations:r.totalViolations,newVsBaselineViolations:r.newVsBaselineViolations,durationMs:r.durationMs,error:r.error}))}function Bs(t,s=30,a=new Date){const r=new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())),i=[];for(let o=s-1;o>=0;o--){const c=new Date(r.getTime()-o*864e5);i.push({date:c.toISOString().slice(0,10),runs:0,totalViolations:0,newViolations:0})}const l=new Map(i.map(o=>[o.date,o]));for(const o of t){const c=o.ranAt.slice(0,10),p=l.get(c);p&&(p.runs++,p.totalViolations+=o.totalViolations,p.newViolations+=o.newVsBaselineViolations)}return i}function Cl(t,s,a=14,n=new Date){const r=s.filter(i=>i.scheduleId===t);return Bs(r,a,n)}function Il(t,s=new Date){const a=[];for(const n of t){if(!n.enabled)continue;n.lastResult==="failed"&&a.push({kind:"failed-run",scheduleId:n.id,url:n.url,detail:n.lastError??"audit failed"});const r=ss[n.cadence]*6e4;if(n.lastRunAt){const i=s.getTime()-new Date(n.lastRunAt).getTime();if(i>r*2){const l=Math.round(i/36e5);a.push({kind:"stale-schedule",scheduleId:n.id,url:n.url,detail:`no fire in ${l}h (expected every ${ss[n.cadence]}min)`})}}(n.lastNewViolationCount??0)>10&&a.push({kind:"large-regression",scheduleId:n.id,url:n.url,detail:`${n.lastNewViolationCount} new violations vs baseline`})}return a}function as(t){const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function Hs(t){try{return new URL(t).hostname+new URL(t).pathname.slice(0,30)}catch{return t}}function ns({buckets:t,height:s=36,width:a=220}){if(t.length===0)return null;const n=Math.max(1,...t.map(o=>o.totalViolations)),r=a/Math.max(1,t.length-1),i=t.map((o,c)=>{const p=c*r,d=s-o.totalViolations/n*(s-4)-2;return`${p.toFixed(1)},${d.toFixed(1)}`}),l=t.map((o,c)=>{const p=c*r,d=s-o.newViolations/n*(s-4)-2;return`${p.toFixed(1)},${d.toFixed(1)}`});return e.jsxs("svg",{width:a,height:s,role:"img","aria-label":"30-day violation trend",children:[e.jsx("polyline",{fill:"none",stroke:"#94a3b8",strokeWidth:"1.5",points:i.join(" ")}),e.jsx("polyline",{fill:"none",stroke:"#dc2626",strokeWidth:"1.5",points:l.join(" ")})]})}function Le({state:t,count:s}){const a={clean:"bg-emerald-100 text-emerald-800","new-violations":"bg-rose-100 text-rose-900",failed:"bg-amber-100 text-amber-900",pending:"bg-slate-100 text-slate-700"},n={clean:"clean","new-violations":"new violations",failed:"failed",pending:"pending"};return e.jsxs("div",{className:`px-2 py-1 rounded text-[11px] ${a[t]}`,children:[e.jsx("strong",{children:s})," ",n[t]]})}function Rl({item:t}){const s={"failed-run":"✗ Failed","stale-schedule":"⏳ Stale","large-regression":"⚠ Regression"},a={"failed-run":"text-rose-700","stale-schedule":"text-amber-700","large-regression":"text-rose-700"};return e.jsxs("li",{className:"border-l-2 border-slate-200 pl-2 py-1",children:[e.jsx("div",{className:`text-[11px] font-medium ${a[t.kind]}`,children:s[t.kind]}),e.jsx("div",{className:"text-[11px] font-mono break-all",children:Hs(t.url)}),e.jsx("div",{className:"text-[10px] text-slate-500",children:t.detail})]})}function El(){const[t,s]=m.useState([]),[a,n]=m.useState([]),[r,i]=m.useState(!0);m.useEffect(()=>{(async()=>{i(!0);try{const[u,h]=await Promise.all([ds(),Ca()]);s(u),n(h)}finally{i(!1)}})()},[]);const l=kl(t),o=Sl(t,5),c=Al(t,a,10),p=Bs(a,30),d=Il(t);return r?e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading dashboard…"}):t.length===0?e.jsxs("div",{className:"p-3 space-y-2 text-xs",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Nothing to summarize yet. Add a scheduled audit from the Schedules tab to start collecting cross-page compliance posture here."})]}):e.jsxs("div",{className:"p-3 space-y-4 text-xs","data-testid":"risk-view-root",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Risk dashboard"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Aggregate posture across every scheduled audit. Read-only — schedules themselves are managed in the Schedules tab."})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 space-y-2 bg-white",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:["Posture · ",l.enabledSchedules," enabled",l.pausedSchedules>0?` · ${l.pausedSchedules} paused`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Le,{state:"clean",count:l.cleanCount}),e.jsx(Le,{state:"new-violations",count:l.newViolationsCount}),e.jsx(Le,{state:"failed",count:l.failedCount}),e.jsx(Le,{state:"pending",count:l.pendingCount})]}),l.totalNewViolations>0&&e.jsxs("p",{className:"text-[11px] text-rose-700 font-medium","data-testid":"risk-total-new",children:[l.totalNewViolations," new WCAG violation",l.totalNewViolations===1?"":"s"," vs baseline across all schedules."]})]}),e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-trend-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"30-day trend"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ns,{buckets:p}),e.jsxs("div",{className:"text-[10px] text-slate-500 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-slate-400 mr-1"})," total violations"]}),e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-3 h-0.5 bg-rose-600 mr-1"})," new vs baseline"]}),e.jsxs("div",{className:"pt-1 text-slate-400",children:["Sum across ",l.enabledSchedules," schedule",l.enabledSchedules===1?"":"s"]})]})]})]}),d.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-actions-section",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:["Action items · ",d.length]}),e.jsx("ul",{className:"space-y-1.5",children:d.map((u,h)=>e.jsx(Rl,{item:u},`${u.kind}-${u.scheduleId}-${h}`))})]}),o.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-top-exposed-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Most exposed pages"}),e.jsx("ul",{className:"space-y-1.5",children:o.map(u=>{const h=Cl(u.scheduleId,a,14),x=h.some(g=>g.runs>0);return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-mono text-[11px] break-all",children:u.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[u.lastTotalViolations," total · ",u.cadence," ·"," ","last run ",u.lastRunAt?as(u.lastRunAt):"never"]})]}),x&&e.jsx("span",{className:"shrink-0",title:"Last 14 days · new violations vs baseline","data-testid":"risk-top-exposed-sparkline",children:e.jsx(ns,{buckets:h,height:20,width:56})}),u.lastNewViolationCount>0&&e.jsxs("span",{className:"shrink-0 text-[11px] font-semibold text-rose-700",children:["+",u.lastNewViolationCount," new"]})]},u.scheduleId)})})]}),c.length>0&&e.jsxs("section",{className:"border border-slate-200 rounded p-3 bg-white","data-testid":"risk-recent-section",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Recent activity"}),e.jsx("ul",{className:"space-y-1",children:c.map((u,h)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-[11px]",children:[e.jsx("span",{className:"text-slate-400 shrink-0",children:as(u.ranAt)}),e.jsx("span",{className:"font-mono truncate flex-1 min-w-0",children:Hs(u.scheduleUrl)}),u.error?e.jsx("span",{className:"text-rose-700 shrink-0",title:u.error,children:"failed"}):u.newVsBaselineViolations>0?e.jsxs("span",{className:"text-rose-700 shrink-0",children:["+",u.newVsBaselineViolations]}):e.jsx("span",{className:"text-emerald-700 shrink-0",children:"ok"})]},`${u.scheduleId}-${u.ranAt}-${h}`))})]})]})}const et="onboarding:dismissed",tt="onboarding:exportTried";function Tl(){const t=b(k=>k.tier),s=b(k=>k.results),a=b(k=>k.baselineList),[n,r]=m.useState(!1),[i,l]=m.useState(!1),[o,c]=m.useState(!1),[p,d]=m.useState(!1);m.useEffect(()=>{(async()=>{const k=await chrome.storage.local.get([et,tt]);r(k[et]===!0),c(k[tt]===!0);const v=["githubRepoUrl","jiraInstanceUrl","azureDevOpsProjectUrl","gitlabProjectUrl"],C=await Promise.all(v.map(N=>Z({type:"SETTINGS_GET",key:N})));d(C.some(N=>typeof N.data=="string"&&N.data.length>0)),l(!0)})()},[]);const u=[{id:"license",label:"Activate a license",state:t&&t!=="free"?"done":"pending"},{id:"audit",label:"Run your first audit",state:s.length>0?"done":"pending"},{id:"baseline",label:"Save a baseline",state:a.length>0?"done":"pending"},{id:"export",label:"Try an export (Delta tab → export menu)",state:o?"done":"pending"},{id:"tracker",label:"Set up an issue tracker",state:p?"done":"pending",optional:!0}],h=u.filter(k=>!k.optional),x=u.filter(k=>k.state==="done").length,g=h.filter(k=>k.state==="done").length,w=x===u.length,A=g===h.length;if(!i||n||A)return null;async function T(){r(!0),await chrome.storage.local.set({[et]:!0})}async function j(){const k=!o;c(k),await chrome.storage.local.set({[tt]:k})}return e.jsxs("div",{"data-testid":"onboarding-checklist",className:"border border-amber-200 bg-amber-50 rounded p-2.5 m-2 text-xs",role:"region","aria-label":"Onboarding checklist",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xs font-semibold text-amber-900",children:["Welcome to wcagcheckr · ",x," of ",u.length," done"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Quick checklist to get you started. ",w?"All steps complete — nice!":"Auto-checks as you go."]})]}),e.jsx("button",{type:"button",onClick:()=>void T(),"aria-label":"Dismiss onboarding checklist",className:"shrink-0 text-amber-800 hover:text-amber-950 text-base leading-none -mt-1",children:"✕"})]}),e.jsx("ul",{className:"space-y-1",children:u.map(k=>e.jsx("li",{className:"flex items-start gap-1.5",children:k.id==="export"?e.jsxs("label",{className:"flex items-start gap-1.5 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:k.state==="done",onChange:()=>void j(),className:"mt-0.5","aria-label":k.label}),e.jsx("span",{className:k.state==="done"?"line-through text-amber-700":"text-amber-900",children:k.label})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mt-0.5","aria-hidden":"true",children:k.state==="done"?"✓":"○"}),e.jsxs("span",{className:k.state==="done"?"line-through text-amber-700":"text-amber-900",children:[k.label,k.optional&&e.jsx("span",{className:"text-amber-600 ml-1",children:"(optional)"})]})]})},k.id))})]})}function $l(){const[t,s]=m.useState(""),[a,n]=m.useState(!1),[r,i]=m.useState(null);async function l(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const o=await te({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(o!=null&&o.validated)){const c=o!=null&&o.seatClaim&&"reason"in o.seatClaim?o.seatClaim.reason:null,p=o!=null&&o.seatClaim&&"hint"in o.seatClaim?o.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${p??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${o!=null&&o.seatClaim&&"message"in o.seatClaim?o.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(o){i(o instanceof Error?o.message:String(o))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:o=>s(o.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Pl(){const t=b(l=>l.view),s=b(l=>l.userMode),a=b(l=>l.tier),[n,r]=m.useState(!1);m.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const i=n&&Ea(a);return m.useEffect(()=>{const l=Pa(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),p=Da();xs({forceRefresh:!0}).catch(()=>{}),Fe().catch(()=>{}),Fa().catch(()=>{}),Ga().catch(()=>{}),Oa().catch(()=>{}),Ia().then(u=>{b.getState().setAcknowledgedKeys(new Set(u.map(h=>h.matchKey)))}).catch(()=>{}),Ra().then(u=>{u&&b.setState({siteCrawlReport:u})}).catch(()=>{});const d=u=>{if(u.key!=="Escape")return;const{pinnedMatchKey:h,setPinned:x,results:g}=b.getState();h&&(x(null),ae().then(w=>{var A;w&&le(w,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:w},(A=g[0])==null?void 0:A.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{p(),l.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx($l,{}),e.jsx(Ee,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(ti,{}),e.jsx(Ee,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(ki,{}),e.jsx(Qt,{}),e.jsx(Ee,{})]}):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(Ds,{}),e.jsx(js,{}),e.jsx(tn,{}),e.jsx(Tl,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(rn,{}),e.jsx(un,{}),e.jsx(Jr,{}),e.jsx(Yr,{}),e.jsx(hn,{}),e.jsx(qr,{}),e.jsx(Qr,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(In,{}),t==="report"&&e.jsx(Hn,{}),t==="delta"&&e.jsx(lr,{}),t==="activity"&&e.jsx(wr,{}),t==="guided"&&e.jsx(Ur,{}),t==="flows"&&e.jsx(Or,{}),t==="scorecard"&&e.jsx(Pr,{}),t==="crawl"&&e.jsx($s,{}),t==="forensic"&&e.jsx(Ls,{}),t==="compliance"&&e.jsx(fl,{}),t==="schedules"&&e.jsx(Nl,{}),t==="risk"&&e.jsx(El,{})]})]}),e.jsx(ei,{}),e.jsx(Xr,{}),e.jsx(Kr,{}),e.jsx(Qt,{}),e.jsx(Ee,{})]})}class Gl extends Ce.Component{constructor(){super(...arguments);kt(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{Pl as A,Gl as E,Fl as d};