@wcag-checkr/ci 1.0.0-rc.76 → 1.0.0-rc.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/forensic-log-VcNR3Xcq.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-BIsozXtc.js","assets/site-report-renderer-CXRggal1.js","assets/App-Bpsz7bQq.js","assets/styles-D2VxXLiY.js","assets/_commonjsHelpers-Cpj98o6Y.js","assets/styles-DyeH361z.css","assets/preload-helper-D7HrI6pR.js"])))=>i.map(i=>d[i]);
2
- var Mt=Object.defineProperty;var Pt=(t,s,a)=>s in t?Mt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ye=(t,s,a)=>Pt(t,typeof s!="symbol"?s+"":s,a);import{_ as je}from"./preload-helper-D7HrI6pR.js";import{R as ye,i as le,r as g,j as e,M as ke,C as Ke,l as Gt,o as xt,t as ft,m as Vt,s as Bt,k as Me}from"./styles-D2VxXLiY.js";import{o as ee,r as Q,s as J,c as gt,b as se,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{g as Wt,a as Z,u as Ht,b as zt,c as Kt,d as bt,e as Ce,f as qt,l as Qt,h as vt,A as Y,s as Jt,i as yt,j as Yt,O as Xt,k as Zt,m as es,n as Xe,o as ts,p as ss,q as as,r as ns,t as rs,T as is,v as os,w as ls}from"./forensic-log-VcNR3Xcq.js";import{B as Pe,i as wt,b as jt,T as Nt}from"./state-BIsozXtc.js";const Ze=t=>{let s;const a=new Set,n=(m,c)=>{const p=typeof m=="function"?m(s):m;if(!Object.is(p,s)){const u=s;s=c??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(f=>f(s,u))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:m=>(a.add(m),()=>a.delete(m))},d=s=t(n,r,l);return l},cs=t=>t?Ze(t):Ze,ds=t=>t;function us(t,s=ds){const a=ye.useSyncExternalStore(t.subscribe,ye.useCallback(()=>s(t.getState()),[t,s]),ye.useCallback(()=>s(t.getInitialState()),[t,s]));return ye.useDebugValue(a),a}const et=t=>{const s=cs(t),a=n=>us(s,n);return Object.assign(a,s),a},ps=t=>t?et(t):et,b=ps(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}})})),Te="sidePanel:lastAudit";function ms(){const t=[];return t.push(ee("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||le.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ee("AUDIT_COMPLETE_EVENT",s=>{var i;b.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"}.`;le.polite(r),hs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(ee("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(ee("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||le.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ee("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ee("SCORECARD_UPDATED_EVENT",()=>{$e()})),t.push(ee("LICENSE_CHANGED_EVENT",()=>{St()})),t.push(ee("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&le.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ee("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),le.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(ee("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),le.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function hs(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Te]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function xs(){const s=(await chrome.storage.local.get(Te))[Te];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function fs(){await chrome.storage.local.remove(Te)}async function kt(){b.getState().clearResults(),await fs()}async function $e(){const t=await Q({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function St(t){const s=await Q({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),At()}async function At(){const{fetchMessages:t}=await je(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ss);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function gs(){const s=(await Q({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function bs(){return chrome.runtime.connect({name:"audit-keepalive"})}let _e=null;async function vs(){if(_e===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(_e=t.id)}catch{}}function Ct(){if(_e===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:_e}).catch(()=>{})}function ce(t){Ct(),J(t)}function ys({onClose:t}){const[s,a]=g.useState(""),[n,r]=g.useState(""),[i,o]=g.useState(!0),[l,d]=g.useState(""),[m,c]=g.useState(!1),[p,u]=g.useState(null);async function f(h){var w;if(h.preventDefault(),!(!s.trim()||!n.trim())){c(!0),u(null);try{const R=await Q({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});R.success?(u({ok:!0,msg:`Sent (ref: ${R.ticketRef??"n/a"})`}),setTimeout(t,1200)):u({ok:!1,msg:((w=R.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:h=>a(h.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:h=>r(h.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:h=>d(h.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:h=>o(h.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)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.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:m,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:m?"Sending…":"Send"})]})]})}function tt({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const Le=gt("messages-client"),ws="https://api.wcagcheckr.com",Et="wcagcheckr",js=1e4;function Ns(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Rt(t,s){const a=await Wt();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ns()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ws}${t}`,{...s,headers:n,signal:AbortSignal.timeout(js)})}async function ks(t){try{const s=await Rt(`/v1/products/${Et}/messages`,{userMode:t??null});return s.ok?await s.json():(Le.warn("fetchMessages http",s.status),null)}catch(s){return Le.warn("fetchMessages failed",s),null}}async function ue(t,s){try{const a=await Rt(`/v1/products/${Et}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Le.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Le.warn("ackMessage failed",a),!1}}const Ss=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ue,fetchMessages:ks},Symbol.toStringTag,{value:"Module"})),As=["http:","https:"];function Cs(t){try{const s=new URL(t);return As.includes(s.protocol)}catch{return!1}}function st(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Cs(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(g.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(g.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function It({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:st(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,m)=>e.jsx("li",{children:st(d)},m))},`u-${i++}`)),n=[])}for(const d of s){const m=d.trimEnd();if(m===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(m);if(c){o(),n.push(c[1]);continue}l(),r.push(m)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Es={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Rs={critical:"bg-rose-50 border-rose-200"};function Is(){const t=b(u=>u.unreadMessageCount),s=b(u=>u.messages),a=b(u=>u.applyMessageAck),[n,r]=g.useState(!1),i=g.useRef(-1),[o,l]=g.useState(!1);g.useEffect(()=>{const u=s.filter(h=>!h.seen);if(u.length===0)return;const f=Math.max(...u.map(h=>h.id));if(f>i.current){i.current=f,l(!0);const h=setTimeout(()=>l(!1),1500);return()=>clearTimeout(h)}},[s]);async function d(){const u=s.filter(f=>!f.seen);if(u.length!==0)for(const f of u)a(f.id,"seen"),ue(f.id,"seen")}function m(){const u=!n;r(u),u&&d()}async function c(u){a(u.id,"dismissed"),await ue(u.id,"dismissed")}async function p(u){u.ctaUrl&&(a(u.id,"clicked"),ue(u.id,"clicked"),chrome.tabs.create({url:u.ctaUrl}).catch(()=>{window.open(u.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:m,"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(Ts,{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($s,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:p})]})}function Ts({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 $s({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=g.useRef(null);return g.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{At()},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 ${Es[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(It,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function _s(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ue(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ue(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Rs.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(It,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const fe=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ls(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Us(){var p,u;const t=b(f=>f.view),s=b(f=>f.setView),a=b(f=>f.setUserMode),n=b(f=>f.results),r=b(f=>f.status),[i,o]=g.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((u=n[0])==null?void 0:u.scope),d=Ls(l),m=n.length>0&&r!=="running";function c(){a("owner"),J({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Is,{}),e.jsx(tt,{onClick:()=>void J({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(tt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),m&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void kt(),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(Ds,{view:t,setView:s}),e.jsx(ke,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(ys,{onClose:()=>o(!1)})})]})}function Ds({view:t,setView:s}){const a=g.useRef([]);function n(i){var d;const o=(i+fe.length)%fe.length,l=fe[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(fe.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:fe.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Os({feature:t,upgradeUrl:s}){const[a,n]=g.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ke,{open:a,onClose:()=>n(!1)})]})}const Fs="https://wcagcheckr.com/upgrade";function Ms(){const[t,s]=g.useState("single-element"),[a,n]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState(null),[d,m]=g.useState(Pe),[c,p]=g.useState(Pe[0].id),u=b(S=>S.status),f=b(S=>S.tier),h=b(S=>S.results.length>0),w=u==="running";g.useEffect(()=>{Promise.all([Q({type:"SETTINGS_GET",key:"matrixPresets"}),Q({type:"SETTINGS_GET",key:"activePresetId"})]).then(([S,B])=>{const A=Array.isArray(S.data)?S.data:null;m(A&&A.length>0?A:Pe),typeof B.data=="string"&&p(B.data)})},[]);function R(S){const B=d.find(A=>A.id===S);B&&(p(S),J({type:"SETTINGS_SET",key:"activePresetId",value:S}),J({type:"SETTINGS_SET",key:"stateMatrix",value:B.matrix}))}const T=wt(f,"storybookAutoIterate");g.useEffect(()=>{const S=ee("ELEMENT_PICKED_EVENT",(A,M)=>{n(!1);const D=M.frameId;j(D),i({selector:A.selector,frameId:D})}),B=ee("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{S(),B()}},[]);async function x(){const S=await Z();S&&(n(!0),await se(S,{type:"PICKER_ACTIVATE_REQUEST",tabId:S}))}function v(){r&&(j(r.frameId),ce({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function y(){if(!T){l("storybook:auto-iterate");return}j(),ce({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function k(){j(),ce({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function I(){j(),ce({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function C(){j(),ce({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function $(){J({type:"CANCEL_AUDIT"})}async function j(S){b.getState().setPinned(null);const B=await Z();if(B)try{await se(B,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:B},S)}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=>s(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:"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:c,onChange:S=>R(S.target.value),disabled:w||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(S=>e.jsx("option",{value:S.id,children:S.name},S.id))}),t==="single-element"?e.jsx(Ps,{picking:a,picked:r,isRunning:w,onPick:x,onRun:v,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:I,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:C,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",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==="all-frames"?e.jsx("button",{onClick:k,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all stories"}),w&&e.jsx("button",{onClick:$,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&h&&e.jsx("button",{type:"button",onClick:()=>void kt(),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(Gs,{selector:r.selector,onRepick:x,onClear:()=>i(null)})]}),e.jsx(ke,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Os,{feature:o??"",upgradeUrl:Fs})})]})}function Ps({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 Gs({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 Vs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Bs={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Ws(){const[t,s]=g.useState(null),[a,n]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState("off"),m=b(f=>f.results).flatMap(f=>f.violations);async function c(f){const h=await Z();h&&(l(f),f==="off"?await se(h,{type:"VISION_SIMULATOR_CLEAR",tabId:h}).catch(()=>{}):await se(h,{type:"VISION_SIMULATOR_APPLY",tabId:h,mode:f}).catch(()=>{}))}async function p(f){const h=await Z();if(h){if(t&&await se(h,{type:Vs[t],tabId:h}).catch(()=>{}),t===f){s(null);return}await se(h,{type:Bs[f],tabId:h}).catch(()=>{}),s(f)}}async function u(){const f=await Z();if(f){if(a){await se(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),i(null);return}if(m.length===0){i("Run an audit first.");return}try{const h=await Ie(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:m});n(!0),i(`Previewing ${h.visualFixCount} visual fix${h.visualFixCount===1?"":"es"} + ${h.annotationCount} annotation${h.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(ge,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(ge,{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:()=>p("tab-order")}),e.jsx(ge,{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:()=>p("reading-order")}),e.jsx(ge,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ge,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:u}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void c(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ge({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 Hs(t){if(!t)return"";const s=[t.pseudoState];return t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),s.join(" · ")}function zs(){const t=b(m=>m.status),s=b(m=>m.progress),a=b(m=>m.aiProgress);if(t!=="running"||!s)return null;const n=a!=null,r=!n&&s.current>=s.total,i=n?a.current/a.total*100:s.current/s.total*100,o=n?a.current:s.current,l=n?a.total:s.total,d=n?`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:n?e.jsxs(e.Fragment,{children:["AI augmentation… ",a.current,"/",a.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:n?a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Hs(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void J({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${n?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":d,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const be={"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 Ks(t){return/^wcag\d/.test(t.wcagCriterion)?[be["ada-iii"],be[508],be.eaa,be["en-301-549"],be.aoda]:[]}const qs={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 Ue({violation:t,alreadyAcknowledged:s}){const a=b(x=>x.pinnedMatchKey),n=b(x=>x.pinnedFound),r=b(x=>x.setPinned),i=b(x=>{var v;return(v=x.results[0])==null?void 0:v.frameId}),o=b(x=>{var v;return(v=x.results[0])==null?void 0:v.scope}),l=b(x=>x.results),d=b(x=>x.acknowledgedKeys.has(t.matchKey)),m=b(x=>x.markAcknowledged),c=b(x=>x.markUnacknowledged),p=s||d,u=a===t.matchKey,f=u&&!n;async function h(x){try{return(await Ie(x,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:x,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const x=await Z();if(!x)return;if(u){r(null);try{await se(x,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:x},i)}catch{}return}const v=await h(x);r(t.matchKey,v)}function R(x){x.stopPropagation(),t.currentState.breakpoint.width<=640&&Ct(),(async()=>{const v=await Z();if(!v)return;try{await Q({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:o,frameId:i})}catch{}const y=await h(v);r(t.matchKey,y)})()}async function T(x){x.stopPropagation();const v=await Z();if(!v)return;try{await Q({type:"STATE_DRIVE_REQUEST",tabId:v,state:Xs(),scope:o,frameId:i})}catch{J({type:"STATE_RESET_REQUEST",tabId:v})}const y=await h(v);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:w,"aria-pressed":u,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
- ${u?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${qs[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(Zs,{violation:t}),e.jsx(sa,{violation:t}),e.jsx(ta,{violation:t}),e.jsx(ea,{text:t.target.failureSummary}),e.jsx(aa,{ruleId:t.ruleId}),u&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Qs(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:R,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),R(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:T,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),T(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),f&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(t.matchKey),Ys(t,l)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),m(t.matchKey),Js(t,l)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Qs(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function Js(t,s){await zt({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Tt(t.componentId,s)}async function Ys(t,s){await Ht(t.componentId,t.matchKey),await Tt(t.componentId,s)}async function Tt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await Q({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function Xs(){const t=jt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function $t(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 Zs({violation:t}){const s=$t(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 ea({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 ta({violation:t}){const s=Ks(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 sa({violation:t}){const s=$t(t),[a,n]=g.useState({kind:"idle"});if(!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await Q({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);n(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function aa({ruleId:t}){const s=Kt(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 na=[{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 ra(t){const s=na.map(i=>ia(i,t)),a=s.reduce((i,o)=>i+oa(o.letter),0)/Math.max(1,s.length),n=la(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 ia(t,s){const a=new Set(t.axeRules),n=s.violations.filter(C=>a.has(C.ruleId)),r=s.manualRuns.filter(C=>t.igtWorkflowIds.includes(C.workflowId)),i=t.igtWorkflowIds.map(C=>s.workflows.find($=>$.id===C)).filter(C=>C!=null);let o=i.length>0;for(const C of i){const $=r.find(S=>S.workflowId===C.id);if(($?Object.keys($.steps).length:0)!==C.steps.length){o=!1;break}}const l=r.some(C=>Object.keys(C.steps).length>0),d=t.verifiedByWorkflowIds??[],m=s.manualRuns.filter(C=>d.includes(C.workflowId)),c=d.map(C=>s.workflows.find($=>$.id===C)).filter(C=>C!=null);let p=d.length>0&&c.length===d.length;for(const C of c){const $=m.find(S=>S.workflowId===C.id);if(($?Object.keys($.steps).length:0)!==C.steps.length){p=!1;break}}let u=null;if(p)for(const C of m)C.completedAt&&(u===null||C.completedAt>u)&&(u=C.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,h=d[0]??t.igtWorkflowIds[0]??null;if(p&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:u,suppressedHeuristicCount:f,primaryVerifierWorkflowId:h,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w=t.axeRules.length>0||t.heuristic!=null,R=t.igtWorkflowIds.length>0;if(w?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:R||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:h,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const x={critical:0,serious:0,moderate:0,minor:0};for(const C of bt(n))x[C.impact]++;x.serious+=f;for(const C of r){const $=i.find(j=>j.id===C.workflowId);if($)for(const j of $.steps){const S=C.steps[j.id];(S==null?void 0:S.status)==="fail"&&(j.severity==="required"?x.serious++:x.moderate++)}}const v=x.critical>0,y=x.serious>0;let k;x.critical>=5?k="F":x.critical>=1?k="D":x.serious>=1?k="C":x.moderate>=1?k="B":k="A";const I=k!=="A"&&(R&&!o||d.length>0&&!p);return{id:t.id,label:t.label,letter:k,untested:!1,needsIgt:I,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:h,counts:x,caps:{cappedAtC:v,cappedAtB:y}}}function oa(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function la(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const ca={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},da={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 ua({violations:t,componentId:s}){var K,te,q,ae,ne,G,Se;const[a,n]=g.useState([]),[r,i]=g.useState([]),[o,l]=g.useState(new Set),[d,m]=g.useState(null),[c,p]=g.useState({}),[u,f]=g.useState(new Set),h=b(_=>_.status),w=b(_=>_.progress),R=b(_=>_.freshThisSession),T=b(_=>_.results),x=(K=T[0])==null?void 0:K.startedAt,v=((te=T[0])==null?void 0:te.pageUrl)??((q=T[0])==null?void 0:q.scope)??null;if(g.useEffect(()=>{if(!s){n([]);return}let _=!1;return chrome.storage.local.get("igtRuns").then(W=>{if(_)return;const U=((W==null?void 0:W.igtRuns)??{})[s]??{};n(Object.values(U))}),()=>{_=!0}},[s]),g.useEffect(()=>{if(!v){i([]);return}let _=!1;return Ce(v).then(W=>{_||i(W)}),()=>{_=!0}},[v]),h==="running")return e.jsx(ba,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const y=ra({violations:t,auditRan:T.length>0,manualRuns:a,workflows:Y,heuristicCounts:{tabOrder:((ne=(ae=T[0])==null?void 0:ae.tabOrderIssues)==null?void 0:ne.length)??0,readingOrder:((Se=(G=T[0])==null?void 0:G.readingOrderIssues)==null?void 0:Se.length)??0}}),k=b(_=>_.acknowledgedKeys),I=T.length>0?qt(T,{runs:a,workflows:Y},"2.1","AA",k,r):void 0,C=T.length>0?Qt(vt({audits:T,igtRuns:a,workflows:Y,acknowledgedMatchKeys:k,incompleteResolutions:r}),Y):void 0,$=I?I.failingCriteria.length>0||I.inconclusiveCriteria.length>0:!1,j=$&&y.overallLetter==="A"?"B":y.overallLetter;async function S(_){var H;if(!v||!((H=I==null?void 0:I.inconclusiveReasons)!=null&&H[_]))return;const N=I.inconclusiveReasons[_].filter(V=>V.source==="axe-incomplete"&&V.elements&&V.elements.length>0);if(N.length===0)return;l(V=>new Set(V).add(_)),m(null);const U=[];let L=0;try{for(const O of N){const z=await J({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:O.ruleOrStepId,pageUrl:O.pageUrl??v,wcagCriterion:_,elements:O.elements??[],targetLevel:"AA"});if(z!=null&&z.unavailableReason){m(z.unavailableReason);break}z!=null&&z.resolutions&&(U.push(...z.resolutions),L+=z.totalCostUsd??0)}if(v){const O=await Ce(v);i(O)}const V={total:U.length,pass:U.filter(O=>O.verdict==="pass").length,fail:U.filter(O=>O.verdict==="fail").length,uncertain:U.filter(O=>O.verdict==="uncertain").length,costUsd:L,resolutions:U};p(O=>({...O,[_]:V}))}finally{l(V=>{const O=new Set(V);return O.delete(_),O})}}function B(_){f(W=>{const N=new Set(W);return N.has(_)?N.delete(_):N.add(_),N})}async function A(_){var z,he;if(!v)return;const W=((z=I==null?void 0:I.inconclusiveReasons)==null?void 0:z[_])??[],N=((he=I==null?void 0:I.failingReasons)==null?void 0:he[_])??[],U=[],L=new Set;for(const P of W){if(P.source!=="axe-incomplete"||!P.elements)continue;const re=P.pageUrl??v;for(const ie of P.elements){const xe=`${re}::${P.ruleOrStepId}::${ie.selector}`;L.has(xe)||(L.add(xe),U.push({ruleId:P.ruleOrStepId,pageUrl:re,selector:ie.selector}))}}for(const P of N){if(P.source!=="ai"||!P.selector)continue;const re=P.ruleOrStepId.startsWith("ai-resolved::")?P.ruleOrStepId.slice(13):P.ruleOrStepId,ie=P.pageUrl??v,xe=`${ie}::${re}::${P.selector}`;L.has(xe)||(L.add(xe),U.push({ruleId:re,pageUrl:ie,selector:P.selector}))}if(U.length===0)return;const H=new Date().toISOString(),V=[];for(const P of U){const re=r.find(ie=>ie.pageUrl===P.pageUrl&&ie.ruleId===P.ruleId&&ie.selector===P.selector);re&&re.verdict==="pass"&&re.reasoning.startsWith("Marked as visually verified")||V.push({pageUrl:P.pageUrl,ruleId:P.ruleId,selector:P.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${H.slice(0,10)}.`,resolvedAt:H,costUsd:0,wcagCriterion:_})}if(V.length===0)return;await Jt(V);const O=await Ce(v);i(O),p(P=>({...P,[_]:{total:V.length,pass:V.length,fail:0,uncertain:0,costUsd:0,resolutions:V}}))}const M=(()=>{if(!$||y.overallLetter!=="A"||!I)return null;const _=I.inconclusiveCriteria.length,W=I.failingCriteria.length,N=[];W>0&&N.push(`${W} WCAG ${I.targetLevel} ${W===1?"criterion":"criteria"} failing`),_>0&&N.push(`${_} WCAG ${I.targetLevel} ${_===1?"criterion":"criteria"} inconclusive`);const U=W>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${N.join(" + ")}. ${U}`})();let D=0;for(const _ of Y){const W=a.find(U=>U.workflowId===_.id);if(!W)continue;_.steps.every(U=>{const L=W.steps[U.id];return(L==null?void 0:L.status)==="pass"||(L==null?void 0:L.status)==="fail"||(L==null?void 0:L.status)==="skip"||(L==null?void 0:L.status)==="not-applicable"})&&D++}const X=bt(t.filter(_=>!k.has(_.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!R&&x&&e.jsx(va,{scannedAt:x}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ca[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 ",y.subGrades.length," verification areas below. Untested areas count as F until verified."]}),M&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:M})]})]}),y.isLawsuitRisk&&e.jsx(ha,{areas:y.warningAreas}),e.jsx(xa,{grades:y.subGrades}),I&&e.jsx(pa,{coverage:I,onResolveWithAi:S,onMarkVisuallyVerified:A,resolving:o,resolveError:d,lastResolveResult:c,expandedResultFor:u,onToggleResultDetail:B}),C&&e.jsx(ma,{layers:C}),e.jsx(ga,{violationsRemaining:X,manualCompleted:D,manualTotal:Y.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:Y.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/Y.length*100}%`}})})]}):null]})}function pa({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[m,c]=g.useState(d>0&&d<=3),p=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),u=t.canClaimConformance,f=[];return t.failingCriteria.length>0&&f.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&f.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&f.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${u?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${u?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",p,"%)"]}),u&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!u&&(()=>{const h=[];t.failingCriteria.length>0&&h.push("failing"),t.inconclusiveCriteria.length>0&&h.push("inconclusive"),t.untestedCriteria.length>0&&h.push("untested");const w=h.length===0?"unresolved":h.length===1?h[0]:h.length===2?`${h[0]} or ${h[1]}`:`${h.slice(0,-1).join(", ")}, or ${h[h.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",w,"."]})})(),!u&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!u&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!u&&f.length>0&&e.jsx("button",{type:"button",onClick:()=>c(h=>!h),className:"text-[11px] underline shrink-0 self-start",children:m?"hide":"show list"})]}),m&&!u&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[f.map(h=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${h.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[h.kind==="untested"?"Untested":h.kind==="inconclusive"?"Inconclusive":"Failing"," (",h.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:h.ids.map(w=>{var C,$;const R=h.kind==="inconclusive"?(C=t.inconclusiveReasons)==null?void 0:C[w]:void 0,T=h.kind==="failing"?($=t.failingReasons)==null?void 0:$[w]:void 0,x=R==null?void 0:R.some(j=>j.source==="axe-incomplete"&&j.elements&&j.elements.length>0),v=T==null?void 0:T.some(j=>j.source==="ai"),y=(n==null?void 0:n.has(w))??!1,k=i==null?void 0:i[w],I=(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]}),(h.kind==="inconclusive"&&x||h.kind==="failing"&&v)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:y,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:y?"Resolving…":k?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:y,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:h.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),k&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",k.total," ",k.total===1?"verdict":"verdicts",":",k.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",k.pass," pass"]}),k.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",k.fail," fail"]}),k.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",k.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",k.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(w),className:"ml-auto text-[10px] underline text-brand-700",children:I?"hide reasoning":"show reasoning"})]}),k.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",k.uncertain," ",k.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),k.pass===k.total&&k.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),I&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:k.resolutions.map((j,S)=>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})]},S))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map((j,S)=>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})]},S))}),R&&R.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:R.map((j,S)=>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((B,A,M)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:B.selector}),A<M.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},A)),j.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",j.elements.length-3," more"]})]})]},S))}):h.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)})})]},h.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 at={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 ma({layers:t}){const s=b(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,d=r.cleared,m=i>0&&o===0&&l===0,c=m?"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 ${m?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:m?"✓":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:at[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:at[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 ha({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 xa({grades:t}){const s=b(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${da[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(fa,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function fa({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=Y.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?_t(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 ga({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const d=l===i,m=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:m?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:m?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:m?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function ba({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function va({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",_t(s)," old). Re-scan to grade the current page state."]})]})}function _t(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}const qe="dismissedFindings";function Oe(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function pe(t){return`reading-order::${t}`}function me(t){return`tab-order::${t}`}async function Fe(){try{const t=await chrome.storage.local.get(qe),s=t==null?void 0:t[qe];if(s&&typeof s=="object")return s}catch{}return{}}async function Je(t){await chrome.storage.local.set({[qe]:t})}async function De(t){return(await Fe())[Oe(t)]??{}}async function Lt(t,s,a,n){const r=await Fe(),i=Oe(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await Je(r)}async function Ne(t,s){if(s.length===0)return;const a=await Fe(),n=Oe(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 Je(a)}async function Ut(t,s){const a=await Fe(),n=Oe(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Je(a))}const ya=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Lt,addDismissals:Ne,dismissalKeyForReadingOrder:pe,dismissalKeyForTabOrder:me,getDismissalsForUrl:De,removeDismissal:Ut},Symbol.toStringTag,{value:"Module"}));function Dt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ot(t){return`${yt(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function wa(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Ot(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 nt={critical:0,serious:1,moderate:2,minor:3};function ja(){var h,w,R,T;const t=b(x=>x.results),s=b(x=>x.componentId),a=b(x=>x.setView),n=((h=t[0])==null?void 0:h.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(new Set);if(g.useEffect(()=>{if(!n)return;De(n).then(i);const x=()=>{document.visibilityState==="visible"&&n&&De(n).then(i)};return document.addEventListener("visibilitychange",x),()=>document.removeEventListener("visibilitychange",x)},[n]),g.useEffect(()=>{if(!s){l(new Set);return}let x=!1;const v=async()=>{const k=await chrome.storage.local.get("igtRuns");if(x)return;const C=((k==null?void 0:k.igtRuns)??{})[s]??{},$=new Set;for(const j of Y){const S=C[j.id];S&&Object.keys(S.steps).length===j.steps.length&&$.add(j.id)}l($)};v();const y=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",y),()=>{x=!0,document.removeEventListener("visibilitychange",y)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((x,v)=>x+v.durationMs,0),m=t.reduce((x,v)=>x+v.violations.length,0),c=wa(t);c.sort((x,v)=>{const y=nt[x.representative.impact]??99,k=nt[v.representative.impact]??99;return y!==k?y-k:v.states.length-x.states.length});const p=t.map(x=>Dt(x.state)).join(`
4
- `),u=o.has("keyboard")?0:(((R=t[0])==null?void 0:R.tabOrderIssues)??[]).filter(x=>!(me(x.selector)in r)).length,f=o.has("page-structure")?0:(((T=t[0])==null?void 0:T.readingOrderIssues)??[]).filter(x=>!(pe(x.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(ua,{violations:t.flatMap(x=>x.violations),componentId:s}),(u>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[u>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:u})," tab-order issue",u===1?"":"s"," (WCAG 2.4.3)"]}),u>0&&f>0&&" · ",f>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:f})," reading-order issue",f===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:p,"aria-label":`${t.length} states tested: ${p.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",c.length," unique ",c.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",m," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),c.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic px-1",children:"No violations found."}):e.jsx("div",{className:"space-y-1.5",children:c.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ue,{violation:x.representative}),e.jsx(Na,{states:x.states,totalStates:t.length})]},Ot(x.representative)))})]})}function Na({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(Dt))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
5
- `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const ka={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Sa({ruleId:t,violations:s}){const[a,n]=g.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Ue,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ka[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,m)=>e.jsx(Ue,{violation:d},m))})]})}function Aa(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Ca={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Ea({open:t,onClose:s,format:a,content:n,filename:r}){const i=Gt(new Blob([n]).size);function o(){ft(n,r),s()}function l(){xt(n),s()}return e.jsxs(ke,{open:t,onClose:s,title:Ca[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const rt=7800;function Ra(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,u=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,f=r.find(h=>`${h.ruleId}::${h.target.selector}`===p);if(f){f._states.includes(u)||f._states.push(u);continue}r.push({...c,_states:[u]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/forensic-log-VcNR3Xcq.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-BIsozXtc.js","assets/site-report-renderer-CXRggal1.js","assets/App-DO2AIuQt.js","assets/styles-D2VxXLiY.js","assets/_commonjsHelpers-Cpj98o6Y.js","assets/styles-DyeH361z.css","assets/preload-helper-D7HrI6pR.js"])))=>i.map(i=>d[i]);
2
+ var Mt=Object.defineProperty;var Pt=(t,s,a)=>s in t?Mt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Ye=(t,s,a)=>Pt(t,typeof s!="symbol"?s+"":s,a);import{_ as je}from"./preload-helper-D7HrI6pR.js";import{R as ye,i as ce,r as g,j as e,M as ke,C as Ke,l as Gt,o as xt,t as ft,m as Vt,s as Bt,k as Me}from"./styles-D2VxXLiY.js";import{o as ee,r as J,s as Y,c as gt,b as se,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{g as Wt,a as Z,u as Ht,b as zt,c as Kt,d as bt,e as Ce,f as qt,l as Qt,h as vt,A as X,s as Jt,i as yt,j as Yt,O as Xt,k as Zt,m as es,n as Xe,o as ts,p as ss,q as as,r as ns,t as rs,T as is,v as os,w as ls}from"./forensic-log-VcNR3Xcq.js";import{B as Pe,i as wt,b as jt,T as Nt}from"./state-BIsozXtc.js";const Ze=t=>{let s;const a=new Set,n=(m,c)=>{const p=typeof m=="function"?m(s):m;if(!Object.is(p,s)){const u=s;s=c??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(f=>f(s,u))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>d,subscribe:m=>(a.add(m),()=>a.delete(m))},d=s=t(n,r,l);return l},cs=t=>t?Ze(t):Ze,ds=t=>t;function us(t,s=ds){const a=ye.useSyncExternalStore(t.subscribe,ye.useCallback(()=>s(t.getState()),[t,s]),ye.useCallback(()=>s(t.getInitialState()),[t,s]));return ye.useDebugValue(a),a}const et=t=>{const s=cs(t),a=n=>us(s,n);return Object.assign(a,s),a},ps=t=>t?et(t):et,b=ps(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}})})),Te="sidePanel:lastAudit";function ms(){const t=[];return t.push(ee("AUDIT_PROGRESS_EVENT",s=>{const a=b.getState().status==="running";b.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),b.getState().setStatus("running"),a||ce.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(ee("AUDIT_COMPLETE_EVENT",s=>{var i;b.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"}.`;ce.polite(r),hs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(ee("AUDIT_FAILED_EVENT",s=>{b.getState().setError(s.error.message)})),t.push(ee("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=b.getState().aiProgress;b.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ce.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(ee("AI_AUGMENTATION_FAILED_EVENT",s=>{b.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(ee("SCORECARD_UPDATED_EVENT",()=>{$e()})),t.push(ee("LICENSE_CHANGED_EVENT",()=>{St()})),t.push(ee("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ce.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(ee("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ce.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(ee("SITE_CRAWL_FAILED_EVENT",s=>{const a=b.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ce.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function hs(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[Te]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function xs(){const s=(await chrome.storage.local.get(Te))[Te];s&&b.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function fs(){await chrome.storage.local.remove(Te)}async function kt(){b.getState().clearResults(),await fs()}async function $e(){const t=await J({type:"BASELINE_LIST"});b.getState().setBaselineList(t.items)}async function St(t){const s=await J({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});b.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),At()}async function At(){const{fetchMessages:t}=await je(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ss);return{fetchMessages:n}},void 0),s=b.getState().userMode,a=await t(s);a&&b.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function gs(){const s=(await J({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;b.getState().setUserMode(a)}function bs(){return chrome.runtime.connect({name:"audit-keepalive"})}let _e=null;async function vs(){if(_e===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(_e=t.id)}catch{}}function Ct(){if(_e===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:_e}).catch(()=>{})}function oe(t){Ct(),Y(t)}function ys({onClose:t}){const[s,a]=g.useState(""),[n,r]=g.useState(""),[i,o]=g.useState(!0),[l,d]=g.useState(""),[m,c]=g.useState(!1),[p,u]=g.useState(null);async function f(h){var w;if(h.preventDefault(),!(!s.trim()||!n.trim())){c(!0),u(null);try{const R=await J({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});R.success?(u({ok:!0,msg:`Sent (ref: ${R.ticketRef??"n/a"})`}),setTimeout(t,1200)):u({ok:!1,msg:((w=R.error)==null?void 0:w.message)??"Failed to send"})}finally{c(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:h=>a(h.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:h=>r(h.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:h=>d(h.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:h=>o(h.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)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.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:m,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:m?"Sending…":"Send"})]})]})}function tt({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const Le=gt("messages-client"),ws="https://api.wcagcheckr.com",Rt="wcagcheckr",js=1e4;function Ns(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Et(t,s){const a=await Wt();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ns()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ws}${t}`,{...s,headers:n,signal:AbortSignal.timeout(js)})}async function ks(t){try{const s=await Et(`/v1/products/${Rt}/messages`,{userMode:t??null});return s.ok?await s.json():(Le.warn("fetchMessages http",s.status),null)}catch(s){return Le.warn("fetchMessages failed",s),null}}async function ue(t,s){try{const a=await Et(`/v1/products/${Rt}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Le.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Le.warn("ackMessage failed",a),!1}}const Ss=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ue,fetchMessages:ks},Symbol.toStringTag,{value:"Module"})),As=["http:","https:"];function Cs(t){try{const s=new URL(t);return As.includes(s.protocol)}catch{return!1}}function st(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),d=t.slice(i+2,o);Cs(d)?s.push(e.jsx("a",{href:d,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(g.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(g.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function It({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const d=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:st(d)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((d,m)=>e.jsx("li",{children:st(d)},m))},`u-${i++}`)),n=[])}for(const d of s){const m=d.trimEnd();if(m===""){o(),l();continue}const c=/^[-*]\s+(.*)$/.exec(m);if(c){o(),n.push(c[1]);continue}l(),r.push(m)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Rs={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Es={critical:"bg-rose-50 border-rose-200"};function Is(){const t=b(u=>u.unreadMessageCount),s=b(u=>u.messages),a=b(u=>u.applyMessageAck),[n,r]=g.useState(!1),i=g.useRef(-1),[o,l]=g.useState(!1);g.useEffect(()=>{const u=s.filter(h=>!h.seen);if(u.length===0)return;const f=Math.max(...u.map(h=>h.id));if(f>i.current){i.current=f,l(!0);const h=setTimeout(()=>l(!1),1500);return()=>clearTimeout(h)}},[s]);async function d(){const u=s.filter(f=>!f.seen);if(u.length!==0)for(const f of u)a(f.id,"seen"),ue(f.id,"seen")}function m(){const u=!n;r(u),u&&d()}async function c(u){a(u.id,"dismissed"),await ue(u.id,"dismissed")}async function p(u){u.ctaUrl&&(a(u.id,"clicked"),ue(u.id,"clicked"),chrome.tabs.create({url:u.ctaUrl}).catch(()=>{window.open(u.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:m,"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(Ts,{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($s,{messages:s,onClose:()=>r(!1),onDismiss:c,onCtaClick:p})]})}function Ts({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 $s({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=g.useRef(null);return g.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{At()},className:"text-[11px] text-brand-700 hover:underline",children:"Refresh"})]}),t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-[11px]",children:"No messages."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:t.map(i=>e.jsx("li",{className:`p-3 ${i.seen?"":"bg-slate-50"}`,children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:`shrink-0 w-1 self-stretch rounded ${Rs[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(It,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function _s(){const t=b(i=>i.messages),s=b(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await ue(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),ue(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Es.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(It,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const fe=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ls(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Us(){var p,u;const t=b(f=>f.view),s=b(f=>f.setView),a=b(f=>f.setUserMode),n=b(f=>f.results),r=b(f=>f.status),[i,o]=g.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((u=n[0])==null?void 0:u.scope),d=Ls(l),m=n.length>0&&r!=="running";function c(){a("owner"),Y({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Is,{}),e.jsx(tt,{onClick:()=>void Y({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(tt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),m&&d&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${d}`,children:d}),e.jsx("button",{type:"button",onClick:()=>void kt(),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(Ds,{view:t,setView:s}),e.jsx(ke,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(ys,{onClose:()=>o(!1)})})]})}function Ds({view:t,setView:s}){const a=g.useRef([]);function n(i){var d;const o=(i+fe.length)%fe.length,l=fe[o];l&&(s(l),(d=a.current[o])==null||d.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(fe.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:fe.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:d=>{a.current[o]=d},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:d=>r(d,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Os({feature:t,upgradeUrl:s}){const[a,n]=g.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Ke,{open:a,onClose:()=>n(!1)})]})}const Fs="https://wcagcheckr.com/upgrade";function Ms(){const[t,s]=g.useState("single-element"),[a,n]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState(null),[d,m]=g.useState(Pe),[c,p]=g.useState(Pe[0].id),u=b(U=>U.status),f=b(U=>U.tier),h=b(U=>U.results.length>0),w=u==="running";g.useEffect(()=>{Promise.all([J({type:"SETTINGS_GET",key:"matrixPresets"}),J({type:"SETTINGS_GET",key:"activePresetId"})]).then(([U,S])=>{const O=Array.isArray(U.data)?U.data:null;m(O&&O.length>0?O:Pe),typeof S.data=="string"&&p(S.data)})},[]);function R(U){const S=d.find(O=>O.id===U);S&&(p(U),Y({type:"SETTINGS_SET",key:"activePresetId",value:U}),Y({type:"SETTINGS_SET",key:"stateMatrix",value:S.matrix}))}const I=wt(f,"storybookAutoIterate");g.useEffect(()=>{const U=ee("ELEMENT_PICKED_EVENT",(O,P)=>{n(!1);const K=P.frameId;L(K),i({selector:O.selector,frameId:K})}),S=ee("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{U(),S()}},[]);async function x(){const U=await Z();U&&(n(!0),await se(U,{type:"PICKER_ACTIVATE_REQUEST",tabId:U}))}function v(){r&&(L(r.frameId),oe({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),b.getState().startNewScan())}function y(){if(!I){l("storybook:auto-iterate");return}L(),oe({type:"START_AUDIT",mode:"storybook-all"}),b.getState().startNewScan()}function k(){L(),oe({type:"START_AUDIT",mode:"all-frames"}),b.getState().startNewScan()}function E(){L(),oe({type:"START_AUDIT",mode:"full-page"}),b.getState().startNewScan()}function A(){L(),oe({type:"START_AUDIT",mode:"quick-scan"}),b.getState().startNewScan()}function T(){L(),oe({type:"START_AUDIT",mode:"parallel-scan"}),b.getState().startNewScan()}function j(){Y({type:"CANCEL_AUDIT"})}async function L(U){b.getState().setPinned(null);const S=await Z();if(S)try{await se(S,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:S},U)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:U=>s(U.target.value),disabled: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)",I?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:c,onChange:U=>R(U.target.value),disabled:w||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:d.map(U=>e.jsx("option",{value:U.id,children:U.name},U.id))}),t==="single-element"?e.jsx(Ps,{picking:a,picked:r,isRunning:w,onPick:x,onRun:v,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:E,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:A,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:T,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:k,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:w,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:w?"Auditing…":"Audit all stories"}),w&&e.jsx("button",{onClick:j,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!w&&h&&e.jsx("button",{type:"button",onClick:()=>void kt(),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(Gs,{selector:r.selector,onRepick:x,onClear:()=>i(null)})]}),e.jsx(ke,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Os,{feature:o??"",upgradeUrl:Fs})})]})}function Ps({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 Gs({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 Vs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Bs={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Ws(){const[t,s]=g.useState(null),[a,n]=g.useState(!1),[r,i]=g.useState(null),[o,l]=g.useState("off"),m=b(f=>f.results).flatMap(f=>f.violations);async function c(f){const h=await Z();h&&(l(f),f==="off"?await se(h,{type:"VISION_SIMULATOR_CLEAR",tabId:h}).catch(()=>{}):await se(h,{type:"VISION_SIMULATOR_APPLY",tabId:h,mode:f}).catch(()=>{}))}async function p(f){const h=await Z();if(h){if(t&&await se(h,{type:Vs[t],tabId:h}).catch(()=>{}),t===f){s(null);return}await se(h,{type:Bs[f],tabId:h}).catch(()=>{}),s(f)}}async function u(){const f=await Z();if(f){if(a){await se(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),n(!1),i(null);return}if(m.length===0){i("Run an audit first.");return}try{const h=await Ie(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:m});n(!0),i(`Previewing ${h.visualFixCount} visual fix${h.visualFixCount===1?"":"es"} + ${h.annotationCount} annotation${h.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(ge,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(ge,{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:()=>p("tab-order")}),e.jsx(ge,{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:()=>p("reading-order")}),e.jsx(ge,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ge,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:u}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void c(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ge({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 Hs(t){if(!t)return"";const s=[t.pseudoState];return t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),s.join(" · ")}function zs(){const t=b(m=>m.status),s=b(m=>m.progress),a=b(m=>m.aiProgress);if(t!=="running"||!s)return null;const n=a!=null,r=!n&&s.current>=s.total,i=n?a.current/a.total*100:s.current/s.total*100,o=n?a.current:s.current,l=n?a.total:s.total,d=n?`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:n?e.jsxs(e.Fragment,{children:["AI augmentation… ",a.current,"/",a.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:n?a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Hs(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${n?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":d,children:e.jsx("div",{className:`h-full transition-all ${n?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const be={"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 Ks(t){return/^wcag\d/.test(t.wcagCriterion)?[be["ada-iii"],be[508],be.eaa,be["en-301-549"],be.aoda]:[]}const qs={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 Ue({violation:t,alreadyAcknowledged:s}){const a=b(x=>x.pinnedMatchKey),n=b(x=>x.pinnedFound),r=b(x=>x.setPinned),i=b(x=>{var v;return(v=x.results[0])==null?void 0:v.frameId}),o=b(x=>{var v;return(v=x.results[0])==null?void 0:v.scope}),l=b(x=>x.results),d=b(x=>x.acknowledgedKeys.has(t.matchKey)),m=b(x=>x.markAcknowledged),c=b(x=>x.markUnacknowledged),p=s||d,u=a===t.matchKey,f=u&&!n;async function h(x){try{return(await Ie(x,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:x,selector:t.target.selector},i)).found}catch{return!0}}async function w(){const x=await Z();if(!x)return;if(u){r(null);try{await se(x,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:x},i)}catch{}return}const v=await h(x);r(t.matchKey,v)}function R(x){x.stopPropagation(),t.currentState.breakpoint.width<=640&&Ct(),(async()=>{const v=await Z();if(!v)return;try{await J({type:"STATE_DRIVE_REQUEST",tabId:v,state:t.currentState,scope:o,frameId:i})}catch{}const y=await h(v);r(t.matchKey,y)})()}async function I(x){x.stopPropagation();const v=await Z();if(!v)return;try{await J({type:"STATE_DRIVE_REQUEST",tabId:v,state:Xs(),scope:o,frameId:i})}catch{Y({type:"STATE_RESET_REQUEST",tabId:v})}const y=await h(v);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:w,"aria-pressed":u,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
+ ${u?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${qs[t.impact]}`,children:t.impact})]})]}),e.jsx("p",{className:"text-xs text-slate-700 mb-2",children:t.description}),e.jsx("code",{className:"text-[11px] bg-slate-50 p-1.5 rounded block text-slate-600 font-mono whitespace-pre-wrap break-all",children:t.target.outerHTML}),e.jsx(Zs,{violation:t}),e.jsx(sa,{violation:t}),e.jsx(ta,{violation:t}),e.jsx(ea,{text:t.target.failureSummary}),e.jsx(aa,{ruleId:t.ruleId}),u&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Qs(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:R,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),R(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:I,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),I(x))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),f&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(t.matchKey),Ys(t,l)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),m(t.matchKey),Js(t,l)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:x=>x.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Qs(t){const s=[];return s.push(t.pseudoState==="default"?"default":`:${t.pseudoState}`),t.theme!=="light"&&s.push(t.theme),t.direction!=="ltr"&&s.push(t.direction),t.breakpoint.id!=="desktop"&&s.push(t.breakpoint.id),t.ariaVariation&&s.push(t.ariaVariation.id),s.join(" · ")}async function Js(t,s){await zt({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Tt(t.componentId,s)}async function Ys(t,s){await Ht(t.componentId,t.matchKey),await Tt(t.componentId,s)}async function Tt(t,s){const a=s.flatMap(n=>n.violations);try{const n=await J({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});b.getState().setDelta(n.delta)}catch{}}function Xs(){const t=jt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function $t(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 Zs({violation:t}){const s=$t(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 ea({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 ta({violation:t}){const s=Ks(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 sa({violation:t}){const s=$t(t),[a,n]=g.useState({kind:"idle"});if(!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await J({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(d=>d.matchKey===t.matchKey);n(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function aa({ruleId:t}){const s=Kt(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 na=[{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 ra(t){const s=na.map(i=>ia(i,t)),a=s.reduce((i,o)=>i+oa(o.letter),0)/Math.max(1,s.length),n=la(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 ia(t,s){const a=new Set(t.axeRules),n=s.violations.filter(A=>a.has(A.ruleId)),r=s.manualRuns.filter(A=>t.igtWorkflowIds.includes(A.workflowId)),i=t.igtWorkflowIds.map(A=>s.workflows.find(T=>T.id===A)).filter(A=>A!=null);let o=i.length>0;for(const A of i){const T=r.find(L=>L.workflowId===A.id);if((T?Object.keys(T.steps).length:0)!==A.steps.length){o=!1;break}}const l=r.some(A=>Object.keys(A.steps).length>0),d=t.verifiedByWorkflowIds??[],m=s.manualRuns.filter(A=>d.includes(A.workflowId)),c=d.map(A=>s.workflows.find(T=>T.id===A)).filter(A=>A!=null);let p=d.length>0&&c.length===d.length;for(const A of c){const T=m.find(L=>L.workflowId===A.id);if((T?Object.keys(T.steps).length:0)!==A.steps.length){p=!1;break}}let u=null;if(p)for(const A of m)A.completedAt&&(u===null||A.completedAt>u)&&(u=A.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,h=d[0]??t.igtWorkflowIds[0]??null;if(p&&d.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:u,suppressedHeuristicCount:f,primaryVerifierWorkflowId:h,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w=t.axeRules.length>0||t.heuristic!=null,R=t.igtWorkflowIds.length>0;if(w?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:R||d.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:h,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const x={critical:0,serious:0,moderate:0,minor:0};for(const A of bt(n))x[A.impact]++;x.serious+=f;for(const A of r){const T=i.find(j=>j.id===A.workflowId);if(T)for(const j of T.steps){const L=A.steps[j.id];(L==null?void 0:L.status)==="fail"&&(j.severity==="required"?x.serious++:x.moderate++)}}const v=x.critical>0,y=x.serious>0;let k;x.critical>=5?k="F":x.critical>=1?k="D":x.serious>=1?k="C":x.moderate>=1?k="B":k="A";const E=k!=="A"&&(R&&!o||d.length>0&&!p);return{id:t.id,label:t.label,letter:k,untested:!1,needsIgt:E,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:h,counts:x,caps:{cappedAtC:v,cappedAtB:y}}}function oa(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function la(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const ca={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},da={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 ua({violations:t,componentId:s}){var q,te,Q,ae,ne,V,Se;const[a,n]=g.useState([]),[r,i]=g.useState([]),[o,l]=g.useState(new Set),[d,m]=g.useState(null),[c,p]=g.useState({}),[u,f]=g.useState(new Set),h=b($=>$.status),w=b($=>$.progress),R=b($=>$.freshThisSession),I=b($=>$.results),x=(q=I[0])==null?void 0:q.startedAt,v=((te=I[0])==null?void 0:te.pageUrl)??((Q=I[0])==null?void 0:Q.scope)??null;if(g.useEffect(()=>{if(!s){n([]);return}let $=!1;return chrome.storage.local.get("igtRuns").then(W=>{if($)return;const D=((W==null?void 0:W.igtRuns)??{})[s]??{};n(Object.values(D))}),()=>{$=!0}},[s]),g.useEffect(()=>{if(!v){i([]);return}let $=!1;return Ce(v).then(W=>{$||i(W)}),()=>{$=!0}},[v]),h==="running")return e.jsx(ba,{current:w==null?void 0:w.current,total:w==null?void 0:w.total});const y=ra({violations:t,auditRan:I.length>0,manualRuns:a,workflows:X,heuristicCounts:{tabOrder:((ne=(ae=I[0])==null?void 0:ae.tabOrderIssues)==null?void 0:ne.length)??0,readingOrder:((Se=(V=I[0])==null?void 0:V.readingOrderIssues)==null?void 0:Se.length)??0}}),k=b($=>$.acknowledgedKeys),E=I.length>0?qt(I,{runs:a,workflows:X},"2.1","AA",k,r):void 0,A=I.length>0?Qt(vt({audits:I,igtRuns:a,workflows:X,acknowledgedMatchKeys:k,incompleteResolutions:r}),X):void 0,T=E?E.failingCriteria.length>0||E.inconclusiveCriteria.length>0:!1,j=T&&y.overallLetter==="A"?"B":y.overallLetter;async function L($){var H;if(!v||!((H=E==null?void 0:E.inconclusiveReasons)!=null&&H[$]))return;const N=E.inconclusiveReasons[$].filter(B=>B.source==="axe-incomplete"&&B.elements&&B.elements.length>0);if(N.length===0)return;l(B=>new Set(B).add($)),m(null);const D=[];let _=0;try{for(const F of N){const z=await Y({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:F.ruleOrStepId,pageUrl:F.pageUrl??v,wcagCriterion:$,elements:F.elements??[],targetLevel:"AA"});if(z!=null&&z.unavailableReason){m(z.unavailableReason);break}z!=null&&z.resolutions&&(D.push(...z.resolutions),_+=z.totalCostUsd??0)}if(v){const F=await Ce(v);i(F)}const B={total:D.length,pass:D.filter(F=>F.verdict==="pass").length,fail:D.filter(F=>F.verdict==="fail").length,uncertain:D.filter(F=>F.verdict==="uncertain").length,costUsd:_,resolutions:D};p(F=>({...F,[$]:B}))}finally{l(B=>{const F=new Set(B);return F.delete($),F})}}function U($){f(W=>{const N=new Set(W);return N.has($)?N.delete($):N.add($),N})}async function S($){var z,he;if(!v)return;const W=((z=E==null?void 0:E.inconclusiveReasons)==null?void 0:z[$])??[],N=((he=E==null?void 0:E.failingReasons)==null?void 0:he[$])??[],D=[],_=new Set;for(const G of W){if(G.source!=="axe-incomplete"||!G.elements)continue;const re=G.pageUrl??v;for(const ie of G.elements){const xe=`${re}::${G.ruleOrStepId}::${ie.selector}`;_.has(xe)||(_.add(xe),D.push({ruleId:G.ruleOrStepId,pageUrl:re,selector:ie.selector}))}}for(const G of N){if(G.source!=="ai"||!G.selector)continue;const re=G.ruleOrStepId.startsWith("ai-resolved::")?G.ruleOrStepId.slice(13):G.ruleOrStepId,ie=G.pageUrl??v,xe=`${ie}::${re}::${G.selector}`;_.has(xe)||(_.add(xe),D.push({ruleId:re,pageUrl:ie,selector:G.selector}))}if(D.length===0)return;const H=new Date().toISOString(),B=[];for(const G of D){const re=r.find(ie=>ie.pageUrl===G.pageUrl&&ie.ruleId===G.ruleId&&ie.selector===G.selector);re&&re.verdict==="pass"&&re.reasoning.startsWith("Marked as visually verified")||B.push({pageUrl:G.pageUrl,ruleId:G.ruleId,selector:G.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${H.slice(0,10)}.`,resolvedAt:H,costUsd:0,wcagCriterion:$})}if(B.length===0)return;await Jt(B);const F=await Ce(v);i(F),p(G=>({...G,[$]:{total:B.length,pass:B.length,fail:0,uncertain:0,costUsd:0,resolutions:B}}))}const O=(()=>{if(!T||y.overallLetter!=="A"||!E)return null;const $=E.inconclusiveCriteria.length,W=E.failingCriteria.length,N=[];W>0&&N.push(`${W} WCAG ${E.targetLevel} ${W===1?"criterion":"criteria"} failing`),$>0&&N.push(`${$} WCAG ${E.targetLevel} ${$===1?"criterion":"criteria"} inconclusive`);const D=W>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${N.join(" + ")}. ${D}`})();let P=0;for(const $ of X){const W=a.find(D=>D.workflowId===$.id);if(!W)continue;$.steps.every(D=>{const _=W.steps[D.id];return(_==null?void 0:_.status)==="pass"||(_==null?void 0:_.status)==="fail"||(_==null?void 0:_.status)==="skip"||(_==null?void 0:_.status)==="not-applicable"})&&P++}const K=bt(t.filter($=>!k.has($.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!R&&x&&e.jsx(va,{scannedAt:x}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ca[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 ",y.subGrades.length," verification areas below. Untested areas count as F until verified."]}),O&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:O})]})]}),y.isLawsuitRisk&&e.jsx(ha,{areas:y.warningAreas}),e.jsx(xa,{grades:y.subGrades}),E&&e.jsx(pa,{coverage:E,onResolveWithAi:L,onMarkVisuallyVerified:S,resolving:o,resolveError:d,lastResolveResult:c,expandedResultFor:u,onToggleResultDetail:U}),A&&e.jsx(ma,{layers:A}),e.jsx(ga,{violationsRemaining:K,manualCompleted:P,manualTotal:X.length}),P>0||I.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:P})," of ",e.jsx("strong",{children:X.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${P/X.length*100}%`}})})]}):null]})}function pa({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const d=t.untestedCriteria.length+t.inconclusiveCriteria.length,[m,c]=g.useState(d>0&&d<=3),p=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),u=t.canClaimConformance,f=[];return t.failingCriteria.length>0&&f.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&f.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&f.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${u?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${u?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",p,"%)"]}),u&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!u&&(()=>{const h=[];t.failingCriteria.length>0&&h.push("failing"),t.inconclusiveCriteria.length>0&&h.push("inconclusive"),t.untestedCriteria.length>0&&h.push("untested");const w=h.length===0?"unresolved":h.length===1?h[0]:h.length===2?`${h[0]} or ${h[1]}`:`${h.slice(0,-1).join(", ")}, or ${h[h.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",w,"."]})})(),!u&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!u&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!u&&f.length>0&&e.jsx("button",{type:"button",onClick:()=>c(h=>!h),className:"text-[11px] underline shrink-0 self-start",children:m?"hide":"show list"})]}),m&&!u&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[f.map(h=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${h.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[h.kind==="untested"?"Untested":h.kind==="inconclusive"?"Inconclusive":"Failing"," (",h.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:h.ids.map(w=>{var A,T;const R=h.kind==="inconclusive"?(A=t.inconclusiveReasons)==null?void 0:A[w]:void 0,I=h.kind==="failing"?(T=t.failingReasons)==null?void 0:T[w]:void 0,x=R==null?void 0:R.some(j=>j.source==="axe-incomplete"&&j.elements&&j.elements.length>0),v=I==null?void 0:I.some(j=>j.source==="ai"),y=(n==null?void 0:n.has(w))??!1,k=i==null?void 0:i[w],E=(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]}),(h.kind==="inconclusive"&&x||h.kind==="failing"&&v)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:y,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:y?"Resolving…":k?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:y,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:h.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),k&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",k.total," ",k.total===1?"verdict":"verdicts",":",k.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",k.pass," pass"]}),k.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",k.fail," fail"]}),k.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",k.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",k.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(w),className:"ml-auto text-[10px] underline text-brand-700",children:E?"hide reasoning":"show reasoning"})]}),k.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",k.uncertain," ",k.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),k.pass===k.total&&k.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),E&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:k.resolutions.map((j,L)=>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})]},L))})]}),I&&I.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:I.map((j,L)=>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})]},L))}),R&&R.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:R.map((j,L)=>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((U,S,O)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:U.selector}),S<O.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},S)),j.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",j.elements.length-3," more"]})]})]},L))}):h.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)})})]},h.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 at={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 ma({layers:t}){const s=b(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,d=r.cleared,m=i>0&&o===0&&l===0,c=m?"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 ${m?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:m?"✓":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:at[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${c}`,children:i===0?"no coverage yet":`${d}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:at[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 ha({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 xa({grades:t}){const s=b(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${da[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(fa,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function fa({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=X.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?_t(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 ga({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=b(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const d=l===i,m=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:m?"font-mono text-emerald-700 shrink-0":d?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:m?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:d?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:m?"text-slate-500 line-through leading-snug":d?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function ba({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function va({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",_t(s)," old). Re-scan to grade the current page state."]})]})}function _t(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}const qe="dismissedFindings";function Oe(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function pe(t){return`reading-order::${t}`}function me(t){return`tab-order::${t}`}async function Fe(){try{const t=await chrome.storage.local.get(qe),s=t==null?void 0:t[qe];if(s&&typeof s=="object")return s}catch{}return{}}async function Je(t){await chrome.storage.local.set({[qe]:t})}async function De(t){return(await Fe())[Oe(t)]??{}}async function Lt(t,s,a,n){const r=await Fe(),i=Oe(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await Je(r)}async function Ne(t,s){if(s.length===0)return;const a=await Fe(),n=Oe(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 Je(a)}async function Ut(t,s){const a=await Fe(),n=Oe(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await Je(a))}const ya=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Lt,addDismissals:Ne,dismissalKeyForReadingOrder:pe,dismissalKeyForTabOrder:me,getDismissalsForUrl:De,removeDismissal:Ut},Symbol.toStringTag,{value:"Module"}));function Dt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ot(t){return`${yt(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function wa(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=Ot(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 nt={critical:0,serious:1,moderate:2,minor:3};function ja(){var h,w,R,I;const t=b(x=>x.results),s=b(x=>x.componentId),a=b(x=>x.setView),n=((h=t[0])==null?void 0:h.pageUrl)??((w=t[0])==null?void 0:w.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(new Set);if(g.useEffect(()=>{if(!n)return;De(n).then(i);const x=()=>{document.visibilityState==="visible"&&n&&De(n).then(i)};return document.addEventListener("visibilitychange",x),()=>document.removeEventListener("visibilitychange",x)},[n]),g.useEffect(()=>{if(!s){l(new Set);return}let x=!1;const v=async()=>{const k=await chrome.storage.local.get("igtRuns");if(x)return;const A=((k==null?void 0:k.igtRuns)??{})[s]??{},T=new Set;for(const j of X){const L=A[j.id];L&&Object.keys(L.steps).length===j.steps.length&&T.add(j.id)}l(T)};v();const y=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",y),()=>{x=!0,document.removeEventListener("visibilitychange",y)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((x,v)=>x+v.durationMs,0),m=t.reduce((x,v)=>x+v.violations.length,0),c=wa(t);c.sort((x,v)=>{const y=nt[x.representative.impact]??99,k=nt[v.representative.impact]??99;return y!==k?y-k:v.states.length-x.states.length});const p=t.map(x=>Dt(x.state)).join(`
4
+ `),u=o.has("keyboard")?0:(((R=t[0])==null?void 0:R.tabOrderIssues)??[]).filter(x=>!(me(x.selector)in r)).length,f=o.has("page-structure")?0:(((I=t[0])==null?void 0:I.readingOrderIssues)??[]).filter(x=>!(pe(x.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(ua,{violations:t.flatMap(x=>x.violations),componentId:s}),(u>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[u>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:u})," tab-order issue",u===1?"":"s"," (WCAG 2.4.3)"]}),u>0&&f>0&&" · ",f>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:f})," reading-order issue",f===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:p,"aria-label":`${t.length} states tested: ${p.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",c.length," unique ",c.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",m," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),c.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic px-1",children:"No violations found."}):e.jsx("div",{className:"space-y-1.5",children:c.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ue,{violation:x.representative}),e.jsx(Na,{states:x.states,totalStates:t.length})]},Ot(x.representative)))})]})}function Na({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(Dt))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
5
+ `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const ka={minor:"bg-blue-100 text-blue-700",moderate:"bg-yellow-100 text-yellow-700",serious:"bg-orange-100 text-orange-700",critical:"bg-red-100 text-red-700"};function Sa({ruleId:t,violations:s}){const[a,n]=g.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Ue,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ka[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((d,m)=>e.jsx(Ue,{violation:d},m))})]})}function Aa(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Ca={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Ra({open:t,onClose:s,format:a,content:n,filename:r}){const i=Gt(new Blob([n]).size);function o(){ft(n,r),s()}function l(){xt(n),s()}return e.jsxs(ke,{open:t,onClose:s,title:Ca[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const rt=7800;function Ea(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,u=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,f=r.find(h=>`${h.ruleId}::${h.target.selector}`===p);if(f){f._states.includes(u)||f._states.push(u);continue}r.push({...c,_states:[u]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`### \`${c.ruleId}\` — ${c.impact}`),o.push(""),o.push(c.description),o.push(""),o.push(`- **WCAG:** ${c.wcagCriterion} (${c.wcagLevel})`),o.push(`- **Selector:** \`${c.target.selector}\``),o.push(`- **Found in state(s):** ${c._states.join(", ")}`),c.helpUrl&&o.push(`- **More info:** ${c.helpUrl}`),o.push(""),o.push("```html"),o.push(c.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
6
6
  `),d=new URLSearchParams({title:i,body:l});let m=`${n}/issues/new?${d.toString()}`;return m.length>rt&&(m=m.slice(0,rt)),{url:m,title:i,body:l}}const it=7800;function Ia(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const c of a){const p=`${c.ruleId}::${c.target.selector}`,u=`:${c.currentState.pseudoState} · ${c.currentState.theme} · ${c.currentState.direction}`,f=r.find(h=>`${h.ruleId}::${h.target.selector}`===p);if(f){f._states.includes(u)||f._states.push(u);continue}r.push({...c,_states:[u]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const c of r)o.push(`Rule: ${c.ruleId} (${c.impact})`),o.push(`WCAG: ${c.wcagCriterion} ${c.wcagLevel}`),o.push(`Description: ${c.description}`),o.push(`Selector: ${c.target.selector}`),o.push(`Found in state(s): ${c._states.join(", ")}`),c.helpUrl&&o.push(`More info: ${c.helpUrl}`),o.push(""),o.push(`HTML: ${c.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
7
- `),d=new URLSearchParams({summary:i,description:l});let m=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return m.length>it&&(m=m.slice(0,it)),{url:m,summary:i,description:l}}function Ta(){const t=b(v=>v.delta),s=b(v=>v.componentId),a=b(v=>v.results),n=b(v=>v.tier),r=b(v=>v.baselineList),i=b(v=>v.siteCrawlReport),[o,l]=g.useState(""),[d,m]=g.useState(""),[c,p]=g.useState(null);g.useEffect(()=>{Promise.all([Q({type:"SETTINGS_GET",key:"githubRepoUrl"}),Q({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,y])=>{l(typeof v.data=="string"?v.data:""),m(typeof y.data=="string"?y.data:"")})},[]);const u=wt(n,"exportJson"),f=Nt[n].maxBaselines,h=r.some(v=>v.componentId===s),w=h||r.length<f;if(!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit to see the delta against your baseline."});async function R(){if(!s||a.length===0)return;const v=a.flatMap(S=>S.violations),y=a.flatMap(S=>S.announcements??[]),k=a.flatMap(S=>S.focusEvents??[]),I=a[0],$=(await Q({type:"SETTINGS_GET",key:"stateMatrix"})).data??jt;await J({type:"BASELINE_SET",componentId:s,violations:v,announcements:y,focusEvents:k,snapshotMeta:{url:window.location.href,axeVersion:I.axeVersion,matrixConfig:$,capturedAt:new Date().toISOString()}});const j=await Q({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:y,focusEvents:k,currentMatrix:$});b.getState().setDelta(j.delta),le.polite(`Baseline saved for ${s}.`)}async function T(){if(!s||!h||!window.confirm(`Remove the saved baseline for "${s}"?
7
+ `),d=new URLSearchParams({summary:i,description:l});let m=`${n}/secure/CreateIssue!default.jspa?${d.toString()}`;return m.length>it&&(m=m.slice(0,it)),{url:m,summary:i,description:l}}function Ta(){const t=b(v=>v.delta),s=b(v=>v.componentId),a=b(v=>v.results),n=b(v=>v.tier),r=b(v=>v.baselineList),i=b(v=>v.siteCrawlReport),[o,l]=g.useState(""),[d,m]=g.useState(""),[c,p]=g.useState(null);g.useEffect(()=>{Promise.all([J({type:"SETTINGS_GET",key:"githubRepoUrl"}),J({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([v,y])=>{l(typeof v.data=="string"?v.data:""),m(typeof y.data=="string"?y.data:"")})},[]);const u=wt(n,"exportJson"),f=Nt[n].maxBaselines,h=r.some(v=>v.componentId===s),w=h||r.length<f;if(!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit to see the delta against your baseline."});async function R(){if(!s||a.length===0)return;const v=a.flatMap(L=>L.violations),y=a.flatMap(L=>L.announcements??[]),k=a.flatMap(L=>L.focusEvents??[]),E=a[0],T=(await J({type:"SETTINGS_GET",key:"stateMatrix"})).data??jt;await Y({type:"BASELINE_SET",componentId:s,violations:v,announcements:y,focusEvents:k,snapshotMeta:{url:window.location.href,axeVersion:E.axeVersion,matrixConfig:T,capturedAt:new Date().toISOString()}});const j=await J({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:y,focusEvents:k,currentMatrix:T});b.getState().setDelta(j.delta),ce.polite(`Baseline saved for ${s}.`)}async function I(){if(!s||!h||!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 J({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(j=>j.violations),k=a.flatMap(j=>j.announcements??[]),I=a.flatMap(j=>j.focusEvents??[]),C=await Q({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:k,focusEvents:I});b.getState().setDelta(C.delta);const $=await Q({type:"BASELINE_LIST"});b.getState().setBaselineList($.items),le.polite(`Baseline cleared for ${s}.`)}async function x(v,y=!1){var D,X;if(a.length===0)return;let k;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const K=await chrome.storage.local.get("igtRuns"),q=((K==null?void 0:K.igtRuns)??{})[s]??{};k=Object.values(q)}let I,C;if(v==="ai-prompt"){const K=((D=a[0])==null?void 0:D.pageUrl)??((X=a[0])==null?void 0:X.scope)??"";if(K){const{getDismissalsForUrl:te}=await je(async()=>{const{getDismissalsForUrl:ne}=await Promise.resolve().then(()=>ya);return{getDismissalsForUrl:ne}},void 0),q=await te(K);I=Object.keys(q);const{getResolutionsForPage:ae}=await je(async()=>{const{getResolutionsForPage:ne}=await import("./forensic-log-VcNR3Xcq.js").then(G=>G.M);return{getResolutionsForPage:ne}},__vite__mapDeps([0,1,2]));C=await ae(K)}}const $=await Q({type:"EXPORT_REQUEST",format:v,results:a,delta:y?void 0:t??void 0,manualRuns:k,siteCrawlReport:v==="ai-prompt"?i??void 0:void 0,dismissedKeys:I,incompleteResolutions:C});if(v==="defense-bundle"||v==="evidence-bundle"){const K=Vt(v,s);await Bt()?ft($.content,K):p({open:!0,format:v,content:$.content,filename:K});return}if(v==="html-print"||v==="vpat"){xt($.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText($.content)}catch{}const te=`<!doctype html><html><head><meta charset="utf-8"><title>AI fix prompt</title>
9
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await Y({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(j=>j.violations),k=a.flatMap(j=>j.announcements??[]),E=a.flatMap(j=>j.focusEvents??[]),A=await J({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:k,focusEvents:E});b.getState().setDelta(A.delta);const T=await J({type:"BASELINE_LIST"});b.getState().setBaselineList(T.items),ce.polite(`Baseline cleared for ${s}.`)}async function x(v,y=!1){var P,K;if(a.length===0)return;let k;if((v==="defense-bundle"||v==="evidence-bundle"||v==="ai-prompt")&&s){const q=await chrome.storage.local.get("igtRuns"),Q=((q==null?void 0:q.igtRuns)??{})[s]??{};k=Object.values(Q)}let E,A;if(v==="ai-prompt"){const q=((P=a[0])==null?void 0:P.pageUrl)??((K=a[0])==null?void 0:K.scope)??"";if(q){const{getDismissalsForUrl:te}=await je(async()=>{const{getDismissalsForUrl:ne}=await Promise.resolve().then(()=>ya);return{getDismissalsForUrl:ne}},void 0),Q=await te(q);E=Object.keys(Q);const{getResolutionsForPage:ae}=await je(async()=>{const{getResolutionsForPage:ne}=await import("./forensic-log-VcNR3Xcq.js").then(V=>V.M);return{getResolutionsForPage:ne}},__vite__mapDeps([0,1,2]));A=await ae(q)}}const T=await J({type:"EXPORT_REQUEST",format:v,results:a,delta:y?void 0:t??void 0,manualRuns:k,siteCrawlReport:v==="ai-prompt"?i??void 0:void 0,dismissedKeys:E,incompleteResolutions:A});if(v==="defense-bundle"||v==="evidence-bundle"){const q=Vt(v,s);await Bt()?ft(T.content,q):p({open:!0,format:v,content:T.content,filename:q});return}if(v==="html-print"||v==="vpat"){xt(T.content);return}if(v==="ai-prompt"){try{await navigator.clipboard.writeText(T.content)}catch{}const te=`<!doctype html><html><head><meta charset="utf-8"><title>AI fix prompt</title>
10
10
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
11
11
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
12
12
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}
@@ -17,46 +17,46 @@ button:hover{background:#f1f5f9;}</style></head>
17
17
  <strong>Already copied to your clipboard.</strong> Paste it into Claude, Cursor, Copilot Chat, or any LLM with codebase access.
18
18
  <button id="copy" style="margin-left:12px;">Copy again</button>
19
19
  </div>
20
- <pre id="content">${$.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>
20
+ <pre id="content">${T.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>
21
21
  <script>
22
22
  document.getElementById('copy').addEventListener('click', () => {
23
23
  navigator.clipboard.writeText(document.getElementById('content').textContent || '');
24
24
  });
25
25
  <\/script>
26
- </body></html>`,q=new Blob([te],{type:"text/html"}),ae=URL.createObjectURL(q);window.open(ae,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(ae),6e4);return}const j=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",S=v==="junit"?"xml":v,B=new Blob([$.content],{type:j}),A=URL.createObjectURL(B),M=document.createElement("a");M.href=A,M.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${S}`,M.click(),URL.revokeObjectURL(A)}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:R,disabled:!w,title:w?void 0:`Free tier limits you to ${f} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),h&&e.jsx("button",{onClick:T,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx(Ua,{disabled:!u,onExport:x,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!w&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const v=Ge(t.new),y=Ge(t.persistent),k=Ge(t.fixed),I=[...v.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(ve,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>_a(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>La(d,s,v.findings)}]:[]]}),e.jsx(ve,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(ve,{title:"Fixed",violations:k.findings,count:t.fixedCount,accent:"green"}),I.length>0&&e.jsx(ve,{title:"Needs review (does not affect grade)",violations:I,count:I.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ve,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),c&&e.jsx(Ea,{open:c.open,onClose:()=>p(null),format:c.format,content:c.content,filename:c.filename})]})}const $a={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ge(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 ve({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=g.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${$a[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,m)=>e.jsx(Ue,{violation:d,alreadyAcknowledged:!0},m)):Aa(s).map(d=>e.jsx(Sa,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function _a(t,s,a){if(a.length===0)return;const{url:n}=Ra(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function La(t,s,a){if(a.length===0)return;const{url:n}=Ia(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Ua({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=g.useState(!1),[i,o]=g.useState(!1);function l(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(oe,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(oe,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(oe,{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(oe,{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(oe,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(oe,{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(oe,{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(oe,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function oe({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 ot="igtRuns";async function Da(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(ot))[ot];return s&&typeof s=="object"?s:{}}async function Oa(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Da())[t];if(i)for(const d of Y){const m=i[d.id];if(m)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=m.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const u=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const f=a.tabOrderIssues??[];if(f.length===0)continue;await Ne(n,f.map(h=>({key:me(h.selector),reason:u,snippet:`${h.selector} — ${h.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const f=a.readingOrderIssues??[];if(f.length===0)continue;await Ne(n,f.map(h=>({key:pe(h.selector),reason:u,snippet:`${h.selector} — ${h.textSnippet||"(no text)"}`})))}}}}const Fa=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"]),Ma=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 Pa(t){return Fa.has(t.ruleId)}function Ga(t){return Ma.has(t.ruleId)}function Va(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ba(){var $,j,S,B;const t=b(A=>A.results),s=b(A=>A.delta),a=b(A=>A.componentId),n=(($=t[0])==null?void 0:$.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(0);g.useEffect(()=>{if(!n)return;let A=!1;return(async()=>{if(a&&t.length>0)try{await Oa(a,t)}catch{}if(A)return;const M=await De(n);A||i(M)})(),()=>{A=!0}},[n,o,a,t]);async function d(A,M){if(!n)return;const D=window.prompt(`Why is this finding a false positive?
26
+ </body></html>`,Q=new Blob([te],{type:"text/html"}),ae=URL.createObjectURL(Q);window.open(ae,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(ae),6e4);return}const j=v==="json"?"application/json":v==="sarif"?"application/sarif+json":"application/xml",L=v==="junit"?"xml":v,U=new Blob([T.content],{type:j}),S=URL.createObjectURL(U),O=document.createElement("a");O.href=S,O.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${L}`,O.click(),URL.revokeObjectURL(S)}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:R,disabled:!w,title:w?void 0:`Free tier limits you to ${f} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),h&&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(Ua,{disabled:!u,onExport:x,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!w&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const v=Ge(t.new),y=Ge(t.persistent),k=Ge(t.fixed),E=[...v.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(ve,{title:"New",violations:v.findings,count:v.findings.length,accent:"red",actions:[...o&&v.findings.length>0?[{label:"File GitHub issue",onClick:()=>_a(o,s,v.findings)}]:[],...d&&v.findings.length>0?[{label:"File Jira issue",onClick:()=>La(d,s,v.findings)}]:[]]}),e.jsx(ve,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(ve,{title:"Fixed",violations:k.findings,count:t.fixedCount,accent:"green"}),E.length>0&&e.jsx(ve,{title:"Needs review (does not affect grade)",violations:E,count:E.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ve,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),c&&e.jsx(Ra,{open:c.open,onClose:()=>p(null),format:c.format,content:c.content,filename:c.filename})]})}const $a={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ge(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 ve({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=g.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${$a[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(d=>!d):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(d=>e.jsx("button",{type:"button",onClick:d.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:d.label},d.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((d,m)=>e.jsx(Ue,{violation:d,alreadyAcknowledged:!0},m)):Aa(s).map(d=>e.jsx(Sa,{ruleId:d.ruleId,violations:d.violations},d.ruleId))}):null]})}function _a(t,s,a){if(a.length===0)return;const{url:n}=Ea(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function La(t,s,a){if(a.length===0)return;const{url:n}=Ia(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Ua({disabled:t,onExport:s,hasBaselineDelta:a}){const[n,r]=g.useState(!1),[i,o]=g.useState(!1);function l(d){r(!1),s(d,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(d=>!d),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),n&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[a&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>o(d.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(le,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(le,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(le,{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(le,{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(le,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(le,{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(le,{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(le,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function le({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 ot="igtRuns";async function Da(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(ot))[ot];return s&&typeof s=="object"?s:{}}async function Oa(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Da())[t];if(i)for(const d of X){const m=i[d.id];if(m)for(const c of d.steps){if(!c.autoDismissActivity||((l=(o=m.steps)==null?void 0:o[c.id])==null?void 0:l.status)!=="pass")continue;const u=`Auto-dismissed by Guided test: "${c.id}" marked pass`;if(c.autoDismissActivity==="tab-order"){const f=a.tabOrderIssues??[];if(f.length===0)continue;await Ne(n,f.map(h=>({key:me(h.selector),reason:u,snippet:`${h.selector} — ${h.textSnippet||"(no text)"}`})))}else if(c.autoDismissActivity==="reading-order"){const f=a.readingOrderIssues??[];if(f.length===0)continue;await Ne(n,f.map(h=>({key:pe(h.selector),reason:u,snippet:`${h.selector} — ${h.textSnippet||"(no text)"}`})))}}}}const Fa=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"]),Ma=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 Pa(t){return Fa.has(t.ruleId)}function Ga(t){return Ma.has(t.ruleId)}function Va(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ba(){var T,j,L,U;const t=b(S=>S.results),s=b(S=>S.delta),a=b(S=>S.componentId),n=((T=t[0])==null?void 0:T.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=g.useState({}),[o,l]=g.useState(0);g.useEffect(()=>{if(!n)return;let S=!1;return(async()=>{if(a&&t.length>0)try{await Oa(a,t)}catch{}if(S)return;const O=await De(n);S||i(O)})(),()=>{S=!0}},[n,o,a,t]);async function d(S,O){if(!n)return;const P=window.prompt(`Why is this finding a false positive?
27
27
 
28
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");D!==null&&(await Lt(n,A,D||"(no reason given)",M),l(X=>X+1))}async function m(A){n&&(await Ut(n,A),l(M=>M+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((A,M)=>{var D;return A+(((D=M.announcements)==null?void 0:D.length)??0)},0),p=t.reduce((A,M)=>{var D;return A+(((D=M.focusEvents)==null?void 0:D.length)??0)},0),u=t.reduce((A,M)=>{var D;return A+(((D=M.focusEvents)==null?void 0:D.filter(X=>X.isFocusReset).length)??0)},0),f=lt(t,Pa),h=lt(t,Ga),w=f.length,R=h.length,T=((S=t[0])==null?void 0:S.readingOrderIssues)??[],x=((B=t[0])==null?void 0:B.tabOrderIssues)??[],v=T.filter(A=>!(pe(A.selector)in r)),y=T.filter(A=>pe(A.selector)in r),k=x.filter(A=>!(me(A.selector)in r)),I=x.filter(A=>me(A.selector)in r);if(c===0&&p===0&&w===0&&R===0&&v.length===0&&k.length===0&&y.length===0&&I.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const C=y.length+I.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[w," structural · ",R," form ·"," ",k.length," tab-order ·"," ",v.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",p," focus ",p===1?"event":"events",u>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",u," focus reset",u===1?"":"s"]}),C>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",C," dismissed"]})]}),k.length>0&&e.jsx(za,{issues:k,onDismiss:d}),v.length>0&&e.jsx(Ka,{issues:v,onDismiss:d}),C>0&&e.jsx(qa,{dismissedReadingOrder:y,dismissedTabOrder:I,dismissals:r,onRestore:m}),w>0&&e.jsx(ct,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:f}),R>0&&e.jsx(ct,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:h}),e.jsx(Wa,{delta:s}),t.map((A,M)=>{const D=A.announcements??[],X=A.focusEvents??[];return D.length===0&&X.length===0?null:e.jsx(Ha,{state:A.state,announcements:D,focusEvents:X},M)})]})}function Wa({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function lt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=yt(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 ct({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 Ha({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:Va(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 za({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 Ka({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 qa({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=g.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,m=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),m&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",m.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,m=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),m&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",m.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Qe="igtRuns";async function Qa(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ne(r,o.map(l=>({key:me(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 Ne(r,o.map(l=>({key:pe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Ja={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"}},Ya={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"}},Xa={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function dt(t,s){const a=await Z();if(!a)return;const n=s?Ja[t]:Ya[t];try{await se(a,n)}catch{}}async function Za(){const s=(await chrome.storage.local.get(Qe))[Qe];return s&&typeof s=="object"?s:{}}async function ut(t){await chrome.storage.local.set({[Qe]:t})}function en(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 tn(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=g.useState({}),[r,i]=g.useState(null);if(g.useEffect(()=>{Za().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,p,u){var h;const f={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((h=o[c])==null?void 0:h.steps)??{},[p]:u},completedAt:new Date().toISOString()}}};if(n(f),ut(f),u.status==="pass"){const w=Y.find(T=>T.id===c),R=w==null?void 0:w.steps.find(T=>T.id===p);R!=null&&R.autoDismissActivity&&Qa(R.autoDismissActivity,s,p)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[c];const u={...a,[t]:p};n(u),ut(u)}const m=Y.find(c=>c.id===r);if(m){const c=o[m.id];return e.jsx(sn,{workflow:m,run:c,results:s,onAnswer:(p,u)=>l(m.id,p,u),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."}),Y.map(c=>{const p=o[c.id],u=p?Yt(p,c):null,f=p?u!=null&&u.failed&&u.failed>0?"failed":u!=null&&u.unanswered&&u.unanswered>0?"in-progress":"done":"unstarted",h={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[f];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${h}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),f==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),f==="in-progress"&&u&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[u.unanswered," unanswered"]})]}),u&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[u.passed," pass"]}),u.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",u.failed," fail"]}),u.notApplicable>0&&e.jsxs("span",{children:[" · ",u.notApplicable," N/A"]}),u.skipped>0&&e.jsxs("span",{children:[" · ",u.skipped," skip"]})," / ",u.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),p&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function sn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=g.useMemo(()=>{const d={};for(const m of t.steps)d[m.id]=en(m,a);return d},[t,a]);function o(){for(const d of t.steps){const m=i[d.id];(m==null?void 0:m.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${m.ruleId}, ${m.statesAudited} states).`})}}const l=t.steps.filter(d=>{var m;return((m=i[d.id])==null?void 0:m.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,m)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[m+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const p=i[d.id];return p?p.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:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.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:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void dt(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Xa[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void dt(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Ae,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(Ae,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(Ae,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(Ae,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:p=>n(d.id,{status:c.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const an={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 Ae({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?an[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Ee="savedFlows";async function nn(){const t=await chrome.storage.local.get(Ee);return Array.isArray(t[Ee])?t[Ee]:[]}async function pt(t){await chrome.storage.local.set({[Ee]:t})}function rn(){const[t,s]=g.useState([]),[a,n]=g.useState(!1),[r,i]=g.useState(null);g.useEffect(()=>{nn().then(s)},[]);async function o(){const c=await Z();if(!c){i("No audit-target tab found.");return}try{await se(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await Z();if(c)try{const p=await Ie(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const u=typeof prompt=="function"?prompt(`Captured ${p.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!u.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:u.trim(),steps:p.steps,savedAt:new Date().toISOString()},h=[f,...t];s(h),await pt(h),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function d(c){const p=await Z();if(p){i(`Replaying "${c.name}"…`);try{const u=await Ie(p,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${u.played} step${u.played===1?"":"s"}`+(u.errored?`, ${u.errored} errored (selector not found)`:"")+".")}catch(u){i(`Replay failed: ${u instanceof Error?u.message:String(u)}`)}}}async function m(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(u=>u.id!==c);s(p),await pt(p)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>m(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function on(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(ln).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function ln(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function cn(){const t=b(l=>l.baselineList),s=b(l=>l.tier),a=Nt[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=g.useState(!1);if(g.useEffect(()=>{$e().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 J({type:"BASELINE_DELETE",componentId:l}),await $e()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=on(l.componentId),m=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),m&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(de,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),m.criticalCount>0&&e.jsxs(de,{tone:"rose",title:`${m.criticalCount} critical violations`,children:[m.criticalCount," critical"]}),m.seriousCount>0&&e.jsxs(de,{tone:"orange",title:`${m.seriousCount} serious violations`,children:[m.seriousCount," serious"]}),m.focusResetCount>0&&e.jsxs(de,{tone:"rose",title:`${m.focusResetCount} focus resets observed`,children:[m.focusResetCount," focus reset",m.focusResetCount===1?"":"s"]}),m.targetSizeFailCount>0&&e.jsxs(de,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[m.targetSizeFailCount," small targets"]}),m.hoverContrastFail&&e.jsx(de,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),m.announcementCount>0&&e.jsxs(de,{tone:"indigo",title:"aria-live announcements observed",children:[m.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 dn={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function de({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${dn[t]}`,children:a})}const un={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},pn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},mn={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 hn({onBack:t}){const s=b(p=>p.siteCrawlStatus),a=b(p=>p.siteCrawlProgress),n=b(p=>p.siteCrawlReport),r=b(p=>p.siteCrawlError),[i,o]=g.useState(""),[l,d]=g.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(p=>{var f;const u=(f=p[0])==null?void 0:f.url;u&&/^https?:\/\//.test(u)&&i===""&&o(u)});function m(){i&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),ce({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function c(){J({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:p=>o(p.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:p=>d(Math.min(200,Math.max(1,parseInt(p.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:m,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(xn,{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 xn({report:t}){function s(){je(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-CXRggal1.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,0,1,2])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${un[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${pn[t.siteRisk]}`,children:Xt[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=Zt(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 ${mn[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 Ve="onboardingDismissed",Be=[{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 fn(){const[t,s]=g.useState(!1),[a,n]=g.useState(0);g.useEffect(()=>{chrome.storage.local.get(Ve).then(l=>{l[Ve]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ve]:!0}),s(!1),n(0)}const i=a===Be.length-1,o=Be[a];return e.jsxs(ke,{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," / ",Be.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 gn(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function bn(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=g.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,m)=>e.jsx("li",{children:d},m))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function vn(){const[t,s]=g.useState(!1);return g.useEffect(()=>ee("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(ke,{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 yn(){var i;const[t,s]=g.useState(null);if(g.useEffect(()=>{es().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Xe(),b.getState().startNewScan(),t.mode==="storybook-all"?ce({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&ce({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Xe(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const We="storybook:hintDismissed";function wn(){const[t,s]=g.useState(!1),[a,n]=g.useState();g.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(We))[We])return;const o=await Z();if(o)try{const m=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(p=c.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(c=>{var p;return(p=c.result)==null?void 0:p.detected});m&&(n((l=m.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[We]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function jn(){var i;const t=b(o=>o.results),s=b(o=>o.baselineList),a=b(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 ${Nn(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 Nn(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 kn(){const t=b(l=>l.results),s=b(l=>l.componentId),[a,n]=g.useState([]);if(g.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=ts(r,a.length>0?{runs:a,workflows:Y}: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 Sn(){const t=b(a=>a.setUserMode);function s(a){t(a),J({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 Re="wcagcheckr";function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function we(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 An(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Cn(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 En(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 Rn(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 In(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${F(t.receipt.tsaName)}) — anchored ${F(we(t.receipt.anchoredAt))}</td></tr>
29
- <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${F(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
- ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${F(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${F(Re)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
28
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");P!==null&&(await Lt(n,S,P||"(no reason given)",O),l(K=>K+1))}async function m(S){n&&(await Ut(n,S),l(O=>O+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const c=t.reduce((S,O)=>{var P;return S+(((P=O.announcements)==null?void 0:P.length)??0)},0),p=t.reduce((S,O)=>{var P;return S+(((P=O.focusEvents)==null?void 0:P.length)??0)},0),u=t.reduce((S,O)=>{var P;return S+(((P=O.focusEvents)==null?void 0:P.filter(K=>K.isFocusReset).length)??0)},0),f=lt(t,Pa),h=lt(t,Ga),w=f.length,R=h.length,I=((L=t[0])==null?void 0:L.readingOrderIssues)??[],x=((U=t[0])==null?void 0:U.tabOrderIssues)??[],v=I.filter(S=>!(pe(S.selector)in r)),y=I.filter(S=>pe(S.selector)in r),k=x.filter(S=>!(me(S.selector)in r)),E=x.filter(S=>me(S.selector)in r);if(c===0&&p===0&&w===0&&R===0&&v.length===0&&k.length===0&&y.length===0&&E.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 A=y.length+E.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 · ",R," form ·"," ",k.length," tab-order ·"," ",v.length," reading-order ·"," ",c," ",c===1?"announcement":"announcements"," ·"," ",p," focus ",p===1?"event":"events",u>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",u," focus reset",u===1?"":"s"]}),A>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",A," dismissed"]})]}),k.length>0&&e.jsx(za,{issues:k,onDismiss:d}),v.length>0&&e.jsx(Ka,{issues:v,onDismiss:d}),A>0&&e.jsx(qa,{dismissedReadingOrder:y,dismissedTabOrder:E,dismissals:r,onRestore:m}),w>0&&e.jsx(ct,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:f}),R>0&&e.jsx(ct,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:h}),e.jsx(Wa,{delta:s}),t.map((S,O)=>{const P=S.announcements??[],K=S.focusEvents??[];return P.length===0&&K.length===0?null:e.jsx(Ha,{state:S.state,announcements:P,focusEvents:K},O)})]})}function Wa({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function lt(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=yt(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 ct({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 Ha({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:Va(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 za({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 Ka({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 qa({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=g.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const d=`tab-order::${l.selector}`,m=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),m&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",m.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)}),t.map(l=>{const d=`reading-order::${l.selector}`,m=a[d];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),m&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",m.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(d),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},d)})]})]})]})}const Qe="igtRuns";async function Qa(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Ne(r,o.map(l=>({key:me(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 Ne(r,o.map(l=>({key:pe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Ja={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"}},Ya={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"}},Xa={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function dt(t,s){const a=await Z();if(!a)return;const n=s?Ja[t]:Ya[t];try{await se(a,n)}catch{}}async function Za(){const s=(await chrome.storage.local.get(Qe))[Qe];return s&&typeof s=="object"?s:{}}async function ut(t){await chrome.storage.local.set({[Qe]:t})}function en(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 tn(){const t=b(c=>c.componentId),s=b(c=>c.results),[a,n]=g.useState({}),[r,i]=g.useState(null);if(g.useEffect(()=>{Za().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(c,p,u){var h;const f={...a,[t]:{...o,[c]:{...o[c]??{componentId:t,workflowId:c,steps:{},completedAt:new Date().toISOString()},steps:{...((h=o[c])==null?void 0:h.steps)??{},[p]:u},completedAt:new Date().toISOString()}}};if(n(f),ut(f),u.status==="pass"){const w=X.find(I=>I.id===c),R=w==null?void 0:w.steps.find(I=>I.id===p);R!=null&&R.autoDismissActivity&&Qa(R.autoDismissActivity,s,p)}}function d(c){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[c];const u={...a,[t]:p};n(u),ut(u)}const m=X.find(c=>c.id===r);if(m){const c=o[m.id];return e.jsx(sn,{workflow:m,run:c,results:s,onAnswer:(p,u)=>l(m.id,p,u),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."}),X.map(c=>{const p=o[c.id],u=p?Yt(p,c):null,f=p?u!=null&&u.failed&&u.failed>0?"failed":u!=null&&u.unanswered&&u.unanswered>0?"in-progress":"done":"unstarted",h={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[f];return e.jsxs("button",{type:"button",onClick:()=>i(c.id),className:`w-full text-left border rounded p-2 block transition-colors ${h}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:c.name}),f==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),f==="in-progress"&&u&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[u.unanswered," unanswered"]})]}),u&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[u.passed," pass"]}),u.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",u.failed," fail"]}),u.notApplicable>0&&e.jsxs("span",{children:[" · ",u.notApplicable," N/A"]}),u.skipped>0&&e.jsxs("span",{children:[" · ",u.skipped," skip"]})," / ",u.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:c.blurb}),p&&e.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),d(c.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},c.id)})]})}function sn({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=g.useMemo(()=>{const d={};for(const m of t.steps)d[m.id]=en(m,a);return d},[t,a]);function o(){for(const d of t.steps){const m=i[d.id];(m==null?void 0:m.kind)==="clean"&&!(s!=null&&s.steps[d.id])&&n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${m.ruleId}, ${m.statesAudited} states).`})}}const l=t.steps.filter(d=>{var m;return((m=i[d.id])==null?void 0:m.kind)==="clean"&&!(s!=null&&s.steps[d.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((d,m)=>{const c=s==null?void 0:s.steps[d.id];return e.jsxs("div",{className:`border rounded p-2 ${(c==null?void 0:c.status)==="pass"?"border-emerald-300 bg-emerald-50":(c==null?void 0:c.status)==="fail"?"border-rose-300 bg-rose-50":(c==null?void 0:c.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[m+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),d.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",d.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",d.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",d.question]}),d.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:d.relatedAxeRule})]}),(()=>{const p=i[d.id];return p?p.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:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.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:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!c&&e.jsx("button",{type:"button",onClick:()=>n(d.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),d.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void dt(d.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",Xa[d.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void dt(d.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Ae,{label:"Pass",active:(c==null?void 0:c.status)==="pass",tone:"emerald",onClick:()=>n(d.id,{status:"pass",notes:c==null?void 0:c.notes})}),e.jsx(Ae,{label:"Fail",active:(c==null?void 0:c.status)==="fail",tone:"rose",onClick:()=>n(d.id,{status:"fail",notes:c==null?void 0:c.notes})}),e.jsx(Ae,{label:"N/A",active:(c==null?void 0:c.status)==="not-applicable",tone:"slate",onClick:()=>n(d.id,{status:"not-applicable",notes:c==null?void 0:c.notes})}),e.jsx(Ae,{label:"Skip",active:(c==null?void 0:c.status)==="skip",tone:"slate",onClick:()=>n(d.id,{status:"skip",notes:c==null?void 0:c.notes})})]}),c&&e.jsx("textarea",{placeholder:"Notes (optional)",value:c.notes??"",onChange:p=>n(d.id,{status:c.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},d.id)})})]})}const an={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 Ae({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?an[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Re="savedFlows";async function nn(){const t=await chrome.storage.local.get(Re);return Array.isArray(t[Re])?t[Re]:[]}async function pt(t){await chrome.storage.local.set({[Re]:t})}function rn(){const[t,s]=g.useState([]),[a,n]=g.useState(!1),[r,i]=g.useState(null);g.useEffect(()=>{nn().then(s)},[]);async function o(){const c=await Z();if(!c){i("No audit-target tab found.");return}try{await se(c,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const c=await Z();if(c)try{const p=await Ie(c,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const u=typeof prompt=="function"?prompt(`Captured ${p.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!u.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:u.trim(),steps:p.steps,savedAt:new Date().toISOString()},h=[f,...t];s(h),await pt(h),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function d(c){const p=await Z();if(p){i(`Replaying "${c.name}"…`);try{const u=await Ie(p,{type:"FLOW_PLAY_REQUEST",steps:c.steps});i(`Replayed ${u.played} step${u.played===1?"":"s"}`+(u.errored?`, ${u.errored} errored (selector not found)`:"")+".")}catch(u){i(`Replay failed: ${u instanceof Error?u.message:String(u)}`)}}}async function m(c){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(u=>u.id!==c);s(p),await pt(p)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(c=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:c.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[c.steps.length," step",c.steps.length===1?"":"s"," ·"," ",new Date(c.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>d(c),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>m(c.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},c.id))})]})}function on(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(d=>d.split("-").map(ln).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function ln(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function cn(){const t=b(l=>l.baselineList),s=b(l=>l.tier),a=Nt[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=g.useState(!1);if(g.useEffect(()=>{$e().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 $e()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const d=on(l.componentId),m=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:d.primary}),d.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:d.secondary,children:d.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),m&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(de,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),m.criticalCount>0&&e.jsxs(de,{tone:"rose",title:`${m.criticalCount} critical violations`,children:[m.criticalCount," critical"]}),m.seriousCount>0&&e.jsxs(de,{tone:"orange",title:`${m.seriousCount} serious violations`,children:[m.seriousCount," serious"]}),m.focusResetCount>0&&e.jsxs(de,{tone:"rose",title:`${m.focusResetCount} focus resets observed`,children:[m.focusResetCount," focus reset",m.focusResetCount===1?"":"s"]}),m.targetSizeFailCount>0&&e.jsxs(de,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[m.targetSizeFailCount," small targets"]}),m.hoverContrastFail&&e.jsx(de,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),m.announcementCount>0&&e.jsxs(de,{tone:"indigo",title:"aria-live announcements observed",children:[m.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 dn={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function de({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${dn[t]}`,children:a})}const un={low:"bg-emerald-50 border-emerald-200",moderate:"bg-yellow-50 border-yellow-200",high:"bg-orange-50 border-orange-200",critical:"bg-rose-50 border-rose-300"},pn={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},mn={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 hn({onBack:t}){const s=b(p=>p.siteCrawlStatus),a=b(p=>p.siteCrawlProgress),n=b(p=>p.siteCrawlReport),r=b(p=>p.siteCrawlError),[i,o]=g.useState(""),[l,d]=g.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(p=>{var f;const u=(f=p[0])==null?void 0:f.url;u&&/^https?:\/\//.test(u)&&i===""&&o(u)});function m(){i&&(b.getState().setSiteCrawlStatus("running"),b.getState().setSiteCrawlReport(null),b.getState().setSiteCrawlError(null),oe({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function c(){Y({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:p=>o(p.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:p=>d(Math.min(200,Math.max(1,parseInt(p.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:m,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:c,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(xn,{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 xn({report:t}){function s(){je(async()=>{const{renderSiteReportHtml:a}=await import("./site-report-renderer-CXRggal1.js");return{renderSiteReportHtml:a}},__vite__mapDeps([3,0,1,2])).then(({renderSiteReportHtml:a})=>{const n=a(t),r=new Blob([n],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${un[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${pn[t.siteRisk]}`,children:Xt[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=Zt(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 ${mn[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 Ve="onboardingDismissed",Be=[{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 fn(){const[t,s]=g.useState(!1),[a,n]=g.useState(0);g.useEffect(()=>{chrome.storage.local.get(Ve).then(l=>{l[Ve]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Ve]:!0}),s(!1),n(0)}const i=a===Be.length-1,o=Be[a];return e.jsxs(ke,{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," / ",Be.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 gn(){const t=b(n=>n.status),s=b(n=>n.errorMessage),a=b(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function bn(){const t=b(d=>d.aiFailure),s=b(d=>d.clearAiFailure),[a,n]=g.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(d=>!d),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((d,m)=>e.jsx("li",{children:d},m))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function vn(){const[t,s]=g.useState(!1);return g.useEffect(()=>ee("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),b.getState().setStatus("idle"))}),[]),e.jsxs(ke,{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 yn(){var i;const[t,s]=g.useState(null);if(g.useEffect(()=>{es().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await Xe(),b.getState().startNewScan(),t.mode==="storybook-all"?oe({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&oe({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await Xe(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const We="storybook:hintDismissed";function wn(){const[t,s]=g.useState(!1),[a,n]=g.useState();g.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(We))[We])return;const o=await Z();if(o)try{const m=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const c=window;return{detected:typeof c.__STORYBOOK_PREVIEW__=="object",version:(p=c.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(c=>{var p;return(p=c.result)==null?void 0:p.detected});m&&(n((l=m.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[We]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function jn(){var i;const t=b(o=>o.results),s=b(o=>o.baselineList),a=b(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 ${Nn(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 Nn(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 kn(){const t=b(l=>l.results),s=b(l=>l.componentId),[a,n]=g.useState([]);if(g.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(d=>{if(l)return;const c=((d==null?void 0:d.igtRuns)??{})[s]??{};n(Object.values(c))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=ts(r,a.length>0?{runs:a,workflows:X}: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 Sn(){const t=b(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 Ee="wcagcheckr";function M(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function we(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 An(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Cn(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 Rn(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function En(t){switch(t){case"A":return"grade-a";case"B":return"grade-b";case"C":return"grade-c";case"D":return"grade-d";case"F":return"grade-f"}}function In(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${M(t.receipt.tsaName)}) — anchored ${M(we(t.receipt.anchoredAt))}</td></tr>
29
+ <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${M(t.receipt.serverKeyFingerprint)}</code></td></tr>
30
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${M(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${M(Ee)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
31
31
  <article class="entry">
32
32
  <header class="entry-header">
33
- <span class="grade-badge ${Rn(t.grade)}">${F(t.grade)}</span>
33
+ <span class="grade-badge ${En(t.grade)}">${M(t.grade)}</span>
34
34
  <div class="entry-headline">
35
- <div class="entry-time">${F(we(t.capturedAt))}</div>
35
+ <div class="entry-time">${M(we(t.capturedAt))}</div>
36
36
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
37
37
  </div>
38
38
  </header>
39
39
  <table class="entry-fields">
40
- <tr><th>Audit identity hash</th><td><code class="hash">${F(t.hash)}</code></td></tr>
41
- <tr><th>Page URL</th><td><code>${F(t.pageUrl)}</code></td></tr>
42
- <tr><th>Scope</th><td><code>${F(t.scope)}</code></td></tr>
43
- <tr><th>axe-core version</th><td>${F(t.axeVersion)}</td></tr>
40
+ <tr><th>Audit identity hash</th><td><code class="hash">${M(t.hash)}</code></td></tr>
41
+ <tr><th>Page URL</th><td><code>${M(t.pageUrl)}</code></td></tr>
42
+ <tr><th>Scope</th><td><code>${M(t.scope)}</code></td></tr>
43
+ <tr><th>axe-core version</th><td>${M(t.axeVersion)}</td></tr>
44
44
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
45
45
  ${n}
46
46
  </table>
47
47
  </article>`}function Tn(t){return`
48
48
  <section class="component-section">
49
49
  <h2>
50
- <span class="component-id">${F(t.componentId)}</span>
50
+ <span class="component-id">${M(t.componentId)}</span>
51
51
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
52
52
  </h2>
53
- <p class="component-url"><strong>Page audited:</strong> <code>${F(t.pageUrl)}</code></p>
53
+ <p class="component-url"><strong>Page audited:</strong> <code>${M(t.pageUrl)}</code></p>
54
54
  ${t.entries.map(In).join("")}
55
- </section>`}function $n(t){const{entries:s,extensionVersion:a}=t,n=En(s),r=Cn(s),i=(t.axeVersions??An(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,m=we(new Date().toISOString());return`<!doctype html>
55
+ </section>`}function $n(t){const{entries:s,extensionVersion:a}=t,n=Rn(s),r=Cn(s),i=(t.axeVersions??An(s)).join(", "),o=s.length,l=s.filter(c=>c.receipt).length,d=o-l,m=we(new Date().toISOString());return`<!doctype html>
56
56
  <html lang="en">
57
57
  <head>
58
58
  <meta charset="utf-8" />
59
- <title>Pre-litigation accessibility audit report — ${F(t.matterReference??m)}</title>
59
+ <title>Pre-litigation accessibility audit report — ${M(t.matterReference??m)}</title>
60
60
  <style>
61
61
  *, *::before, *::after { box-sizing: border-box; }
62
62
  :root {
@@ -197,17 +197,17 @@ document.getElementById('copy').addEventListener('click', () => {
197
197
  <p class="eyebrow">Accessibility audit — pre-litigation report</p>
198
198
  <h1>Audit history &amp; chain-of-custody</h1>
199
199
  <dl class="cover-meta">
200
- ${t.matterReference?`<dt>Matter reference</dt><dd>${F(t.matterReference)}</dd>`:""}
201
- ${t.preparedBy?`<dt>Prepared by</dt><dd>${F(t.preparedBy)}</dd>`:""}
202
- ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${F(t.jurisdiction)}</dd>`:""}
203
- <dt>Report generated</dt><dd>${F(m)}</dd>
204
- <dt>Audit period</dt><dd>${r?`${F(we(r.earliest))} — ${F(we(r.latest))}`:"No audits recorded"}</dd>
200
+ ${t.matterReference?`<dt>Matter reference</dt><dd>${M(t.matterReference)}</dd>`:""}
201
+ ${t.preparedBy?`<dt>Prepared by</dt><dd>${M(t.preparedBy)}</dd>`:""}
202
+ ${t.jurisdiction?`<dt>Jurisdiction</dt><dd>${M(t.jurisdiction)}</dd>`:""}
203
+ <dt>Report generated</dt><dd>${M(m)}</dd>
204
+ <dt>Audit period</dt><dd>${r?`${M(we(r.earliest))} — ${M(we(r.latest))}`:"No audits recorded"}</dd>
205
205
  </dl>
206
206
  </section>
207
207
 
208
208
  <aside class="attestation">
209
209
  <h3>Attestation</h3>
210
- <p>The audit records summarized below were captured by the <strong>${F(Re)}</strong> Chrome extension, version <strong>${F(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${F(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
210
+ <p>The audit records summarized below were captured by the <strong>${M(Ee)}</strong> Chrome extension, version <strong>${M(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${M(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
211
211
  <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
212
212
  <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
213
213
  </aside>
@@ -217,8 +217,8 @@ document.getElementById('copy').addEventListener('click', () => {
217
217
  <tr><th>RFC 3161-anchored audits</th><td>${l}</td></tr>
218
218
  <tr><th>Local-only audits</th><td>${d}</td></tr>
219
219
  <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
220
- <tr><th>axe-core version(s) observed</th><td>${F(i||"n/a")}</td></tr>
221
- <tr><th>Tool</th><td>${F(Re)} ${F(a)}</td></tr>
220
+ <tr><th>axe-core version(s) observed</th><td>${M(i||"n/a")}</td></tr>
221
+ <tr><th>Tool</th><td>${M(Ee)} ${M(a)}</td></tr>
222
222
  </table>
223
223
 
224
224
  ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Tn).join("")}
@@ -245,12 +245,12 @@ document.getElementById('copy').addEventListener('click', () => {
245
245
  </section>
246
246
 
247
247
  <footer>
248
- <span>Generated ${F(m)} by ${F(Re)} ${F(a)}</span>
248
+ <span>Generated ${M(m)} by ${M(Ee)} ${M(a)}</span>
249
249
  <span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
250
250
  </footer>
251
251
  </body>
252
- </html>`}async function _n(t){const s=$n(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Ln(){const[t,s]=g.useState(null),[a,n]=g.useState(null),[r,i]=g.useState(0),[o,l]=g.useState(!1),[d,m]=g.useState(""),[c,p]=g.useState(""),[u,f]=g.useState(""),[h,w]=g.useState(!1);if(g.useEffect(()=>{let y=!1;return s(null),n(null),ss().then(k=>{y||s(k)}).catch(k=>{y||n(k instanceof Error?k.message:String(k))}),()=>{y=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const R=t.length,T=t.filter(y=>y.receipt).length;async function x(){if(!(!t||t.length===0)){w(!0);try{await _n({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:u.trim()||void 0}),l(!1)}finally{w(!1)}}}async function v(){if(!t||t.length===0)return;const y={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},k=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),I=URL.createObjectURL(k),C=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,$=document.createElement("a");$.href=I,$.download=C,$.click(),setTimeout(()=>URL.revokeObjectURL(I),1e3)}return R===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:[R," ",R===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&&R>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(y=>!y),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void v(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(y=>y+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:y=>m(y.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:y=>p(y.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:u,onChange:y=>f(y.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:h||R===0,onClick:x,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:h?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(y=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${y.grade==="A"?"bg-emerald-100 text-emerald-700":y.grade==="B"?"bg-lime-100 text-lime-700":y.grade==="C"?"bg-yellow-100 text-yellow-700":y.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:y.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:y.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${y.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:y.receipt?`Anchored to ${y.receipt.tsaName} at ${y.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:y.receipt?`RFC 3161 (${y.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:y.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:y.capturedAt}),(y.totals.critical>0||y.totals.serious>0)&&e.jsxs("span",{children:[y.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[y.totals.critical," crit"]}),y.totals.critical>0&&y.totals.serious>0&&" · ",y.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[y.totals.serious," sev"]})]}),e.jsxs("span",{children:[y.statesAudited," ",y.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:y.hash,children:[y.hash.slice(0,12),"…"]})]})]},`${y.componentId}::${y.capturedAt}`))})]})}function Un(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const d of l){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:o,selector:c.target.selector})}const m=d.axeRulesEvaluated;if(m){for(const c of m.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of m.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of m.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Dn(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const m of a){const c=m.steps.filter(p=>p.wcag===t);if(c.length!==0){r+=c.length;for(const[p,u]of s){const f=u[m.id];if(!f){i+=c.length;continue}for(const h of c){const w=f.steps[h.id];if(!w){i++;continue}w.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${m.id}.${h.id}`,description:h.question,pageUrl:p,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function On(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 Fn(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 Mn(t,s){var p;const a=[];for(const u of s.auditsByUrl.values())a.push(...u);const n=[];for(const u of s.igtRunsByUrl.values())n.push(...Object.values(u));const r=vt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions}),i=as(t.targetVersion,t.targetLevel),o=[];for(const u of i){const f=Un(u.id,s.auditsByUrl,s.acknowledgedMatchKeys),h=Dn(u.id,s.igtRunsByUrl,s.workflows),w=f.rulesFiring.size===0&&h.stepsCovering===0,R={axeRulesFiringForCriterion:f.rulesFiring.size,axeFailures:f.failures,igtStepsCoveringCriterion:h.stepsCovering,igtFailures:h.failures,unmapped:w},T=(p=t.overrides)==null?void 0:p[u.id];let x,v,y=!1;if(T)x=T.verdict,v=T.rationale,y=!0;else{const k=r.get(u.id);k?x=k.state:x=On(R,h.unanswered,f.hasIncomplete,h.allNotApplicable),v=Fn(u,x,R)}o.push({criterion:u,understandingUrl:ns(u,t.targetVersion),verdict:x,signals:R,overridden:y,rationale:v})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const u of o)u.verdict==="pass"?l.pass++:u.verdict==="fail"?l.fail++:u.verdict==="inconclusive"?l.inconclusive++:u.verdict==="not-applicable"?l.notApplicable++:u.verdict==="not-evaluated"&&l.notEvaluated++;function d(u){const f={A:1,AA:2,AAA:3},h=f[u];return o.every(w=>f[w.criterion.level]>h?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let m=null;d("AAA")?m="AAA":d("AA")?m="AA":d("A")&&(m="A");const c=m===t.targetLevel||m==="AAA"&&t.targetLevel==="AA"||m==="AAA"&&t.targetLevel==="A"||m==="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:m,meetsTarget:c}}}const Pn={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},mt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function E(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function He(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 Gn(t,s){const{inputs:a,rows:n,summary:r,generatedAt:i}=t,o=r.meetsTarget?`MEETS WCAG ${a.targetVersion} Level ${a.targetLevel}`:`DOES NOT MEET WCAG ${a.targetVersion} Level ${a.targetLevel}`,l=new Map;for(const m of n){const c=m.criterion.id.split(".").slice(0,2).join("."),p=l.get(c)??[];p.push(m),l.set(c,p)}const d=Array.from(l.entries()).sort(([m],[c])=>m.localeCompare(c,void 0,{numeric:!0})).map(([m,c])=>`
253
- <h3 class="guideline-h">Guideline ${E(m)}</h3>
252
+ </html>`}async function _n(t){const s=$n(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function Ln(){const[t,s]=g.useState(null),[a,n]=g.useState(null),[r,i]=g.useState(0),[o,l]=g.useState(!1),[d,m]=g.useState(""),[c,p]=g.useState(""),[u,f]=g.useState(""),[h,w]=g.useState(!1);if(g.useEffect(()=>{let y=!1;return s(null),n(null),ss().then(k=>{y||s(k)}).catch(k=>{y||n(k instanceof Error?k.message:String(k))}),()=>{y=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const R=t.length,I=t.filter(y=>y.receipt).length;async function x(){if(!(!t||t.length===0)){w(!0);try{await _n({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:d.trim()||void 0,preparedBy:c.trim()||void 0,jurisdiction:u.trim()||void 0}),l(!1)}finally{w(!1)}}}async function v(){if(!t||t.length===0)return;const y={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},k=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),E=URL.createObjectURL(k),A=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,T=document.createElement("a");T.href=E,T.download=A,T.click(),setTimeout(()=>URL.revokeObjectURL(E),1e3)}return R===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:[R," ",R===1?"entry":"entries",I>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[I," RFC 3161-anchored"]})]}),I===0&&R>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(y=>!y),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void v(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(y=>y+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:d,onChange:y=>m(y.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:c,onChange:y=>p(y.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:u,onChange:y=>f(y.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:h||R===0,onClick:x,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:h?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(y=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${y.grade==="A"?"bg-emerald-100 text-emerald-700":y.grade==="B"?"bg-lime-100 text-lime-700":y.grade==="C"?"bg-yellow-100 text-yellow-700":y.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:y.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:y.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${y.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:y.receipt?`Anchored to ${y.receipt.tsaName} at ${y.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:y.receipt?`RFC 3161 (${y.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:y.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:y.capturedAt}),(y.totals.critical>0||y.totals.serious>0)&&e.jsxs("span",{children:[y.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[y.totals.critical," crit"]}),y.totals.critical>0&&y.totals.serious>0&&" · ",y.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[y.totals.serious," sev"]})]}),e.jsxs("span",{children:[y.statesAudited," ",y.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:y.hash,children:[y.hash.slice(0,12),"…"]})]})]},`${y.componentId}::${y.capturedAt}`))})]})}function Un(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const d of l){for(const c of d.violations)if(c.wcagCriterion===t){if(a!=null&&a.has(c.matchKey)){n.add(c.ruleId);continue}if(c.needsReview){n.add(c.ruleId),i=!0;continue}n.add(c.ruleId),r.push({source:"axe",ruleOrStepId:c.ruleId,description:c.description||c.ruleId,pageUrl:o,selector:c.target.selector})}const m=d.axeRulesEvaluated;if(m){for(const c of m.passed)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of m.inapplicable)c.wcagCriterion===t&&n.add(c.ruleId);for(const c of m.incomplete)c.wcagCriterion===t&&(n.add(c.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function Dn(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const m of a){const c=m.steps.filter(p=>p.wcag===t);if(c.length!==0){r+=c.length;for(const[p,u]of s){const f=u[m.id];if(!f){i+=c.length;continue}for(const h of c){const w=f.steps[h.id];if(!w){i++;continue}w.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${m.id}.${h.id}`,description:h.question,pageUrl:p,notes:w.notes})):w.status==="skip"?i++:w.status==="not-applicable"?(o++,l++):o++}}}}const d=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:d}}function On(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 Fn(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 Mn(t,s){var p;const a=[];for(const u of s.auditsByUrl.values())a.push(...u);const n=[];for(const u of s.igtRunsByUrl.values())n.push(...Object.values(u));const r=vt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions}),i=as(t.targetVersion,t.targetLevel),o=[];for(const u of i){const f=Un(u.id,s.auditsByUrl,s.acknowledgedMatchKeys),h=Dn(u.id,s.igtRunsByUrl,s.workflows),w=f.rulesFiring.size===0&&h.stepsCovering===0,R={axeRulesFiringForCriterion:f.rulesFiring.size,axeFailures:f.failures,igtStepsCoveringCriterion:h.stepsCovering,igtFailures:h.failures,unmapped:w},I=(p=t.overrides)==null?void 0:p[u.id];let x,v,y=!1;if(I)x=I.verdict,v=I.rationale,y=!0;else{const k=r.get(u.id);k?x=k.state:x=On(R,h.unanswered,f.hasIncomplete,h.allNotApplicable),v=Fn(u,x,R)}o.push({criterion:u,understandingUrl:ns(u,t.targetVersion),verdict:x,signals:R,overridden:y,rationale:v})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const u of o)u.verdict==="pass"?l.pass++:u.verdict==="fail"?l.fail++:u.verdict==="inconclusive"?l.inconclusive++:u.verdict==="not-applicable"?l.notApplicable++:u.verdict==="not-evaluated"&&l.notEvaluated++;function d(u){const f={A:1,AA:2,AAA:3},h=f[u];return o.every(w=>f[w.criterion.level]>h?!0:w.verdict==="pass"||w.verdict==="not-applicable")}let m=null;d("AAA")?m="AAA":d("AA")?m="AA":d("A")&&(m="A");const c=m===t.targetLevel||m==="AAA"&&t.targetLevel==="AA"||m==="AAA"&&t.targetLevel==="A"||m==="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:m,meetsTarget:c}}}const Pn={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},mt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function C(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function He(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 Gn(t,s){const{inputs:a,rows:n,summary:r,generatedAt:i}=t,o=r.meetsTarget?`MEETS WCAG ${a.targetVersion} Level ${a.targetLevel}`:`DOES NOT MEET WCAG ${a.targetVersion} Level ${a.targetLevel}`,l=new Map;for(const m of n){const c=m.criterion.id.split(".").slice(0,2).join("."),p=l.get(c)??[];p.push(m),l.set(c,p)}const d=Array.from(l.entries()).sort(([m],[c])=>m.localeCompare(c,void 0,{numeric:!0})).map(([m,c])=>`
253
+ <h3 class="guideline-h">Guideline ${C(m)}</h3>
254
254
  <table class="criteria-table">
255
255
  <thead>
256
256
  <tr>
@@ -260,11 +260,11 @@ document.getElementById('copy').addEventListener('click', () => {
260
260
  <tbody>
261
261
  ${c.map(p=>`
262
262
  <tr class="${mt[p.verdict]}">
263
- <td><a href="${E(p.understandingUrl)}" target="_blank" rel="noopener">${E(p.criterion.id)}</a></td>
264
- <td>${E(p.criterion.title)}</td>
265
- <td>${E(p.criterion.level)}</td>
263
+ <td><a href="${C(p.understandingUrl)}" target="_blank" rel="noopener">${C(p.criterion.id)}</a></td>
264
+ <td>${C(p.criterion.title)}</td>
265
+ <td>${C(p.criterion.level)}</td>
266
266
  <td><span class="verdict-badge ${mt[p.verdict]}">${Pn[p.verdict]}</span>${p.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
267
- <td class="rationale">${E(p.rationale)}</td>
267
+ <td class="rationale">${C(p.rationale)}</td>
268
268
  </tr>
269
269
  ${p.signals.axeFailures.length>0||p.signals.igtFailures.length>0?`
270
270
  <tr class="evidence-row">
@@ -275,11 +275,11 @@ document.getElementById('copy').addEventListener('click', () => {
275
275
  <ul>
276
276
  ${[...p.signals.axeFailures,...p.signals.igtFailures].slice(0,20).map(u=>`
277
277
  <li>
278
- <code>${E(u.ruleOrStepId)}</code>
279
- ${u.pageUrl?` on <a href="${E(u.pageUrl)}" target="_blank" rel="noopener"><code>${E(u.pageUrl)}</code></a>`:""}
280
- — ${E(u.description)}
281
- ${u.selector?`<br><span class="ev-selector"><code>${E(u.selector)}</code></span>`:""}
282
- ${u.notes?`<br><em>${E(u.notes)}</em>`:""}
278
+ <code>${C(u.ruleOrStepId)}</code>
279
+ ${u.pageUrl?` on <a href="${C(u.pageUrl)}" target="_blank" rel="noopener"><code>${C(u.pageUrl)}</code></a>`:""}
280
+ — ${C(u.description)}
281
+ ${u.selector?`<br><span class="ev-selector"><code>${C(u.selector)}</code></span>`:""}
282
+ ${u.notes?`<br><em>${C(u.notes)}</em>`:""}
283
283
  </li>
284
284
  `).join("")}
285
285
  ${p.signals.axeFailures.length+p.signals.igtFailures.length>20?`<li class="ev-more">…and ${p.signals.axeFailures.length+p.signals.igtFailures.length-20} more.</li>`:""}
@@ -295,7 +295,7 @@ document.getElementById('copy').addEventListener('click', () => {
295
295
  <html lang="en">
296
296
  <head>
297
297
  <meta charset="utf-8" />
298
- <title>WCAG ${E(a.targetVersion)} Level ${E(a.targetLevel)} Conformance Report — ${E(a.siteName)}</title>
298
+ <title>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)} Conformance Report — ${C(a.siteName)}</title>
299
299
  <style>
300
300
  *, *::before, *::after { box-sizing: border-box; }
301
301
  body {
@@ -393,24 +393,24 @@ document.getElementById('copy').addEventListener('click', () => {
393
393
  </head>
394
394
  <body>
395
395
  <section class="cover">
396
- <p class="eyebrow">WCAG ${E(a.targetVersion)} Conformance Evaluation Report</p>
397
- <h1>${E(a.siteName)}</h1>
398
- <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${E(a.siteUrl)}</code></p>
396
+ <p class="eyebrow">WCAG ${C(a.targetVersion)} Conformance Evaluation Report</p>
397
+ <h1>${C(a.siteName)}</h1>
398
+ <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${C(a.siteUrl)}</code></p>
399
399
  <div class="conformance-banner ${r.meetsTarget?"met":"not-met"}">
400
- ${E(o)}
400
+ ${C(o)}
401
401
  </div>
402
402
  <dl class="meta">
403
403
  <dt>Highest level fully satisfied</dt>
404
- <dd>${r.levelAchieved?`WCAG ${E(a.targetVersion)} Level ${E(r.levelAchieved)}`:"None (target level not met)"}</dd>
404
+ <dd>${r.levelAchieved?`WCAG ${C(a.targetVersion)} Level ${C(r.levelAchieved)}`:"None (target level not met)"}</dd>
405
405
  <dt>Target conformance level</dt>
406
- <dd>WCAG ${E(a.targetVersion)} Level ${E(a.targetLevel)}</dd>
406
+ <dd>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)}</dd>
407
407
  <dt>Report generated</dt>
408
- <dd>${E(He(i))}</dd>
408
+ <dd>${C(He(i))}</dd>
409
409
  <dt>Evaluator</dt>
410
410
  <dd>
411
- ${E(a.evaluator.name)}
412
- ${a.evaluator.organization?`, ${E(a.evaluator.organization)}`:""}
413
- ${a.evaluator.qualifications?`<br><span style="color: #64748b">${E(a.evaluator.qualifications)}</span>`:""}
411
+ ${C(a.evaluator.name)}
412
+ ${a.evaluator.organization?`, ${C(a.evaluator.organization)}`:""}
413
+ ${a.evaluator.qualifications?`<br><span style="color: #64748b">${C(a.evaluator.qualifications)}</span>`:""}
414
414
  </dd>
415
415
  </dl>
416
416
  </section>
@@ -426,13 +426,13 @@ document.getElementById('copy').addEventListener('click', () => {
426
426
 
427
427
  <h2>1 — Evaluation scope</h2>
428
428
  <dl class="meta">
429
- <dt>Website / application</dt><dd><strong>${E(a.siteName)}</strong> — <code>${E(a.siteUrl)}</code></dd>
430
- <dt>Conformance target</dt><dd>WCAG ${E(a.targetVersion)} Level ${E(a.targetLevel)}</dd>
429
+ <dt>Website / application</dt><dd><strong>${C(a.siteName)}</strong> — <code>${C(a.siteUrl)}</code></dd>
430
+ <dt>Conformance target</dt><dd>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)}</dd>
431
431
  <dt>Accessibility-support baseline</dt>
432
- <dd>${E(a.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
432
+ <dd>${C(a.accessibilitySupportBaseline)||"<em>(not specified)</em>"}</dd>
433
433
  ${a.additionalStandards&&a.additionalStandards.length>0?`
434
434
  <dt>Additional standards evaluated against</dt>
435
- <dd>${a.additionalStandards.map(E).join(", ")}</dd>
435
+ <dd>${a.additionalStandards.map(C).join(", ")}</dd>
436
436
  `:""}
437
437
  </dl>
438
438
 
@@ -443,9 +443,9 @@ document.getElementById('copy').addEventListener('click', () => {
443
443
  <tbody>
444
444
  ${a.pageSample.map(m=>`
445
445
  <tr>
446
- <td><a href="${E(m.url)}" target="_blank" rel="noopener"><code>${E(m.url)}</code></a></td>
447
- <td>${E(m.pageType)}</td>
448
- <td>${E(m.selectionType)}</td>
446
+ <td><a href="${C(m.url)}" target="_blank" rel="noopener"><code>${C(m.url)}</code></a></td>
447
+ <td>${C(m.pageType)}</td>
448
+ <td>${C(m.selectionType)}</td>
449
449
  <td>${m.hasAuditData?"✓":'<em style="color:#94a3b8">no audit data</em>'}</td>
450
450
  </tr>
451
451
  `).join("")}
@@ -470,7 +470,7 @@ document.getElementById('copy').addEventListener('click', () => {
470
470
 
471
471
  <section class="attestation">
472
472
  <h3>Conformance claim</h3>
473
- <p>${r.meetsTarget?`Based on the evidence collected, <strong>${E(a.siteName)}</strong> meets the success criteria required for <strong>WCAG ${E(a.targetVersion)} Level ${E(a.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${E(a.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${E(a.targetVersion)} Level ${E(a.targetLevel)} conformance. ${r.fail>0?`${r.fail} criterion failure${r.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
473
+ <p>${r.meetsTarget?`Based on the evidence collected, <strong>${C(a.siteName)}</strong> meets the success criteria required for <strong>WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${C(a.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${C(a.targetVersion)} Level ${C(a.targetLevel)} conformance. ${r.fail>0?`${r.fail} criterion failure${r.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
474
474
  <p style="font-size: 9.5pt; color: #475569;">This conformance claim is the responsibility of the named evaluator. The wcagcheckr tooling assembled the per-criterion evidence; the evaluator's signature attests that the methodology was followed and the verdicts reflect the site under evaluation.</p>
475
475
  </section>
476
476
 
@@ -479,11 +479,11 @@ document.getElementById('copy').addEventListener('click', () => {
479
479
  <h3>Forensic anchor — report integrity proof</h3>
480
480
  <p style="font-size: 10pt;">The content of this report was hashed and the hash was anchored to a public RFC 3161 Time Stamping Authority, then counter-signed by the wcagcheckr server's ed25519 key. Any alteration to the conformance-bearing content above invalidates the hash; the receipt below is verifiable offline by anyone with the wcagcheckr-ci CLI.</p>
481
481
  <table class="anchor-table">
482
- <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${E(s.reportHash)}</code></td></tr>
483
- <tr><th>Anchored at</th><td>${E(He(s.receipt.anchoredAt))}</td></tr>
484
- <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${E(s.receipt.tsaName)}</td></tr>
485
- <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${E(s.receipt.serverKeyFingerprint)}</code></td></tr>
486
- ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${E(s.receipt.prevAuditHash)}</code></td></tr>`:""}
482
+ <tr><th>Report content hash (SHA-256)</th><td><code class="hash">${C(s.reportHash)}</code></td></tr>
483
+ <tr><th>Anchored at</th><td>${C(He(s.receipt.anchoredAt))}</td></tr>
484
+ <tr><th>Trusted Time Stamping Authority</th><td>RFC 3161 — ${C(s.receipt.tsaName)}</td></tr>
485
+ <tr><th>Server signature algorithm</th><td>ed25519, key fingerprint <code>${C(s.receipt.serverKeyFingerprint)}</code></td></tr>
486
+ ${s.receipt.prevAuditHash?`<tr><th>Previous anchor in chain</th><td><code class="hash">${C(s.receipt.prevAuditHash)}</code></td></tr>`:""}
487
487
  </table>
488
488
  <p style="font-size: 9pt; color: #64748b; margin-top: 8pt;">
489
489
  To verify: download the verification bundle JSON from the wcagcheckr Compliance tab,
@@ -494,7 +494,7 @@ document.getElementById('copy').addEventListener('click', () => {
494
494
  <!-- Machine-readable receipt — verifier can extract from the printed PDF
495
495
  if the JSON bundle was lost. Inert in browsers; serves only as
496
496
  structured-data preservation. -->
497
- <script type="application/json" id="wcagcheckr-anchor-receipt">${E(JSON.stringify(s))}<\/script>
497
+ <script type="application/json" id="wcagcheckr-anchor-receipt">${C(JSON.stringify(s))}<\/script>
498
498
  </section>
499
499
  `:`
500
500
  <section class="anchor-block anchor-missing">
@@ -505,15 +505,15 @@ document.getElementById('copy').addEventListener('click', () => {
505
505
 
506
506
  <section class="declaration">
507
507
  <h3>Evaluator declaration</h3>
508
- <p>I, <strong>${E(a.evaluator.name)}</strong>${a.evaluator.organization?` of <strong>${E(a.evaluator.organization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${a.evaluator.qualifications?`My qualifications: ${E(a.evaluator.qualifications)}.`:""} ${a.evaluator.contact?`I may be contacted at <code>${E(a.evaluator.contact)}</code>.`:""}</p>
508
+ <p>I, <strong>${C(a.evaluator.name)}</strong>${a.evaluator.organization?` of <strong>${C(a.evaluator.organization)}</strong>`:""}, performed the accessibility evaluation described in this report. The methodology followed the W3C WCAG-EM 1.0 specification, applied to the page sample and conformance target stated above. ${a.evaluator.qualifications?`My qualifications: ${C(a.evaluator.qualifications)}.`:""} ${a.evaluator.contact?`I may be contacted at <code>${C(a.evaluator.contact)}</code>.`:""}</p>
509
509
  <p style="margin-top: 14pt;">Signature: <span style="display:inline-block; min-width:200pt; border-bottom:1px solid #94a3b8;">&nbsp;</span> &nbsp; Date: <span style="display:inline-block; min-width:90pt; border-bottom:1px solid #94a3b8;">&nbsp;</span></p>
510
510
  </section>
511
511
 
512
512
  <footer class="report-footer">
513
- <span>Generated ${E(He(i))} by wcagcheckr</span>
513
+ <span>Generated ${C(He(i))} by wcagcheckr</span>
514
514
  <span>${r.totalCriteria} criteria · ${r.pass} pass · ${r.fail} fail · ${r.inconclusive} inconclusive</span>
515
515
  </footer>
516
516
  </body>
517
- </html>`}async function Vn(t,s){const a=Gn(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const ze=gt("wcag-em-anchor"),Bn="https://api.wcagcheckr.com",Wn="wcagcheckr",Hn=15e3;function Ft(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 zn(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 Kn(t){return zn(rs(Ft(t)))}function qn(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 Qn(t,s){const a=await Kn(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Bn}/v1/products/${Wn}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Hn)});if(!i.ok)return ze.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return qn(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(ze.warn("anchor returned malformed receipt",o),null)}catch(i){return ze.warn("anchor request failed",i),null}}function Jn(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ft(t)}}const ht="igtRuns",Yn={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"},Xn={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Zn(){const t=b(N=>N.results),s=b(N=>N.acknowledgedKeys),[a,n]=g.useState(""),[r,i]=g.useState(""),o=os,l=is,[d,m]=g.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,p]=g.useState(""),[u,f]=g.useState(""),[h,w]=g.useState(""),[R,T]=g.useState(""),[x,v]=g.useState(""),[y,k]=g.useState(""),[I,C]=g.useState({}),[$,j]=g.useState(!1),[S,B]=g.useState([]),[A,M]=g.useState(null),[D,X]=g.useState(!1),[K,te]=g.useState(null);g.useEffect(()=>{let N=!1;return chrome.storage.local.get(ht).then(U=>{if(N)return;const L=U[ht]??{};C(L),j(!0)}).catch(()=>{N||j(!0)}),()=>{N=!0}},[]),g.useEffect(()=>{var N;if(!a&&((N=t[0])!=null&&N.pageUrl))try{const U=new URL(t[0].pageUrl);n(U.hostname),i(U.origin)}catch{}},[t,a]),g.useEffect(()=>{const N=new Set;for(const L of t)N.add(L.pageUrl??L.scope);if(N.size===0){B([]);return}let U=!1;return Promise.all(Array.from(N).map(L=>Ce(L))).then(L=>{U||B(L.flat())}).catch(()=>{}),()=>{U=!0}},[t]);const q=g.useMemo(()=>{const N=new Map,U=new Map;for(const H of t){const V=H.pageUrl??H.scope,O=N.get(V)??[];O.push(H),N.set(V,O)}const L=new Map;for(const H of t){const V=H.pageUrl??H.scope;L.set(H.componentId,V)}for(const[H,V]of Object.entries(I)){const O=L.get(H);if(!O)continue;const z=U.get(O)??{};Object.assign(z,V),U.set(O,z)}return{auditsByUrl:N,igtRunsByUrl:U,workflows:Y,acknowledgedMatchKeys:s,incompleteResolutions:S}},[t,I,s,S]),ae=g.useMemo(()=>{const N=[],U=new Set;for(const L of q.auditsByUrl.keys())U.has(L)||(U.add(L),N.push({url:L,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const L of y.split(`
518
- `).map(H=>H.trim()).filter(Boolean))U.has(L)||(U.add(L),N.push({url:L,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return N},[q,y]),ne=g.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(N=>N.trim()).filter(Boolean),pageSample:ae,evaluator:{name:u||"(evaluator name pending)",organization:h||void 0,qualifications:R||void 0,contact:x||void 0}}),[a,r,o,l,d,c,ae,u,h,R,x]),G=g.useMemo(()=>$?Mn(ne,q):null,[ne,q,$]);async function Se(){G&&await Vn(G,A)}async function _(){if(G){X(!0),te(null);try{const N=await Qn(G);if(!N){te("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}M(N)}finally{X(!1)}}}function W(){var z,he,P;if(!G||!A)return;const N=((P=(he=(z=chrome.runtime).getManifest)==null?void 0:he.call(z))==null?void 0:P.version)??"0.0.0",U=Jn(G,A,N),L=new Blob([JSON.stringify(U,null,2)],{type:"application/json"}),H=URL.createObjectURL(L),V=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,O=document.createElement("a");O.href=H,O.download=V,O.click(),setTimeout(()=>URL.revokeObjectURL(H),1e3)}return g.useEffect(()=>{M(null),te(null)},[a,r,d,c,u,h,R,x,y]),$?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."})]}),G&&G.summary.totalCriteria>0&&e.jsx(er,{totalCriteria:G.summary.totalCriteria,pass:G.summary.pass,fail:G.summary.fail,inconclusive:G.summary.inconclusive,notEvaluated:G.summary.notEvaluated,notApplicable:G.summary.notApplicable,levelAchieved:G.summary.levelAchieved,meetsTarget:G.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:q.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:N=>n(N.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:N=>i(N.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:N=>m(N.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:N=>p(N.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.",q.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:q.auditsByUrl.size})," URL",q.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:y,onChange:N=>k(N.target.value),rows:3,placeholder:`https://app.example.com/checkout
519
- https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:u,onChange:N=>f(N.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:h,onChange:N=>w(N.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:R,onChange:N=>T(N.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:x,onChange:N=>v(N.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),G&&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 (",G.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:G.rows.map(N=>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:[N.criterion.id," · ",N.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:N.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Yn[N.verdict]}`,children:Xn[N.verdict]})]},N.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"}),A?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:[A.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",A.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.`}),K&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:K}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!G||!a||!u||D,onClick:()=>void _(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:D?"Anchoring…":A?"Re-anchor":"Anchor this report"}),A&&e.jsx("button",{type:"button",onClick:W,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!G||!a||!u,onClick:()=>void Se(),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 er({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:m,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${d} Level ${m}`:`Does not currently meet WCAG ${d} Level ${m}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}function tr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const sr={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."},ar={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."},nr={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},rr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function ir(){const t=b(p=>p.tier),s=b(p=>p.trialDaysRemaining),a=b(p=>p.seatsUsed),n=b(p=>p.seatsTotal),r=b(p=>p.planCode),i=b(p=>p.licenseDaysRemaining),o=b(p=>p.pastDue),[l,d]=g.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,u=p!==null&&p<=7,f=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} days left`;return e.jsxs("aside",{"aria-label":"License status",className:u?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:u?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),f&&e.jsxs("span",{className:u?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",f]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:u?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:u?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:u?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ke,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?rr:nr,u=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,f=t==="team"&&a!==null&&n!==null&&a>n,h=t==="team"&&a!==null&&n!==null&&a===n,w=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:f?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:h?{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:["✓ ",p.label]}),e.jsxs("span",{className:w.subtitle,children:[" · ",u]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),f&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),h&&!f&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const m=t==="trial"?sr:ar,c=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:m.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:m.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:m.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void J({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(Ke,{open:l,onClose:()=>d(!1)})]})}const or=g.lazy(()=>je(()=>import("./App-Bpsz7bQq.js"),__vite__mapDeps([4,5,6,1,2,7,8,0])).then(t=>({default:t.NormalApp})));function hr(){const t=b(a=>a.view),s=b(a=>a.userMode);return g.useEffect(()=>{const a=bs(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=ms();St({forceRefresh:!0}).catch(()=>{}),$e().catch(()=>{}),gs().catch(()=>{}),vs().catch(()=>{}),xs().catch(()=>{}),ls().then(l=>{b.getState().setAcknowledgedKeys(new Set(l.map(d=>d.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:m,results:c}=b.getState();d&&(m(null),Z().then(p=>{var u;p&&se(p,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:p},(u=c[0])==null?void 0:u.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(Sn,{}),e.jsx(Me,{})]}):s==="owner"?e.jsxs(g.Suspense,{fallback:e.jsx("div",{className:"p-4 text-sm text-slate-500",children:"Loading…"}),children:[e.jsx(or,{}),e.jsx(Me,{})]}):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(ir,{}),e.jsx(_s,{}),e.jsx(Us,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ms,{}),e.jsx(Ws,{}),e.jsx(wn,{}),e.jsx(yn,{}),e.jsx(zs,{}),e.jsx(gn,{}),e.jsx(bn,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(ja,{}),t==="delta"&&e.jsx(Ta,{}),t==="activity"&&e.jsx(Ba,{}),t==="guided"&&e.jsx(tn,{}),t==="flows"&&e.jsx(rn,{}),t==="scorecard"&&e.jsx(cn,{}),t==="crawl"&&e.jsx(hn,{}),t==="forensic"&&e.jsx(Ln,{}),t==="compliance"&&e.jsx(Zn,{})]})]}),e.jsx(kn,{}),e.jsx(jn,{}),e.jsx(fn,{}),e.jsx(vn,{}),e.jsx(Me,{})]})}class xr extends ye.Component{constructor(){super(...arguments);Ye(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{hr as A,xr as E,ps as c};
517
+ </html>`}async function Vn(t,s){const a=Gn(t,s),n=new Blob([a],{type:"text/html;charset=utf-8"}),r=URL.createObjectURL(n);await chrome.tabs.create({url:r})}const ze=gt("wcag-em-anchor"),Bn="https://api.wcagcheckr.com",Wn="wcagcheckr",Hn=15e3;function Ft(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 zn(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 Kn(t){return zn(rs(Ft(t)))}function qn(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 Qn(t,s){const a=await Kn(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Bn}/v1/products/${Wn}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Hn)});if(!i.ok)return ze.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return qn(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(ze.warn("anchor returned malformed receipt",o),null)}catch(i){return ze.warn("anchor request failed",i),null}}function Jn(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:Ft(t)}}const ht="igtRuns",Yn={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"},Xn={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Zn(){const t=b(N=>N.results),s=b(N=>N.acknowledgedKeys),[a,n]=g.useState(""),[r,i]=g.useState(""),o=os,l=is,[d,m]=g.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[c,p]=g.useState(""),[u,f]=g.useState(""),[h,w]=g.useState(""),[R,I]=g.useState(""),[x,v]=g.useState(""),[y,k]=g.useState(""),[E,A]=g.useState({}),[T,j]=g.useState(!1),[L,U]=g.useState([]),[S,O]=g.useState(null),[P,K]=g.useState(!1),[q,te]=g.useState(null);g.useEffect(()=>{let N=!1;return chrome.storage.local.get(ht).then(D=>{if(N)return;const _=D[ht]??{};A(_),j(!0)}).catch(()=>{N||j(!0)}),()=>{N=!0}},[]),g.useEffect(()=>{var N;if(!a&&((N=t[0])!=null&&N.pageUrl))try{const D=new URL(t[0].pageUrl);n(D.hostname),i(D.origin)}catch{}},[t,a]),g.useEffect(()=>{const N=new Set;for(const _ of t)N.add(_.pageUrl??_.scope);if(N.size===0){U([]);return}let D=!1;return Promise.all(Array.from(N).map(_=>Ce(_))).then(_=>{D||U(_.flat())}).catch(()=>{}),()=>{D=!0}},[t]);const Q=g.useMemo(()=>{const N=new Map,D=new Map;for(const H of t){const B=H.pageUrl??H.scope,F=N.get(B)??[];F.push(H),N.set(B,F)}const _=new Map;for(const H of t){const B=H.pageUrl??H.scope;_.set(H.componentId,B)}for(const[H,B]of Object.entries(E)){const F=_.get(H);if(!F)continue;const z=D.get(F)??{};Object.assign(z,B),D.set(F,z)}return{auditsByUrl:N,igtRunsByUrl:D,workflows:X,acknowledgedMatchKeys:s,incompleteResolutions:L}},[t,E,s,L]),ae=g.useMemo(()=>{const N=[],D=new Set;for(const _ of Q.auditsByUrl.keys())D.has(_)||(D.add(_),N.push({url:_,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const _ of y.split(`
518
+ `).map(H=>H.trim()).filter(Boolean))D.has(_)||(D.add(_),N.push({url:_,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return N},[Q,y]),ne=g.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:d,additionalStandards:c.split(",").map(N=>N.trim()).filter(Boolean),pageSample:ae,evaluator:{name:u||"(evaluator name pending)",organization:h||void 0,qualifications:R||void 0,contact:x||void 0}}),[a,r,o,l,d,c,ae,u,h,R,x]),V=g.useMemo(()=>T?Mn(ne,Q):null,[ne,Q,T]);async function Se(){V&&await Vn(V,S)}async function $(){if(V){K(!0),te(null);try{const N=await Qn(V);if(!N){te("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}O(N)}finally{K(!1)}}}function W(){var z,he,G;if(!V||!S)return;const N=((G=(he=(z=chrome.runtime).getManifest)==null?void 0:he.call(z))==null?void 0:G.version)??"0.0.0",D=Jn(V,S,N),_=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),H=URL.createObjectURL(_),B=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,F=document.createElement("a");F.href=H,F.download=B,F.click(),setTimeout(()=>URL.revokeObjectURL(H),1e3)}return g.useEffect(()=>{O(null),te(null)},[a,r,d,c,u,h,R,x,y]),T?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),V&&V.summary.totalCriteria>0&&e.jsx(er,{totalCriteria:V.summary.totalCriteria,pass:V.summary.pass,fail:V.summary.fail,inconclusive:V.summary.inconclusive,notEvaluated:V.summary.notEvaluated,notApplicable:V.summary.notApplicable,levelAchieved:V.summary.levelAchieved,meetsTarget:V.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:Q.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:N=>n(N.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:N=>i(N.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:d,onChange:N=>m(N.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:c,onChange:N=>p(N.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.",Q.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:Q.auditsByUrl.size})," URL",Q.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:y,onChange:N=>k(N.target.value),rows:3,placeholder:`https://app.example.com/checkout
519
+ https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:u,onChange:N=>f(N.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:h,onChange:N=>w(N.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:R,onChange:N=>I(N.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:x,onChange:N=>v(N.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),V&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",V.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:V.rows.map(N=>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:[N.criterion.id," · ",N.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:N.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Yn[N.verdict]}`,children:Xn[N.verdict]})]},N.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"}),S?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:[S.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",S.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.`}),q&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:q}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!V||!a||!u||P,onClick:()=>void $(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:P?"Anchoring…":S?"Re-anchor":"Anchor this report"}),S&&e.jsx("button",{type:"button",onClick:W,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!V||!a||!u,onClick:()=>void Se(),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 er({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:d,targetLevel:m,auditedUrlCount:c}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${d} Level ${m}`:`Does not currently meet WCAG ${d} Level ${m}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",c," audited URL",c===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}function tr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const sr={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."},ar={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."},nr={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},rr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function ir(){const t=b(p=>p.tier),s=b(p=>p.trialDaysRemaining),a=b(p=>p.seatsUsed),n=b(p=>p.seatsTotal),r=b(p=>p.planCode),i=b(p=>p.licenseDaysRemaining),o=b(p=>p.pastDue),[l,d]=g.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,u=p!==null&&p<=7,f=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} days left`;return e.jsxs("aside",{"aria-label":"License status",className:u?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:u?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),f&&e.jsxs("span",{className:u?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",f]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:u?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:u?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"OPEN_SETTINGS"}),className:u?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Ke,{open:l,onClose:()=>d(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?rr:nr,u=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,f=t==="team"&&a!==null&&n!==null&&a>n,h=t==="team"&&a!==null&&n!==null&&a===n,w=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:f?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:h?{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:["✓ ",p.label]}),e.jsxs("span",{className:w.subtitle,children:[" · ",u]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),f&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),h&&!f&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void Y({type:"OPEN_SETTINGS"}),className:w.link,children:"Manage license →"})})]})}const m=t==="trial"?sr:ar,c=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:m.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:c})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:m.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:m.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void Y({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Ke,{open:l,onClose:()=>d(!1)})]})}const or=g.lazy(()=>je(()=>import("./App-DO2AIuQt.js"),__vite__mapDeps([4,5,6,1,2,7,8,0])).then(t=>({default:t.NormalApp})));function hr(){const t=b(a=>a.view),s=b(a=>a.userMode);return g.useEffect(()=>{const a=bs(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),i=ms();St({forceRefresh:!0}).catch(()=>{}),$e().catch(()=>{}),gs().catch(()=>{}),vs().catch(()=>{}),xs().catch(()=>{}),ls().then(l=>{b.getState().setAcknowledgedKeys(new Set(l.map(d=>d.matchKey)))}).catch(()=>{});const o=l=>{if(l.key!=="Escape")return;const{pinnedMatchKey:d,setPinned:m,results:c}=b.getState();d&&(m(null),Z().then(p=>{var u;p&&se(p,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:p},(u=c[0])==null?void 0:u.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(Sn,{}),e.jsx(Me,{})]}):s==="owner"?e.jsxs(g.Suspense,{fallback:e.jsx("div",{className:"p-4 text-sm text-slate-500",children:"Loading…"}),children:[e.jsx(or,{}),e.jsx(Me,{})]}):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(ir,{}),e.jsx(_s,{}),e.jsx(Us,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ms,{}),e.jsx(Ws,{}),e.jsx(wn,{}),e.jsx(yn,{}),e.jsx(zs,{}),e.jsx(gn,{}),e.jsx(bn,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(ja,{}),t==="delta"&&e.jsx(Ta,{}),t==="activity"&&e.jsx(Ba,{}),t==="guided"&&e.jsx(tn,{}),t==="flows"&&e.jsx(rn,{}),t==="scorecard"&&e.jsx(cn,{}),t==="crawl"&&e.jsx(hn,{}),t==="forensic"&&e.jsx(Ln,{}),t==="compliance"&&e.jsx(Zn,{})]})]}),e.jsx(kn,{}),e.jsx(jn,{}),e.jsx(fn,{}),e.jsx(vn,{}),e.jsx(Me,{})]})}class xr extends ye.Component{constructor(){super(...arguments);Ye(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{hr as A,xr as E,ps as c};