@wcag-checkr/ci 1.0.0-rc.94 → 1.0.0-rc.96

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,19 +1,19 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-COzuc_9B.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-BSUQ7Is6.js","assets/forensic-log-46dfCeYC.js","assets/state-BIsozXtc.js"])))=>i.map(i=>d[i]);
2
- var Cs=Object.defineProperty;var Is=(t,s,a)=>s in t?Cs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var vt=(t,s,a)=>Is(t,typeof s!="symbol"?s+"":s,a);import{R as Se,i as ne,r as h,j as e,M as be,C as Ze,l as Rs,o as it,t as ot,m as Ht,s as zt,k as He}from"./styles-QO3WH6KW.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as ae,r as X,s as Y,c as Kt,b as ie,d as Ce}from"./crash-reporter-Dc5lvxvY.js";import{g as Es,a as te,u as Ts,b as $s,c as Ls,d as lt,e as qt,A as Q,l as ct,f as $e,h as Qt,i as _s,j as dt,s as Us,k as Os,O as Ds,m as Fs,n as Ms,o as yt,p as Ps,q as Yt,r as Gs,t as Vs,v as Ws,w as Bs,x as Hs,y as zs,T as Ks,z as qs,B as Qs}from"./forensic-log-46dfCeYC.js";import{B as ze,i as Jt,b as Xt,T as Zt}from"./state-BIsozXtc.js";import{getColorSuggestion as Ys,saveColorSuggestion as Js,saveColorSuggestions as Xs}from"./color-suggestion-store-ClqdzGNO.js";const jt=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const m=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,m))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,l);return l},Zs=t=>t?jt(t):jt,ea=t=>t;function ta(t,s=ea){const a=Se.useSyncExternalStore(t.subscribe,Se.useCallback(()=>s(t.getState()),[t,s]),Se.useCallback(()=>s(t.getInitialState()),[t,s]));return Se.useDebugValue(a),a}const wt=t=>{const s=Zs(t),a=n=>ta(s,n);return Object.assign(a,s),a},sa=t=>t?wt(t):wt,f=sa(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),Ue="sidePanel:lastAudit";function aa(){const t=[];return t.push(ae("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||ne.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ae("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;ne.polite(r),na({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(ae("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(ae("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ne.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ae("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ae("SCORECARD_UPDATED_EVENT",()=>{Oe()})),t.push(ae("LICENSE_CHANGED_EVENT",()=>{es()})),t.push(ae("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ne.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ae("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ne.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(ae("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ne.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function na(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Ue]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function ra(){const s=(await chrome.storage.local.get(Ue))[Ue];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ia(){await chrome.storage.local.remove(Ue)}async function Ve(){f.getState().clearResults(),await ia()}async function Oe(){const t=await X({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function es(t){const s=await X({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ts()}async function ts(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>xa);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function oa(){const s=(await X({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function la(){return chrome.runtime.connect({name:"audit-keepalive"})}let De=null;async function ca(){if(De===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(De=t.id)}catch{}}function ss(){if(De===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:De}).catch(()=>{})}function re(t){ss(),Y(t)}function da({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,o]=h.useState(!0),[l,c]=h.useState(""),[p,d]=h.useState(!1),[u,m]=h.useState(null);async function x(g){var v;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const N=await X({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});N.success?(m({ok:!0,msg:`Sent (ref: ${N.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((v=N.error)==null?void 0:v.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:l,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=>o(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 Nt({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 Fe=Kt("messages-client"),ua="https://api.wcagcheckr.com",as="wcagcheckr",pa=1e4;function ma(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ns(t,s){const a=await Es();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":ma()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ua}${t}`,{...s,headers:n,signal:AbortSignal.timeout(pa)})}async function ha(t){try{const s=await ns(`/v1/products/${as}/messages`,{userMode:t??null});return s.ok?await s.json():(Fe.warn("fetchMessages http",s.status),null)}catch(s){return Fe.warn("fetchMessages failed",s),null}}async function xe(t,s){try{const a=await ns(`/v1/products/${as}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Fe.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Fe.warn("ackMessage failed",a),!1}}const xa=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:xe,fetchMessages:ha},Symbol.toStringTag,{value:"Module"})),ga=["http:","https:"];function fa(t){try{const s=new URL(t);return ga.includes(s.protocol)}catch{return!1}}function kt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),c=t.slice(i+2,o);fa(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function rs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:kt(c)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:kt(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){o(),n.push(d[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const ba={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},va={critical:"bg-rose-50 border-rose-200"};function is(){const t=f(m=>m.unreadMessageCount),s=f(m=>m.messages),a=f(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[o,l]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,l(!0);const g=setTimeout(()=>l(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),xe(x.id,"seen")}function p(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await xe(m.id,"dismissed")}async function u(m){m.ctaUrl&&(a(m.id,"clicked"),xe(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(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=h.useRef(null);return h.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{ts()},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 ${ba[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(rs,{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 os(){const t=f(i=>i.messages),s=f(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await xe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),xe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${va.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(rs,{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 ve=["matrix","report","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function wa(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Na(){var u,m;const t=f(x=>x.view),s=f(x=>x.setView),a=f(x=>x.setUserMode),n=f(x=>x.results),r=f(x=>x.status),[i,o]=h.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((m=n[0])==null?void 0:m.scope),c=wa(l),p=n.length>0&&r!=="running";function d(){a("owner"),Y({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick: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(is,{}),e.jsx(Nt,{onClick:()=>void Y({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Nt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Ve(),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(ka,{view:t,setView:s}),e.jsx(be,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(da,{onClose:()=>o(!1)})})]})}function ka({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const o=(i+ve.length)%ve.length,l=ve[o];l&&(s(l),(c=a.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ve.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ve.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{a.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Sa({feature:t,upgradeUrl:s}){const[a,n]=h.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ze,{open:a,onClose:()=>n(!1)})]})}const Aa="https://wcagcheckr.com/upgrade";function Ca(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(null),[c,p]=h.useState(ze),[d,u]=h.useState(ze[0].id),m=f(_=>_.status),x=f(_=>_.tier),g=f(_=>_.results.length>0),v=m==="running";h.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"matrixPresets"}),X({type:"SETTINGS_GET",key:"activePresetId"})]).then(([_,w])=>{const O=Array.isArray(_.data)?_.data:null;p(O&&O.length>0?O:ze),typeof w.data=="string"&&u(w.data)})},[]);function N(_){const w=c.find(O=>O.id===_);w&&(u(_),Y({type:"SETTINGS_SET",key:"activePresetId",value:_}),Y({type:"SETTINGS_SET",key:"stateMatrix",value:w.matrix}))}const T=Jt(x,"storybookAutoIterate");h.useEffect(()=>{const _=ae("ELEMENT_PICKED_EVENT",(O,D)=>{n(!1);const F=D.frameId;$(F),i({selector:O.selector,frameId:F})}),w=ae("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{_(),w()}},[]);async function k(){const _=await te();_&&(n(!0),await ie(_,{type:"PICKER_ACTIVATE_REQUEST",tabId:_}))}function C(){r&&($(r.frameId),re({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function b(){if(!T){l("storybook:auto-iterate");return}$(),re({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function y(){$(),re({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function S(){$(),re({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function I(){$(),re({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function L(){$(),re({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function j(){Y({type:"CANCEL_AUDIT"})}async function $(_){f.getState().setPinned(null);const w=await te();if(w)try{await ie(w,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:w},_)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:_=>s(_.target.value),disabled:v||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:_=>N(_.target.value),disabled:v||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(_=>e.jsx("option",{value:_.id,children:_.name},_.id))}),t==="single-element"?e.jsx(Ia,{picking:a,picked:r,isRunning:v,onPick:k,onRun:C,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:S,disabled:v,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:v?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:I,disabled:v,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:v?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:L,disabled:v,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:v?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:y,disabled:v,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:v?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:b,disabled:v,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:v?"Auditing…":"Audit all stories"}),v&&e.jsx("button",{onClick:j,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!v&&g&&e.jsx("button",{type:"button",onClick:()=>void Ve(),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&&!v&&e.jsx(Ra,{selector:r.selector,onRepick:k,onClear:()=>i(null)})]}),e.jsx(be,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Sa,{feature:o??"",upgradeUrl:Aa})})]})}function Ia({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ra({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Ea={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Ta={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function $a(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState("off"),p=f(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await te();g&&(l(x),x==="off"?await ie(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await ie(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await te();if(g){if(t&&await ie(g,{type:Ea[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await ie(g,{type:Ta[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await te();if(x){if(a){await ie(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 Ce(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(ye,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ye,{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(ye,{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(ye,{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(ye,{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:m}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ye({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 La(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 _a(){const t=f(c=>c.status),s=f(c=>c.progress),a=f(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":La(s.currentState),o=n?100:s.current/s.total*100,l=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(St,{label:r,detail:i,pct:o,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),l&&e.jsx(St,{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 St({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const 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 Ua(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const Oa={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Me({violation:t,alreadyAcknowledged:s}){const a=f(k=>k.pinnedMatchKey),n=f(k=>k.pinnedFound),r=f(k=>k.setPinned),i=f(k=>{var C;return(C=k.results[0])==null?void 0:C.frameId}),o=f(k=>{var C;return(C=k.results[0])==null?void 0:C.scope}),l=f(k=>k.results),c=f(k=>k.acknowledgedKeys.has(t.matchKey)),p=f(k=>k.markAcknowledged),d=f(k=>k.markUnacknowledged),u=s||c,m=a===t.matchKey,x=m&&!n;async function g(k){try{return(await Ce(k,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:k,selector:t.target.selector},i)).found}catch{return!0}}async function v(){const k=await te();if(!k)return;if(m){r(null);try{await ie(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},i)}catch{}return}const C=await g(k);r(t.matchKey,C)}function N(k){k.stopPropagation(),t.currentState.breakpoint.width<=640&&ss(),(async()=>{const C=await te();if(!C)return;try{await X({type:"STATE_DRIVE_REQUEST",tabId:C,state:t.currentState,scope:o,frameId:i})}catch{}const b=await g(C);r(t.matchKey,b)})()}async function T(k){k.stopPropagation();const C=await te();if(!C)return;try{await X({type:"STATE_DRIVE_REQUEST",tabId:C,state:Pa(),scope:o,frameId:i})}catch{Y({type:"STATE_RESET_REQUEST",tabId:C})}const b=await g(C);r(t.matchKey,b)}return e.jsxs("button",{type:"button",onClick:v,"aria-pressed":m,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
- ${m?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Oa[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(Ga,{violation:t}),e.jsx(Ba,{violation:t}),e.jsx(Wa,{violation:t}),e.jsx(Va,{text:t.target.failureSummary}),e.jsx(Ha,{ruleId:t.ruleId}),m&&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: ",Da(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:N,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),N(k))},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:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),T(k))},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:k=>{k.stopPropagation(),d(t.matchKey),Ma(t,l)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.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:k=>{k.stopPropagation(),p(t.matchKey),Fa(t,l)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.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:k=>k.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Da(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function Fa(t,s){await $s({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await ls(t.componentId,s)}async function Ma(t,s){await Ts(t.componentId,t.matchKey),await ls(t.componentId,s)}async function ls(t,s){const a=s.flatMap(n=>n.violations);try{const n=await X({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function Pa(){const t=Xt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function cs(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function Ga({violation:t}){const s=cs(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 Va({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function Wa({violation:t}){const s=Ua(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function Ba({violation:t}){const s=cs(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ys(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await X({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(c=>c.matchKey===t.matchKey);l?(await Js(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Ha({ruleId:t}){const s=Ls(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const et=[{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 ut(t){const s=et.map(i=>za(i,t)),a=s.reduce((i,o)=>i+Ka(o.letter),0)/Math.max(1,s.length),n=qa(Math.round(a)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:n,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function za(t,s){const a=new Set(t.axeRules),n=s.violations.filter(w=>a.has(w.ruleId)),r=s.manualRuns.filter(w=>t.igtWorkflowIds.includes(w.workflowId)),i=t.igtWorkflowIds.map(w=>s.workflows.find(O=>O.id===w)).filter(w=>w!=null);let o=i.length>0;for(const w of i){const O=r.find(F=>F.workflowId===w.id);if((O?Object.keys(O.steps).length:0)!==w.steps.length){o=!1;break}}const l=r.some(w=>Object.keys(w.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(w=>c.includes(w.workflowId)),d=c.map(w=>s.workflows.find(O=>O.id===w)).filter(w=>w!=null);let u=c.length>0&&d.length===c.length;for(const w of d){const O=p.find(F=>F.workflowId===w.id);if((O?Object.keys(O.steps).length:0)!==w.steps.length){u=!1;break}}let m=null;if(u)for(const w of p)w.completedAt&&(m===null||w.completedAt>m)&&(m=w.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,v=s.interactiveAuditVerdicts,N=[];v&&(t.id==="tab-order"&&v.focusOrder&&N.push({verdict:v.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(v.keyboardTrap&&N.push({verdict:v.keyboardTrap,criterionId:"2.1.2"}),v.focusVisible&&N.push({verdict:v.focusVisible,criterionId:"2.4.7"})));const T=N.some(w=>w.verdict==="fail");if(N.length>0&&N.every(w=>w.verdict==="pass")&&c.length>0&&!u)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:N.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:N.map(w=>w.criterionId)};if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const C=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(C?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||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 S={critical:0,serious:0,moderate:0,minor:0};for(const w of lt(n))S[w.impact]++;N.length>0&&N.every(w=>w.verdict==="pass")||(S.serious+=x),T&&(S.serious+=N.filter(w=>w.verdict==="fail").length);for(const w of r){const O=i.find(D=>D.id===w.workflowId);if(O)for(const D of O.steps){const F=w.steps[D.id];(F==null?void 0:F.status)==="fail"&&(D.severity==="required"?S.serious++:S.moderate++)}}const L=S.critical>0,j=S.serious>0;let $;S.critical>=5?$="F":S.critical>=1?$="D":S.serious>=1?$="C":S.moderate>=1?$="B":$="A";const _=$!=="A"&&(b&&!o||c.length>0&&!u);return{id:t.id,label:t.label,letter:$,untested:!1,needsIgt:_,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:S,caps:{cappedAtC:L,cappedAtB:j}}}function Ka(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function qa(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const tt="dismissedFindings";function We(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ge(t){return`reading-order::${t}`}function fe(t){return`tab-order::${t}`}async function Be(){try{const t=await chrome.storage.local.get(tt),s=t==null?void 0:t[tt];if(s&&typeof s=="object")return s}catch{}return{}}async function pt(t){await chrome.storage.local.set({[tt]:t})}async function Pe(t){return(await Be())[We(t)]??{}}async function ds(t,s,a,n){const r=await Be(),i=We(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await pt(r)}async function Ie(t,s){if(s.length===0)return;const a=await Be(),n=We(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await pt(a)}async function us(t,s){const a=await Be(),n=We(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await pt(a))}const Vi=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:ds,addDismissals:Ie,dismissalKeyForReadingOrder:ge,dismissalKeyForTabOrder:fe,getDismissalsForUrl:Pe,removeDismissal:us},Symbol.toStringTag,{value:"Module"}));function ps(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ms(t){return`${ct(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Qa(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=ms(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 At={critical:0,serious:1,moderate:2,minor:3};function Ya(){var T,k,C,b;const t=f(y=>y.results),s=f(y=>y.componentId),a=f(y=>y.setView),n=((T=t[0])==null?void 0:T.pageUrl)??((k=t[0])==null?void 0:k.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(new Set),[c,p]=h.useState({});if(h.useEffect(()=>{if(!s){p({});return}let y=!1;const S=async()=>{const L=await qt(s);if(y)return;const j={};for(const $ of L)$.criterionId==="2.4.3"?j.focusOrder=$.verdict:$.criterionId==="2.1.2"?j.keyboardTrap=$.verdict:$.criterionId==="2.4.7"&&(j.focusVisible=$.verdict);p(j)};S();const I=L=>{L.interactiveAuditResults&&S()};return chrome.storage.local.onChanged.addListener(I),()=>{y=!0,chrome.storage.local.onChanged.removeListener(I)}},[s]),h.useEffect(()=>{if(!n)return;Pe(n).then(i);const y=()=>{document.visibilityState==="visible"&&n&&Pe(n).then(i)};return document.addEventListener("visibilitychange",y),()=>document.removeEventListener("visibilitychange",y)},[n]),h.useEffect(()=>{if(!s){l(new Set);return}let y=!1;const S=async()=>{const L=await chrome.storage.local.get("igtRuns");if(y)return;const $=((L==null?void 0:L.igtRuns)??{})[s]??{},_=new Set;for(const w of Q){const O=$[w.id];O&&Object.keys(O.steps).length===w.steps.length&&_.add(w.id)}l(_)};S();const I=()=>{document.visibilityState==="visible"&&S()};return document.addEventListener("visibilitychange",I),()=>{y=!0,document.removeEventListener("visibilitychange",I)}},[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((y,S)=>y+S.durationMs,0),u=t.reduce((y,S)=>y+S.violations.length,0),m=Qa(t);m.sort((y,S)=>{const I=At[y.representative.impact]??99,L=At[S.representative.impact]??99;return I!==L?I-L:S.states.length-y.states.length});const x=t.map(y=>ps(y.state)).join(`
4
- `),g=c.focusOrder!==void 0,v=o.has("keyboard")||g?0:(((C=t[0])==null?void 0:C.tabOrderIssues)??[]).filter(y=>!(fe(y.selector)in r)).length,N=o.has("page-structure")?0:(((b=t[0])==null?void 0:b.readingOrderIssues)??[]).filter(y=>!(ge(y.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(en,{violations:t.flatMap(y=>y.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(v>0||N>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:[v>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:v})," tab-order issue",v===1?"":"s"," (WCAG 2.4.3)"]}),v>0&&N>0&&" · ",N>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:N})," reading-order issue",N===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),m.length>0&&e.jsx(sn,{interactiveVerdicts:c,findingCount:m.length}),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"]})," · ",m.length," unique ",m.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",u," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(Xa,{groups:m,totalStates:t.length,violations:t.flatMap(y=>y.violations),interactiveVerdicts:c})]})}const Ja={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 Xa({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=ut({violations:a,auditRan:!0,manualRuns:[],workflows:Q,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,o=new Set;for(const c of et){for(const p of c.axeRules)o.add(p);i.set(c.id,[])}const l=[];for(const c of t){let p=!1;for(const d of et)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),p=!0;break}p||l.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(Ct,{subGrade:c,groups:p,totalStates:s},c.id)}),l.length>0&&e.jsx(Ct,{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:l,totalStates:s})]})}function Ct({subGrade:t,groups:s,totalStates:a}){const[n,r]=h.useState(!1),[i,o]=h.useState("idle"),[l,c]=h.useState(null),[p,d]=h.useState(0),u=s.length>0,m=Ja[t.letter],x=s.filter(N=>N.representative.ruleId==="color-contrast"||N.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function v(N){N.stopPropagation(),o("loading"),c(null);try{const T=x.map(C=>{const b=C.representative.target.outerHTML,y=C.representative.target.failureSummary,S=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(y),I=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(y);if(!S||!I)return null;const L=C.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:C.representative.matchKey,foreground:S[1],background:I[1],fontSize:16,fontWeight:400,targetLevel:L,_html:b}}).filter(C=>C!==null);if(T.length===0){o("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const k=await X({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:C,...b})=>b)});if(k.unavailableReason&&k.results.length===0){o("error"),c(k.unavailableReason);return}await Xs(k.results),o("done"),d(C=>C+1),n||r(!0)}catch(T){o("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(N=>!N),"aria-expanded":n,disabled:!u,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${m}`,"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:N=>void v(N),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),v(N))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${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"&&l&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:l}),n&&u&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(N=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Me,{violation:N.representative}),e.jsx(tn,{states:N.states,totalStates:a})]},`${ms(N.representative)}::${p}`))})]})}const Za={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=f(p=>p.setView),o=ut({violations:t,auditRan:!0,manualRuns:a,workflows:Q,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=lt(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 ${Za[o]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:o})}),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(ps))),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]})]})}function sn({interactiveVerdicts:t,findingCount:s}){const a=f(v=>v.results),n=f(v=>v.componentId),r=f(v=>v.delta),i=f(v=>v.siteCrawlReport),[o,l]=h.useState(!1),[c,p]=h.useState(!1),[d,u]=h.useState(null),m=[t.focusOrder,t.keyboardTrap,t.focusVisible].filter(Boolean).length,x=[t.focusOrder,t.keyboardTrap,t.focusVisible].filter(v=>v==="fail").length;async function g(){if(a.length!==0){l(!0),u(null);try{const{copyAiFixerPrompt:v}=await Ge(async()=>{const{copyAiFixerPrompt:N}=await import("./copy-ai-fixer-prompt-COzuc_9B.js");return{copyAiFixerPrompt:N}},__vite__mapDeps([0,1,2]));await v({results:a,componentId:n,delta:r,siteCrawlReport:i}),p(!0),setTimeout(()=>p(!1),4e3)}catch(v){u(v instanceof Error?v.message:String(v))}finally{l(!1)}}}return e.jsxs("div",{className:"border border-sky-200 bg-sky-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🤖"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-sky-900",children:"Fix everything with your AI coder"}),e.jsxs("p",{className:"text-[11px] text-sky-800 leading-snug mt-0.5",children:["Copy a complete fix-instruction prompt covering all"," ",e.jsx("strong",{children:s})," finding",s===1?"":"s",m>0&&e.jsxs(e.Fragment,{children:[" ","+ ",e.jsx("strong",{children:m})," AI keyboard walkthrough",m===1?"":"s",x>0&&e.jsxs("span",{className:"text-rose-700",children:[" ","(",x," fail",x===1?"":"s"," to address)"]})]}),". Paste into Cursor / Claude Code / your AI fixer to get every issue resolved in code. Re-run the audit afterward to confirm."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void g(),disabled:o,className:"text-[12px] px-3 py-1.5 bg-sky-600 text-white rounded hover:bg-sky-700 disabled:opacity-50 font-medium",children:o?"Building prompt…":c?"✓ Copied — paste into your AI fixer":"Copy AI-fixer prompt to clipboard"}),d&&e.jsxs("span",{className:"text-[11px] text-rose-700",children:["Failed: ",d]})]})]})}const an={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},nn={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 rn({violations:t,componentId:s}){var se,pe,ce,oe,B,le,me;const[a,n]=h.useState([]),[r,i]=h.useState([]),[o,l]=h.useState(new Set),[c,p]=h.useState(null),[d,u]=h.useState({}),[m,x]=h.useState(new Set),g=f(R=>R.status),v=f(R=>R.progress),N=f(R=>R.freshThisSession),T=f(R=>R.results),k=(se=T[0])==null?void 0:se.startedAt,C=((pe=T[0])==null?void 0:pe.pageUrl)??((ce=T[0])==null?void 0:ce.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let R=!1;return chrome.storage.local.get("igtRuns").then(z=>{if(R)return;const K=((z==null?void 0:z.igtRuns)??{})[s]??{};n(Object.values(K))}),()=>{R=!0}},[s]),h.useEffect(()=>{if(!C){i([]);return}let R=!1;return $e(C).then(z=>{R||i(z)}),()=>{R=!0}},[C]),g==="running")return e.jsx(mn,{current:v==null?void 0:v.current,total:v==null?void 0:v.total});const b=ut({violations:t,auditRan:T.length>0,manualRuns:a,workflows:Q,heuristicCounts:{tabOrder:((B=(oe=T[0])==null?void 0:oe.tabOrderIssues)==null?void 0:B.length)??0,readingOrder:((me=(le=T[0])==null?void 0:le.readingOrderIssues)==null?void 0:me.length)??0}}),y=f(R=>R.acknowledgedKeys),S=T.length>0?Qt(T,{runs:a,workflows:Q},"2.1","AA",y,r):void 0,I=T.length>0?_s(dt({audits:T,igtRuns:a,workflows:Q,acknowledgedMatchKeys:y,incompleteResolutions:r}),Q):void 0,L=S?S.failingCriteria.length>0||S.inconclusiveCriteria.length>0:!1,j=L&&b.overallLetter==="A"?"B":b.overallLetter;async function $(R){var de;if(!C||!((de=S==null?void 0:S.inconclusiveReasons)!=null&&de[R]))return;const Z=S.inconclusiveReasons[R].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(Z.length===0)return;l(J=>new Set(J).add(R)),p(null);const K=[];let H=0;try{for(const q of Z){const A=await Y({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:q.ruleOrStepId,pageUrl:q.pageUrl??C,wcagCriterion:R,elements:q.elements??[],targetLevel:"AA"});if(A!=null&&A.unavailableReason){p(A.unavailableReason);break}A!=null&&A.resolutions&&(K.push(...A.resolutions),H+=A.totalCostUsd??0)}if(C){const q=await $e(C);i(q)}const J={total:K.length,pass:K.filter(q=>q.verdict==="pass").length,fail:K.filter(q=>q.verdict==="fail").length,uncertain:K.filter(q=>q.verdict==="uncertain").length,costUsd:H,resolutions:K};u(q=>({...q,[R]:J}))}finally{l(J=>{const q=new Set(J);return q.delete(R),q})}}function _(R){x(z=>{const Z=new Set(z);return Z.has(R)?Z.delete(R):Z.add(R),Z})}async function w(R){var A,G;if(!C)return;const z=((A=S==null?void 0:S.inconclusiveReasons)==null?void 0:A[R])??[],Z=((G=S==null?void 0:S.failingReasons)==null?void 0:G[R])??[],K=[],H=new Set;for(const U of z){if(U.source!=="axe-incomplete"||!U.elements)continue;const M=U.pageUrl??C;for(const V of U.elements){const W=`${M}::${U.ruleOrStepId}::${V.selector}`;H.has(W)||(H.add(W),K.push({ruleId:U.ruleOrStepId,pageUrl:M,selector:V.selector}))}}for(const U of Z){if(U.source!=="ai"||!U.selector)continue;const M=U.ruleOrStepId.startsWith("ai-resolved::")?U.ruleOrStepId.slice(13):U.ruleOrStepId,V=U.pageUrl??C,W=`${V}::${M}::${U.selector}`;H.has(W)||(H.add(W),K.push({ruleId:M,pageUrl:V,selector:U.selector}))}if(K.length===0)return;const de=new Date().toISOString(),J=[];for(const U of K){const M=r.find(V=>V.pageUrl===U.pageUrl&&V.ruleId===U.ruleId&&V.selector===U.selector);M&&M.verdict==="pass"&&M.reasoning.startsWith("Marked as visually verified")||J.push({pageUrl:U.pageUrl,ruleId:U.ruleId,selector:U.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${de.slice(0,10)}.`,resolvedAt:de,costUsd:0,wcagCriterion:R})}if(J.length===0)return;await Us(J);const q=await $e(C);i(q),u(U=>({...U,[R]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const O=(()=>{if(!L||b.overallLetter!=="A"||!S)return null;const R=S.inconclusiveCriteria.length,z=S.failingCriteria.length,Z=[];z>0&&Z.push(`${z} WCAG ${S.targetLevel} ${z===1?"criterion":"criteria"} failing`),R>0&&Z.push(`${R} WCAG ${S.targetLevel} ${R===1?"criterion":"criteria"} inconclusive`);const K=z>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${Z.join(" + ")}. ${K}`})();let D=0;for(const R of Q){const z=a.find(K=>K.workflowId===R.id);if(!z)continue;R.steps.every(K=>{const H=z.steps[K.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"})&&D++}const F=lt(t.filter(R=>!y.has(R.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!N&&k&&e.jsx(hn,{scannedAt:k}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${an[j]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:j})}),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 ",b.subGrades.length," verification areas below. Untested areas count as F until verified."]}),O&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:O})]})]}),b.isLawsuitRisk&&e.jsx(cn,{areas:b.warningAreas}),e.jsx(dn,{grades:b.subGrades}),S&&e.jsx(on,{coverage:S,onResolveWithAi:$,onMarkVisuallyVerified:w,resolving:o,resolveError:c,lastResolveResult:d,expandedResultFor:m,onToggleResultDetail:_}),I&&e.jsx(ln,{layers:I}),e.jsx(pn,{violationsRemaining:F,manualCompleted:D,manualTotal:Q.length}),D>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:D})," of ",e.jsx("strong",{children:Q.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${D/Q.length*100}%`}})})]}):null]})}function on({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=h.useState(c>0&&c<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),m=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 ${m?"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 ${m?"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,"%)"]}),m&&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)."]}),!m&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const v=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 ",v,"."]})})(),!m&&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."]}),!m&&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."]})]}),!m&&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&&!m&&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(v=>{var I,L;const N=g.kind==="inconclusive"?(I=t.inconclusiveReasons)==null?void 0:I[v]:void 0,T=g.kind==="failing"?(L=t.failingReasons)==null?void 0:L[v]:void 0,k=N==null?void 0:N.some(j=>j.source==="axe-incomplete"&&j.elements&&j.elements.length>0),C=T==null?void 0:T.some(j=>j.source==="ai"),b=(n==null?void 0:n.has(v))??!1,y=i==null?void 0:i[v],S=(o==null?void 0:o.has(v))??!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:["· ",v]}),(g.kind==="inconclusive"&&k||g.kind==="failing"&&C)&&(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:b,onClick:()=>s(v),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:b?"Resolving…":y?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>a(v),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"})]})]}),y&&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 ",y.total," ",y.total===1?"verdict":"verdicts",":",y.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",y.pass," pass"]}),y.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",y.fail," fail"]}),y.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",y.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",y.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(v),className:"ml-auto text-[10px] underline text-brand-700",children:S?"hide reasoning":"show reasoning"})]}),y.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",y.uncertain," ",y.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),y.pass===y.total&&y.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."]}),S&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:y.resolutions.map((j,$)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:j.verdict==="pass"?"text-emerald-700 font-semibold":j.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:j.verdict==="pass"?"✓":j.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:j.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:j.reasoning})]},$))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((j,$)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[j.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:j.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),j.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:j.ruleOrStepId})," fail — "]}),j.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:j.ruleOrStepId})," fail — "]}),j.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:j.selector}),j.notes&&e.jsx("span",{className:"text-rose-700",children:j.notes})]},$))}),N&&N.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:N.map((j,$)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[j.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:j.ruleOrStepId})," — "]}),j.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:j.ruleOrStepId})," skipped — "]}),j.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:j.ruleOrStepId})," — "]}),j.resolutionHint,j.elements&&j.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",j.elements.length===1?"element":`${j.elements.length} elements`,":"," ",j.elements.slice(0,3).map((_,w,O)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:_.selector}),w<O.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},w)),j.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",j.elements.length-3," more"]})]})]},$))}):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.)"})]},v)})})]},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 It={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 ln({layers:t}){const s=f(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,c=r.cleared,p=i>0&&o===0&&l===0,d=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:It[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:It[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function cn({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 dn({grades:t}){const s=f(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${nn[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(un,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function un({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=Q.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?hs(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=f(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const c=l===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function mn({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 hn({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 (",hs(s)," old). Re-scan to grade the current page state."]})]})}function hs(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 xn(){const t=f(a=>a.results),s=f(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(rn,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(gn,{})]})}function gn(){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(we,{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(we,{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(we,{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(we,{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(we,{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 we({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 fn={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 bn({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Me,{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 ${fn[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Me,{violation:c},p))})]})}function vn(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"};function xs({open:t,onClose:s,format:a,content:n,filename:r}){const i=Rs(new Blob([n]).size);function o(){ot(n,r),s()}function l(){it(n),s()}return e.jsxs(be,{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:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Rt=7800;function jn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
6
- `),c=new URLSearchParams({title:i,body:l});let p=`${n}/issues/new?${c.toString()}`;return p.length>Rt&&(p=p.slice(0,Rt)),{url:p,title:i,body:l}}const Et=7800;function wn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`Rule: ${d.ruleId} (${d.impact})`),o.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),o.push(`Description: ${d.description}`),o.push(`Selector: ${d.target.selector}`),o.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&o.push(`More info: ${d.helpUrl}`),o.push(""),o.push(`HTML: ${d.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
7
- `),c=new URLSearchParams({summary:i,description:l});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>Et&&(p=p.slice(0,Et)),{url:p,summary:i,description:l}}const Tt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Nn=["wcag-component-auditor","wcag-forensic-log"];async function kn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Tt);s=Object.keys(n).length,await chrome.storage.local.remove(Tt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Nn)try{await Sn(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 Sn(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}function An(){const t=f(j=>j.delta),s=f(j=>j.componentId),a=f(j=>j.results),n=f(j=>j.tier),r=f(j=>j.baselineList),i=f(j=>j.siteCrawlReport),[o,l]=h.useState(""),[c,p]=h.useState(""),[d,u]=h.useState(!1),[m,x]=h.useState(!1),[g,v]=h.useState(null),[N,T]=h.useState(null);h.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"githubRepoUrl"}),X({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([j,$])=>{l(typeof j.data=="string"?j.data:""),p(typeof $.data=="string"?$.data:"")})},[]);const k=Jt(n,"exportJson"),C=Zt[n].maxBaselines,b=r.some(j=>j.componentId===s),y=b||r.length<C;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 S(){if(!s||a.length===0)return;const j=a.flatMap(se=>se.violations),$=a.flatMap(se=>se.announcements??[]),_=a.flatMap(se=>se.focusEvents??[]),w=a[0],D=(await X({type:"SETTINGS_GET",key:"stateMatrix"})).data??Xt;await Y({type:"BASELINE_SET",componentId:s,violations:j,announcements:$,focusEvents:_,snapshotMeta:{url:window.location.href,axeVersion:w.axeVersion,matrixConfig:D,capturedAt:new Date().toISOString()}});const F=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:j,announcements:$,focusEvents:_,currentMatrix:D});f.getState().setDelta(F.delta),ne.polite(`Baseline saved for ${s}.`)}async function I(){if(!s||!b||!window.confirm(`Remove the saved baseline for "${s}"?
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-jQDU30Cp.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-DCeEGNkg.js","assets/forensic-log-C7yfaAkj.js","assets/state-BIsozXtc.js"])))=>i.map(i=>d[i]);
2
+ var Cs=Object.defineProperty;var Is=(t,s,a)=>s in t?Cs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var vt=(t,s,a)=>Is(t,typeof s!="symbol"?s+"":s,a);import{R as Se,i as ne,r as h,j as e,M as be,C as Xe,l as Rs,o as rt,t as it,m as Ht,s as zt,k as Be}from"./styles-DhnON7zr.js";import{_ as ot}from"./preload-helper-D7HrI6pR.js";import{o as ae,r as X,s as Y,c as Kt,b as ie,d as Ce}from"./crash-reporter-Dc5lvxvY.js";import{g as Es,a as te,b as Ts,u as $s,c as Ls,s as _s,d as Us,e as lt,f as qt,A as Q,l as ct,h as Os,i as $e,j as Qt,k as Ds,m as dt,n as Fs,o as Ms,O as Ps,p as Gs,q as Vs,r as yt,t as Ws,v as Yt,w as Bs,x as Hs,y as zs,z as Ks,B as qs,C as Qs,T as Ys,D as Js,E as Xs}from"./forensic-log-C7yfaAkj.js";import{B as He,i as Jt,b as Xt,T as Zt}from"./state-BIsozXtc.js";const jt=t=>{let s;const a=new Set,n=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const m=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),a.forEach(x=>x(s,m))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>c,subscribe:p=>(a.add(p),()=>a.delete(p))},c=s=t(n,r,l);return l},Zs=t=>t?jt(t):jt,ea=t=>t;function ta(t,s=ea){const a=Se.useSyncExternalStore(t.subscribe,Se.useCallback(()=>s(t.getState()),[t,s]),Se.useCallback(()=>s(t.getInitialState()),[t,s]));return Se.useDebugValue(a),a}const wt=t=>{const s=Zs(t),a=n=>ta(s,n);return Object.assign(a,s),a},sa=t=>t?wt(t):wt,f=sa(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),Ue="sidePanel:lastAudit";function aa(){const t=[];return t.push(ae("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||ne.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ae("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;ne.polite(r),na({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(ae("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(ae("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ne.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ae("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ae("SCORECARD_UPDATED_EVENT",()=>{Oe()})),t.push(ae("LICENSE_CHANGED_EVENT",()=>{es()})),t.push(ae("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ne.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ae("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ne.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(ae("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ne.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function na(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Ue]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function ra(){const s=(await chrome.storage.local.get(Ue))[Ue];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ia(){await chrome.storage.local.remove(Ue)}async function Ge(){f.getState().clearResults(),await ia()}async function Oe(){const t=await X({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function es(t){const s=await X({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ts()}async function ts(){const{fetchMessages:t}=await ot(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>xa);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function oa(){const s=(await X({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function la(){return chrome.runtime.connect({name:"audit-keepalive"})}let De=null;async function ca(){if(De===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(De=t.id)}catch{}}function ss(){if(De===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:De}).catch(()=>{})}function re(t){ss(),Y(t)}function da({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,o]=h.useState(!0),[l,c]=h.useState(""),[p,d]=h.useState(!1),[u,m]=h.useState(null);async function x(g){var w;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const k=await X({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});k.success?(m({ok:!0,msg:`Sent (ref: ${k.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((w=k.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:l,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=>o(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 Nt({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 Fe=Kt("messages-client"),ua="https://api.wcagcheckr.com",as="wcagcheckr",pa=1e4;function ma(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function ns(t,s){const a=await Es();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":ma()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ua}${t}`,{...s,headers:n,signal:AbortSignal.timeout(pa)})}async function ha(t){try{const s=await ns(`/v1/products/${as}/messages`,{userMode:t??null});return s.ok?await s.json():(Fe.warn("fetchMessages http",s.status),null)}catch(s){return Fe.warn("fetchMessages failed",s),null}}async function xe(t,s){try{const a=await ns(`/v1/products/${as}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Fe.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Fe.warn("ackMessage failed",a),!1}}const xa=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:xe,fetchMessages:ha},Symbol.toStringTag,{value:"Module"})),ga=["http:","https:"];function fa(t){try{const s=new URL(t);return ga.includes(s.protocol)}catch{return!1}}function kt(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),c=t.slice(i+2,o);fa(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function rs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:kt(c)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,p)=>e.jsx("li",{children:kt(c)},p))},`u-${i++}`)),n=[])}for(const c of s){const p=c.trimEnd();if(p===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){o(),n.push(d[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const ba={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},va={critical:"bg-rose-50 border-rose-200"};function is(){const t=f(m=>m.unreadMessageCount),s=f(m=>m.messages),a=f(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[o,l]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,l(!0);const g=setTimeout(()=>l(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),xe(x.id,"seen")}function p(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await xe(m.id,"dismissed")}async function u(m){m.ctaUrl&&(a(m.id,"clicked"),xe(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(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=h.useRef(null);return h.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{ts()},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 ${ba[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(rs,{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 os(){const t=f(i=>i.messages),s=f(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await xe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),xe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${va.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(rs,{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 ve=["matrix","report","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function wa(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Na(){var u,m;const t=f(x=>x.view),s=f(x=>x.setView),a=f(x=>x.setUserMode),n=f(x=>x.results),r=f(x=>x.status),[i,o]=h.useState(!1),l=((u=n[0])==null?void 0:u.pageUrl)??((m=n[0])==null?void 0:m.scope),c=wa(l),p=n.length>0&&r!=="running";function d(){a("owner"),Y({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick: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(is,{}),e.jsx(Nt,{onClick:()=>void Y({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Nt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void Ge(),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(ka,{view:t,setView:s}),e.jsx(be,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(da,{onClose:()=>o(!1)})})]})}function ka({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const o=(i+ve.length)%ve.length,l=ve[o];l&&(s(l),(c=a.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ve.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ve.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{a.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Sa({feature:t,upgradeUrl:s}){const[a,n]=h.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Xe,{open:a,onClose:()=>n(!1)})]})}const Aa="https://wcagcheckr.com/upgrade";function Ca(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(null),[c,p]=h.useState(He),[d,u]=h.useState(He[0].id),m=f(_=>_.status),x=f(_=>_.tier),g=f(_=>_.results.length>0),w=m==="running";h.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"matrixPresets"}),X({type:"SETTINGS_GET",key:"activePresetId"})]).then(([_,j])=>{const O=Array.isArray(_.data)?_.data:null;p(O&&O.length>0?O:He),typeof j.data=="string"&&u(j.data)})},[]);function k(_){const j=c.find(O=>O.id===_);j&&(u(_),Y({type:"SETTINGS_SET",key:"activePresetId",value:_}),Y({type:"SETTINGS_SET",key:"stateMatrix",value:j.matrix}))}const T=Jt(x,"storybookAutoIterate");h.useEffect(()=>{const _=ae("ELEMENT_PICKED_EVENT",(O,D)=>{n(!1);const F=D.frameId;$(F),i({selector:O.selector,frameId:F})}),j=ae("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{_(),j()}},[]);async function N(){const _=await te();_&&(n(!0),await ie(_,{type:"PICKER_ACTIVATE_REQUEST",tabId:_}))}function C(){r&&($(r.frameId),re({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function b(){if(!T){l("storybook:auto-iterate");return}$(),re({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function v(){$(),re({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function S(){$(),re({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function I(){$(),re({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function L(){$(),re({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function y(){Y({type:"CANCEL_AUDIT"})}async function $(_){f.getState().setPinned(null);const j=await te();if(j)try{await ie(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},_)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:_=>s(_.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:_=>k(_.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(_=>e.jsx("option",{value:_.id,children:_.name},_.id))}),t==="single-element"?e.jsx(Ia,{picking:a,picked:r,isRunning:w,onPick:N,onRun:C,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:S,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:I,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:L,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: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 iframes"}):e.jsx("button",{onClick:b,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 Ge(),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(Ra,{selector:r.selector,onRepick:N,onClear:()=>i(null)})]}),e.jsx(be,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Sa,{feature:o??"",upgradeUrl:Aa})})]})}function Ia({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ra({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Ea={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Ta={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function $a(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState("off"),p=f(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await te();g&&(l(x),x==="off"?await ie(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await ie(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function u(x){const g=await te();if(g){if(t&&await ie(g,{type:Ea[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await ie(g,{type:Ta[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await te();if(x){if(a){await ie(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 Ce(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(ye,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(ye,{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(ye,{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(ye,{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(ye,{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:m}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ye({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 La(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 _a(){const t=f(c=>c.status),s=f(c=>c.progress),a=f(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":La(s.currentState),o=n?100:s.current/s.total*100,l=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(St,{label:r,detail:i,pct:o,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),l&&e.jsx(St,{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 St({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const 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 Ua(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const Oa={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Me({violation:t,alreadyAcknowledged:s}){const a=f(N=>N.pinnedMatchKey),n=f(N=>N.pinnedFound),r=f(N=>N.setPinned),i=f(N=>{var C;return(C=N.results[0])==null?void 0:C.frameId}),o=f(N=>{var C;return(C=N.results[0])==null?void 0:C.scope}),l=f(N=>N.results),c=f(N=>N.acknowledgedKeys.has(t.matchKey)),p=f(N=>N.markAcknowledged),d=f(N=>N.markUnacknowledged),u=s||c,m=a===t.matchKey,x=m&&!n;async function g(N){try{return(await Ce(N,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:N,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const N=await te();if(!N)return;if(m){r(null);try{await ie(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},i)}catch{}return}const C=await g(N);r(t.matchKey,C)}function k(N){N.stopPropagation(),t.currentState.breakpoint.width<=640&&ss(),(async()=>{const C=await te();if(!C)return;try{await X({type:"STATE_DRIVE_REQUEST",tabId:C,state:t.currentState,scope:o,frameId:i})}catch{}const b=await g(C);r(t.matchKey,b)})()}async function T(N){N.stopPropagation();const C=await te();if(!C)return;try{await X({type:"STATE_DRIVE_REQUEST",tabId:C,state:Pa(),scope:o,frameId:i})}catch{Y({type:"STATE_RESET_REQUEST",tabId:C})}const b=await g(C);r(t.matchKey,b)}return e.jsxs("button",{type:"button",onClick:w,"aria-pressed":m,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
+ ${m?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Oa[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(Ga,{violation:t}),e.jsx(Ba,{violation:t}),e.jsx(Wa,{violation:t}),e.jsx(Va,{text:t.target.failureSummary}),e.jsx(Ha,{ruleId:t.ruleId}),m&&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: ",Da(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:k,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k(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),Ma(t,l)},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),Fa(t,l)},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 Da(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function Fa(t,s){await Ls({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await ls(t.componentId,s)}async function Ma(t,s){await $s(t.componentId,t.matchKey),await ls(t.componentId,s)}async function ls(t,s){const a=s.flatMap(n=>n.violations);try{const n=await X({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function Pa(){const t=Xt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function cs(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function Ga({violation:t}){const s=cs(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 Va({text:t}){return t?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-slate-500 cursor-pointer hover:text-slate-700",children:"Show failure detail"}),e.jsx("pre",{className:"text-[11px] text-slate-600 whitespace-pre-wrap mt-1 bg-slate-50 p-1.5 rounded",children:t})]}):null}function Wa({violation:t}){const s=Ua(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function Ba({violation:t}){const s=cs(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ts(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await X({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(c=>c.matchKey===t.matchKey);l?(await _s(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Ha({ruleId:t}){const s=Us(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 Ze=[{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 ut(t){const s=Ze.map(i=>za(i,t)),a=s.reduce((i,o)=>i+Ka(o.letter),0)/Math.max(1,s.length),n=qa(Math.round(a)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:n,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function za(t,s){const a=new Set(t.axeRules),n=s.violations.filter(j=>a.has(j.ruleId)),r=s.manualRuns.filter(j=>t.igtWorkflowIds.includes(j.workflowId)),i=t.igtWorkflowIds.map(j=>s.workflows.find(O=>O.id===j)).filter(j=>j!=null);let o=i.length>0;for(const j of i){const O=r.find(F=>F.workflowId===j.id);if((O?Object.keys(O.steps).length:0)!==j.steps.length){o=!1;break}}const l=r.some(j=>Object.keys(j.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(j=>c.includes(j.workflowId)),d=c.map(j=>s.workflows.find(O=>O.id===j)).filter(j=>j!=null);let u=c.length>0&&d.length===c.length;for(const j of d){const O=p.find(F=>F.workflowId===j.id);if((O?Object.keys(O.steps).length:0)!==j.steps.length){u=!1;break}}let m=null;if(u)for(const j of p)j.completedAt&&(m===null||j.completedAt>m)&&(m=j.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,k=[];w&&(t.id==="tab-order"&&w.focusOrder&&k.push({verdict:w.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(w.keyboardTrap&&k.push({verdict:w.keyboardTrap,criterionId:"2.1.2"}),w.focusVisible&&k.push({verdict:w.focusVisible,criterionId:"2.4.7"})));const T=k.some(j=>j.verdict==="fail");if(k.length>0&&k.every(j=>j.verdict==="pass")&&c.length>0&&!u)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:k.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:k.map(j=>j.criterionId)};if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const C=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(C?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||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 S={critical:0,serious:0,moderate:0,minor:0};for(const j of lt(n))S[j.impact]++;k.length>0&&k.every(j=>j.verdict==="pass")||(S.serious+=x),T&&(S.serious+=k.filter(j=>j.verdict==="fail").length);for(const j of r){const O=i.find(D=>D.id===j.workflowId);if(O)for(const D of O.steps){const F=j.steps[D.id];(F==null?void 0:F.status)==="fail"&&(D.severity==="required"?S.serious++:S.moderate++)}}const L=S.critical>0,y=S.serious>0;let $;S.critical>=5?$="F":S.critical>=1?$="D":S.serious>=1?$="C":S.moderate>=1?$="B":$="A";const _=$!=="A"&&(b&&!o||c.length>0&&!u);return{id:t.id,label:t.label,letter:$,untested:!1,needsIgt:_,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:S,caps:{cappedAtC:L,cappedAtB:y}}}function Ka(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function qa(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const et="dismissedFindings";function Ve(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ge(t){return`reading-order::${t}`}function fe(t){return`tab-order::${t}`}async function We(){try{const t=await chrome.storage.local.get(et),s=t==null?void 0:t[et];if(s&&typeof s=="object")return s}catch{}return{}}async function pt(t){await chrome.storage.local.set({[et]:t})}async function Pe(t){return(await We())[Ve(t)]??{}}async function ds(t,s,a,n){const r=await We(),i=Ve(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await pt(r)}async function Ie(t,s){if(s.length===0)return;const a=await We(),n=Ve(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await pt(a)}async function us(t,s){const a=await We(),n=Ve(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await pt(a))}const Pi=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:ds,addDismissals:Ie,dismissalKeyForReadingOrder:ge,dismissalKeyForTabOrder:fe,getDismissalsForUrl:Pe,removeDismissal:us},Symbol.toStringTag,{value:"Module"}));function ps(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function ms(t){return`${ct(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function Qa(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=ms(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 At={critical:0,serious:1,moderate:2,minor:3};function Ya(){var T,N,C,b;const t=f(v=>v.results),s=f(v=>v.componentId),a=f(v=>v.setView),n=((T=t[0])==null?void 0:T.pageUrl)??((N=t[0])==null?void 0:N.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(new Set),[c,p]=h.useState({});if(h.useEffect(()=>{if(!s){p({});return}let v=!1;const S=async()=>{const L=await qt(s);if(v)return;const y={};for(const $ of L)$.criterionId==="2.4.3"?y.focusOrder=$.verdict:$.criterionId==="2.1.2"?y.keyboardTrap=$.verdict:$.criterionId==="2.4.7"&&(y.focusVisible=$.verdict);p(y)};S();const I=L=>{L.interactiveAuditResults&&S()};return chrome.storage.local.onChanged.addListener(I),()=>{v=!0,chrome.storage.local.onChanged.removeListener(I)}},[s]),h.useEffect(()=>{if(!n)return;Pe(n).then(i);const v=()=>{document.visibilityState==="visible"&&n&&Pe(n).then(i)};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)},[n]),h.useEffect(()=>{if(!s){l(new Set);return}let v=!1;const S=async()=>{const L=await chrome.storage.local.get("igtRuns");if(v)return;const $=((L==null?void 0:L.igtRuns)??{})[s]??{},_=new Set;for(const j of Q){const O=$[j.id];O&&Object.keys(O.steps).length===j.steps.length&&_.add(j.id)}l(_)};S();const I=()=>{document.visibilityState==="visible"&&S()};return document.addEventListener("visibilitychange",I),()=>{v=!0,document.removeEventListener("visibilitychange",I)}},[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((v,S)=>v+S.durationMs,0),u=t.reduce((v,S)=>v+S.violations.length,0),m=Qa(t);m.sort((v,S)=>{const I=At[v.representative.impact]??99,L=At[S.representative.impact]??99;return I!==L?I-L:S.states.length-v.states.length});const x=t.map(v=>ps(v.state)).join(`
4
+ `),g=c.focusOrder!==void 0,w=o.has("keyboard")||g?0:(((C=t[0])==null?void 0:C.tabOrderIssues)??[]).filter(v=>!(fe(v.selector)in r)).length,k=o.has("page-structure")?0:(((b=t[0])==null?void 0:b.readingOrderIssues)??[]).filter(v=>!(ge(v.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(en,{violations:t.flatMap(v=>v.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(w>0||k>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&&k>0&&" · ",k>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:k})," reading-order issue",k===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"]})," · ",m.length," unique ",m.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",u," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(Xa,{groups:m,totalStates:t.length,violations:t.flatMap(v=>v.violations),interactiveVerdicts:c})]})}const Ja={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 Xa({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=ut({violations:a,auditRan:!0,manualRuns:[],workflows:Q,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,o=new Set;for(const c of Ze){for(const p of c.axeRules)o.add(p);i.set(c.id,[])}const l=[];for(const c of t){let p=!1;for(const d of Ze)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),p=!0;break}p||l.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(Ct,{subGrade:c,groups:p,totalStates:s},c.id)}),l.length>0&&e.jsx(Ct,{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:l,totalStates:s})]})}function Ct({subGrade:t,groups:s,totalStates:a}){const[n,r]=h.useState(!1),[i,o]=h.useState("idle"),[l,c]=h.useState(null),[p,d]=h.useState(0),u=s.length>0,m=Ja[t.letter],x=s.filter(k=>k.representative.ruleId==="color-contrast"||k.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function w(k){k.stopPropagation(),o("loading"),c(null);try{const T=x.map(C=>{const b=C.representative.target.outerHTML,v=C.representative.target.failureSummary,S=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(v),I=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(v);if(!S||!I)return null;const L=C.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:C.representative.matchKey,foreground:S[1],background:I[1],fontSize:16,fontWeight:400,targetLevel:L,_html:b}}).filter(C=>C!==null);if(T.length===0){o("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const N=await X({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:C,...b})=>b)});if(N.unavailableReason&&N.results.length===0){o("error"),c(N.unavailableReason);return}await Os(N.results),o("done"),d(C=>C+1),n||r(!0)}catch(T){o("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(k=>!k),"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 ${m}`,"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:k=>void w(k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),w(k))},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"&&l&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:l}),n&&u&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(k=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Me,{violation:k.representative}),e.jsx(tn,{states:k.states,totalStates:a})]},`${ms(k.representative)}::${p}`))})]})}const Za={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=f(p=>p.setView),o=ut({violations:t,auditRan:!0,manualRuns:a,workflows:Q,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=lt(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 ${Za[o]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:o})}),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(ps))),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 sn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},an={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 nn({violations:t,componentId:s}){var se,pe,ce,oe,B,le,me;const[a,n]=h.useState([]),[r,i]=h.useState([]),[o,l]=h.useState(new Set),[c,p]=h.useState(null),[d,u]=h.useState({}),[m,x]=h.useState(new Set),g=f(R=>R.status),w=f(R=>R.progress),k=f(R=>R.freshThisSession),T=f(R=>R.results),N=(se=T[0])==null?void 0:se.startedAt,C=((pe=T[0])==null?void 0:pe.pageUrl)??((ce=T[0])==null?void 0:ce.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let R=!1;return chrome.storage.local.get("igtRuns").then(z=>{if(R)return;const K=((z==null?void 0:z.igtRuns)??{})[s]??{};n(Object.values(K))}),()=>{R=!0}},[s]),h.useEffect(()=>{if(!C){i([]);return}let R=!1;return $e(C).then(z=>{R||i(z)}),()=>{R=!0}},[C]),g==="running")return e.jsx(pn,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const b=ut({violations:t,auditRan:T.length>0,manualRuns:a,workflows:Q,heuristicCounts:{tabOrder:((B=(oe=T[0])==null?void 0:oe.tabOrderIssues)==null?void 0:B.length)??0,readingOrder:((me=(le=T[0])==null?void 0:le.readingOrderIssues)==null?void 0:me.length)??0}}),v=f(R=>R.acknowledgedKeys),S=T.length>0?Qt(T,{runs:a,workflows:Q},"2.1","AA",v,r):void 0,I=T.length>0?Ds(dt({audits:T,igtRuns:a,workflows:Q,acknowledgedMatchKeys:v,incompleteResolutions:r}),Q):void 0,L=S?S.failingCriteria.length>0||S.inconclusiveCriteria.length>0:!1,y=L&&b.overallLetter==="A"?"B":b.overallLetter;async function $(R){var de;if(!C||!((de=S==null?void 0:S.inconclusiveReasons)!=null&&de[R]))return;const Z=S.inconclusiveReasons[R].filter(J=>J.source==="axe-incomplete"&&J.elements&&J.elements.length>0);if(Z.length===0)return;l(J=>new Set(J).add(R)),p(null);const K=[];let H=0;try{for(const q of Z){const A=await Y({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:q.ruleOrStepId,pageUrl:q.pageUrl??C,wcagCriterion:R,elements:q.elements??[],targetLevel:"AA"});if(A!=null&&A.unavailableReason){p(A.unavailableReason);break}A!=null&&A.resolutions&&(K.push(...A.resolutions),H+=A.totalCostUsd??0)}if(C){const q=await $e(C);i(q)}const J={total:K.length,pass:K.filter(q=>q.verdict==="pass").length,fail:K.filter(q=>q.verdict==="fail").length,uncertain:K.filter(q=>q.verdict==="uncertain").length,costUsd:H,resolutions:K};u(q=>({...q,[R]:J}))}finally{l(J=>{const q=new Set(J);return q.delete(R),q})}}function _(R){x(z=>{const Z=new Set(z);return Z.has(R)?Z.delete(R):Z.add(R),Z})}async function j(R){var A,G;if(!C)return;const z=((A=S==null?void 0:S.inconclusiveReasons)==null?void 0:A[R])??[],Z=((G=S==null?void 0:S.failingReasons)==null?void 0:G[R])??[],K=[],H=new Set;for(const U of z){if(U.source!=="axe-incomplete"||!U.elements)continue;const M=U.pageUrl??C;for(const V of U.elements){const W=`${M}::${U.ruleOrStepId}::${V.selector}`;H.has(W)||(H.add(W),K.push({ruleId:U.ruleOrStepId,pageUrl:M,selector:V.selector}))}}for(const U of Z){if(U.source!=="ai"||!U.selector)continue;const M=U.ruleOrStepId.startsWith("ai-resolved::")?U.ruleOrStepId.slice(13):U.ruleOrStepId,V=U.pageUrl??C,W=`${V}::${M}::${U.selector}`;H.has(W)||(H.add(W),K.push({ruleId:M,pageUrl:V,selector:U.selector}))}if(K.length===0)return;const de=new Date().toISOString(),J=[];for(const U of K){const M=r.find(V=>V.pageUrl===U.pageUrl&&V.ruleId===U.ruleId&&V.selector===U.selector);M&&M.verdict==="pass"&&M.reasoning.startsWith("Marked as visually verified")||J.push({pageUrl:U.pageUrl,ruleId:U.ruleId,selector:U.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${de.slice(0,10)}.`,resolvedAt:de,costUsd:0,wcagCriterion:R})}if(J.length===0)return;await Fs(J);const q=await $e(C);i(q),u(U=>({...U,[R]:{total:J.length,pass:J.length,fail:0,uncertain:0,costUsd:0,resolutions:J}}))}const O=(()=>{if(!L||b.overallLetter!=="A"||!S)return null;const R=S.inconclusiveCriteria.length,z=S.failingCriteria.length,Z=[];z>0&&Z.push(`${z} WCAG ${S.targetLevel} ${z===1?"criterion":"criteria"} failing`),R>0&&Z.push(`${R} WCAG ${S.targetLevel} ${R===1?"criterion":"criteria"} inconclusive`);const K=z>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${Z.join(" + ")}. ${K}`})();let D=0;for(const R of Q){const z=a.find(K=>K.workflowId===R.id);if(!z)continue;R.steps.every(K=>{const H=z.steps[K.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"})&&D++}const F=lt(t.filter(R=>!v.has(R.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!k&&N&&e.jsx(mn,{scannedAt:N}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${sn[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 ",b.subGrades.length," verification areas below. Untested areas count as F until verified."]}),O&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:O})]})]}),b.isLawsuitRisk&&e.jsx(ln,{areas:b.warningAreas}),e.jsx(cn,{grades:b.subGrades}),S&&e.jsx(rn,{coverage:S,onResolveWithAi:$,onMarkVisuallyVerified:j,resolving:o,resolveError:c,lastResolveResult:d,expandedResultFor:m,onToggleResultDetail:_}),I&&e.jsx(on,{layers:I}),e.jsx(un,{violationsRemaining:F,manualCompleted:D,manualTotal:Q.length}),D>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:D})," of ",e.jsx("strong",{children:Q.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${D/Q.length*100}%`}})})]}):null]})}function rn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[p,d]=h.useState(c>0&&c<=3),u=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),m=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 ${m?"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 ${m?"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,"%)"]}),m&&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)."]}),!m&&(()=>{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,"."]})})(),!m&&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."]}),!m&&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."]})]}),!m&&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&&!m&&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 I,L;const k=g.kind==="inconclusive"?(I=t.inconclusiveReasons)==null?void 0:I[w]:void 0,T=g.kind==="failing"?(L=t.failingReasons)==null?void 0:L[w]:void 0,N=k==null?void 0:k.some(y=>y.source==="axe-incomplete"&&y.elements&&y.elements.length>0),C=T==null?void 0:T.some(y=>y.source==="ai"),b=(n==null?void 0:n.has(w))??!1,v=i==null?void 0:i[w],S=(o==null?void 0:o.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"&&C)&&(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:b,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:b?"Resolving…":v?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:b,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"})]})]}),v&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",v.total," ",v.total===1?"verdict":"verdicts",":",v.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",v.pass," pass"]}),v.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",v.fail," fail"]}),v.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",v.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",v.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(w),className:"ml-auto text-[10px] underline text-brand-700",children:S?"hide reasoning":"show reasoning"})]}),v.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",v.uncertain," ",v.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),v.pass===v.total&&v.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),S&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:v.resolutions.map((y,$)=>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})]},$))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((y,$)=>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})]},$))}),k&&k.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:k.map((y,$)=>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((_,j,O)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:_.selector}),j<O.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},j)),y.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",y.elements.length-3," more"]})]})]},$))}):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 It={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 on({layers:t}){const s=f(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,c=r.cleared,p=i>0&&o===0&&l===0,d=p?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${p?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:p?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:It[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:It[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function ln({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 cn({grades:t}){const s=f(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${an[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(dn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function dn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=Q.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?hs(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 un({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const c=l===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function pn({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 mn({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 (",hs(s)," old). Re-scan to grade the current page state."]})]})}function hs(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=f(a=>a.results),s=f(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(nn,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(xn,{})]})}function xn(){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(we,{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(we,{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(we,{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(we,{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(we,{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 we({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 gn={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 fn({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Me,{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 ${gn[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(Me,{violation:c},p))})]})}function bn(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 vn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function xs({open:t,onClose:s,format:a,content:n,filename:r}){const i=Rs(new Blob([n]).size);function o(){it(n,r),s()}function l(){rt(n),s()}return e.jsxs(be,{open:t,onClose:s,title:vn[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Rt=7800;function yn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
6
+ `),c=new URLSearchParams({title:i,body:l});let p=`${n}/issues/new?${c.toString()}`;return p.length>Rt&&(p=p.slice(0,Rt)),{url:p,title:i,body:l}}const Et=7800;function jn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const u=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===u);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`Rule: ${d.ruleId} (${d.impact})`),o.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),o.push(`Description: ${d.description}`),o.push(`Selector: ${d.target.selector}`),o.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&o.push(`More info: ${d.helpUrl}`),o.push(""),o.push(`HTML: ${d.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
7
+ `),c=new URLSearchParams({summary:i,description:l});let p=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return p.length>Et&&(p=p.slice(0,Et)),{url:p,summary:i,description:l}}const Tt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],wn=["wcag-component-auditor","wcag-forensic-log"];async function Nn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Tt);s=Object.keys(n).length,await chrome.storage.local.remove(Tt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of wn)try{await kn(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 kn(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}function Sn(){const t=f(y=>y.delta),s=f(y=>y.componentId),a=f(y=>y.results),n=f(y=>y.tier),r=f(y=>y.baselineList),i=f(y=>y.siteCrawlReport),[o,l]=h.useState(""),[c,p]=h.useState(""),[d,u]=h.useState(!1),[m,x]=h.useState(!1),[g,w]=h.useState(null),[k,T]=h.useState(null);h.useEffect(()=>{Promise.all([X({type:"SETTINGS_GET",key:"githubRepoUrl"}),X({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([y,$])=>{l(typeof y.data=="string"?y.data:""),p(typeof $.data=="string"?$.data:"")})},[]);const N=Jt(n,"exportJson"),C=Zt[n].maxBaselines,b=r.some(y=>y.componentId===s),v=b||r.length<C;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 S(){if(!s||a.length===0)return;const y=a.flatMap(se=>se.violations),$=a.flatMap(se=>se.announcements??[]),_=a.flatMap(se=>se.focusEvents??[]),j=a[0],D=(await X({type:"SETTINGS_GET",key:"stateMatrix"})).data??Xt;await Y({type:"BASELINE_SET",componentId:s,violations:y,announcements:$,focusEvents:_,snapshotMeta:{url:window.location.href,axeVersion:j.axeVersion,matrixConfig:D,capturedAt:new Date().toISOString()}});const F=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:$,focusEvents:_,currentMatrix:D});f.getState().setDelta(F.delta),ne.polite(`Baseline saved for ${s}.`)}async function I(){if(!s||!b||!window.confirm(`Remove the saved baseline for "${s}"?
8
8
 
9
- Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Y({type:"BASELINE_DELETE",componentId:s});const $=a.flatMap(F=>F.violations),_=a.flatMap(F=>F.announcements??[]),w=a.flatMap(F=>F.focusEvents??[]),O=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:$,announcements:_,focusEvents:w});f.getState().setDelta(O.delta);const D=await X({type:"BASELINE_LIST"});f.getState().setBaselineList(D.items),ne.polite(`Baseline cleared for ${s}.`)}async function L(j,$=!1){if(a.length===0)return;if(j==="ai-prompt"){const{copyAiFixerPrompt:B}=await Ge(async()=>{const{copyAiFixerPrompt:le}=await import("./copy-ai-fixer-prompt-COzuc_9B.js");return{copyAiFixerPrompt:le}},__vite__mapDeps([0,1,2]));await B({results:a,componentId:s,delta:$?void 0:t,siteCrawlReport:i});return}let _;if((j==="defense-bundle"||j==="evidence-bundle")&&s){const B=await chrome.storage.local.get("igtRuns"),me=((B==null?void 0:B.igtRuns)??{})[s]??{};_=Object.values(me)}const D=await X({type:"EXPORT_REQUEST",format:j,results:a,delta:$?void 0:t??void 0,manualRuns:_,dismissedKeys:void 0,incompleteResolutions:void 0});if(j==="defense-bundle"||j==="evidence-bundle"){const B=Ht(j,s);await zt()?ot(D.content,B):T({open:!0,format:j,content:D.content,filename:B});return}if(j==="html-print"||j==="vpat"){it(D.content);return}const F=j==="json"?"application/json":j==="sarif"?"application/sarif+json":"application/xml",se=j==="junit"?"xml":j,pe=new Blob([D.content],{type:F}),ce=URL.createObjectURL(pe),oe=document.createElement("a");oe.href=ce,oe.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${se}`,oe.click(),URL.revokeObjectURL(ce)}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:S,disabled:!y,title:y?void 0:`Free tier limits you to ${C} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),b&&e.jsx("button",{onClick:I,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>u(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx(En,{disabled:!k,onExport:L,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!y&&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 j=Ke(t.new),$=Ke(t.persistent),_=Ke(t.fixed),w=[...j.review,...$.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{title:"New",violations:j.findings,count:j.findings.length,accent:"red",actions:[...o&&j.findings.length>0?[{label:"File GitHub issue",onClick:()=>In(o,s,j.findings)}]:[],...c&&j.findings.length>0?[{label:"File Jira issue",onClick:()=>Rn(c,s,j.findings)}]:[]]}),e.jsx(Ne,{title:"Persistent",violations:$.findings,count:$.findings.length,accent:"slate"}),e.jsx(Ne,{title:"Fixed",violations:_.findings,count:t.fixedCount,accent:"green"}),w.length>0&&e.jsx(Ne,{title:"Needs review (does not affect grade)",violations:w,count:w.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ne,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),N&&e.jsx(xs,{open:N.open,onClose:()=>T(null),format:N.format,content:N.content,filename:N.filename}),d&&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"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{u(!1),v(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>u(!1),disabled:m,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()=>{x(!0);try{const j=await kn();v(j),await Ve(),ne.polite("Audit data reset. Ready for a fresh scan.")}catch(j){v({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[j instanceof Error?j.message:String(j)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const Cn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ke(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 Ne({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=h.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 ${Cn[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(Me,{violation:c,alreadyAcknowledged:!0},p)):vn(s).map(c=>e.jsx(bn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function In(t,s,a){if(a.length===0)return;const{url:n}=jn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Rn(t,s,a){if(a.length===0)return;const{url:n}=wn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function En({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=h.useState(!1),[i,o]=h.useState(!1);function l(c){r(!1),s(c,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(c=>!c),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c=>o(c.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ue,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{onClick:()=>l("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>l("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ue,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{onClick:()=>l("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ue,{onClick:()=>l("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ue({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const $t="igtRuns";async function Tn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get($t))[$t];return s&&typeof s=="object"?s:{}}async function $n(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Tn())[t];if(i)for(const c of Q){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Ie(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Ie(n,x.map(g=>({key:ge(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const Ln=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"]),_n=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function Un(t){return Ln.has(t.ruleId)}function On(t){return _n.has(t.ruleId)}function Dn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Fn(){var L,j,$,_;const t=f(w=>w.results),s=f(w=>w.delta),a=f(w=>w.componentId),n=((L=t[0])==null?void 0:L.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(0);h.useEffect(()=>{if(!n)return;let w=!1;return(async()=>{if(a&&t.length>0)try{await $n(a,t)}catch{}if(w)return;const O=await Pe(n);w||i(O)})(),()=>{w=!0}},[n,o,a,t]);async function c(w,O){if(!n)return;const D=window.prompt(`Why is this finding a false positive?
9
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Y({type:"BASELINE_DELETE",componentId:s});const $=a.flatMap(F=>F.violations),_=a.flatMap(F=>F.announcements??[]),j=a.flatMap(F=>F.focusEvents??[]),O=await X({type:"BASELINE_COMPARE",componentId:s,currentViolations:$,announcements:_,focusEvents:j});f.getState().setDelta(O.delta);const D=await X({type:"BASELINE_LIST"});f.getState().setBaselineList(D.items),ne.polite(`Baseline cleared for ${s}.`)}async function L(y,$=!1){if(a.length===0)return;if(y==="ai-prompt"){const{copyAiFixerPrompt:B}=await ot(async()=>{const{copyAiFixerPrompt:le}=await import("./copy-ai-fixer-prompt-jQDU30Cp.js");return{copyAiFixerPrompt:le}},__vite__mapDeps([0,1,2]));await B({results:a,componentId:s,delta:$?void 0:t,siteCrawlReport:i});return}let _;if((y==="defense-bundle"||y==="evidence-bundle")&&s){const B=await chrome.storage.local.get("igtRuns"),me=((B==null?void 0:B.igtRuns)??{})[s]??{};_=Object.values(me)}const D=await X({type:"EXPORT_REQUEST",format:y,results:a,delta:$?void 0:t??void 0,manualRuns:_,dismissedKeys:void 0,incompleteResolutions:void 0});if(y==="defense-bundle"||y==="evidence-bundle"){const B=Ht(y,s);await zt()?it(D.content,B):T({open:!0,format:y,content:D.content,filename:B});return}if(y==="html-print"||y==="vpat"){rt(D.content);return}const F=y==="json"?"application/json":y==="sarif"?"application/sarif+json":"application/xml",se=y==="junit"?"xml":y,pe=new Blob([D.content],{type:F}),ce=URL.createObjectURL(pe),oe=document.createElement("a");oe.href=ce,oe.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${se}`,oe.click(),URL.revokeObjectURL(ce)}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:S,disabled:!v,title:v?void 0:`Free tier limits you to ${C} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),b&&e.jsx("button",{onClick:I,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>u(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx(Rn,{disabled:!N,onExport:L,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!v&&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 y=ze(t.new),$=ze(t.persistent),_=ze(t.fixed),j=[...y.review,...$.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{title:"New",violations:y.findings,count:y.findings.length,accent:"red",actions:[...o&&y.findings.length>0?[{label:"File GitHub issue",onClick:()=>Cn(o,s,y.findings)}]:[],...c&&y.findings.length>0?[{label:"File Jira issue",onClick:()=>In(c,s,y.findings)}]:[]]}),e.jsx(Ne,{title:"Persistent",violations:$.findings,count:$.findings.length,accent:"slate"}),e.jsx(Ne,{title:"Fixed",violations:_.findings,count:t.fixedCount,accent:"green"}),j.length>0&&e.jsx(Ne,{title:"Needs review (does not affect grade)",violations:j,count:j.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ne,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),k&&e.jsx(xs,{open:k.open,onClose:()=>T(null),format:k.format,content:k.content,filename:k.filename}),d&&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"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{u(!1),w(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>u(!1),disabled:m,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()=>{x(!0);try{const y=await Nn();w(y),await Ge(),ne.polite("Audit data reset. Ready for a fresh scan.")}catch(y){w({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[y instanceof Error?y.message:String(y)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const An={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function ze(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 Ne({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=h.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 ${An[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(Me,{violation:c,alreadyAcknowledged:!0},p)):bn(s).map(c=>e.jsx(fn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Cn(t,s,a){if(a.length===0)return;const{url:n}=yn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function In(t,s,a){if(a.length===0)return;const{url:n}=jn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Rn({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=h.useState(!1),[i,o]=h.useState(!1);function l(c){r(!1),s(c,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(c=>!c),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c=>o(c.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ue,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ue,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ue,{onClick:()=>l("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>l("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ue,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ue,{onClick:()=>l("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ue,{onClick:()=>l("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ue,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ue({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const $t="igtRuns";async function En(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get($t))[$t];return s&&typeof s=="object"?s:{}}async function Tn(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await En())[t];if(i)for(const c of Q){const p=i[c.id];if(p)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=p.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Ie(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Ie(n,x.map(g=>({key:ge(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const $n=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"]),Ln=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 _n(t){return $n.has(t.ruleId)}function Un(t){return Ln.has(t.ruleId)}function On(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Dn(){var L,y,$,_;const t=f(j=>j.results),s=f(j=>j.delta),a=f(j=>j.componentId),n=((L=t[0])==null?void 0:L.pageUrl)??((y=t[0])==null?void 0:y.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(0);h.useEffect(()=>{if(!n)return;let j=!1;return(async()=>{if(a&&t.length>0)try{await Tn(a,t)}catch{}if(j)return;const O=await Pe(n);j||i(O)})(),()=>{j=!0}},[n,o,a,t]);async function c(j,O){if(!n)return;const D=window.prompt(`Why is this finding a false positive?
10
10
 
11
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");D!==null&&(await ds(n,w,D||"(no reason given)",O),l(F=>F+1))}async function p(w){n&&(await us(n,w),l(O=>O+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((w,O)=>{var D;return w+(((D=O.announcements)==null?void 0:D.length)??0)},0),u=t.reduce((w,O)=>{var D;return w+(((D=O.focusEvents)==null?void 0:D.length)??0)},0),m=t.reduce((w,O)=>{var D;return w+(((D=O.focusEvents)==null?void 0:D.filter(F=>F.isFocusReset).length)??0)},0),x=Lt(t,Un),g=Lt(t,On),v=x.length,N=g.length,T=(($=t[0])==null?void 0:$.readingOrderIssues)??[],k=((_=t[0])==null?void 0:_.tabOrderIssues)??[],C=T.filter(w=>!(ge(w.selector)in r)),b=T.filter(w=>ge(w.selector)in r),y=k.filter(w=>!(fe(w.selector)in r)),S=k.filter(w=>fe(w.selector)in r);if(d===0&&u===0&&v===0&&N===0&&C.length===0&&y.length===0&&b.length===0&&S.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 I=b.length+S.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:[v," structural · ",N," form ·"," ",y.length," tab-order ·"," ",C.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),I>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",I," dismissed"]})]}),y.length>0&&e.jsx(Gn,{issues:y,onDismiss:c}),C.length>0&&e.jsx(Vn,{issues:C,onDismiss:c}),I>0&&e.jsx(Wn,{dismissedReadingOrder:b,dismissedTabOrder:S,dismissals:r,onRestore:p}),v>0&&e.jsx(_t,{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}),N>0&&e.jsx(_t,{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(Mn,{delta:s}),t.map((w,O)=>{const D=w.announcements??[],F=w.focusEvents??[];return D.length===0&&F.length===0?null:e.jsx(Pn,{state:w.state,announcements:D,focusEvents:F},O)})]})}function Mn({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 Lt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ct(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function _t({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 Pn({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Dn(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Gn({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 Vn({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 Wn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const c=`tab-order::${l.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const st="igtRuns";async function Bn(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ie(r,o.map(l=>({key:fe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Ie(r,o.map(l=>({key:ge(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Hn={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"}},zn={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"}},Kn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Ut(t,s){const a=await te();if(!a)return;const n=s?Hn[t]:zn[t];try{await ie(a,n)}catch{}}async function qn(){const s=(await chrome.storage.local.get(st))[st];return s&&typeof s=="object"?s:{}}async function Ot(t){await chrome.storage.local.set({[st]:t})}function Qn(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 Yn(){const t=f(d=>d.componentId),s=f(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{qn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(d,u,m){var g;const x={...a,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[d])==null?void 0:g.steps)??{},[u]:m},completedAt:new Date().toISOString()}}};if(n(x),Ot(x),m.status==="pass"){const v=Q.find(T=>T.id===d),N=v==null?void 0:v.steps.find(T=>T.id===u);N!=null&&N.autoDismissActivity&&Bn(N.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[d];const m={...a,[t]:u};n(m),Ot(m)}const p=Q.find(d=>d.id===r);if(p){const d=o[p.id];return e.jsx(Jn,{workflow:p,run:d,results:s,onAnswer:(u,m)=>l(p.id,u,m),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),Q.map(d=>{const u=o[d.id],m=u?Os(u,d):null,x=u?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.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"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:v=>{v.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function Jn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=Qn(p,a);return c},[t,a]);function o(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Ut(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Kn[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Ut(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Re,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Re,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Re,{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(Re,{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 Xn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Re({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?Xn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Le="savedFlows";async function Zn(){const t=await chrome.storage.local.get(Le);return Array.isArray(t[Le])?t[Le]:[]}async function Dt(t){await chrome.storage.local.set({[Le]:t})}function er(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{Zn().then(s)},[]);async function o(){const d=await te();if(!d){i("No audit-target tab found.");return}try{await ie(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await te();if(d)try{const u=await Ce(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Dt(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 te();if(u){i(`Replaying "${d.name}"…`);try{const m=await Ce(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(m=>m.id!==d);s(u),await Dt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function tr(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(sr).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function sr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function ar(){const t=f(l=>l.baselineList),s=f(l=>l.tier),a=Zt[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Oe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await Y({type:"BASELINE_DELETE",componentId:l}),await Oe()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const c=tr(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const nr={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 he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${nr[t]}`,children:a})}const rr={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"},ir={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},or={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 gs({onBack:t}){const s=f(u=>u.siteCrawlStatus),a=f(u=>u.siteCrawlProgress),n=f(u=>u.siteCrawlReport),r=f(u=>u.siteCrawlError),[i,o]=h.useState(""),[l,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const m=(x=u[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&o(m)});function p(){i&&(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),re({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function d(){Y({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(lr,{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 lr({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-BSUQ7Is6.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,4,2,5])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${rr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${ir[t.siteRisk]}`,children:Ds[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(a=>{const n=Fs(a.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${or[a.impact]}`,children:a.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:n.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:a.urlsAffected})," page",a.urlsAffected===1?"":"s"," · ",a.totalOccurrences," total spot",a.totalOccurrences===1?"":"s"]})]})]})},a.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(a=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${a.grade==="A"?"text-emerald-700":a.grade==="B"?"text-lime-700":a.grade==="C"?"text-yellow-700":a.grade==="D"?"text-orange-700":"text-rose-700"}`,children:a.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:a.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:a.uniqueViolations})]},a.url))})]})]})}const qe="onboardingDismissed",Qe=[{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 cr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(qe).then(l=>{l[qe]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[qe]:!0}),s(!1),n(0)}const i=a===Qe.length-1,o=Qe[a];return e.jsxs(be,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Qe.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function dr(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function ur(){const t=f(c=>c.aiFailure),s=f(c=>c.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Ft(){const[t,s]=h.useState(!1);return h.useEffect(()=>ae("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(be,{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 pr(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{Ms().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await yt(),f.getState().startNewScan(),t.mode==="storybook-all"?re({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&re({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await yt(),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 Ye="storybook:hintDismissed";function mr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(Ye))[Ye])return;const o=await te();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Ye]:!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 hr(){var i;const t=f(o=>o.results),s=f(o=>o.baselineList),a=f(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${xr(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 xr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function gr(){const t=f(l=>l.results),s=f(l=>l.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=Ps(r,a.length>0?{runs:a,workflows:Q}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function fr(){const t=f(a=>a.setUserMode);function s(a){t(a),Y({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const br=["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"],vr={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 yr(t){const s=new Set(br),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 o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:vr[o]}}const fs={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},jr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[fs]},wr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[fs]};function mt(t){return t==="thorough"?wr:jr}function Mt(t){const s=mt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const _e="wcagcheckr";function P(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ae(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 Nr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function kr(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 Sr(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 Ar(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 Cr(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${P(t.receipt.tsaName)}) — anchored ${P(Ae(t.receipt.anchoredAt))}</td></tr>
11
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");D!==null&&(await ds(n,j,D||"(no reason given)",O),l(F=>F+1))}async function p(j){n&&(await us(n,j),l(O=>O+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((j,O)=>{var D;return j+(((D=O.announcements)==null?void 0:D.length)??0)},0),u=t.reduce((j,O)=>{var D;return j+(((D=O.focusEvents)==null?void 0:D.length)??0)},0),m=t.reduce((j,O)=>{var D;return j+(((D=O.focusEvents)==null?void 0:D.filter(F=>F.isFocusReset).length)??0)},0),x=Lt(t,_n),g=Lt(t,Un),w=x.length,k=g.length,T=(($=t[0])==null?void 0:$.readingOrderIssues)??[],N=((_=t[0])==null?void 0:_.tabOrderIssues)??[],C=T.filter(j=>!(ge(j.selector)in r)),b=T.filter(j=>ge(j.selector)in r),v=N.filter(j=>!(fe(j.selector)in r)),S=N.filter(j=>fe(j.selector)in r);if(d===0&&u===0&&w===0&&k===0&&C.length===0&&v.length===0&&b.length===0&&S.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 I=b.length+S.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 · ",k," form ·"," ",v.length," tab-order ·"," ",C.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",u," focus ",u===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),I>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",I," dismissed"]})]}),v.length>0&&e.jsx(Pn,{issues:v,onDismiss:c}),C.length>0&&e.jsx(Gn,{issues:C,onDismiss:c}),I>0&&e.jsx(Vn,{dismissedReadingOrder:b,dismissedTabOrder:S,dismissals:r,onRestore:p}),w>0&&e.jsx(_t,{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}),k>0&&e.jsx(_t,{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(Fn,{delta:s}),t.map((j,O)=>{const D=j.announcements??[],F=j.focusEvents??[];return D.length===0&&F.length===0?null:e.jsx(Mn,{state:j.state,announcements:D,focusEvents:F},O)})]})}function Fn({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 Lt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ct(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function _t({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 Mn({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:On(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 Pn({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 Gn({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Vn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const c=`tab-order::${l.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,p=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const tt="igtRuns";async function Wn(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ie(r,o.map(l=>({key:fe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Ie(r,o.map(l=>({key:ge(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Bn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},Hn={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"}},zn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Ut(t,s){const a=await te();if(!a)return;const n=s?Bn[t]:Hn[t];try{await ie(a,n)}catch{}}async function Kn(){const s=(await chrome.storage.local.get(tt))[tt];return s&&typeof s=="object"?s:{}}async function Ot(t){await chrome.storage.local.set({[tt]:t})}function qn(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 Qn(){const t=f(d=>d.componentId),s=f(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{Kn().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(d,u,m){var g;const x={...a,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[d])==null?void 0:g.steps)??{},[u]:m},completedAt:new Date().toISOString()}}};if(n(x),Ot(x),m.status==="pass"){const w=Q.find(T=>T.id===d),k=w==null?void 0:w.steps.find(T=>T.id===u);k!=null&&k.autoDismissActivity&&Wn(k.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[d];const m={...a,[t]:u};n(m),Ot(m)}const p=Q.find(d=>d.id===r);if(p){const d=o[p.id];return e.jsx(Yn,{workflow:p,run:d,results:s,onAnswer:(u,m)=>l(p.id,u,m),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),Q.map(d=>{const u=o[d.id],m=u?Ms(u,d):null,x=u?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.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"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.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 Yn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=qn(p,a);return c},[t,a]);function o(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Ut(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",zn[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Ut(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Re,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Re,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Re,{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(Re,{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 Jn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Re({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?Jn[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Le="savedFlows";async function Xn(){const t=await chrome.storage.local.get(Le);return Array.isArray(t[Le])?t[Le]:[]}async function Dt(t){await chrome.storage.local.set({[Le]:t})}function Zn(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{Xn().then(s)},[]);async function o(){const d=await te();if(!d){i("No audit-target tab found.");return}try{await ie(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await te();if(d)try{const u=await Ce(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:u.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Dt(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 te();if(u){i(`Replaying "${d.name}"…`);try{const m=await Ce(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(m=>m.id!==d);s(u),await Dt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function er(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(tr).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function tr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function sr(){const t=f(l=>l.baselineList),s=f(l=>l.tier),a=Zt[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Oe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await Y({type:"BASELINE_DELETE",componentId:l}),await Oe()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const c=er(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const ar={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 he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${ar[t]}`,children:a})}const nr={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},rr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},ir={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 gs({onBack:t}){const s=f(u=>u.siteCrawlStatus),a=f(u=>u.siteCrawlProgress),n=f(u=>u.siteCrawlReport),r=f(u=>u.siteCrawlError),[i,o]=h.useState(""),[l,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var x;const m=(x=u[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&o(m)});function p(){i&&(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),re({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function d(){Y({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(or,{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 or({report:t}){function s(){ot(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-DCeEGNkg.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,4,2,5])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${nr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${rr[t.siteRisk]}`,children:Ps[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(a=>{const n=Gs(a.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ir[a.impact]}`,children:a.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:n.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:a.urlsAffected})," page",a.urlsAffected===1?"":"s"," · ",a.totalOccurrences," total spot",a.totalOccurrences===1?"":"s"]})]})]})},a.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(a=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${a.grade==="A"?"text-emerald-700":a.grade==="B"?"text-lime-700":a.grade==="C"?"text-yellow-700":a.grade==="D"?"text-orange-700":"text-rose-700"}`,children:a.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:a.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:a.uniqueViolations})]},a.url))})]})]})}const Ke="onboardingDismissed",qe=[{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 lr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(Ke).then(l=>{l[Ke]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ke]:!0}),s(!1),n(0)}const i=a===qe.length-1,o=qe[a];return e.jsxs(be,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",qe.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function cr(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function dr(){const t=f(c=>c.aiFailure),s=f(c=>c.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Ft(){const[t,s]=h.useState(!1);return h.useEffect(()=>ae("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(be,{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 ur(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{Vs().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await yt(),f.getState().startNewScan(),t.mode==="storybook-all"?re({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&re({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await yt(),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 Qe="storybook:hintDismissed";function pr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(Qe))[Qe])return;const o=await te();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(n((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Qe]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function mr(){var i;const t=f(o=>o.results),s=f(o=>o.baselineList),a=f(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${hr(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 hr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function xr(){const t=f(l=>l.results),s=f(l=>l.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=Ws(r,a.length>0?{runs:a,workflows:Q}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function gr(){const t=f(a=>a.setUserMode);function s(a){t(a),Y({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const fr=["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"],br={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 vr(t){const s=new Set(fr),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 o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:br[o]}}const fs={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},yr={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[fs]},jr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[fs]};function mt(t){return t==="thorough"?jr:yr}function Mt(t){const s=mt(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const _e="wcagcheckr";function P(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ae(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 wr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Nr(t){if(t.length===0)return null;const s=[...t].sort((a,n)=>a.capturedAt.localeCompare(n.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function kr(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function Sr(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function Ar(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${P(t.receipt.tsaName)}) — anchored ${P(Ae(t.receipt.anchoredAt))}</td></tr>
12
12
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${P(t.receipt.serverKeyFingerprint)}</code></td></tr>
13
13
  ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${P(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${P(_e)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
14
14
  <article class="entry">
15
15
  <header class="entry-header">
16
- <span class="grade-badge ${Ar(t.grade)}">${P(t.grade)}</span>
16
+ <span class="grade-badge ${Sr(t.grade)}">${P(t.grade)}</span>
17
17
  <div class="entry-headline">
18
18
  <div class="entry-time">${P(Ae(t.capturedAt))}</div>
19
19
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
@@ -27,15 +27,15 @@ Future audits will treat every detected violation as new (no delta filtering). T
27
27
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
28
28
  ${n}
29
29
  </table>
30
- </article>`}function Ir(t){return`
30
+ </article>`}function Cr(t){return`
31
31
  <section class="component-section">
32
32
  <h2>
33
33
  <span class="component-id">${P(t.componentId)}</span>
34
34
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
35
35
  </h2>
36
36
  <p class="component-url"><strong>Page audited:</strong> <code>${P(t.pageUrl)}</code></p>
37
- ${t.entries.map(Cr).join("")}
38
- </section>`}function Rr(t){const{entries:s,extensionVersion:a}=t,n=Sr(s),r=kr(s),i=(t.axeVersions??Nr(s)).join(", "),o=s.length,l=s.filter(d=>d.receipt).length,c=o-l,p=Ae(new Date().toISOString());return`<!doctype html>
37
+ ${t.entries.map(Ar).join("")}
38
+ </section>`}function Ir(t){const{entries:s,extensionVersion:a}=t,n=kr(s),r=Nr(s),i=(t.axeVersions??wr(s)).join(", "),o=s.length,l=s.filter(d=>d.receipt).length,c=o-l,p=Ae(new Date().toISOString());return`<!doctype html>
39
39
  <html lang="en">
40
40
  <head>
41
41
  <meta charset="utf-8" />
@@ -204,7 +204,7 @@ Future audits will treat every detected violation as new (no delta filtering). T
204
204
  <tr><th>Tool</th><td>${P(_e)} ${P(a)}</td></tr>
205
205
  </table>
206
206
 
207
- ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Ir).join("")}
207
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Cr).join("")}
208
208
 
209
209
  <section class="methodology">
210
210
  <h2>Methodology</h2>
@@ -232,12 +232,12 @@ Future audits will treat every detected violation as new (no delta filtering). T
232
232
  <span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
233
233
  </footer>
234
234
  </body>
235
- </html>`}async function Er(t){const s=Rr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function bs(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[o,l]=h.useState(!1),[c,p]=h.useState(""),[d,u]=h.useState(""),[m,x]=h.useState(""),[g,v]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),Yt().then(y=>{b||s(y)}).catch(y=>{b||n(y instanceof Error?y.message:String(y))}),()=>{b=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const N=t.length,T=t.filter(b=>b.receipt).length;async function k(){if(!(!t||t.length===0)){v(!0);try{await Er({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:m.trim()||void 0}),l(!1)}finally{v(!1)}}}async function C(){if(!t||t.length===0)return;const b={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},y=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),S=URL.createObjectURL(y),I=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,L=document.createElement("a");L.href=S,L.download=I,L.click(),setTimeout(()=>URL.revokeObjectURL(S),1e3)}return N===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[N," ",N===1?"entry":"entries",T>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[T," RFC 3161-anchored"]})]}),T===0&&N>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void C(),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(b=>b+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:b=>p(b.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:b=>u(b.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:m,onChange:b=>x(b.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||N===0,onClick:k,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(b=>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 ${b.grade==="A"?"bg-emerald-100 text-emerald-700":b.grade==="B"?"bg-lime-100 text-lime-700":b.grade==="C"?"bg-yellow-100 text-yellow-700":b.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:b.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:b.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${b.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:b.receipt?`Anchored to ${b.receipt.tsaName} at ${b.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:b.receipt?`RFC 3161 (${b.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:b.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:b.capturedAt}),(b.totals.critical>0||b.totals.serious>0)&&e.jsxs("span",{children:[b.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[b.totals.critical," crit"]}),b.totals.critical>0&&b.totals.serious>0&&" · ",b.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[b.totals.serious," sev"]})]}),e.jsxs("span",{children:[b.statesAudited," ",b.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:b.hash,children:[b.hash.slice(0,12),"…"]})]})]},`${b.componentId}::${b.capturedAt}`))})]})}function Tr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let c=!1;return Yt().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(be,{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(bs,{})})})]})}function $r(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Lr={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."},_r={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},Ur={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Or={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function vs(){const t=f(u=>u.tier),s=f(u=>u.trialDaysRemaining),a=f(u=>u.seatsUsed),n=f(u=>u.seatsTotal),r=f(u=>u.planCode),i=f(u=>u.licenseDaysRemaining),o=f(u=>u.pastDue),[l,c]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,m=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:m?"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:m?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:m?"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:m?"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:m?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ze,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?Or:Ur,m=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,v=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}: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 ${v.bg} border-b ${v.border} px-3 py-2 space-y-1 text-[11px] ${v.shadow}`,children:[e.jsxs("div",{className:v.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",u.label]}),e.jsxs("span",{className:v.subtitle,children:[" · ",m]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),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 Y({type:"OPEN_SETTINGS"}),className:v.link,children:"Manage license →"})})]})}const p=t==="trial"?Lr:_r,d=t==="trial"?$r(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 Y({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Ze,{open:l,onClose:()=>c(!1)})]})}const Dr={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},Fr={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Pt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Mr={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"},Gt={critical:0,serious:1,moderate:2,minor:3};function Pr(){const t=f(u=>u.setUserMode),s=f(u=>u.status),a=f(u=>u.setStatus),n=f(u=>u.errorMessage),r=f(u=>u.setError),[i,o]=h.useState(!1),[l,c]=h.useState(!1),p=h.useRef(s);h.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]),h.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{f.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"),Y({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(vs,{}),e.jsx(os,{}),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(is,{}),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(Gr,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{f.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(gs,{onBack:()=>o(!1)}):e.jsx(Wr,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Vr,{})]}),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 Gr(){const t=f(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function Vr(){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 Wr({onPickCrawl:t}){const s=f(u=>u.status),a=f(u=>u.results),[n,r]=h.useState("quick"),[i,o]=h.useState("all"),l=s==="running",c=a.flatMap(u=>u.violations),p=a.length>0;function d(){re({type:"START_AUDIT",mode:"full-page",matrixOverride:mt(n)}),f.getState().startNewScan(),ne.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:l,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(Hr,{depth:n,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(Br,{}),p&&e.jsx(zr,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function Br(){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 Hr({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(Vt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Mt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Vt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Mt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Vt({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 zr({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var S;const r=f(I=>I.status),i=f(I=>I.results),o=f(I=>I.freshThisSession),l=f(I=>I.componentId),c=(S=i[0])==null?void 0:S.startedAt,p=yr(t),d=r==="running",[u,m]=h.useState([]);h.useEffect(()=>{if(!l){m([]);return}let I=!1;return chrome.storage.local.get("igtRuns").then(L=>{if(I)return;const $=((L==null?void 0:L.igtRuns)??{})[l]??{};m(Object.values($))}),()=>{I=!0}},[l]);const x=f(I=>I.acknowledgedKeys),g=i.length>0?Qt(i,{runs:u,workflows:Q},"2.1","AA",x):void 0;function v(){re({type:"START_AUDIT",mode:"full-page",matrixOverride:mt(n)}),f.getState().startNewScan(),ne.polite("Re-scanning this page now.")}const N=s==="lawsuit-risk"?t.filter(I=>I.impact==="critical"||I.impact==="serious"):t,T=new Map;for(const I of N){const L=ct(I.ruleId,I.target.selector);T.has(L)||T.set(L,I)}const k=Array.from(T.values()),C=new Map;for(const I of k){const L=C.get(I.ruleId)??[];L.push(I),C.set(I.ruleId,L)}const b=Array.from(C.entries()).sort((I,L)=>(Gt[I[1][0].impact]??99)-(Gt[L[1][0].impact]??99)),y=t.filter(I=>I.impact==="critical"||I.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(Xr,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Ve(),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:v,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 ${Dr[p.tier]}`,children:[!o&&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 ${Fr[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 ${Pt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Pt[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(Kr,{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(Jr,{}),e.jsx(Tr,{}),t.length>0&&e.jsx(qr,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:y}),e.jsxs("div",{className:"space-y-2",children:[b.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."]}),b.map(([I,L])=>e.jsx(Qr,{ruleId:I,violations:L},I))]})]})}function Kr({coverage:t}){const s=f(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),Y({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function qr({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 Qr({ruleId:t,violations:s}){var u;const[a,n]=h.useState(!1),r=(u=s.find(m=>m.target.opacityContext))==null?void 0:u.target.opacityContext,i=Gs(t,r),o=s[0].impact,l=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,d=l.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Mr[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(Yr,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Yr({violation:t}){const s=f(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const o=await te();if(o)try{const l=await Ce(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const Ee=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function Jr(){const t=f(d=>d.results),s=f(d=>d.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[o,l]=h.useState(null);async function c(d,u){if(t.length!==0){n(d);try{const m=await X({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=Ht(d,s);await zt()?ot(m.content,x):l({open:!0,format:d,content:m.content,filename:x})}else if(u)it(m.content);else{try{await navigator.clipboard.writeText(m.content),ne.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
235
+ </html>`}async function Rr(t){const s=Ir(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function bs(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[o,l]=h.useState(!1),[c,p]=h.useState(""),[d,u]=h.useState(""),[m,x]=h.useState(""),[g,w]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),Yt().then(v=>{b||s(v)}).catch(v=>{b||n(v instanceof Error?v.message:String(v))}),()=>{b=!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 k=t.length,T=t.filter(b=>b.receipt).length;async function N(){if(!(!t||t.length===0)){w(!0);try{await Rr({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:m.trim()||void 0}),l(!1)}finally{w(!1)}}}async function C(){if(!t||t.length===0)return;const b={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},v=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),S=URL.createObjectURL(v),I=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,L=document.createElement("a");L.href=S,L.download=I,L.click(),setTimeout(()=>URL.revokeObjectURL(S),1e3)}return k===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:[k," ",k===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&&k>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void C(),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(b=>b+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:b=>p(b.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:b=>u(b.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:m,onChange:b=>x(b.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||k===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(b=>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 ${b.grade==="A"?"bg-emerald-100 text-emerald-700":b.grade==="B"?"bg-lime-100 text-lime-700":b.grade==="C"?"bg-yellow-100 text-yellow-700":b.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:b.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:b.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${b.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:b.receipt?`Anchored to ${b.receipt.tsaName} at ${b.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:b.receipt?`RFC 3161 (${b.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:b.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:b.capturedAt}),(b.totals.critical>0||b.totals.serious>0)&&e.jsxs("span",{children:[b.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[b.totals.critical," crit"]}),b.totals.critical>0&&b.totals.serious>0&&" · ",b.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[b.totals.serious," sev"]})]}),e.jsxs("span",{children:[b.statesAudited," ",b.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:b.hash,children:[b.hash.slice(0,12),"…"]})]})]},`${b.componentId}::${b.capturedAt}`))})]})}function Er(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let c=!1;return Yt().then(p=>{c||s(p)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(be,{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(bs,{})})})]})}function Tr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const $r={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."},Lr={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."},_r={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Ur={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function vs(){const t=f(u=>u.tier),s=f(u=>u.trialDaysRemaining),a=f(u=>u.seatsUsed),n=f(u=>u.seatsTotal),r=f(u=>u.planCode),i=f(u=>u.licenseDaysRemaining),o=f(u=>u.pastDue),[l,c]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const u=i,m=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:m?"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:m?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:m?"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:m?"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:m?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Xe,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const u=t==="team"?Ur:_r,m=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=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}: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:[" · ",m]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),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 Y({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const p=t==="trial"?$r:Lr,d=t==="trial"?Tr(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 Y({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Xe,{open:l,onClose:()=>c(!1)})]})}const Or={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"},Dr={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Pt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},Fr={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"},Gt={critical:0,serious:1,moderate:2,minor:3};function Mr(){const t=f(u=>u.setUserMode),s=f(u=>u.status),a=f(u=>u.setStatus),n=f(u=>u.errorMessage),r=f(u=>u.setError),[i,o]=h.useState(!1),[l,c]=h.useState(!1),p=h.useRef(s);h.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]),h.useEffect(()=>{if(s!=="running")return;const u=setTimeout(()=>{f.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"),Y({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(vs,{}),e.jsx(os,{}),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(is,{}),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(Pr,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{f.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(gs,{onBack:()=>o(!1)}):e.jsx(Vr,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Gr,{})]}),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 Pr(){const t=f(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function Gr(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function Vr({onPickCrawl:t}){const s=f(u=>u.status),a=f(u=>u.results),[n,r]=h.useState("quick"),[i,o]=h.useState("all"),l=s==="running",c=a.flatMap(u=>u.violations),p=a.length>0;function d(){re({type:"START_AUDIT",mode:"full-page",matrixOverride:mt(n)}),f.getState().startNewScan(),ne.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:l,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(Br,{depth:n,onChange:r,disabled:l})]}),!p&&!l&&e.jsx(Wr,{}),p&&e.jsx(Hr,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function Wr(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function Br({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(Vt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Mt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Vt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Mt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Vt({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 Hr({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var S;const r=f(I=>I.status),i=f(I=>I.results),o=f(I=>I.freshThisSession),l=f(I=>I.componentId),c=(S=i[0])==null?void 0:S.startedAt,p=vr(t),d=r==="running",[u,m]=h.useState([]);h.useEffect(()=>{if(!l){m([]);return}let I=!1;return chrome.storage.local.get("igtRuns").then(L=>{if(I)return;const $=((L==null?void 0:L.igtRuns)??{})[l]??{};m(Object.values($))}),()=>{I=!0}},[l]);const x=f(I=>I.acknowledgedKeys),g=i.length>0?Qt(i,{runs:u,workflows:Q},"2.1","AA",x):void 0;function w(){re({type:"START_AUDIT",mode:"full-page",matrixOverride:mt(n)}),f.getState().startNewScan(),ne.polite("Re-scanning this page now.")}const k=s==="lawsuit-risk"?t.filter(I=>I.impact==="critical"||I.impact==="serious"):t,T=new Map;for(const I of k){const L=ct(I.ruleId,I.target.selector);T.has(L)||T.set(L,I)}const N=Array.from(T.values()),C=new Map;for(const I of N){const L=C.get(I.ruleId)??[];L.push(I),C.set(I.ruleId,L)}const b=Array.from(C.entries()).sort((I,L)=>(Gt[I[1][0].impact]??99)-(Gt[L[1][0].impact]??99)),v=t.filter(I=>I.impact==="critical"||I.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(Jr,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void Ge(),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 ${Or[p.tier]}`,children:[!o&&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 ${Dr[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 ${Pt[p.tier]} capitalize`,children:[p.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Pt[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(zr,{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(Yr,{}),e.jsx(Er,{}),t.length>0&&e.jsx(Kr,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:v}),e.jsxs("div",{className:"space-y-2",children:[b.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."]}),b.map(([I,L])=>e.jsx(qr,{ruleId:I,violations:L},I))]})]})}function zr({coverage:t}){const s=f(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),Y({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function Kr({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function qr({ruleId:t,violations:s}){var u;const[a,n]=h.useState(!1),r=(u=s.find(m=>m.target.opacityContext))==null?void 0:u.target.opacityContext,i=Bs(t,r),o=s[0].impact,l=s[0],p=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,d=l.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Fr[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:p}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(Qr,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function Qr({violation:t}){const s=f(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const o=await te();if(o)try{const l=await Ce(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const Ee=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function Yr(){const t=f(d=>d.results),s=f(d=>d.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[o,l]=h.useState(null);async function c(d,u){if(t.length!==0){n(d);try{const m=await X({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=Ht(d,s);await zt()?it(m.content,x):l({open:!0,format:d,content:m.content,filename:x})}else if(u)rt(m.content);else{try{await navigator.clipboard.writeText(m.content),ne.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
236
236
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
237
237
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
238
238
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
239
239
  <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>
240
- <pre>${m.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,v=new Blob([g],{type:"text/html"}),N=URL.createObjectURL(v);window.open(N,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(N),6e4)}}finally{n(null)}}}const p=r?Ee:Ee.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(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 ",Ee.length-2," more report option",Ee.length-2===1?"":"s"," ↓"]}),o&&e.jsx(xs,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Xr({iso:t}){const[,s]=h.useState(0);h.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 Zr(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const c of l){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:o,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 ei(t,s,a){const n=[];let r=0,i=0,o=0,l=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,m]of s){const x=m[p.id];if(!x){i+=d.length;continue}for(const g of d){const v=x.steps[g.id];if(!v){i++;continue}v.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${p.id}.${g.id}`,description:g.question,pageUrl:u,notes:v.notes})):v.status==="skip"?i++:v.status==="not-applicable"?(o++,l++):o++}}}}const c=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function ti(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 si(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 ai(t,s){var u;const a=[];for(const m of s.auditsByUrl.values())a.push(...m);const n=[];for(const m of s.igtRunsByUrl.values())n.push(...Object.values(m));const r=dt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Vs(t.targetVersion,t.targetLevel),o=[];for(const m of i){const x=Zr(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=ei(m.id,s.igtRunsByUrl,s.workflows),v=x.rulesFiring.size===0&&g.stepsCovering===0,N={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:v},T=(u=t.overrides)==null?void 0:u[m.id];let k,C,b=!1;if(T)k=T.verdict,C=T.rationale,b=!0;else{const y=r.get(m.id);y?k=y.state:k=ti(N,g.unanswered,x.hasIncomplete,g.allNotApplicable),C=si(m,k,N)}o.push({criterion:m,understandingUrl:Ws(m,t.targetVersion),verdict:k,signals:N,overridden:b,rationale:C})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of o)m.verdict==="pass"?l.pass++:m.verdict==="fail"?l.fail++:m.verdict==="inconclusive"?l.inconclusive++:m.verdict==="not-applicable"?l.notApplicable++:m.verdict==="not-evaluated"&&l.notEvaluated++;function c(m){const x={A:1,AA:2,AAA:3},g=x[m];return o.every(v=>x[v.criterion.level]>g?!0:v.verdict==="pass"||v.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:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:p,meetsTarget:d}}}const ni={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Wt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function E(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ke(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function ri(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,c=o.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 m=u.criterion.id.split(".").slice(0,2).join("."),x=p.get(m)??[];x.push(u),p.set(m,x)}const d=Array.from(p.entries()).sort(([u],[m])=>u.localeCompare(m,void 0,{numeric:!0})).map(([u,m])=>`
240
+ <pre>${m.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,w=new Blob([g],{type:"text/html"}),k=URL.createObjectURL(w);window.open(k,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(k),6e4)}}finally{n(null)}}}const p=r?Ee:Ee.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:p.map(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 ",Ee.length-2," more report option",Ee.length-2===1?"":"s"," ↓"]}),o&&e.jsx(xs,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function Jr({iso:t}){const[,s]=h.useState(0);h.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 Xr(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const c of l){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:o,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 Zr(t,s,a){const n=[];let r=0,i=0,o=0,l=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,m]of s){const x=m[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"?(o++,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"?(o++,l++):o++}}}}const c=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function ei(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 ti(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 si(t,s){var u;const a=[];for(const m of s.auditsByUrl.values())a.push(...m);const n=[];for(const m of s.igtRunsByUrl.values())n.push(...Object.values(m));const r=dt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Hs(t.targetVersion,t.targetLevel),o=[];for(const m of i){const x=Xr(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=Zr(m.id,s.igtRunsByUrl,s.workflows),w=x.rulesFiring.size===0&&g.stepsCovering===0,k={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:w},T=(u=t.overrides)==null?void 0:u[m.id];let N,C,b=!1;if(T)N=T.verdict,C=T.rationale,b=!0;else{const v=r.get(m.id);v?N=v.state:N=ei(k,g.unanswered,x.hasIncomplete,g.allNotApplicable),C=ti(m,N,k)}o.push({criterion:m,understandingUrl:zs(m,t.targetVersion),verdict:N,signals:k,overridden:b,rationale:C})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of o)m.verdict==="pass"?l.pass++:m.verdict==="fail"?l.fail++:m.verdict==="inconclusive"?l.inconclusive++:m.verdict==="not-applicable"?l.notApplicable++:m.verdict==="not-evaluated"&&l.notEvaluated++;function c(m){const x={A:1,AA:2,AAA:3},g=x[m];return o.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:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:p,meetsTarget:d}}}const ai={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Wt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function E(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ke(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function ni(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,c=o.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 m=u.criterion.id.split(".").slice(0,2).join("."),x=p.get(m)??[];x.push(u),p.set(m,x)}const d=Array.from(p.entries()).sort(([u],[m])=>u.localeCompare(m,void 0,{numeric:!0})).map(([u,m])=>`
241
241
  <h3 class="guideline-h">Guideline ${E(u)}</h3>
242
242
  <table class="criteria-table">
243
243
  <thead>
@@ -251,7 +251,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
251
251
  <td><a href="${E(x.understandingUrl)}" target="_blank" rel="noopener">${E(x.criterion.id)}</a></td>
252
252
  <td>${E(x.criterion.title)}</td>
253
253
  <td>${E(x.criterion.level)}</td>
254
- <td><span class="verdict-badge ${Wt[x.verdict]}">${ni[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
254
+ <td><span class="verdict-badge ${Wt[x.verdict]}">${ai[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
255
255
  <td class="rationale">${E(x.rationale)}</td>
256
256
  </tr>
257
257
  ${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
@@ -539,6 +539,6 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
539
539
  <span>${o.totalCriteria} criteria · ${o.pass} pass · ${o.fail} fail · ${o.inconclusive} inconclusive</span>
540
540
  </footer>
541
541
  </body>
542
- </html>`}async function ii(t,s,a,n){const r=ri(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const Je=Kt("wcag-em-anchor"),oi="https://api.wcagcheckr.com",li="wcagcheckr",ci=15e3;function ys(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 di(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 ui(t){return di(Bs(ys(t)))}function pi(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 mi(t,s){const a=await ui(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${oi}/v1/products/${li}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(ci)});if(!i.ok)return Je.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return pi(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Je.warn("anchor returned malformed receipt",o),null)}catch(i){return Je.warn("anchor request failed",i),null}}function hi(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:ys(t)}}const at="auditAttestations",nt="auditAttestation:defaultSigner";function ht(t,s){return`${t}::${s}`}async function xt(){try{const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:{}}catch{return{}}}async function js(t){await chrome.storage.local.set({[at]:t})}async function xi(t){const s=await xt();s[ht(t.componentId,t.auditCapturedAt)]=t,await js(s)}async function ws(t,s){return(await xt())[ht(t,s)]??null}async function gi(t,s){const a=await xt();delete a[ht(t,s)],await js(a)}async function fi(){try{const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:null}catch{return null}}async function bi(t){await chrome.storage.local.set({[nt]:t})}function vi(t,s){return t.auditCapturedAt!==s}function yi(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 ji(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(""),[p,d]=h.useState(""),[u,m]=h.useState(""),[x,g]=h.useState(""),[v,N]=h.useState("");h.useEffect(()=>{let y=!1;return Promise.all([ws(t.componentId,t.auditCapturedAt),fi()]).then(([S,I])=>{y||(a(S),S?(c(S.signerName),d(S.signerEmail),m(S.signerOrganization??""),g(S.signerQualifications??""),N(S.claim)):I&&(c(I.signerName),d(I.signerEmail),m(I.signerOrganization??""),g(I.signerQualifications??"")),N(L=>L||yi({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{y=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!l.trim()||!p.trim())return;const y={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:x.trim()||void 0,claim:v.trim(),scope:t.scope};await xi(y),await bi({signerName:y.signerName,signerEmail:y.signerEmail,signerOrganization:y.signerOrganization,signerQualifications:y.signerQualifications}),a(y),o(!1)}async function k(){await gi(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const C=s&&vi(s,t.auditCapturedAt);if(s&&!C&&!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:()=>o(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void k(),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&&C&&!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:()=>o(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=l.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:l,onChange:y=>c(y.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:y=>d(y.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:y=>m(y.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:y=>g(y.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:v,onChange:y=>N(y.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:()=>o(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!b,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 rt="spotAuditReviews";function Ns(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function gt(){try{const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function ks(t){await chrome.storage.local.set({[rt]:t})}async function wi(t){const s=await gt();s[t.key]=t,await ks(s)}async function Ni(t){const s=await gt();delete s[t],await ks(s)}async function Ss(){const t=await gt();return Object.values(t)}function As(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function ki(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 Si(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 o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:Ns({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:l})}return n}const Ai={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"},Ci={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 Ii({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Si(t,s),[t,s]),[n,r]=h.useState([]),[i,o]=h.useState(!0),[l,c]=h.useState(null),[p,d]=h.useState(5),[u,m]=h.useState(!1);h.useEffect(()=>{let b=!1;return Ss().then(y=>{b||(r(y),o(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),g=h.useMemo(()=>As(x,n),[x,n]),N=(u?x:l||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(y=>y.key===b)).filter(b=>!!b);async function T(b,y,S){const I={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:y,correction:(S==null?void 0:S.trim())||void 0,reviewedAt:new Date().toISOString()};await wi(I),r(L=>[I,...L.filter(j=>j.key!==I.key)])}async function k(b){await Ni(b.key),r(y=>y.filter(S=>S.key!==b.key))}function C(){c(ki(x,p)),m(!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(Te,{label:"AI determinations",value:g.total}),e.jsx(Te,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Te,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Te,{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:b=>d(Math.max(1,Math.min(a.length,Number(b.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:C,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:()=>{m(b=>!b),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})`}),l&&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…"}):N.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:N.map(b=>e.jsx(Ri,{row:b,review:n.find(y=>y.key===b.key)??null,onAgree:()=>void T(b,"agreed"),onDisagree:y=>void T(b,"disagreed",y),onClear:()=>void k(b)},b.key))})]})}function Te({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 Ri(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,o]=h.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="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 ${Ai[s.outcome]}`,children:Ci[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 ${l==="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 ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&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)&&l==="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=>o(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),o((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 Xe(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(null);h.useEffect(()=>{let u=!1;return Hs(t.componentId,t.criterionId).then(m=>{u||(a(m),r(!1))}),()=>{u=!0}},[t.componentId,t.criterionId]);async function p(){o(!0),c(null);try{const m=await Y({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});m.ok?m.result&&a(m.result):c(m.error??"Audit failed.")}catch(u){c(u instanceof Error?u.message:String(u))}finally{o(!1)}}async function d(){await zs(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&&!l&&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"}),l&&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:l}),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}),e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",s.steps.filter(u=>u.action!=="initial").length," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:s.steps.filter(u=>u.action!=="initial").map(u=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",u.focused.role||u.focused.tag,"]"]})," ",u.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:u.focused.selector})]},u.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 Ei(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return te().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(Xe,{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(Xe,{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(Xe,{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.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 Bt="igtRuns",Ti={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"},$i={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Li(){var de,J,q;const t=f(A=>A.results),s=f(A=>A.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),o=qs,l=Ks,[c,p]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,u]=h.useState(""),[m,x]=h.useState(""),[g,v]=h.useState(""),[N,T]=h.useState(""),[k,C]=h.useState(""),[b,y]=h.useState(""),[S,I]=h.useState({}),[L,j]=h.useState(!1),[$,_]=h.useState([]),[w,O]=h.useState([]),[D,F]=h.useState(null),[se,pe]=h.useState(!1),[ce,oe]=h.useState(null);h.useEffect(()=>{let A=!1;return chrome.storage.local.get(Bt).then(G=>{if(A)return;const U=G[Bt]??{};I(U),j(!0)}).catch(()=>{A||j(!0)}),()=>{A=!0}},[]),h.useEffect(()=>{var V;const A=(V=t[0])==null?void 0:V.componentId;if(!A)return;let G=!1;const U=()=>{qt(A).then(W=>{G||O(W.map(ee=>({criterionId:ee.criterionId,ruleId:`ai-interactive::${ee.criterionId}`,pageUrl:ee.pageUrl,verdict:ee.verdict,reasoning:ee.reasoning})))})};U();const M=W=>{W.interactiveAuditResults&&U()};return chrome.storage.local.onChanged.addListener(M),()=>{G=!0,chrome.storage.local.onChanged.removeListener(M)}},[t]),h.useEffect(()=>{var A;if(!a&&((A=t[0])!=null&&A.pageUrl))try{const G=new URL(t[0].pageUrl);n(G.hostname),i(G.origin)}catch{}},[t,a]),h.useEffect(()=>{const A=new Set;for(const U of t)A.add(U.pageUrl??U.scope);if(A.size===0){_([]);return}let G=!1;return Promise.all(Array.from(A).map(U=>$e(U))).then(U=>{G||_(U.flat())}).catch(()=>{}),()=>{G=!0}},[t]);const B=h.useMemo(()=>{const A=new Map,G=new Map;for(const M of t){const V=M.pageUrl??M.scope,W=A.get(V)??[];W.push(M),A.set(V,W)}const U=new Map;for(const M of t){const V=M.pageUrl??M.scope;U.set(M.componentId,V)}for(const[M,V]of Object.entries(S)){const W=U.get(M);if(!W)continue;const ee=G.get(W)??{};Object.assign(ee,V),G.set(W,ee)}return{auditsByUrl:A,igtRunsByUrl:G,workflows:Q,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:w}},[t,S,s,$,w]),le=h.useMemo(()=>{const A=[],G=new Set;for(const U of B.auditsByUrl.keys())G.has(U)||(G.add(U),A.push({url:U,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const U of b.split(`
543
- `).map(M=>M.trim()).filter(Boolean))G.has(U)||(G.add(U),A.push({url:U,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return A},[B,b]),me=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(A=>A.trim()).filter(Boolean),pageSample:le,evaluator:{name:m||"(evaluator name pending)",organization:g||void 0,qualifications:N||void 0,contact:k||void 0}}),[a,r,o,l,c,d,le,m,g,N,k]),R=h.useMemo(()=>L?ai(me,B):null,[me,B,L]),z=h.useMemo(()=>{const A=Array.from(B.auditsByUrl.values()).flat(),G=Object.values(S).flatMap(U=>Object.values(U));return dt({audits:A,igtRuns:G,workflows:Q,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:w})},[B,S,s,$,w]);async function Z(){if(!R)return;const A=t[0],G=A!=null&&A.componentId&&(A!=null&&A.startedAt)?await ws(A.componentId,A.startedAt):null,U=await Ss(),M=[];for(const W of z.values())for(const ee of W.evidence)ee.source==="ai"&&M.push(Ns({criterionId:W.criterionId,ruleOrStepId:ee.ruleOrStepId,pageUrl:ee.pageUrl,selector:ee.selector}));const V=As(M,U);await ii(R,D,G,V)}async function K(){if(R){pe(!0),oe(null);try{const A=await mi(R);if(!A){oe("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}F(A)}finally{pe(!1)}}}function H(){var ee,ft,bt;if(!R||!D)return;const A=((bt=(ft=(ee=chrome.runtime).getManifest)==null?void 0:ft.call(ee))==null?void 0:bt.version)??"0.0.0",G=hi(R,D,A),U=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),M=URL.createObjectURL(U),V=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,W=document.createElement("a");W.href=M,W.download=V,W.click(),setTimeout(()=>URL.revokeObjectURL(M),1e3)}return h.useEffect(()=>{F(null),oe(null)},[a,r,c,d,m,g,N,k,b]),L?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."})]}),R&&R.summary.totalCriteria>0&&e.jsx(_i,{totalCriteria:R.summary.totalCriteria,pass:R.summary.pass,fail:R.summary.fail,inconclusive:R.summary.inconclusive,notEvaluated:R.summary.notEvaluated,notApplicable:R.summary.notApplicable,levelAchieved:R.summary.levelAchieved,meetsTarget:R.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:B.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:A=>n(A.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:A=>i(A.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:c,onChange:A=>p(A.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:d,onChange:A=>u(A.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",B.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:B.auditsByUrl.size})," URL",B.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:b,onChange:A=>y(A.target.value),rows:3,placeholder:`https://app.example.com/checkout
544
- 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:m,onChange:A=>x(A.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:g,onChange:A=>v(A.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:N,onChange:A=>T(A.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:k,onChange:A=>C(A.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),R&&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 (",R.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:R.rows.map(A=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[A.criterion.id," · ",A.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:A.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Ti[A.verdict]}`,children:$i[A.verdict]})]},A.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),D?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:[D.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",D.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.`}),ce&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:ce}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!R||!a||!m||se,onClick:()=>void K(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:se?"Anchoring…":D?"Re-anchor":"Anchor this report"}),D&&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"})]})]}),R&&((de=t[0])==null?void 0:de.componentId)&&e.jsx(Ei,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),R&&e.jsx(Ii,{verdicts:z,incompleteResolutions:$}),R&&((J=t[0])==null?void 0:J.componentId)&&((q=t[0])==null?void 0:q.startedAt)&&e.jsx(ji,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:R.summary.pass+R.summary.fail+R.summary.inconclusive+R.summary.notApplicable,totalCount:R.summary.totalCriteria,canClaimConformance:R.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:!R||!a||!m,onClick:()=>void Z(),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 _i({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:c,targetLevel:p,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${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:o??"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]})]})}function Wi(){const t=f(a=>a.view),s=f(a=>a.userMode);return h.useEffect(()=>{const a=la(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=aa();es({forceRefresh:!0}).catch(()=>{}),Oe().catch(()=>{}),oa().catch(()=>{}),ca().catch(()=>{}),ra().catch(()=>{}),Qs().then(l=>{f.getState().setAcknowledgedKeys(new Set(l.map(c=>c.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:c,setPinned:p,results:d}=f.getState();c&&(p(null),te().then(u=>{var m;u&&ie(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(m=d[0])==null?void 0:m.frameId).catch(()=>{})}))};return window.addEventListener("keydown",o),()=>{i(),a.disconnect(),r==null||r.disconnect(),window.removeEventListener("keydown",o)}},[]),s===null?e.jsxs(e.Fragment,{children:[e.jsx(fr,{}),e.jsx(He,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{}),e.jsx(Ft,{}),e.jsx(He,{})]}):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(vs,{}),e.jsx(os,{}),e.jsx(Na,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ca,{}),e.jsx($a,{}),e.jsx(mr,{}),e.jsx(pr,{}),e.jsx(_a,{}),e.jsx(dr,{}),e.jsx(ur,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Ya,{}),t==="report"&&e.jsx(xn,{}),t==="delta"&&e.jsx(An,{}),t==="activity"&&e.jsx(Fn,{}),t==="guided"&&e.jsx(Yn,{}),t==="flows"&&e.jsx(er,{}),t==="scorecard"&&e.jsx(ar,{}),t==="crawl"&&e.jsx(gs,{}),t==="forensic"&&e.jsx(bs,{}),t==="compliance"&&e.jsx(Li,{})]})]}),e.jsx(gr,{}),e.jsx(hr,{}),e.jsx(cr,{}),e.jsx(Ft,{}),e.jsx(He,{})]})}class Bi extends Se.Component{constructor(){super(...arguments);vt(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{Wi as A,Bi as E,Vi as d};
542
+ </html>`}async function ri(t,s,a,n){const r=ni(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const Ye=Kt("wcag-em-anchor"),ii="https://api.wcagcheckr.com",oi="wcagcheckr",li=15e3;function ys(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 ci(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 di(t){return ci(Ks(ys(t)))}function ui(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 pi(t,s){const a=await di(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${ii}/v1/products/${oi}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(li)});if(!i.ok)return Ye.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return ui(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Ye.warn("anchor returned malformed receipt",o),null)}catch(i){return Ye.warn("anchor request failed",i),null}}function mi(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:ys(t)}}const st="auditAttestations",at="auditAttestation:defaultSigner";function ht(t,s){return`${t}::${s}`}async function xt(){try{const s=(await chrome.storage.local.get(st))[st];return s&&typeof s=="object"?s:{}}catch{return{}}}async function js(t){await chrome.storage.local.set({[st]:t})}async function hi(t){const s=await xt();s[ht(t.componentId,t.auditCapturedAt)]=t,await js(s)}async function ws(t,s){return(await xt())[ht(t,s)]??null}async function xi(t,s){const a=await xt();delete a[ht(t,s)],await js(a)}async function gi(){try{const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:null}catch{return null}}async function fi(t){await chrome.storage.local.set({[at]:t})}function bi(t,s){return t.auditCapturedAt!==s}function vi(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 yi(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(""),[p,d]=h.useState(""),[u,m]=h.useState(""),[x,g]=h.useState(""),[w,k]=h.useState("");h.useEffect(()=>{let v=!1;return Promise.all([ws(t.componentId,t.auditCapturedAt),gi()]).then(([S,I])=>{v||(a(S),S?(c(S.signerName),d(S.signerEmail),m(S.signerOrganization??""),g(S.signerQualifications??""),k(S.claim)):I&&(c(I.signerName),d(I.signerEmail),m(I.signerOrganization??""),g(I.signerQualifications??"")),k(L=>L||vi({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{v=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!l.trim()||!p.trim())return;const v={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:p.trim(),signerOrganization:u.trim()||void 0,signerQualifications:x.trim()||void 0,claim:w.trim(),scope:t.scope};await hi(v),await fi({signerName:v.signerName,signerEmail:v.signerEmail,signerOrganization:v.signerOrganization,signerQualifications:v.signerQualifications}),a(v),o(!1)}async function N(){await xi(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const C=s&&bi(s,t.auditCapturedAt);if(s&&!C&&!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:()=>o(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void 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&&C&&!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:()=>o(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=l.trim().length>0&&p.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:l,onChange:v=>c(v.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:v=>d(v.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:v=>m(v.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:v=>g(v.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:v=>k(v.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:()=>o(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!b,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 nt="spotAuditReviews";function Ns(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function gt(){try{const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function ks(t){await chrome.storage.local.set({[nt]:t})}async function ji(t){const s=await gt();s[t.key]=t,await ks(s)}async function wi(t){const s=await gt();delete s[t],await ks(s)}async function Ss(){const t=await gt();return Object.values(t)}function As(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Ni(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 ki(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 o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:Ns({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:l})}return n}const Si={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"},Ai={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 Ci({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>ki(t,s),[t,s]),[n,r]=h.useState([]),[i,o]=h.useState(!0),[l,c]=h.useState(null),[p,d]=h.useState(5),[u,m]=h.useState(!1);h.useEffect(()=>{let b=!1;return Ss().then(v=>{b||(r(v),o(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),g=h.useMemo(()=>As(x,n),[x,n]),k=(u?x:l||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(v=>v.key===b)).filter(b=>!!b);async function T(b,v,S){const I={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:v,correction:(S==null?void 0:S.trim())||void 0,reviewedAt:new Date().toISOString()};await ji(I),r(L=>[I,...L.filter(y=>y.key!==I.key)])}async function N(b){await wi(b.key),r(v=>v.filter(S=>S.key!==b.key))}function C(){c(Ni(x,p)),m(!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(Te,{label:"AI determinations",value:g.total}),e.jsx(Te,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Te,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Te,{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:b=>d(Math.max(1,Math.min(a.length,Number(b.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:C,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:()=>{m(b=>!b),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})`}),l&&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…"}):k.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:k.map(b=>e.jsx(Ii,{row:b,review:n.find(v=>v.key===b.key)??null,onAgree:()=>void T(b,"agreed"),onDisagree:v=>void T(b,"disagreed",v),onClear:()=>void N(b)},b.key))})]})}function Te({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 Ii(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,o]=h.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="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 ${Si[s.outcome]}`,children:Ai[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 ${l==="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 ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&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)&&l==="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=>o(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),o((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 Je(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(null);h.useEffect(()=>{let u=!1;return qs(t.componentId,t.criterionId).then(m=>{u||(a(m),r(!1))}),()=>{u=!0}},[t.componentId,t.criterionId]);async function p(){o(!0),c(null);try{const m=await Y({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});m.ok?m.result&&a(m.result):c(m.error??"Audit failed.")}catch(u){c(u instanceof Error?u.message:String(u))}finally{o(!1)}}async function d(){await Qs(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&&!l&&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"}),l&&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:l}),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}),e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",s.steps.filter(u=>u.action!=="initial").length," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:s.steps.filter(u=>u.action!=="initial").map(u=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",u.focused.role||u.focused.tag,"]"]})," ",u.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:u.focused.selector})]},u.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 Ri(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return te().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(Je,{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(Je,{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(Je,{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.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 Bt="igtRuns",Ei={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"},Ti={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function $i(){var de,J,q;const t=f(A=>A.results),s=f(A=>A.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),o=Js,l=Ys,[c,p]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,u]=h.useState(""),[m,x]=h.useState(""),[g,w]=h.useState(""),[k,T]=h.useState(""),[N,C]=h.useState(""),[b,v]=h.useState(""),[S,I]=h.useState({}),[L,y]=h.useState(!1),[$,_]=h.useState([]),[j,O]=h.useState([]),[D,F]=h.useState(null),[se,pe]=h.useState(!1),[ce,oe]=h.useState(null);h.useEffect(()=>{let A=!1;return chrome.storage.local.get(Bt).then(G=>{if(A)return;const U=G[Bt]??{};I(U),y(!0)}).catch(()=>{A||y(!0)}),()=>{A=!0}},[]),h.useEffect(()=>{var V;const A=(V=t[0])==null?void 0:V.componentId;if(!A)return;let G=!1;const U=()=>{qt(A).then(W=>{G||O(W.map(ee=>({criterionId:ee.criterionId,ruleId:`ai-interactive::${ee.criterionId}`,pageUrl:ee.pageUrl,verdict:ee.verdict,reasoning:ee.reasoning})))})};U();const M=W=>{W.interactiveAuditResults&&U()};return chrome.storage.local.onChanged.addListener(M),()=>{G=!0,chrome.storage.local.onChanged.removeListener(M)}},[t]),h.useEffect(()=>{var A;if(!a&&((A=t[0])!=null&&A.pageUrl))try{const G=new URL(t[0].pageUrl);n(G.hostname),i(G.origin)}catch{}},[t,a]),h.useEffect(()=>{const A=new Set;for(const U of t)A.add(U.pageUrl??U.scope);if(A.size===0){_([]);return}let G=!1;return Promise.all(Array.from(A).map(U=>$e(U))).then(U=>{G||_(U.flat())}).catch(()=>{}),()=>{G=!0}},[t]);const B=h.useMemo(()=>{const A=new Map,G=new Map;for(const M of t){const V=M.pageUrl??M.scope,W=A.get(V)??[];W.push(M),A.set(V,W)}const U=new Map;for(const M of t){const V=M.pageUrl??M.scope;U.set(M.componentId,V)}for(const[M,V]of Object.entries(S)){const W=U.get(M);if(!W)continue;const ee=G.get(W)??{};Object.assign(ee,V),G.set(W,ee)}return{auditsByUrl:A,igtRunsByUrl:G,workflows:Q,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:j}},[t,S,s,$,j]),le=h.useMemo(()=>{const A=[],G=new Set;for(const U of B.auditsByUrl.keys())G.has(U)||(G.add(U),A.push({url:U,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const U of b.split(`
543
+ `).map(M=>M.trim()).filter(Boolean))G.has(U)||(G.add(U),A.push({url:U,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return A},[B,b]),me=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(A=>A.trim()).filter(Boolean),pageSample:le,evaluator:{name:m||"(evaluator name pending)",organization:g||void 0,qualifications:k||void 0,contact:N||void 0}}),[a,r,o,l,c,d,le,m,g,k,N]),R=h.useMemo(()=>L?si(me,B):null,[me,B,L]),z=h.useMemo(()=>{const A=Array.from(B.auditsByUrl.values()).flat(),G=Object.values(S).flatMap(U=>Object.values(U));return dt({audits:A,igtRuns:G,workflows:Q,acknowledgedMatchKeys:s,incompleteResolutions:$,interactiveAuditResults:j})},[B,S,s,$,j]);async function Z(){if(!R)return;const A=t[0],G=A!=null&&A.componentId&&(A!=null&&A.startedAt)?await ws(A.componentId,A.startedAt):null,U=await Ss(),M=[];for(const W of z.values())for(const ee of W.evidence)ee.source==="ai"&&M.push(Ns({criterionId:W.criterionId,ruleOrStepId:ee.ruleOrStepId,pageUrl:ee.pageUrl,selector:ee.selector}));const V=As(M,U);await ri(R,D,G,V)}async function K(){if(R){pe(!0),oe(null);try{const A=await pi(R);if(!A){oe("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}F(A)}finally{pe(!1)}}}function H(){var ee,ft,bt;if(!R||!D)return;const A=((bt=(ft=(ee=chrome.runtime).getManifest)==null?void 0:ft.call(ee))==null?void 0:bt.version)??"0.0.0",G=mi(R,D,A),U=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),M=URL.createObjectURL(U),V=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,W=document.createElement("a");W.href=M,W.download=V,W.click(),setTimeout(()=>URL.revokeObjectURL(M),1e3)}return h.useEffect(()=>{F(null),oe(null)},[a,r,c,d,m,g,k,N,b]),L?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."})]}),R&&R.summary.totalCriteria>0&&e.jsx(Li,{totalCriteria:R.summary.totalCriteria,pass:R.summary.pass,fail:R.summary.fail,inconclusive:R.summary.inconclusive,notEvaluated:R.summary.notEvaluated,notApplicable:R.summary.notApplicable,levelAchieved:R.summary.levelAchieved,meetsTarget:R.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:B.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:A=>n(A.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:A=>i(A.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:c,onChange:A=>p(A.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:d,onChange:A=>u(A.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",B.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:B.auditsByUrl.size})," URL",B.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:b,onChange:A=>v(A.target.value),rows:3,placeholder:`https://app.example.com/checkout
544
+ 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:m,onChange:A=>x(A.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:g,onChange:A=>w(A.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:k,onChange:A=>T(A.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:N,onChange:A=>C(A.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),R&&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 (",R.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:R.rows.map(A=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[A.criterion.id," · ",A.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:A.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Ei[A.verdict]}`,children:Ti[A.verdict]})]},A.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),D?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:[D.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",D.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.`}),ce&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:ce}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!R||!a||!m||se,onClick:()=>void K(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:se?"Anchoring…":D?"Re-anchor":"Anchor this report"}),D&&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"})]})]}),R&&((de=t[0])==null?void 0:de.componentId)&&e.jsx(Ri,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),R&&e.jsx(Ci,{verdicts:z,incompleteResolutions:$}),R&&((J=t[0])==null?void 0:J.componentId)&&((q=t[0])==null?void 0:q.startedAt)&&e.jsx(yi,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:R.summary.pass+R.summary.fail+R.summary.inconclusive+R.summary.notApplicable,totalCount:R.summary.totalCriteria,canClaimConformance:R.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:!R||!a||!m,onClick:()=>void Z(),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 Li({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:c,targetLevel:p,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${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:o??"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]})]})}function Gi(){const t=f(a=>a.view),s=f(a=>a.userMode);return h.useEffect(()=>{const a=la(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=aa();es({forceRefresh:!0}).catch(()=>{}),Oe().catch(()=>{}),oa().catch(()=>{}),ca().catch(()=>{}),ra().catch(()=>{}),Xs().then(l=>{f.getState().setAcknowledgedKeys(new Set(l.map(c=>c.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:c,setPinned:p,results:d}=f.getState();c&&(p(null),te().then(u=>{var m;u&&ie(u,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:u},(m=d[0])==null?void 0:m.frameId).catch(()=>{})}))};return window.addEventListener("keydown",o),()=>{i(),a.disconnect(),r==null||r.disconnect(),window.removeEventListener("keydown",o)}},[]),s===null?e.jsxs(e.Fragment,{children:[e.jsx(gr,{}),e.jsx(Be,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Mr,{}),e.jsx(Ft,{}),e.jsx(Be,{})]}):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(vs,{}),e.jsx(os,{}),e.jsx(Na,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ca,{}),e.jsx($a,{}),e.jsx(pr,{}),e.jsx(ur,{}),e.jsx(_a,{}),e.jsx(cr,{}),e.jsx(dr,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(Ya,{}),t==="report"&&e.jsx(hn,{}),t==="delta"&&e.jsx(Sn,{}),t==="activity"&&e.jsx(Dn,{}),t==="guided"&&e.jsx(Qn,{}),t==="flows"&&e.jsx(Zn,{}),t==="scorecard"&&e.jsx(sr,{}),t==="crawl"&&e.jsx(gs,{}),t==="forensic"&&e.jsx(bs,{}),t==="compliance"&&e.jsx($i,{})]})]}),e.jsx(xr,{}),e.jsx(mr,{}),e.jsx(lr,{}),e.jsx(Ft,{}),e.jsx(Be,{})]})}class Vi extends Se.Component{constructor(){super(...arguments);vt(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{Gi as A,Vi as E,Pi as d};