@wcag-checkr/ci 1.0.0-rc.39 → 1.0.0-rc.40
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.
- package/dist/assets/{ErrorBoundary-CUdCWey5.js → ErrorBoundary-V5BJ5Ixo.js} +3 -3
- package/dist/assets/{devtools-panel-BHPfdUSQ.js → devtools-panel-D9zsnKC7.js} +1 -1
- package/dist/assets/forensic-log-DD-VdXBF.js +129 -0
- package/dist/assets/{service-worker.ts-C1PC6l4D.js → service-worker.ts-paxxSe0U.js} +1 -1
- package/dist/assets/{side-panel-9RLX7_UY.js → side-panel-DZVGGW_8.js} +1 -1
- package/dist/assets/{site-report-renderer-C9fIcwfC.js → site-report-renderer-BJxX-AaN.js} +1 -1
- package/dist/devtools/panel.html +3 -3
- package/dist/manifest.json +2 -2
- package/dist/service-worker-loader.js +1 -1
- package/dist/side-panel/side-panel.html +3 -3
- package/package.json +1 -1
- package/dist/assets/forensic-log-8R3PpGR3.js +0 -129
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-
|
|
2
|
-
var Qt=Object.defineProperty;var Jt=(t,s,n)=>s in t?Qt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Qe=(t,s,n)=>Jt(t,typeof s!="symbol"?s+"":s,n);import{R as de,i as K,r as x,j as e,M as ae,C as Le,l as Yt,o as Oe,t as Pe,m as gt,s as ft,k as Ae}from"./styles-IBhtavYg.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as H,r as F,s as M,c as bt,b as Q,d as fe}from"./crash-reporter-Dc5lvxvY.js";import{g as Xt,a as W,u as Zt,b as es,c as ts,d as ss,A as q,l as Ve,s as ns,O as vt,e as as,f as rs,h as Je,i as yt,j as jt,k as is,m as os,n as ls,o as cs}from"./forensic-log-8R3PpGR3.js";import{B as Ce,i as wt,b as Nt,T as St}from"./state-PELIq3oj.js";const Ye=t=>{let s;const n=new Set,a=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),n.forEach(f=>f(s,h))}},r=()=>s,l={setState:a,getState:r,getInitialState:()=>c,subscribe:p=>(n.add(p),()=>n.delete(p))},c=s=t(a,r,l);return l},ds=t=>t?Ye(t):Ye,us=t=>t;function ps(t,s=us){const n=de.useSyncExternalStore(t.subscribe,de.useCallback(()=>s(t.getState()),[t,s]),de.useCallback(()=>s(t.getInitialState()),[t,s]));return de.useDebugValue(n),n}const Xe=t=>{const s=ds(t),n=a=>ps(s,a);return Object.assign(n,s),n},hs=t=>t?Xe(t):Xe,g=hs(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,n,a)=>t({results:s,delta:n,componentId:a,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,n)=>t({tier:s,trialDaysRemaining:(n==null?void 0:n.trialDaysRemaining)??null,seatsUsed:(n==null?void 0:n.seatsUsed)??null,seatsTotal:(n==null?void 0:n.seatsTotal)??null,planCode:(n==null?void 0:n.planCode)??null,licenseDaysRemaining:(n==null?void 0:n.licenseDaysRemaining)??null,pastDue:(n==null?void 0:n.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,n=!0)=>t({pinnedMatchKey:s,pinnedFound:n}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(n=>({acknowledgedKeys:new Set(n.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(n=>{const a=new Set(n.acknowledgedKeys);return a.delete(s),{acknowledgedKeys:a}}),setMessages:(s,n,a)=>t({messages:s,unreadMessageCount:n,criticalUnacked:a}),applyMessageAck:(s,n)=>t(a=>{const r=a.messages.map(l=>l.id!==s?l:n==="seen"?{...l,seen:!0}:n==="dismissed"?{...l,dismissed:!0}:n==="acknowledged"?{...l,acknowledged:!0}:n==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),be="sidePanel:lastAudit";function ms(){const t=[];return t.push(H("AUDIT_PROGRESS_EVENT",s=>{const n=g.getState().status==="running";g.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),g.getState().setStatus("running"),n||K.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(H("AUDIT_COMPLETE_EVENT",s=>{var i;g.getState().setResults(s.results,s.delta,s.componentId);const n=s.results.reduce((o,l)=>o+l.violations.length,0),a=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${a} new violation${a===1?"":"s"} versus baseline.`:`Audit complete. ${n} violation${n===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;K.polite(r),xs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(H("AUDIT_FAILED_EVENT",s=>{g.getState().setError(s.error.message)})),t.push(H("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const n=g.getState().aiProgress;g.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),n||K.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(H("AI_AUGMENTATION_FAILED_EVENT",s=>{g.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(H("SCORECARD_UPDATED_EVENT",()=>{ve()})),t.push(H("LICENSE_CHANGED_EVENT",()=>{kt()})),t.push(H("SITE_CRAWL_PROGRESS_EVENT",s=>{const n=g.getState();n.setSiteCrawlStatus("running"),n.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&K.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(H("SITE_CRAWL_COMPLETE_EVENT",s=>{const n=g.getState();n.setSiteCrawlStatus("complete"),n.setSiteCrawlReport(s.report),n.setSiteCrawlProgress(null),K.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(H("SITE_CRAWL_FAILED_EVENT",s=>{const n=g.getState();n.setSiteCrawlStatus("failed"),n.setSiteCrawlError(s.error.message),n.setSiteCrawlProgress(null),K.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function xs(t){const s={...t,results:t.results.map(({screenshotDataUrl:n,...a})=>a)};try{await chrome.storage.local.set({[be]:s})}catch(n){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",n)}}async function gs(){const s=(await chrome.storage.local.get(be))[be];s&&g.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function fs(){await chrome.storage.local.remove(be)}async function We(){g.getState().clearResults(),await fs()}async function ve(){const t=await F({type:"BASELINE_LIST"});g.getState().setBaselineList(t.items)}async function kt(t){const s=await F({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});g.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),At()}async function At(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:a}=await Promise.resolve().then(()=>As);return{fetchMessages:a}},void 0),s=g.getState().userMode,n=await t(s);n&&g.getState().setMessages(n.messages,n.unreadCount,n.criticalUnacked)}async function bs(){const s=(await F({type:"SETTINGS_GET",key:"userMode"})).data,n=s==="owner"||s==="dev"?s:null;g.getState().setUserMode(n)}function vs(){return chrome.runtime.connect({name:"audit-keepalive"})}let ye=null;async function ys(){if(ye===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(ye=t.id)}catch{}}function Ct(){if(ye===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:ye}).catch(()=>{})}function X(t){Ct(),M(t)}function js({onClose:t}){const[s,n]=x.useState(""),[a,r]=x.useState(""),[i,o]=x.useState(!0),[l,c]=x.useState(""),[p,d]=x.useState(!1),[u,h]=x.useState(null);async function f(v){var j;if(v.preventDefault(),!(!s.trim()||!a.trim())){d(!0),h(null);try{const C=await F({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:a.trim(),includeContext:i,replyEmail:l.trim()||void 0});C.success?(h({ok:!0,msg:`Sent (ref: ${C.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=C.error)==null?void 0:j.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:v=>n(v.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:a,onChange:v=>r(v.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:v=>c(v.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:v=>o(v.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function Ze({onClick:t,ariaLabel:s,title:n,children:a,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:n??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:a})}const je=bt("messages-client"),ws="https://api.wcagcheckr.com",It="wcagcheckr",Ns=1e4;function Ss(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Et(t,s){const n=await Xt();if(!n)throw new Error("no_license_token");const a={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${n}`,"X-Extension-Version":Ss()};return s!=null&&s.userMode&&(a["X-User-Mode"]=s.userMode),fetch(`${ws}${t}`,{...s,headers:a,signal:AbortSignal.timeout(Ns)})}async function ks(t){try{const s=await Et(`/v1/products/${It}/messages`,{userMode:t??null});return s.ok?await s.json():(je.warn("fetchMessages http",s.status),null)}catch(s){return je.warn("fetchMessages failed",s),null}}async function ne(t,s){try{const n=await Et(`/v1/products/${It}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return n.ok?!0:(je.warn("ackMessage http",n.status,"action",s),!1)}catch(n){return je.warn("ackMessage failed",n),!1}}const As=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ne,fetchMessages:ks},Symbol.toStringTag,{value:"Module"})),Cs=["http:","https:"];function Is(t){try{const s=new URL(t);return Cs.includes(s.protocol)}catch{return!1}}function et(t){const s=[];let n=0,a=0;for(;n<t.length;){if(t[n]==="["){const i=t.indexOf("]",n+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(n+1,i),c=t.slice(i+2,o);Is(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${a++}`)):s.push(e.jsx(x.Fragment,{children:l},`l-${a++}`)),n=o+1;continue}}}if(t[n]==="*"&&t[n+1]==="*"){const i=t.indexOf("**",n+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(n+2,i)},`b-${a++}`)),n=i+2;continue}}if(t[n]==="*"&&t[n+1]!=="*"){const i=t.indexOf("*",n+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(n+1,i)},`i-${a++}`)),n=i+1;continue}}let r=n+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(n,r)},`t-${a++}`)),n=r}return s}function Rt({source:t}){const s=t.split(/\r?\n/),n=[];let a=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");n.push(e.jsx("p",{className:"leading-snug",children:et(c)},`p-${i++}`)),r=[]}function l(){a.length!==0&&(n.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:a.map((c,p)=>e.jsx("li",{children:et(c)},p))},`u-${i++}`)),a=[])}for(const c of s){const p=c.trimEnd();if(p===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){o(),a.push(d[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:n})}const 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 Tt(){const t=g(h=>h.unreadMessageCount),s=g(h=>h.messages),n=g(h=>h.applyMessageAck),[a,r]=x.useState(!1),i=x.useRef(-1),[o,l]=x.useState(!1);x.useEffect(()=>{const h=s.filter(v=>!v.seen);if(h.length===0)return;const f=Math.max(...h.map(v=>v.id));if(f>i.current){i.current=f,l(!0);const v=setTimeout(()=>l(!1),1500);return()=>clearTimeout(v)}},[s]);async function c(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)n(f.id,"seen"),ne(f.id,"seen")}function p(){const h=!a;r(h),h&&c()}async function d(h){n(h.id,"dismissed"),await ne(h.id,"dismissed")}async function u(h){h.ctaUrl&&(n(h.id,"clicked"),ne(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":a,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(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"})]}),a&&e.jsx($s,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}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:n,onCtaClick:a}){const r=x.useRef(null);return x.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:()=>n(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(Rt,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>a(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function $t(){const t=g(i=>i.messages),s=g(i=>i.applyMessageAck),n=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!n)return null;async function a(){s(n.id,"acknowledged"),await ne(n.id,"acknowledged")}async function r(){n.ctaUrl&&(s(n.id,"clicked"),ne(n.id,"clicked"),chrome.tabs.create({url:n.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${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:n.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(Rt,{source:n.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[n.ctaLabel&&n.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:n.ctaLabel}),e.jsx("button",{type:"button",onClick:a,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const ie=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ds(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function _s(){var u,h;const t=g(f=>f.view),s=g(f=>f.setView),n=g(f=>f.setUserMode),a=g(f=>f.results),r=g(f=>f.status),[i,o]=x.useState(!1),l=((u=a[0])==null?void 0:u.pageUrl)??((h=a[0])==null?void 0:h.scope),c=Ds(l),p=a.length>0&&r!=="running";function d(){n("owner"),M({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Tt,{}),e.jsx(Ze,{onClick:()=>void M({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ze,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void We(),className:"shrink-0 text-[11px] px-2 py-0.5 rounded border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-400",title:"Clear these results so you can run a fresh audit",children:"Clear"})]}),e.jsx(Ls,{view:t,setView:s}),e.jsx(ae,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(js,{onClose:()=>o(!1)})})]})}function Ls({view:t,setView:s}){const n=x.useRef([]);function a(i){var c;const o=(i+ie.length)%ie.length,l=ie[o];l&&(s(l),(c=n.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),a(o+1);break;case"ArrowLeft":i.preventDefault(),a(o-1);break;case"Home":i.preventDefault(),a(0);break;case"End":i.preventDefault(),a(ie.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ie.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{n.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Us({feature:t,upgradeUrl:s}){const[n,a]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Le,{open:n,onClose:()=>a(!1)})]})}const Fs="https://wcagcheckr.com/upgrade";function Ms(){const[t,s]=x.useState("single-element"),[n,a]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState(null),[c,p]=x.useState(Ce),[d,u]=x.useState(Ce[0].id),h=g(w=>w.status),f=g(w=>w.tier),v=g(w=>w.results.length>0),j=h==="running";x.useEffect(()=>{Promise.all([F({type:"SETTINGS_GET",key:"matrixPresets"}),F({type:"SETTINGS_GET",key:"activePresetId"})]).then(([w,T])=>{const I=Array.isArray(w.data)?w.data:null;p(I&&I.length>0?I:Ce),typeof T.data=="string"&&u(T.data)})},[]);function C(w){const T=c.find(I=>I.id===w);T&&(u(w),M({type:"SETTINGS_SET",key:"activePresetId",value:w}),M({type:"SETTINGS_SET",key:"stateMatrix",value:T.matrix}))}const S=wt(f,"storybookAutoIterate");x.useEffect(()=>{const w=H("ELEMENT_PICKED_EVENT",(I,L)=>{a(!1);const _=L.frameId;R(_),i({selector:I.selector,frameId:_})}),T=H("PICKER_CANCELLED_EVENT",()=>a(!1));return()=>{w(),T()}},[]);async function m(){const w=await W();w&&(a(!0),await Q(w,{type:"PICKER_ACTIVATE_REQUEST",tabId:w}))}function b(){r&&(R(r.frameId),X({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),g.getState().startNewScan())}function y(){if(!S){l("storybook:auto-iterate");return}R(),X({type:"START_AUDIT",mode:"storybook-all"}),g.getState().startNewScan()}function E(){R(),X({type:"START_AUDIT",mode:"all-frames"}),g.getState().startNewScan()}function D(){R(),X({type:"START_AUDIT",mode:"full-page"}),g.getState().startNewScan()}function k(){M({type:"CANCEL_AUDIT"})}async function R(w){g.getState().setPinned(null);const T=await W();if(T)try{await Q(T,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:T},w)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:w=>s(w.target.value),disabled:j||n,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",S?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:w=>C(w.target.value),disabled:j||n,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))}),t==="single-element"?e.jsx(Os,{picking:n,picked:r,isRunning:j,onPick:m,onRun:b,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:D,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Scan page"}):t==="all-frames"?e.jsx("button",{onClick:E,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all stories"}),j&&e.jsx("button",{onClick:k,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&v&&e.jsx("button",{type:"button",onClick:()=>void We(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!n&&!j&&e.jsx(Ps,{selector:r.selector,onRepick:m,onClear:()=>i(null)})]}),e.jsx(ae,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Us,{feature:o??"",upgradeUrl:Fs})})]})}function Os({picking:t,picked:s,isRunning:n,onPick:a,onRun:r,onClearPick:i}){return n?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:a,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ps({selector:t,onRepick:s,onClear:n}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:n,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Gs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Vs={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]=x.useState(null),[n,a]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState("off"),p=g(f=>f.results).flatMap(f=>f.violations);async function d(f){const v=await W();v&&(l(f),f==="off"?await Q(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await Q(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function u(f){const v=await W();if(v){if(t&&await Q(v,{type:Gs[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await Q(v,{type:Vs[f],tabId:v}).catch(()=>{}),s(f)}}async function h(){const f=await W();if(f){if(n){await Q(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),a(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const v=await fe(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});a(!0),i(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(oe,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(oe,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(oe,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(oe,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(oe,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:n,onClick:h}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void d(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function oe({label:t,title:s,on:n,onClick:a}){return e.jsx("button",{type:"button",title:s,"aria-pressed":n,onClick:a,className:`text-xs px-2 py-1 rounded border transition-colors ${n?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Bs(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 Hs(){const t=g(p=>p.status),s=g(p=>p.progress),n=g(p=>p.aiProgress);if(t!=="running"||!s)return null;const a=n!=null,r=!a&&s.current>=s.total,i=a?n.current/n.total*100:s.current/s.total*100,o=a?n.current:s.current,l=a?n.total:s.total,c=a?`AI augmentation: ${n.current} of ${n.total} checks. ${n.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:a?e.jsxs(e.Fragment,{children:["AI augmentation… ",n.current,"/",n.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:a?n.candidatesTotal&&n.candidatesTotal>0?`${n.currentCheckLabel} (${n.candidatesDone??0}/${n.candidatesTotal})`:n.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Bs(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void M({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${a?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":c,children:e.jsx("div",{className:`h-full transition-all ${a?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const le={"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 zs(t){return/^wcag\d/.test(t.wcagCriterion)?[le["ada-iii"],le[508],le.eaa,le["en-301-549"],le.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 we({violation:t,alreadyAcknowledged:s}){const n=g(m=>m.pinnedMatchKey),a=g(m=>m.pinnedFound),r=g(m=>m.setPinned),i=g(m=>{var b;return(b=m.results[0])==null?void 0:b.frameId}),o=g(m=>{var b;return(b=m.results[0])==null?void 0:b.scope}),l=g(m=>m.results),c=g(m=>m.acknowledgedKeys.has(t.matchKey)),p=g(m=>m.markAcknowledged),d=g(m=>m.markUnacknowledged),u=s||c,h=n===t.matchKey,f=h&&!a;async function v(m){try{return(await fe(m,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:m,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const m=await W();if(!m)return;if(h){r(null);try{await Q(m,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:m},i)}catch{}return}const b=await v(m);r(t.matchKey,b)}function C(m){m.stopPropagation(),t.currentState.breakpoint.width<=640&&Ct(),(async()=>{const b=await W();if(!b)return;try{await F({type:"STATE_DRIVE_REQUEST",tabId:b,state:t.currentState,scope:o,frameId:i})}catch{}const y=await v(b);r(t.matchKey,y)})()}async function S(m){m.stopPropagation();const b=await W();if(!b)return;try{await F({type:"STATE_DRIVE_REQUEST",tabId:b,state:Ys(),scope:o,frameId:i})}catch{M({type:"STATE_RESET_REQUEST",tabId:b})}const y=await v(b);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:j,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-BJxX-AaN.js","assets/forensic-log-DD-VdXBF.js","assets/crash-reporter-Dc5lvxvY.js","assets/state-PELIq3oj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Qt=Object.defineProperty;var Jt=(t,s,n)=>s in t?Qt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Qe=(t,s,n)=>Jt(t,typeof s!="symbol"?s+"":s,n);import{R as de,i as K,r as x,j as e,M as ae,C as Le,l as Yt,o as Oe,t as Pe,m as gt,s as ft,k as Ae}from"./styles-IBhtavYg.js";import{_ as Ge}from"./preload-helper-D7HrI6pR.js";import{o as H,r as F,s as M,c as bt,b as Q,d as fe}from"./crash-reporter-Dc5lvxvY.js";import{g as Xt,a as W,u as Zt,b as es,c as ts,d as ss,A as q,l as Ve,s as ns,O as vt,e as as,f as rs,h as Je,i as yt,j as jt,k as is,m as os,n as ls,o as cs}from"./forensic-log-DD-VdXBF.js";import{B as Ce,i as wt,b as Nt,T as St}from"./state-PELIq3oj.js";const Ye=t=>{let s;const n=new Set,a=(p,d)=>{const u=typeof p=="function"?p(s):p;if(!Object.is(u,s)){const h=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),n.forEach(f=>f(s,h))}},r=()=>s,l={setState:a,getState:r,getInitialState:()=>c,subscribe:p=>(n.add(p),()=>n.delete(p))},c=s=t(a,r,l);return l},ds=t=>t?Ye(t):Ye,us=t=>t;function ps(t,s=us){const n=de.useSyncExternalStore(t.subscribe,de.useCallback(()=>s(t.getState()),[t,s]),de.useCallback(()=>s(t.getInitialState()),[t,s]));return de.useDebugValue(n),n}const Xe=t=>{const s=ds(t),n=a=>ps(s,a);return Object.assign(n,s),n},hs=t=>t?Xe(t):Xe,g=hs(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,n,a)=>t({results:s,delta:n,componentId:a,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,n)=>t({tier:s,trialDaysRemaining:(n==null?void 0:n.trialDaysRemaining)??null,seatsUsed:(n==null?void 0:n.seatsUsed)??null,seatsTotal:(n==null?void 0:n.seatsTotal)??null,planCode:(n==null?void 0:n.planCode)??null,licenseDaysRemaining:(n==null?void 0:n.licenseDaysRemaining)??null,pastDue:(n==null?void 0:n.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>t({siteCrawlReport:s}),setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,n=!0)=>t({pinnedMatchKey:s,pinnedFound:n}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(n=>({acknowledgedKeys:new Set(n.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(n=>{const a=new Set(n.acknowledgedKeys);return a.delete(s),{acknowledgedKeys:a}}),setMessages:(s,n,a)=>t({messages:s,unreadMessageCount:n,criticalUnacked:a}),applyMessageAck:(s,n)=>t(a=>{const r=a.messages.map(l=>l.id!==s?l:n==="seen"?{...l,seen:!0}:n==="dismissed"?{...l,dismissed:!0}:n==="acknowledged"?{...l,acknowledged:!0}:n==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),be="sidePanel:lastAudit";function ms(){const t=[];return t.push(H("AUDIT_PROGRESS_EVENT",s=>{const n=g.getState().status==="running";g.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),g.getState().setStatus("running"),n||K.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(H("AUDIT_COMPLETE_EVENT",s=>{var i;g.getState().setResults(s.results,s.delta,s.componentId);const n=s.results.reduce((o,l)=>o+l.violations.length,0),a=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${a} new violation${a===1?"":"s"} versus baseline.`:`Audit complete. ${n} violation${n===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;K.polite(r),xs({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(H("AUDIT_FAILED_EVENT",s=>{g.getState().setError(s.error.message)})),t.push(H("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const n=g.getState().aiProgress;g.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),n||K.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(H("AI_AUGMENTATION_FAILED_EVENT",s=>{g.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(H("SCORECARD_UPDATED_EVENT",()=>{ve()})),t.push(H("LICENSE_CHANGED_EVENT",()=>{kt()})),t.push(H("SITE_CRAWL_PROGRESS_EVENT",s=>{const n=g.getState();n.setSiteCrawlStatus("running"),n.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&K.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(H("SITE_CRAWL_COMPLETE_EVENT",s=>{const n=g.getState();n.setSiteCrawlStatus("complete"),n.setSiteCrawlReport(s.report),n.setSiteCrawlProgress(null),K.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(H("SITE_CRAWL_FAILED_EVENT",s=>{const n=g.getState();n.setSiteCrawlStatus("failed"),n.setSiteCrawlError(s.error.message),n.setSiteCrawlProgress(null),K.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function xs(t){const s={...t,results:t.results.map(({screenshotDataUrl:n,...a})=>a)};try{await chrome.storage.local.set({[be]:s})}catch(n){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",n)}}async function gs(){const s=(await chrome.storage.local.get(be))[be];s&&g.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function fs(){await chrome.storage.local.remove(be)}async function We(){g.getState().clearResults(),await fs()}async function ve(){const t=await F({type:"BASELINE_LIST"});g.getState().setBaselineList(t.items)}async function kt(t){const s=await F({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});g.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),At()}async function At(){const{fetchMessages:t}=await Ge(async()=>{const{fetchMessages:a}=await Promise.resolve().then(()=>As);return{fetchMessages:a}},void 0),s=g.getState().userMode,n=await t(s);n&&g.getState().setMessages(n.messages,n.unreadCount,n.criticalUnacked)}async function bs(){const s=(await F({type:"SETTINGS_GET",key:"userMode"})).data,n=s==="owner"||s==="dev"?s:null;g.getState().setUserMode(n)}function vs(){return chrome.runtime.connect({name:"audit-keepalive"})}let ye=null;async function ys(){if(ye===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(ye=t.id)}catch{}}function Ct(){if(ye===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:ye}).catch(()=>{})}function X(t){Ct(),M(t)}function js({onClose:t}){const[s,n]=x.useState(""),[a,r]=x.useState(""),[i,o]=x.useState(!0),[l,c]=x.useState(""),[p,d]=x.useState(!1),[u,h]=x.useState(null);async function f(v){var j;if(v.preventDefault(),!(!s.trim()||!a.trim())){d(!0),h(null);try{const C=await F({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:a.trim(),includeContext:i,replyEmail:l.trim()||void 0});C.success?(h({ok:!0,msg:`Sent (ref: ${C.ticketRef??"n/a"})`}),setTimeout(t,1200)):h({ok:!1,msg:((j=C.error)==null?void 0:j.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:f,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:v=>n(v.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:a,onChange:v=>r(v.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:v=>c(v.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:v=>o(v.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),u&&e.jsx("p",{id:"support-form-result",role:u.ok?"status":"alert",className:`text-xs ${u.ok?"text-green-700":"text-red-700"}`,children:u.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:p?"Sending…":"Send"})]})]})}function Ze({onClick:t,ariaLabel:s,title:n,children:a,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:n??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:a})}const je=bt("messages-client"),ws="https://api.wcagcheckr.com",It="wcagcheckr",Ns=1e4;function Ss(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function Et(t,s){const n=await Xt();if(!n)throw new Error("no_license_token");const a={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${n}`,"X-Extension-Version":Ss()};return s!=null&&s.userMode&&(a["X-User-Mode"]=s.userMode),fetch(`${ws}${t}`,{...s,headers:a,signal:AbortSignal.timeout(Ns)})}async function ks(t){try{const s=await Et(`/v1/products/${It}/messages`,{userMode:t??null});return s.ok?await s.json():(je.warn("fetchMessages http",s.status),null)}catch(s){return je.warn("fetchMessages failed",s),null}}async function ne(t,s){try{const n=await Et(`/v1/products/${It}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return n.ok?!0:(je.warn("ackMessage http",n.status,"action",s),!1)}catch(n){return je.warn("ackMessage failed",n),!1}}const As=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:ne,fetchMessages:ks},Symbol.toStringTag,{value:"Module"})),Cs=["http:","https:"];function Is(t){try{const s=new URL(t);return Cs.includes(s.protocol)}catch{return!1}}function et(t){const s=[];let n=0,a=0;for(;n<t.length;){if(t[n]==="["){const i=t.indexOf("]",n+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(n+1,i),c=t.slice(i+2,o);Is(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${a++}`)):s.push(e.jsx(x.Fragment,{children:l},`l-${a++}`)),n=o+1;continue}}}if(t[n]==="*"&&t[n+1]==="*"){const i=t.indexOf("**",n+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(n+2,i)},`b-${a++}`)),n=i+2;continue}}if(t[n]==="*"&&t[n+1]!=="*"){const i=t.indexOf("*",n+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(n+1,i)},`i-${a++}`)),n=i+1;continue}}let r=n+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(x.Fragment,{children:t.slice(n,r)},`t-${a++}`)),n=r}return s}function Rt({source:t}){const s=t.split(/\r?\n/),n=[];let a=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");n.push(e.jsx("p",{className:"leading-snug",children:et(c)},`p-${i++}`)),r=[]}function l(){a.length!==0&&(n.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:a.map((c,p)=>e.jsx("li",{children:et(c)},p))},`u-${i++}`)),a=[])}for(const c of s){const p=c.trimEnd();if(p===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(p);if(d){o(),a.push(d[1]);continue}l(),r.push(p)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:n})}const 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 Tt(){const t=g(h=>h.unreadMessageCount),s=g(h=>h.messages),n=g(h=>h.applyMessageAck),[a,r]=x.useState(!1),i=x.useRef(-1),[o,l]=x.useState(!1);x.useEffect(()=>{const h=s.filter(v=>!v.seen);if(h.length===0)return;const f=Math.max(...h.map(v=>v.id));if(f>i.current){i.current=f,l(!0);const v=setTimeout(()=>l(!1),1500);return()=>clearTimeout(v)}},[s]);async function c(){const h=s.filter(f=>!f.seen);if(h.length!==0)for(const f of h)n(f.id,"seen"),ne(f.id,"seen")}function p(){const h=!a;r(h),h&&c()}async function d(h){n(h.id,"dismissed"),await ne(h.id,"dismissed")}async function u(h){h.ctaUrl&&(n(h.id,"clicked"),ne(h.id,"clicked"),chrome.tabs.create({url:h.ctaUrl}).catch(()=>{window.open(h.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:p,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":a,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(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"})]}),a&&e.jsx($s,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:u})]})}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:n,onCtaClick:a}){const r=x.useRef(null);return x.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:()=>n(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(Rt,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>a(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function $t(){const t=g(i=>i.messages),s=g(i=>i.applyMessageAck),n=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!n)return null;async function a(){s(n.id,"acknowledged"),await ne(n.id,"acknowledged")}async function r(){n.ctaUrl&&(s(n.id,"clicked"),ne(n.id,"clicked"),chrome.tabs.create({url:n.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${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:n.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(Rt,{source:n.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[n.ctaLabel&&n.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:n.ctaLabel}),e.jsx("button",{type:"button",onClick:a,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const ie=["matrix","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ds(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function _s(){var u,h;const t=g(f=>f.view),s=g(f=>f.setView),n=g(f=>f.setUserMode),a=g(f=>f.results),r=g(f=>f.status),[i,o]=x.useState(!1),l=((u=a[0])==null?void 0:u.pageUrl)??((h=a[0])==null?void 0:h.scope),c=Ds(l),p=a.length>0&&r!=="running";function d(){n("owner"),M({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:d,title:"Switch to the simplified site-owner view",className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",children:"Owner mode"}),e.jsx(Tt,{}),e.jsx(Ze,{onClick:()=>void M({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ze,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),p&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:l??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void We(),className:"shrink-0 text-[11px] px-2 py-0.5 rounded border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-400",title:"Clear these results so you can run a fresh audit",children:"Clear"})]}),e.jsx(Ls,{view:t,setView:s}),e.jsx(ae,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(js,{onClose:()=>o(!1)})})]})}function Ls({view:t,setView:s}){const n=x.useRef([]);function a(i){var c;const o=(i+ie.length)%ie.length,l=ie[o];l&&(s(l),(c=n.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),a(o+1);break;case"ArrowLeft":i.preventDefault(),a(o-1);break;case"Home":i.preventDefault(),a(0);break;case"End":i.preventDefault(),a(ie.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ie.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{n.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Us({feature:t,upgradeUrl:s}){const[n,a]=x.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Le,{open:n,onClose:()=>a(!1)})]})}const Fs="https://wcagcheckr.com/upgrade";function Ms(){const[t,s]=x.useState("single-element"),[n,a]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState(null),[c,p]=x.useState(Ce),[d,u]=x.useState(Ce[0].id),h=g(w=>w.status),f=g(w=>w.tier),v=g(w=>w.results.length>0),j=h==="running";x.useEffect(()=>{Promise.all([F({type:"SETTINGS_GET",key:"matrixPresets"}),F({type:"SETTINGS_GET",key:"activePresetId"})]).then(([w,T])=>{const I=Array.isArray(w.data)?w.data:null;p(I&&I.length>0?I:Ce),typeof T.data=="string"&&u(T.data)})},[]);function C(w){const T=c.find(I=>I.id===w);T&&(u(w),M({type:"SETTINGS_SET",key:"activePresetId",value:w}),M({type:"SETTINGS_SET",key:"stateMatrix",value:T.matrix}))}const S=wt(f,"storybookAutoIterate");x.useEffect(()=>{const w=H("ELEMENT_PICKED_EVENT",(I,L)=>{a(!1);const _=L.frameId;R(_),i({selector:I.selector,frameId:_})}),T=H("PICKER_CANCELLED_EVENT",()=>a(!1));return()=>{w(),T()}},[]);async function m(){const w=await W();w&&(a(!0),await Q(w,{type:"PICKER_ACTIVATE_REQUEST",tabId:w}))}function b(){r&&(R(r.frameId),X({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),g.getState().startNewScan())}function y(){if(!S){l("storybook:auto-iterate");return}R(),X({type:"START_AUDIT",mode:"storybook-all"}),g.getState().startNewScan()}function E(){R(),X({type:"START_AUDIT",mode:"all-frames"}),g.getState().startNewScan()}function D(){R(),X({type:"START_AUDIT",mode:"full-page"}),g.getState().startNewScan()}function k(){M({type:"CANCEL_AUDIT"})}async function R(w){g.getState().setPinned(null);const T=await W();if(T)try{await Q(T,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:T},w)}catch{}}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{"aria-label":"Audit mode",value:t,onChange:w=>s(w.target.value),disabled:j||n,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",S?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:w=>C(w.target.value),disabled:j||n,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))}),t==="single-element"?e.jsx(Os,{picking:n,picked:r,isRunning:j,onPick:m,onRun:b,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:D,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Scan page"}):t==="all-frames"?e.jsx("button",{onClick:E,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:y,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:j?"Auditing…":"Audit all stories"}),j&&e.jsx("button",{onClick:k,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&v&&e.jsx("button",{type:"button",onClick:()=>void We(),className:"text-xs text-slate-500 hover:text-slate-800 hover:underline ml-auto",title:"Clear current results",children:"Clear"})]}),t==="single-element"&&r&&!n&&!j&&e.jsx(Ps,{selector:r.selector,onRepick:m,onClear:()=>i(null)})]}),e.jsx(ae,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx(Us,{feature:o??"",upgradeUrl:Fs})})]})}function Os({picking:t,picked:s,isRunning:n,onPick:a,onRun:r,onClearPick:i}){return n?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:a,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Ps({selector:t,onRepick:s,onClear:n}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:n,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Gs={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Vs={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]=x.useState(null),[n,a]=x.useState(!1),[r,i]=x.useState(null),[o,l]=x.useState("off"),p=g(f=>f.results).flatMap(f=>f.violations);async function d(f){const v=await W();v&&(l(f),f==="off"?await Q(v,{type:"VISION_SIMULATOR_CLEAR",tabId:v}).catch(()=>{}):await Q(v,{type:"VISION_SIMULATOR_APPLY",tabId:v,mode:f}).catch(()=>{}))}async function u(f){const v=await W();if(v){if(t&&await Q(v,{type:Gs[t],tabId:v}).catch(()=>{}),t===f){s(null);return}await Q(v,{type:Vs[f],tabId:v}).catch(()=>{}),s(f)}}async function h(){const f=await W();if(f){if(n){await Q(f,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:f}).catch(()=>{}),a(!1),i(null);return}if(p.length===0){i("Run an audit first.");return}try{const v=await fe(f,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:f,violations:p});a(!0),i(`Previewing ${v.visualFixCount} visual fix${v.visualFixCount===1?"":"es"} + ${v.annotationCount} annotation${v.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(oe,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>u("outline")}),e.jsx(oe,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>u("tab-order")}),e.jsx(oe,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>u("reading-order")}),e.jsx(oe,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>u("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(oe,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:n,onClick:h}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:f=>void d(f.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function oe({label:t,title:s,on:n,onClick:a}){return e.jsx("button",{type:"button",title:s,"aria-pressed":n,onClick:a,className:`text-xs px-2 py-1 rounded border transition-colors ${n?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Bs(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 Hs(){const t=g(p=>p.status),s=g(p=>p.progress),n=g(p=>p.aiProgress);if(t!=="running"||!s)return null;const a=n!=null,r=!a&&s.current>=s.total,i=a?n.current/n.total*100:s.current/s.total*100,o=a?n.current:s.current,l=a?n.total:s.total,c=a?`AI augmentation: ${n.current} of ${n.total} checks. ${n.currentCheckLabel}`:r?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{children:a?e.jsxs(e.Fragment,{children:["AI augmentation… ",n.current,"/",n.total]}):r?e.jsx(e.Fragment,{children:"Running deep analyzers…"}):e.jsxs(e.Fragment,{children:["Auditing… ",s.current,"/",s.total]})}),e.jsx("span",{className:"text-slate-500 truncate flex-1",children:a?n.candidatesTotal&&n.candidatesTotal>0?`${n.currentCheckLabel} (${n.candidatesDone??0}/${n.candidatesTotal})`:n.currentCheckLabel:r?"reading order · tab order · typography · CSS vars · AI candidates":Bs(s.currentState)}),e.jsx("button",{type:"button",onClick:()=>void M({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2 py-0.5 border border-slate-400 bg-white text-slate-700 rounded hover:bg-slate-200 shrink-0",children:"Stop"})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${a?"bg-violet-100":"bg-slate-200"}`,role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":l,"aria-label":c,children:e.jsx("div",{className:`h-full transition-all ${a?"bg-violet-500":"bg-brand-500"}`,style:{width:`${i}%`}})})]})}const le={"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 zs(t){return/^wcag\d/.test(t.wcagCriterion)?[le["ada-iii"],le[508],le.eaa,le["en-301-549"],le.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 we({violation:t,alreadyAcknowledged:s}){const n=g(m=>m.pinnedMatchKey),a=g(m=>m.pinnedFound),r=g(m=>m.setPinned),i=g(m=>{var b;return(b=m.results[0])==null?void 0:b.frameId}),o=g(m=>{var b;return(b=m.results[0])==null?void 0:b.scope}),l=g(m=>m.results),c=g(m=>m.acknowledgedKeys.has(t.matchKey)),p=g(m=>m.markAcknowledged),d=g(m=>m.markUnacknowledged),u=s||c,h=n===t.matchKey,f=h&&!a;async function v(m){try{return(await fe(m,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:m,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const m=await W();if(!m)return;if(h){r(null);try{await Q(m,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:m},i)}catch{}return}const b=await v(m);r(t.matchKey,b)}function C(m){m.stopPropagation(),t.currentState.breakpoint.width<=640&&Ct(),(async()=>{const b=await W();if(!b)return;try{await F({type:"STATE_DRIVE_REQUEST",tabId:b,state:t.currentState,scope:o,frameId:i})}catch{}const y=await v(b);r(t.matchKey,y)})()}async function S(m){m.stopPropagation();const b=await W();if(!b)return;try{await F({type:"STATE_DRIVE_REQUEST",tabId:b,state:Ys(),scope:o,frameId:i})}catch{M({type:"STATE_RESET_REQUEST",tabId:b})}const y=await v(b);r(t.matchKey,y)}return e.jsxs("button",{type:"button",onClick:j,"aria-pressed":h,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
|
|
3
3
|
${h?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${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(Xs,{violation:t}),e.jsx(tn,{violation:t}),e.jsx(en,{violation:t}),e.jsx(Zs,{text:t.target.failureSummary}),e.jsx(sn,{ruleId:t.ruleId}),h&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Ks(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:C,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),C(m))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:S,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),S(m))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),f&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:m=>{m.stopPropagation(),d(t.matchKey),Js(t,l)},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:m=>{m.stopPropagation(),p(t.matchKey),Qs(t,l)},onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Ks(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 Qs(t,s){await es({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await Dt(t.componentId,s)}async function Js(t,s){await Zt(t.componentId,t.matchKey),await Dt(t.componentId,s)}async function Dt(t,s){const n=s.flatMap(a=>a.violations);try{const a=await F({type:"BASELINE_COMPARE",componentId:t,currentViolations:n});g.getState().setDelta(a.delta)}catch{}}function Ys(){const t=Nt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(n=>n.id==="desktop")??t[0]}}function _t(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",n=/contrast of (\d+(?:\.\d+)?)/i.exec(s),a=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!n||!a?null:{ratio:parseFloat(n[1]),required:parseFloat(a[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function Xs({violation:t}){const s=_t(t);if(!s)return null;const n=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:n?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]})]})}function Zs({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 en({violation:t}){const s=zs(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(n=>e.jsx("span",{title:`${n.region} — ${n.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:n.name},n.id))})}function tn({violation:t}){const s=_t(t),[n,a]=x.useState({kind:"idle"});if(!s)return null;async function r(){a({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await F({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(c=>c.matchKey===t.matchKey);a(l?{kind:"ready",suggestion:l}:{kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){a({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[n.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),n.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),n.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:n.reason}),n.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",n.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:n.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),n.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:n.suggestion.reasoning})]})]})}function sn({ruleId:t}){const s=ts(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 nn=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]},{id:"other-manual",label:"Other manual checks",axeRules:[],igtWorkflowIds:["reflow","hover-focus-content","pointer","time-based","error-prevention","consistency"]}];function an(t){const s=nn.map(i=>rn(i,t)),n=s.reduce((i,o)=>i+on(o.letter),0)/Math.max(1,s.length),a=ln(Math.round(n)),r=s.filter(i=>i.letter==="D"||i.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:r,isLawsuitRisk:r.length>0}}function rn(t,s){const n=new Set(t.axeRules),a=s.violations.filter(k=>n.has(k.ruleId)),r=s.manualRuns.filter(k=>t.igtWorkflowIds.includes(k.workflowId)),i=t.igtWorkflowIds.map(k=>s.workflows.find(R=>R.id===k)).filter(k=>k!=null);let o=i.length>0;for(const k of i){const R=r.find(T=>T.workflowId===k.id);if((R?Object.keys(R.steps).length:0)!==k.steps.length){o=!1;break}}const l=r.some(k=>Object.keys(k.steps).length>0),c=t.verifiedByWorkflowIds??[],p=s.manualRuns.filter(k=>c.includes(k.workflowId)),d=c.map(k=>s.workflows.find(R=>R.id===k)).filter(k=>k!=null);let u=c.length>0&&d.length===c.length;for(const k of d){const R=p.find(T=>T.workflowId===k.id);if((R?Object.keys(R.steps).length:0)!==k.steps.length){u=!1;break}}let h=null;if(u)for(const k of p)k.completedAt&&(h===null||k.completedAt>h)&&(h=k.completedAt);const f=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,v=c[0]??t.igtWorkflowIds[0]??null;if(u&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:h,suppressedHeuristicCount:f,primaryVerifierWorkflowId:v,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j=t.axeRules.length>0||t.heuristic!=null,C=t.igtWorkflowIds.length>0;let S=!1;if(j&&C?S=!s.auditRan&&!l:j?S=!s.auditRan:C?S=!l:S=!0,S)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:C||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:v,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const m={critical:0,serious:0,moderate:0,minor:0};for(const k of ss(a))m[k.impact]++;m.serious+=f;for(const k of r){const R=i.find(w=>w.id===k.workflowId);if(R)for(const w of R.steps){const T=k.steps[w.id];(T==null?void 0:T.status)==="fail"&&(w.severity==="required"?m.serious++:m.moderate++)}}const b=m.critical>0,y=m.serious>0;let E;m.critical>=5?E="F":m.critical>=1?E="D":m.serious>=1?E="C":m.moderate>=1?E="B":E="A";const D=C&&!o||c.length>0&&!u;return{id:t.id,label:t.label,letter:E,untested:!1,needsIgt:D,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:v,counts:m,caps:{cappedAtC:b,cappedAtB:y}}}function on(t){return t==="A"?4:t==="B"?3:t==="C"?2:t==="D"?1:0}function ln(t){return t>=4?"A":t>=3?"B":t>=2?"C":t>=1?"D":"F"}const cn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},dn={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function un({violations:t,componentId:s}){var h,f,v,j,C;const[n,a]=x.useState([]),r=g(S=>S.status),i=g(S=>S.progress),o=g(S=>S.freshThisSession),l=g(S=>S.results),c=(h=l[0])==null?void 0:h.startedAt;if(x.useEffect(()=>{if(!s){a([]);return}let S=!1;return chrome.storage.local.get("igtRuns").then(m=>{if(S)return;const y=((m==null?void 0:m.igtRuns)??{})[s]??{};a(Object.values(y))}),()=>{S=!0}},[s]),r==="running")return e.jsx(gn,{current:i==null?void 0:i.current,total:i==null?void 0:i.total});const p=an({violations:t,auditRan:l.length>0,manualRuns:n,workflows:q,heuristicCounts:{tabOrder:((v=(f=l[0])==null?void 0:f.tabOrderIssues)==null?void 0:v.length)??0,readingOrder:((C=(j=l[0])==null?void 0:j.readingOrderIssues)==null?void 0:C.length)??0}});let d=0;for(const S of q){const m=n.find(b=>b.workflowId===S.id);m&&Object.keys(m.steps).length===S.steps.length&&d++}const u=t.length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!o&&c&&e.jsx(fn,{scannedAt:c}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${cn[p.overallLetter]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:p.overallLetter})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",p.subGrades.length," verification areas below. Untested areas count as F until verified."]})]})]}),p.isLawsuitRisk&&e.jsx(pn,{areas:p.warningAreas}),e.jsx(hn,{grades:p.subGrades}),e.jsx(xn,{violationsRemaining:u,manualCompleted:d,manualTotal:q.length}),d>0||l.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:d})," of ",e.jsx("strong",{children:q.length})," workflows complete"]}),e.jsx("div",{className:"flex h-1 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-emerald-500",style:{width:`${d/q.length*100}%`}})})]}):null]})}function pn({areas:t}){const s=t.map(n=>n.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((n,a)=>e.jsxs("span",{children:[e.jsx("strong",{children:n}),a<s.length-1?", ":""]},n)),". Fix these before relying on the overall grade."]})})]})}function hn({grades:t}){const s=g(n=>n.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(n=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${dn[n.letter]}`,"aria-label":`Grade ${n.letter}`,children:n.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:n.label}),e.jsx(mn,{grade:n,onOpenGuided:()=>s("guided")})]},n.id))})]})}function mn({grade:t,onOpenGuided:s}){const n=a=>{if(!a)return"";const r=q.find(i=>i.id===a);return(r==null?void 0:r.name)??a};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",n(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const a=t.verifiedAt?Lt(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",a?` ${a} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",n(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function xn({violationsRemaining:t,manualCompleted:s,manualTotal:n}){const a=g(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:s===n,label:`Run Guided Tests (${s}/${n} workflows complete)`,action:()=>a("guided"),tooltip:'12 separate workflows total. Click → pick a workflow → mark each step pass/fail/skip → "Back to workflows" → click again for the next. Repeat until 12/12.'},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>a("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const c=l===i,p=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:p?"font-mono text-emerald-700 shrink-0":c?"font-mono text-brand-600 font-semibold shrink-0":"font-mono text-slate-400 shrink-0","aria-hidden":"true",children:p?"✓":`${l+1}.`}),o.action?e.jsxs("button",{type:"button",onClick:o.action,title:o.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[o.label," →"]}):e.jsx("span",{className:p?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:o.label})]},l)})})]})}function gn({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function fn({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 (",Lt(s)," old). Re-scan to grade the current page state."]})]})}function Lt(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const n=Math.floor(s/86400);return n===1?"1 day":`${n} days`}const Ue="dismissedFindings";function Se(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function pe(t){return`reading-order::${t}`}function he(t){return`tab-order::${t}`}async function ke(){try{const t=await chrome.storage.local.get(Ue),s=t==null?void 0:t[Ue];if(s&&typeof s=="object")return s}catch{}return{}}async function Be(t){await chrome.storage.local.set({[Ue]:t})}async function Ne(t){return(await ke())[Se(t)]??{}}async function Ut(t,s,n,a){const r=await ke(),i=Se(t),o=r[i]??{};o[s]={reason:n,dismissedAt:new Date().toISOString(),snippet:a},r[i]=o,await Be(r)}async function Fe(t,s){if(s.length===0)return;const n=await ke(),a=Se(t),r=n[a]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};n[a]=r,await Be(n)}async function Ft(t,s){const n=await ke(),a=Se(t),r=n[a];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete n[a]:n[a]=r,await Be(n))}const bn=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:Ut,addDismissals:Fe,dismissalKeyForReadingOrder:pe,dismissalKeyForTabOrder:he,getDismissalsForUrl:Ne,removeDismissal:Ft},Symbol.toStringTag,{value:"Module"}));function Mt(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Ot(t){return`${Ve(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function vn(t){const s=new Map;for(const n of t)for(const a of n.violations){const r=Ot(a),i=s.get(r);i?i.states.push(a.currentState):s.set(r,{representative:a,states:[a.currentState]})}return Array.from(s.values())}const tt={critical:0,serious:1,moderate:2,minor:3};function yn(){var v,j,C,S;const t=g(m=>m.results),s=g(m=>m.componentId),n=g(m=>m.setView),a=((v=t[0])==null?void 0:v.pageUrl)??((j=t[0])==null?void 0:j.scope)??"",[r,i]=x.useState({}),[o,l]=x.useState(new Set);if(x.useEffect(()=>{if(!a)return;Ne(a).then(i);const m=()=>{document.visibilityState==="visible"&&a&&Ne(a).then(i)};return document.addEventListener("visibilitychange",m),()=>document.removeEventListener("visibilitychange",m)},[a]),x.useEffect(()=>{if(!s){l(new Set);return}let m=!1;const b=async()=>{const E=await chrome.storage.local.get("igtRuns");if(m)return;const k=((E==null?void 0:E.igtRuns)??{})[s]??{},R=new Set;for(const w of q){const T=k[w.id];T&&Object.keys(T.steps).length===w.steps.length&&R.add(w.id)}l(R)};b();const y=()=>{document.visibilityState==="visible"&&b()};return document.addEventListener("visibilitychange",y),()=>{m=!0,document.removeEventListener("visibilitychange",y)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const c=t.reduce((m,b)=>m+b.durationMs,0),p=t.reduce((m,b)=>m+b.violations.length,0),d=vn(t);d.sort((m,b)=>{const y=tt[m.representative.impact]??99,E=tt[b.representative.impact]??99;return y!==E?y-E:b.states.length-m.states.length});const u=t.map(m=>Mt(m.state)).join(`
|
|
4
4
|
`),h=o.has("keyboard")?0:(((C=t[0])==null?void 0:C.tabOrderIssues)??[]).filter(m=>!(he(m.selector)in r)).length,f=o.has("page-structure")?0:(((S=t[0])==null?void 0:S.readingOrderIssues)??[]).filter(m=>!(pe(m.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(un,{violations:t.flatMap(m=>m.violations),componentId:s}),(h>0||f>0)&&e.jsxs("button",{type:"button",onClick:()=>n("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:h})," tab-order issue",h===1?"":"s"," (WCAG 2.4.3)"]}),h>0&&f>0&&" · ",f>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:f})," reading-order issue",f===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:u,"aria-label":`${t.length} states tested: ${u.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",d.length," unique ",d.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(c/1e3).toFixed(1),"s"]}),d.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic px-1",children:"No violations found."}):e.jsx("div",{className:"space-y-1.5",children:d.map(m=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(we,{violation:m.representative}),e.jsx(jn,{states:m.states,totalStates:t.length})]},Ot(m.representative)))})]})}function jn({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const n=Array.from(new Set(t.map(Mt))),a=n.slice(0,3).join(", "),r=n.length>3?`, +${n.length-3} more`:"",i=n.join(`
|
|
5
5
|
`);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",n.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[a,r]})]})}const wn={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 Nn({ruleId:t,violations:s}){const[n,a]=x.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(we,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>a(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":n,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${wn[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",l]}),e.jsx("span",{className:"text-slate-400 text-xs",children:n?"▾":"▸"})]})]}),n&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,p)=>e.jsx(we,{violation:c},p))})]})}function Sn(t){const s=[],n=new Map;for(const a of t)n.has(a.ruleId)||(s.push(a.ruleId),n.set(a.ruleId,[])),n.get(a.ruleId).push(a);return s.map(a=>({ruleId:a,violations:n.get(a)}))}const kn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function Pt({open:t,onClose:s,format:n,content:a,filename:r}){const i=Yt(new Blob([a]).size);function o(){Pe(a,r),s()}function l(){Oe(a),s()}return e.jsxs(ae,{open:t,onClose:s,title:kn[n],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const st=7800;function An(t,s,n){const a=t.replace(/\/$/,""),r=[];for(const d of n){const u=`${d.ruleId}::${d.target.selector}`,h=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,f=r.find(v=>`${v.ruleId}::${v.target.selector}`===u);if(f){f._states.includes(h)||f._states.push(h);continue}r.push({...d,_states:[h]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
|
|
@@ -25,7 +25,7 @@ document.getElementById('copy').addEventListener('click', () => {
|
|
|
25
25
|
<\/script>
|
|
26
26
|
</body></html>`,P=new Blob([Y],{type:"text/html"}),te=URL.createObjectURL(P);window.open(te,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(te),6e4);return}const R=b==="json"?"application/json":b==="sarif"?"application/sarif+json":"application/xml",w=b==="junit"?"xml":b,T=new Blob([k.content],{type:R}),I=URL.createObjectURL(T),L=document.createElement("a");L.href=I,L.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${w}`,L.click(),URL.revokeObjectURL(I)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("button",{onClick:C,disabled:!j,title:j?void 0:`Free tier limits you to ${f} baseline. Upgrade for unlimited.`,className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Accept as baseline"}),v&&e.jsx("button",{onClick:S,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx($n,{disabled:!h,onExport:m,hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!j&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const b=Ie(t.new),y=Ie(t.persistent),E=Ie(t.fixed),D=[...b.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:"New",violations:b.findings,count:b.findings.length,accent:"red",actions:[...o&&b.findings.length>0?[{label:"File GitHub issue",onClick:()=>Rn(o,s,b.findings)}]:[],...c&&b.findings.length>0?[{label:"File Jira issue",onClick:()=>Tn(c,s,b.findings)}]:[]]}),e.jsx(ce,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(ce,{title:"Fixed",violations:E.findings,count:t.fixedCount,accent:"green"}),D.length>0&&e.jsx(ce,{title:"Needs review (does not affect grade)",violations:D,count:D.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(ce,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),d&&e.jsx(Pt,{open:d.open,onClose:()=>u(null),format:d.format,content:d.content,filename:d.filename})]})}const En={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ie(t){const s=[],n=[];for(const a of t)a.needsReview?n.push(a):s.push(a);return{findings:s,review:n,fixed:0}}function ce({title:t,violations:s,count:n,accent:a,actions:r,renderAsAcknowledged:i}){const[o,l]=x.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${En[a]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",n,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,p)=>e.jsx(we,{violation:c,alreadyAcknowledged:!0},p)):Sn(s).map(c=>e.jsx(Nn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Rn(t,s,n){if(n.length===0)return;const{url:a}=An(t,s,n);window.open(a,"_blank","noopener,noreferrer")}function Tn(t,s,n){if(n.length===0)return;const{url:a}=Cn(t,s,n);window.open(a,"_blank","noopener,noreferrer")}function $n({disabled:t,onExport:s,hasBaselineDelta:n}){const[a,r]=x.useState(!1),[i,o]=x.useState(!1);function l(c){r(!1),s(c,i)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>r(c=>!c),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),a&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:c=>o(c.target.checked),className:"mt-0.5 shrink-0"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("strong",{children:"Use full audit"})," — include pre-existing baseline violations."]})]}),e.jsx("div",{className:"border-t border-slate-100 my-1"})]}),e.jsx(ee,{onClick:()=>l("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(ee,{onClick:()=>l("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(ee,{onClick:()=>l("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ee,{onClick:()=>l("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(ee,{onClick:()=>l("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(ee,{onClick:()=>l("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(ee,{onClick:()=>l("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(ee,{onClick:()=>l("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"})]})]})]})}function ee({onClick:t,title:s,children:n}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:n})}const Dn=new Set(["heading-order","page-has-heading-one","empty-heading","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","landmark-banner-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-complementary-is-top-level","landmark-unique","region","bypass","duplicate-id","duplicate-id-aria","duplicate-id-active"]),_n=new Set(["label","label-content-name-mismatch","label-title-only","form-field-multiple-labels","input-button-name","input-image-alt","autocomplete-valid","aria-required-attr","aria-required-children","aria-required-parent","aria-input-field-name","aria-toggle-field-name","select-name","button-name"]);function Ln(t){return Dn.has(t.ruleId)}function Un(t){return _n.has(t.ruleId)}function Fn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Mn(){var k,R,w,T;const t=g(I=>I.results),s=g(I=>I.delta),n=((k=t[0])==null?void 0:k.pageUrl)??((R=t[0])==null?void 0:R.scope)??"",[a,r]=x.useState({}),[i,o]=x.useState(0);x.useEffect(()=>{n&&Ne(n).then(r)},[n,i]);async function l(I,L){if(!n)return;const _=window.prompt(`Why is this finding a false positive?
|
|
27
27
|
|
|
28
|
-
(Recorded with the dismissal so future you remembers the reasoning.)`,"");_!==null&&(await Ut(n,I,_||"(no reason given)",L),o(z=>z+1))}async function c(I){n&&(await Ft(n,I),o(L=>L+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const p=t.reduce((I,L)=>{var _;return I+(((_=L.announcements)==null?void 0:_.length)??0)},0),d=t.reduce((I,L)=>{var _;return I+(((_=L.focusEvents)==null?void 0:_.length)??0)},0),u=t.reduce((I,L)=>{var _;return I+(((_=L.focusEvents)==null?void 0:_.filter(z=>z.isFocusReset).length)??0)},0),h=at(t,Ln),f=at(t,Un),v=h.length,j=f.length,C=((w=t[0])==null?void 0:w.readingOrderIssues)??[],S=((T=t[0])==null?void 0:T.tabOrderIssues)??[],m=C.filter(I=>!(pe(I.selector)in a)),b=C.filter(I=>pe(I.selector)in a),y=S.filter(I=>!(he(I.selector)in a)),E=S.filter(I=>he(I.selector)in a);if(p===0&&d===0&&v===0&&j===0&&m.length===0&&y.length===0&&b.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 D=b.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:[v," structural · ",j," form ·"," ",y.length," tab-order ·"," ",m.length," reading-order ·"," ",p," ",p===1?"announcement":"announcements"," ·"," ",d," focus ",d===1?"event":"events",u>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",u," focus reset",u===1?"":"s"]}),D>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",D," dismissed"]})]}),y.length>0&&e.jsx(Gn,{issues:y,onDismiss:l}),m.length>0&&e.jsx(Vn,{issues:m,onDismiss:l}),D>0&&e.jsx(Wn,{dismissedReadingOrder:b,dismissedTabOrder:E,dismissals:a,onRestore:c}),v>0&&e.jsx(rt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:h}),j>0&&e.jsx(rt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:f}),e.jsx(On,{delta:s}),t.map((I,L)=>{const _=I.announcements??[],z=I.focusEvents??[];return _.length===0&&z.length===0?null:e.jsx(Pn,{state:I.state,announcements:_,focusEvents:z},L)})]})}function On({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],n=t.newFocusEvents??[],a=n.filter(r=>r.isFocusReset);return s.length===0&&n.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),a.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",a.length," new focus reset",a.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),n.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",n.length,")"]}),e.jsx("ul",{className:"space-y-1",children:n.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function at(t,s){const n=new Map;for(const a of t)for(const r of a.violations){if(!s(r))continue;const i=Ve(r.ruleId,r.target.selector),o=n.get(i);o?o.states.push(r.currentState):n.set(i,{violation:r,states:[r.currentState]})}return Array.from(n.values()).sort((a,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[a.violation.impact]??99)-(i[r.violation.impact]??99)})}function rt({title:t,subtitle:s,groups:n}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:n.map((a,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:a.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${a.violation.impact==="critical"||a.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:a.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:a.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:a.violation.target.selector})]},r))})]})}function Pn({state:t,announcements:s,focusEvents:n}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Fn(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((a,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:a.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",a.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${a.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:a.role??a.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:a.text})]},r))})]}),n.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",n.length,")"]}),e.jsx("ol",{className:"space-y-1",children:n.map((a,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${a.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",a.msSinceArm,"ms"]}),a.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:a.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:a.toSelector}),a.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Gn({issues:t,onDismiss:s}){const n=t.filter(r=>r.flag==="visual"||r.flag==="both").length,a=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," visual mismatch",n===1?"":"es",a>0&&" · "]}),a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," positive-tabindex reordering",a===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Vn({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((n,a)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",n.domIndex,"→vis",n.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:n.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:n.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${n.selector}`,`${n.selector} — ${n.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},a)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Wn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:n,onRestore:a}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const c=`tab-order::${l.selector}`,p=n[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void a(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,p=n[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void a(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const Me="igtRuns";async function Bn(t,s,n){const a=s[0];if(!a)return;const r=a.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${n}" marked pass`;if(t==="tab-order"){const o=a.tabOrderIssues??[];if(o.length===0)return;await Fe(r,o.map(l=>({key:he(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=a.readingOrderIssues??[];if(o.length===0)return;await Fe(r,o.map(l=>({key:pe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Hn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},zn={outline:{type:"OUTLINE_HIDE_REQUEST"},"tab-order":{type:"TAB_ORDER_HIDE_REQUEST"},"reading-order":{type:"READING_ORDER_HIDE_REQUEST"},targets:{type:"TARGET_SIZE_HIDE_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_HIDE_REQUEST"}},qn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function it(t,s){const n=await W();if(!n)return;const a=s?Hn[t]:zn[t];try{await Q(n,a)}catch{}}async function Kn(){const s=(await chrome.storage.local.get(Me))[Me];return s&&typeof s=="object"?s:{}}async function ot(t){await chrome.storage.local.set({[Me]:t})}function Qn(t,s){if(!t.relatedAxeRule||s.length===0)return null;const n=s.flatMap(a=>a.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(n.length>0){const a=Array.from(new Set(n.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:n.length,states:a}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function Jn(){const t=g(d=>d.componentId),s=g(d=>d.results),[n,a]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{Kn().then(a)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=n[t]??{};function l(d,u,h){var v;const f={...n,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((v=o[d])==null?void 0:v.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(a(f),ot(f),h.status==="pass"){const j=q.find(S=>S.id===d),C=j==null?void 0:j.steps.find(S=>S.id===u);C!=null&&C.autoDismissActivity&&Bn(C.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[d];const h={...n,[t]:u};a(h),ot(h)}const p=q.find(d=>d.id===r);if(p){const d=o[p.id];return e.jsx(Yn,{workflow:p,run:d,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),q.map(d=>{const u=o[d.id],h=u?ns(u,d):null;return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:"w-full text-left border border-slate-200 rounded p-2 bg-white hover:bg-slate-50 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),h&&e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function Yn({workflow:t,run:s,results:n,onAnswer:a,onBack:r}){const i=x.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=Qn(p,n);return c},[t,n]);function o(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&a(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>a(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>a(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void it(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",qn[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void it(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Ee,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>a(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Ee,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>a(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Ee,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>a(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>a(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Xn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Ee({label:t,active:s,tone:n,onClick:a}){return e.jsx("button",{type:"button",onClick:a,className:`text-[11px] px-2 py-1 rounded border ${s?Xn[n]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const xe="savedFlows";async function Zn(){const t=await chrome.storage.local.get(xe);return Array.isArray(t[xe])?t[xe]:[]}async function lt(t){await chrome.storage.local.set({[xe]:t})}function ea(){const[t,s]=x.useState([]),[n,a]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{Zn().then(s)},[]);async function o(){const d=await W();if(!d){i("No audit-target tab found.");return}try{await Q(d,{type:"FLOW_RECORD_START_REQUEST"}),a(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await W();if(d)try{const u=await fe(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(a(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},v=[f,...t];s(v),await lt(v),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await W();if(u){i(`Replaying "${d.name}"…`);try{const h=await fe(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==d);s(u),await lt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:n?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function ta(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const n=t.slice(0,s),a=t.slice(s+2),r=a.indexOf(":");if(r===-1)return{primary:a};const i=a.slice(0,r),o=a.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(sa).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:n||i}}function sa(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function na(){const t=g(l=>l.baselineList),s=g(l=>l.tier),n=St[s].maxBaselines,a=t.length>=n&&Number.isFinite(n),[r,i]=x.useState(!1);if(x.useEffect(()=>{ve().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 M({type:"BASELINE_DELETE",componentId:l}),await ve()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(n)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",n]})]}),a&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const c=ta(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(se,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(se,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(se,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(se,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(se,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(se,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(se,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const aa={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function se({tone:t,title:s,children:n}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${aa[t]}`,children:n})}const ra={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"},ia={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},oa={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Gt({onBack:t}){const s=g(u=>u.siteCrawlStatus),n=g(u=>u.siteCrawlProgress),a=g(u=>u.siteCrawlReport),r=g(u=>u.siteCrawlError),[i,o]=x.useState(""),[l,c]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var f;const h=(f=u[0])==null?void 0:f.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(g.getState().setSiteCrawlStatus("running"),g.getState().setSiteCrawlReport(null),g.getState().setSiteCrawlError(null),X({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function d(){M({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:n.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${n.current/Math.max(1,n.total)*100}%`},role:"progressbar","aria-valuenow":n.current,"aria-valuemin":0,"aria-valuemax":n.total,"aria-label":`Page ${n.current} of ${n.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",n.current," of ",n.total,n.lastViolations!==void 0&&` · last had ${n.lastViolations} issue${n.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&a&&e.jsx(la,{report:a}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function la({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:n}=await import("./site-report-renderer-C9fIcwfC.js");return{renderSiteReportHtml:n}},__vite__mapDeps([0,1,2,3])).then(({renderSiteReportHtml:n})=>{const a=n(t),r=new Blob([a],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${ra[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${ia[t.siteRisk]}`,children:vt[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(n=>{const a=as(n.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${oa[n.impact]}`,children:n.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:a.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:n.urlsAffected})," page",n.urlsAffected===1?"":"s"," · ",n.totalOccurrences," total spot",n.totalOccurrences===1?"":"s"]})]})]})},n.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(n=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${n.grade==="A"?"text-emerald-700":n.grade==="B"?"text-lime-700":n.grade==="C"?"text-yellow-700":n.grade==="D"?"text-orange-700":"text-rose-700"}`,children:n.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:n.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:n.uniqueViolations})]},n.url))})]})]})}const Re="onboardingDismissed",Te=[{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 ca(){const[t,s]=x.useState(!1),[n,a]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(Re).then(l=>{l[Re]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Re]:!0}),s(!1),a(0)}const i=n===Te.length-1,o=Te[n];return e.jsxs(ae,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[n+1," / ",Te.length]}),e.jsxs("div",{className:"flex gap-2",children:[n>0&&e.jsx("button",{onClick:()=>a(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>a(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function da(){const t=g(a=>a.status),s=g(a=>a.errorMessage),n=g(a=>a.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>n("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function ua(){const t=g(c=>c.aiFailure),s=g(c=>c.clearAiFailure),[n,a]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>a(c=>!c),className:"underline hover:no-underline","aria-expanded":n,children:n?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),n&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function ct(){const[t,s]=x.useState(!1);return x.useEffect(()=>H("AUDIT_FAILED_EVENT",n=>{n.error.code==="DEBUGGER_BUSY"&&(s(!0),g.getState().setStatus("idle"))}),[]),e.jsxs(ae,{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 pa(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{rs().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function n(){t&&(await Je(),g.getState().startNewScan(),t.mode==="storybook-all"?X({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&X({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function a(){await Je(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:n,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:a,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const $e="storybook:hintDismissed";function ha(){const[t,s]=x.useState(!1),[n,a]=x.useState();x.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get($e))[$e])return;const o=await W();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(a((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[$e]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",n??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function ma(){var i;const t=g(o=>o.results),s=g(o=>o.baselineList),n=g(o=>o.status),a=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:n==="running"?"auditing…":a?`last audit ${xa(a)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function xa(t,s=new Date){const n=new Date(t),a=s.getTime()-n.getTime(),r=Math.round(a/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:n.toLocaleDateString()}function ga(){const t=g(l=>l.results),s=g(l=>l.componentId),[n,a]=x.useState([]);if(x.useEffect(()=>{if(!s){a([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};a(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=yt(r,n.length>0?{runs:n,workflows:q}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function fa(){const t=g(n=>n.setUserMode);function s(n){t(n),M({type:"SETTINGS_SET",key:"userMode",value:n})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Vt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},ba={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Vt]},va={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Vt]};function He(t){return t==="thorough"?va:ba}function dt(t){const s=He(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const ge="wcagcheckr";function $(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ue(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 ya(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function ja(t){if(t.length===0)return null;const s=[...t].sort((n,a)=>n.capturedAt.localeCompare(a.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function wa(t){const s=new Map;for(const n of t){const a=s.get(n.componentId);a?(a.entries.push(n),n.receipt&&a.anchoredCount++,n.capturedAt>a.latest.capturedAt&&(a.latest=n,a.pageUrl=n.pageUrl)):s.set(n.componentId,{componentId:n.componentId,pageUrl:n.pageUrl,entries:[n],latest:n,anchoredCount:n.receipt?1:0})}for(const n of s.values())n.entries.sort((a,r)=>r.capturedAt.localeCompare(a.capturedAt));return Array.from(s.values()).sort((n,a)=>a.latest.capturedAt.localeCompare(n.latest.capturedAt))}function Na(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 Sa(t){const s=t.totals,n=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',a=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${$(t.receipt.tsaName)}) — anchored ${$(ue(t.receipt.anchoredAt))}</td></tr>
|
|
28
|
+
(Recorded with the dismissal so future you remembers the reasoning.)`,"");_!==null&&(await Ut(n,I,_||"(no reason given)",L),o(z=>z+1))}async function c(I){n&&(await Ft(n,I),o(L=>L+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const p=t.reduce((I,L)=>{var _;return I+(((_=L.announcements)==null?void 0:_.length)??0)},0),d=t.reduce((I,L)=>{var _;return I+(((_=L.focusEvents)==null?void 0:_.length)??0)},0),u=t.reduce((I,L)=>{var _;return I+(((_=L.focusEvents)==null?void 0:_.filter(z=>z.isFocusReset).length)??0)},0),h=at(t,Ln),f=at(t,Un),v=h.length,j=f.length,C=((w=t[0])==null?void 0:w.readingOrderIssues)??[],S=((T=t[0])==null?void 0:T.tabOrderIssues)??[],m=C.filter(I=>!(pe(I.selector)in a)),b=C.filter(I=>pe(I.selector)in a),y=S.filter(I=>!(he(I.selector)in a)),E=S.filter(I=>he(I.selector)in a);if(p===0&&d===0&&v===0&&j===0&&m.length===0&&y.length===0&&b.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 D=b.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:[v," structural · ",j," form ·"," ",y.length," tab-order ·"," ",m.length," reading-order ·"," ",p," ",p===1?"announcement":"announcements"," ·"," ",d," focus ",d===1?"event":"events",u>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",u," focus reset",u===1?"":"s"]}),D>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",D," dismissed"]})]}),y.length>0&&e.jsx(Gn,{issues:y,onDismiss:l}),m.length>0&&e.jsx(Vn,{issues:m,onDismiss:l}),D>0&&e.jsx(Wn,{dismissedReadingOrder:b,dismissedTabOrder:E,dismissals:a,onRestore:c}),v>0&&e.jsx(rt,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:h}),j>0&&e.jsx(rt,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:f}),e.jsx(On,{delta:s}),t.map((I,L)=>{const _=I.announcements??[],z=I.focusEvents??[];return _.length===0&&z.length===0?null:e.jsx(Pn,{state:I.state,announcements:_,focusEvents:z},L)})]})}function On({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],n=t.newFocusEvents??[],a=n.filter(r=>r.isFocusReset);return s.length===0&&n.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),a.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",a.length," new focus reset",a.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),n.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",n.length,")"]}),e.jsx("ul",{className:"space-y-1",children:n.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function at(t,s){const n=new Map;for(const a of t)for(const r of a.violations){if(!s(r))continue;const i=Ve(r.ruleId,r.target.selector),o=n.get(i);o?o.states.push(r.currentState):n.set(i,{violation:r,states:[r.currentState]})}return Array.from(n.values()).sort((a,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[a.violation.impact]??99)-(i[r.violation.impact]??99)})}function rt({title:t,subtitle:s,groups:n}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:n.map((a,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:a.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${a.violation.impact==="critical"||a.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:a.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:a.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:a.violation.target.selector})]},r))})]})}function Pn({state:t,announcements:s,focusEvents:n}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Fn(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((a,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:a.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",a.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${a.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:a.role??a.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:a.text})]},r))})]}),n.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",n.length,")"]}),e.jsx("ol",{className:"space-y-1",children:n.map((a,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${a.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",a.msSinceArm,"ms"]}),a.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:a.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:a.toSelector}),a.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Gn({issues:t,onDismiss:s}){const n=t.filter(r=>r.flag==="visual"||r.flag==="both").length,a=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," visual mismatch",n===1?"":"es",a>0&&" · "]}),a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," positive-tabindex reordering",a===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Vn({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((n,a)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",n.domIndex,"→vis",n.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:n.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:n.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${n.selector}`,`${n.selector} — ${n.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},a)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Wn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:n,onRestore:a}){const[r,i]=x.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const c=`tab-order::${l.selector}`,p=n[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void a(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,p=n[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),p&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",p.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void a(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const Me="igtRuns";async function Bn(t,s,n){const a=s[0];if(!a)return;const r=a.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${n}" marked pass`;if(t==="tab-order"){const o=a.tabOrderIssues??[];if(o.length===0)return;await Fe(r,o.map(l=>({key:he(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=a.readingOrderIssues??[];if(o.length===0)return;await Fe(r,o.map(l=>({key:pe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Hn={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},zn={outline:{type:"OUTLINE_HIDE_REQUEST"},"tab-order":{type:"TAB_ORDER_HIDE_REQUEST"},"reading-order":{type:"READING_ORDER_HIDE_REQUEST"},targets:{type:"TARGET_SIZE_HIDE_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_HIDE_REQUEST"}},qn={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function it(t,s){const n=await W();if(!n)return;const a=s?Hn[t]:zn[t];try{await Q(n,a)}catch{}}async function Kn(){const s=(await chrome.storage.local.get(Me))[Me];return s&&typeof s=="object"?s:{}}async function ot(t){await chrome.storage.local.set({[Me]:t})}function Qn(t,s){if(!t.relatedAxeRule||s.length===0)return null;const n=s.flatMap(a=>a.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(n.length>0){const a=Array.from(new Set(n.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:n.length,states:a}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function Jn(){const t=g(d=>d.componentId),s=g(d=>d.results),[n,a]=x.useState({}),[r,i]=x.useState(null);if(x.useEffect(()=>{Kn().then(a)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=n[t]??{};function l(d,u,h){var v;const f={...n,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((v=o[d])==null?void 0:v.steps)??{},[u]:h},completedAt:new Date().toISOString()}}};if(a(f),ot(f),h.status==="pass"){const j=q.find(S=>S.id===d),C=j==null?void 0:j.steps.find(S=>S.id===u);C!=null&&C.autoDismissActivity&&Bn(C.autoDismissActivity,s,u)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const u={...o};delete u[d];const h={...n,[t]:u};a(h),ot(h)}const p=q.find(d=>d.id===r);if(p){const d=o[p.id];return e.jsx(Yn,{workflow:p,run:d,results:s,onAnswer:(u,h)=>l(p.id,u,h),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),q.map(d=>{const u=o[d.id],h=u?ns(u,d):null;return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:"w-full text-left border border-slate-200 rounded p-2 bg-white hover:bg-slate-50 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),h&&e.jsxs("span",{className:"text-[10px] text-slate-500 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[h.passed," pass"]}),h.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",h.failed," fail"]}),h.skipped>0&&e.jsxs("span",{children:[" · ",h.skipped," skip"]})," / ",h.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),u&&e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function Yn({workflow:t,run:s,results:n,onAnswer:a,onBack:r}){const i=x.useMemo(()=>{const c={};for(const p of t.steps)c[p.id]=Qn(p,n);return c},[t,n]);function o(){for(const c of t.steps){const p=i[c.id];(p==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&a(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`})}}const l=t.steps.filter(c=>{var p;return((p=i[c.id])==null?void 0:p.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),l>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[l," step",l===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:o,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",l," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,p)=>{const d=s==null?void 0:s.steps[c.id];return e.jsxs("div",{className:`border rounded p-2 ${(d==null?void 0:d.status)==="pass"?"border-emerald-300 bg-emerald-50":(d==null?void 0:d.status)==="fail"?"border-rose-300 bg-rose-50":(d==null?void 0:d.status)==="skip"?"border-slate-200 bg-slate-50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:[p+1,"/",t.steps.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.severity==="required"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded",children:"required"}),c.wcag&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:["WCAG ",c.wcag]})]})]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-1",children:[e.jsx("strong",{children:"Do:"})," ",c.prompt]}),e.jsxs("p",{className:"text-xs text-slate-700 mb-2",children:[e.jsx("strong",{children:"Verify:"})," ",c.question]}),c.relatedAxeRule&&e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Related axe rule: ",e.jsx("code",{className:"font-mono",children:c.relatedAxeRule})]}),(()=>{const u=i[c.id];return u?u.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," ran clean across ",u.statesAudited," state",u.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>a(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:u.ruleId})," already found ",u.violationCount," violation",u.violationCount===1?"":"s"," in"," ",u.states.length," state",u.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>a(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${u.ruleId}, ${u.violationCount} hits in: ${u.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void it(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",qn[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void it(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Ee,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>a(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Ee,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>a(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Ee,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>a(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:u=>a(c.id,{status:d.status,notes:u.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const Xn={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Ee({label:t,active:s,tone:n,onClick:a}){return e.jsx("button",{type:"button",onClick:a,className:`text-[11px] px-2 py-1 rounded border ${s?Xn[n]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const xe="savedFlows";async function Zn(){const t=await chrome.storage.local.get(xe);return Array.isArray(t[xe])?t[xe]:[]}async function lt(t){await chrome.storage.local.set({[xe]:t})}function ea(){const[t,s]=x.useState([]),[n,a]=x.useState(!1),[r,i]=x.useState(null);x.useEffect(()=>{Zn().then(s)},[]);async function o(){const d=await W();if(!d){i("No audit-target tab found.");return}try{await Q(d,{type:"FLOW_RECORD_START_REQUEST"}),a(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await W();if(d)try{const u=await fe(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(a(!1),u.steps.length===0){i("Recording stopped — no steps captured.");return}const h=typeof prompt=="function"?prompt(`Captured ${u.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!h.trim()){i("Save canceled.");return}const f={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:h.trim(),steps:u.steps,savedAt:new Date().toISOString()},v=[f,...t];s(v),await lt(v),i(`Saved "${f.name}" with ${f.steps.length} steps.`)}catch(u){i(`Stop failed: ${u instanceof Error?u.message:String(u)}`)}}async function c(d){const u=await W();if(u){i(`Replaying "${d.name}"…`);try{const h=await fe(u,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${h.played} step${h.played===1?"":"s"}`+(h.errored?`, ${h.errored} errored (selector not found)`:"")+".")}catch(h){i(`Replay failed: ${h instanceof Error?h.message:String(h)}`)}}}async function p(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const u=t.filter(h=>h.id!==d);s(u),await lt(u)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:n?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>p(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function ta(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const n=t.slice(0,s),a=t.slice(s+2),r=a.indexOf(":");if(r===-1)return{primary:a};const i=a.slice(0,r),o=a.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(sa).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:n||i}}function sa(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function na(){const t=g(l=>l.baselineList),s=g(l=>l.tier),n=St[s].maxBaselines,a=t.length>=n&&Number.isFinite(n),[r,i]=x.useState(!1);if(x.useEffect(()=>{ve().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 M({type:"BASELINE_DELETE",componentId:l}),await ve()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(n)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",n]})]}),a&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const c=ta(l.componentId),p=l.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:l.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[l.violationCount," ",l.violationCount===1?"violation":"violations"," ·"," ",new Date(l.lastUpdated).toLocaleDateString()]}),p&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(se,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),p.criticalCount>0&&e.jsxs(se,{tone:"rose",title:`${p.criticalCount} critical violations`,children:[p.criticalCount," critical"]}),p.seriousCount>0&&e.jsxs(se,{tone:"orange",title:`${p.seriousCount} serious violations`,children:[p.seriousCount," serious"]}),p.focusResetCount>0&&e.jsxs(se,{tone:"rose",title:`${p.focusResetCount} focus resets observed`,children:[p.focusResetCount," focus reset",p.focusResetCount===1?"":"s"]}),p.targetSizeFailCount>0&&e.jsxs(se,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[p.targetSizeFailCount," small targets"]}),p.hoverContrastFail&&e.jsx(se,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),p.announcementCount>0&&e.jsxs(se,{tone:"indigo",title:"aria-live announcements observed",children:[p.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>o(l.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},l.componentId)})]})}const aa={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function se({tone:t,title:s,children:n}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${aa[t]}`,children:n})}const ra={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"},ia={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},oa={critical:"bg-rose-600 text-white",serious:"bg-orange-500 text-white",moderate:"bg-yellow-500 text-slate-900",minor:"bg-blue-500 text-white"};function Gt({onBack:t}){const s=g(u=>u.siteCrawlStatus),n=g(u=>u.siteCrawlProgress),a=g(u=>u.siteCrawlReport),r=g(u=>u.siteCrawlError),[i,o]=x.useState(""),[l,c]=x.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(u=>{var f;const h=(f=u[0])==null?void 0:f.url;h&&/^https?:\/\//.test(h)&&i===""&&o(h)});function p(){i&&(g.getState().setSiteCrawlStatus("running"),g.getState().setSiteCrawlReport(null),g.getState().setSiteCrawlError(null),X({type:"START_SITE_CRAWL",startUrl:i,maxPages:l}))}function d(){M({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:u=>o(u.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:u=>c(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default."})]}),e.jsx("button",{type:"button",onClick:p,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:n.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${n.current/Math.max(1,n.total)*100}%`},role:"progressbar","aria-valuenow":n.current,"aria-valuemin":0,"aria-valuemax":n.total,"aria-label":`Page ${n.current} of ${n.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",n.current," of ",n.total,n.lastViolations!==void 0&&` · last had ${n.lastViolations} issue${n.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&a&&e.jsx(la,{report:a}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function la({report:t}){function s(){Ge(async()=>{const{renderSiteReportHtml:n}=await import("./site-report-renderer-BJxX-AaN.js");return{renderSiteReportHtml:n}},__vite__mapDeps([0,1,2,3])).then(({renderSiteReportHtml:n})=>{const a=n(t),r=new Blob([a],{type:"text/html"}),i=URL.createObjectURL(r);window.open(i,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(i),6e4)})}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${ra[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${ia[t.siteRisk]}`,children:vt[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(n=>{const a=as(n.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${oa[n.impact]}`,children:n.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:a.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:n.urlsAffected})," page",n.urlsAffected===1?"":"s"," · ",n.totalOccurrences," total spot",n.totalOccurrences===1?"":"s"]})]})]})},n.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(n=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${n.grade==="A"?"text-emerald-700":n.grade==="B"?"text-lime-700":n.grade==="C"?"text-yellow-700":n.grade==="D"?"text-orange-700":"text-rose-700"}`,children:n.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:n.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:n.uniqueViolations})]},n.url))})]})]})}const Re="onboardingDismissed",Te=[{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 ca(){const[t,s]=x.useState(!1),[n,a]=x.useState(0);x.useEffect(()=>{chrome.storage.local.get(Re).then(l=>{l[Re]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[Re]:!0}),s(!1),a(0)}const i=n===Te.length-1,o=Te[n];return e.jsxs(ae,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[n+1," / ",Te.length]}),e.jsxs("div",{className:"flex gap-2",children:[n>0&&e.jsx("button",{onClick:()=>a(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>a(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function da(){const t=g(a=>a.status),s=g(a=>a.errorMessage),n=g(a=>a.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>n("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function ua(){const t=g(c=>c.aiFailure),s=g(c=>c.clearAiFailure),[n,a]=x.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>a(c=>!c),className:"underline hover:no-underline","aria-expanded":n,children:n?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),n&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,p)=>e.jsx("li",{children:c},p))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function ct(){const[t,s]=x.useState(!1);return x.useEffect(()=>H("AUDIT_FAILED_EVENT",n=>{n.error.code==="DEBUGGER_BUSY"&&(s(!0),g.getState().setStatus("idle"))}),[]),e.jsxs(ae,{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 pa(){var i;const[t,s]=x.useState(null);if(x.useEffect(()=>{rs().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function n(){t&&(await Je(),g.getState().startNewScan(),t.mode==="storybook-all"?X({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&X({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function a(){await Je(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:n,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:a,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const $e="storybook:hintDismissed";function ha(){const[t,s]=x.useState(!1),[n,a]=x.useState();x.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get($e))[$e])return;const o=await W();if(o)try{const p=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var u;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(u=d.__STORYBOOK_PREVIEW__)==null?void 0:u.version}}})).find(d=>{var u;return(u=d.result)==null?void 0:u.detected});p&&(a((l=p.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[$e]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",n??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function ma(){var i;const t=g(o=>o.results),s=g(o=>o.baselineList),n=g(o=>o.status),a=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:n==="running"?"auditing…":a?`last audit ${xa(a)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function xa(t,s=new Date){const n=new Date(t),a=s.getTime()-n.getTime(),r=Math.round(a/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:n.toLocaleDateString()}function ga(){const t=g(l=>l.results),s=g(l=>l.componentId),[n,a]=x.useState([]);if(x.useEffect(()=>{if(!s){a([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};a(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=yt(r,n.length>0?{runs:n,workflows:q}:void 0),o=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",o?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function fa(){const t=g(n=>n.setUserMode);function s(n){t(n),M({type:"SETTINGS_SET",key:"userMode",value:n})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Vt={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},ba={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[Vt]},va={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[Vt]};function He(t){return t==="thorough"?va:ba}function dt(t){const s=He(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const ge="wcagcheckr";function $(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ue(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 ya(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function ja(t){if(t.length===0)return null;const s=[...t].sort((n,a)=>n.capturedAt.localeCompare(a.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function wa(t){const s=new Map;for(const n of t){const a=s.get(n.componentId);a?(a.entries.push(n),n.receipt&&a.anchoredCount++,n.capturedAt>a.latest.capturedAt&&(a.latest=n,a.pageUrl=n.pageUrl)):s.set(n.componentId,{componentId:n.componentId,pageUrl:n.pageUrl,entries:[n],latest:n,anchoredCount:n.receipt?1:0})}for(const n of s.values())n.entries.sort((a,r)=>r.capturedAt.localeCompare(a.capturedAt));return Array.from(s.values()).sort((n,a)=>a.latest.capturedAt.localeCompare(n.latest.capturedAt))}function Na(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 Sa(t){const s=t.totals,n=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',a=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${$(t.receipt.tsaName)}) — anchored ${$(ue(t.receipt.anchoredAt))}</td></tr>
|
|
29
29
|
<tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${$(t.receipt.serverKeyFingerprint)}</code></td></tr>
|
|
30
30
|
${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${$(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${$(ge)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
|
|
31
31
|
<article class="entry">
|