@wcag-checkr/ci 1.0.0-rc.126 → 1.0.0-rc.127

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.
Files changed (33) hide show
  1. package/dist/assets/{ErrorBoundary-CWn7ITQT.js → ErrorBoundary-S-LLV1G2.js} +40 -40
  2. package/dist/assets/ai-usage-log-DBBVxutJ.js +1 -0
  3. package/dist/assets/{content-script.ts-bamz_7oc.js → content-script.ts-D8-LVJj3.js} +3 -3
  4. package/dist/assets/{content-script.ts-loader-C1hxb6MX.js → content-script.ts-loader-CtAo2OGP.js} +1 -1
  5. package/dist/assets/copy-ai-fixer-prompt-Ca9DEwvW.js +19 -0
  6. package/dist/assets/devtools-panel-C5PBdRUS.js +1 -0
  7. package/dist/assets/diff-DA41zYPc.js +1 -0
  8. package/dist/assets/{options-BNpK4C5K.js → options-CeZ_qWew.js} +2 -2
  9. package/dist/assets/parallel-tab-flow-CNaSsHNN.js +1 -0
  10. package/dist/assets/scheduled-audit-runner-DHCThfcB.js +693 -0
  11. package/dist/assets/service-worker.ts-Ctmp1xBr.js +564 -0
  12. package/dist/assets/side-panel-BCn_yDeS.js +1 -0
  13. package/dist/assets/{site-report-renderer-cCg8cDS3.js → site-report-renderer--kSYqnJz.js} +3 -3
  14. package/dist/assets/{styles-BipWpq_R.js → styles-BFNj1zaE.js} +1 -1
  15. package/dist/assets/{styles-CGOE50Xt.css → styles-iZ4Mjt1T.css} +1 -1
  16. package/dist/devtools/panel.html +7 -7
  17. package/dist/manifest.json +5 -6
  18. package/dist/options/options.html +4 -5
  19. package/dist/service-worker-loader.js +1 -1
  20. package/dist/side-panel/App.tsx +2 -0
  21. package/dist/side-panel/side-panel.html +7 -7
  22. package/dist/side-panel/store.ts +1 -1
  23. package/package.json +1 -1
  24. package/dist/assets/ai-usage-log-Dj9Ub_DT.js +0 -1
  25. package/dist/assets/copy-ai-fixer-prompt-CO6FY4Hi.js +0 -19
  26. package/dist/assets/devtools-panel-DdMZfMgt.js +0 -1
  27. package/dist/assets/diff-DIBMr3fQ.js +0 -1
  28. package/dist/assets/forensic-log--QZITQ0D.js +0 -131
  29. package/dist/assets/parallel-tab-flow-BJdVOYso.js +0 -1
  30. package/dist/assets/preload-helper-D7HrI6pR.js +0 -1
  31. package/dist/assets/service-worker.ts-rGV5oo7S.js +0 -1125
  32. package/dist/assets/side-panel-B_LV5Vgu.js +0 -1
  33. package/dist/assets/state-BIsozXtc.js +0 -1
@@ -1,19 +1,19 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-CO6FY4Hi.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer-cCg8cDS3.js","assets/forensic-log--QZITQ0D.js","assets/state-BIsozXtc.js"])))=>i.map(i=>d[i]);
2
- var Is=Object.defineProperty;var Rs=(t,s,a)=>s in t?Is(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var yt=(t,s,a)=>Rs(t,typeof s!="symbol"?s+"":s,a);import{R as Ae,i as ce,r as h,j as e,M as be,C as Xe,l as Es,o as it,t as ot,m as zt,s as Kt,k as Ee}from"./styles-BipWpq_R.js";import{s as Ts,g as $s,a as oe,b as Ls,u as Us,c as Os,d as _s,e as Ds,f as lt,h as qt,A as ee,l as ct,i as Fs,j as Ue,k as Qt,m as Ms,n as dt,o as Ps,p as Gs,N as Vs,q as Ws,O as Bs,r as Hs,t as zs,v as Ks,w as jt,x as qs,y as Yt,z as Qs,B as Ys,C as Js,D as Xs,E as Zs,F as ea,T as ta,G as sa,H as aa,I as na,J as ra}from"./forensic-log--QZITQ0D.js";import{_ as ut}from"./preload-helper-D7HrI6pR.js";import{o as le,r as te,s as J,c as Jt,b as ue,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{B as ze,i as Xt,b as Zt,T as es}from"./state-BIsozXtc.js";const wt=t=>{let s;const a=new Set,n=(u,d)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const m=s;s=d??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,m))}},r=()=>s,l={setState:n,getState:r,getInitialState:()=>c,subscribe:u=>(a.add(u),()=>a.delete(u))},c=s=t(n,r,l);return l},ia=t=>t?wt(t):wt,oa=t=>t;function la(t,s=oa){const a=Ae.useSyncExternalStore(t.subscribe,Ae.useCallback(()=>s(t.getState()),[t,s]),Ae.useCallback(()=>s(t.getInitialState()),[t,s]));return Ae.useDebugValue(a),a}const Nt=t=>{const s=ia(t),a=n=>la(s,n);return Object.assign(a,s),a},ca=t=>t?Nt(t):Nt,f=ca(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Ts(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(l=>l.id!==s?l:a==="seen"?{...l,seen:!0}:a==="dismissed"?{...l,dismissed:!0}:a==="acknowledged"?{...l,acknowledged:!0}:a==="clicked"?{...l,clicked:!0}:l).filter(l=>l.severity==="critical"?!l.acknowledged:!l.dismissed),i=r.filter(l=>!l.seen).length,o=r.some(l=>l.severity==="critical"&&!l.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:o}})})),De="sidePanel:lastAudit";function da(){const t=[];return t.push(le("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||ce.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(le("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((o,l)=>o+l.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;ce.polite(r),ua({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(le("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(le("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ce.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(le("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(le("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(le("LICENSE_CHANGED_EVENT",()=>{ts()})),t.push(le("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ce.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(le("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ce.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(le("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ce.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function ua(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[De]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function pa(){const s=(await chrome.storage.local.get(De))[De];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ma(){await chrome.storage.local.remove(De)}async function We(){f.getState().clearResults(),await ma()}async function Fe(){const t=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function ts(t){const s=await te({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),ss()}async function ss(){const{fetchMessages:t}=await ut(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>wa);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function ha(){const s=(await te({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function xa(){return chrome.runtime.connect({name:"audit-keepalive"})}let Me=null;async function ga(){if(Me===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Me=t.id)}catch{}}function as(){if(Me===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Me}).catch(()=>{})}function de(t){as(),J(t)}function fa({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,o]=h.useState(!0),[l,c]=h.useState(""),[u,d]=h.useState(!1),[p,m]=h.useState(null);async function x(g){var y;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const k=await te({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:l.trim()||void 0});k.success?(m({ok:!0,msg:`Sent (ref: ${k.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((y=k.error)==null?void 0:y.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:g=>a(g.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:g=>r(g.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:l,onChange:g=>c(g.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:g=>o(g.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:u?"Sending…":"Send"})]})]})}function kt({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const Pe=Jt("messages-client"),ba="https://api.wcagcheckr.com",ns="wcagcheckr",va=1e4;function ya(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function rs(t,s){const a=await $s();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":ya()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${ba}${t}`,{...s,headers:n,signal:AbortSignal.timeout(va)})}async function ja(t){try{const s=await rs(`/v1/products/${ns}/messages`,{userMode:t??null});return s.ok?await s.json():(Pe.warn("fetchMessages http",s.status),null)}catch(s){return Pe.warn("fetchMessages failed",s),null}}async function xe(t,s){try{const a=await rs(`/v1/products/${ns}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Pe.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Pe.warn("ackMessage failed",a),!1}}const wa=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:xe,fetchMessages:ja},Symbol.toStringTag,{value:"Module"})),Na=["http:","https:"];function ka(t){try{const s=new URL(t);return Na.includes(s.protocol)}catch{return!1}}function St(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const o=t.indexOf(")",i+2);if(o!==-1){const l=t.slice(a+1,i),c=t.slice(i+2,o);ka(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:l},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:l},`l-${n++}`)),a=o+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function is({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function o(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:St(c)},`p-${i++}`)),r=[]}function l(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,u)=>e.jsx("li",{children:St(c)},u))},`u-${i++}`)),n=[])}for(const c of s){const u=c.trimEnd();if(u===""){o(),l();continue}const d=/^[-*]\s+(.*)$/.exec(u);if(d){o(),n.push(d[1]);continue}l(),r.push(u)}return o(),l(),e.jsx("div",{className:"space-y-1.5",children:a})}const Sa={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},Aa={critical:"bg-rose-50 border-rose-200"};function os(){const t=f(m=>m.unreadMessageCount),s=f(m=>m.messages),a=f(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[o,l]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,l(!0);const g=setTimeout(()=>l(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),xe(x.id,"seen")}function u(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await xe(m.id,"dismissed")}async function p(m){m.ctaUrl&&(a(m.id,"clicked"),xe(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:u,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${o?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Ca,{active:t>0}),t>0&&e.jsx("span",{"aria-hidden":"true",className:"absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-rose-500 ring-2 ring-white"})]}),n&&e.jsx(Ia,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:p})]})}function Ca({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 Ia({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=l=>{r.current&&(r.current.contains(l.target)||s())},o=l=>{l.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{ss()},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 ${Sa[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(is,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function ls(){const t=f(i=>i.messages),s=f(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await xe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),xe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${Aa.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(is,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const ve=["matrix","report","delta","activity","guided","flows","scorecard","crawl","forensic","compliance"];function Ra(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function Ea(){var p,m;const t=f(x=>x.view),s=f(x=>x.setView),a=f(x=>x.setUserMode),n=f(x=>x.results),r=f(x=>x.status),[i,o]=h.useState(!1),l=((p=n[0])==null?void 0:p.pageUrl)??((m=n[0])==null?void 0:m.scope),c=Ra(l),u=n.length>0&&r!=="running";function d(){a("owner"),J({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick: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(os,{}),e.jsx(kt,{onClick:()=>void J({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(kt,{onClick:()=>o(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&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(Ta,{view:t,setView:s}),e.jsx(be,{open:i,onClose:()=>o(!1),title:"Send support message",children:e.jsx(fa,{onClose:()=>o(!1)})})]})}function Ta({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const o=(i+ve.length)%ve.length,l=ve[o];l&&(s(l),(c=a.current[o])==null||c.focus())}function r(i,o){switch(i.key){case"ArrowRight":i.preventDefault(),n(o+1);break;case"ArrowLeft":i.preventDefault(),n(o-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ve.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ve.map((i,o)=>{const l=t===i;return e.jsx("button",{ref:c=>{a.current[o]=c},role:"tab","aria-selected":l,tabIndex:l?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,o),className:l?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function $a({feature:t,upgradeUrl:s}){const[a,n]=h.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Xe,{open:a,onClose:()=>n(!1)})]})}const La="https://wcagcheckr.com/upgrade";function Ua(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState(null),[c,u]=h.useState(ze),[d,p]=h.useState(ze[0].id),m=f(w=>w.status),x=f(w=>w.tier),g=f(w=>w.results.length>0),y=m==="running";h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"matrixPresets"}),te({type:"SETTINGS_GET",key:"activePresetId"})]).then(([w,v])=>{const U=Array.isArray(w.data)?w.data:null;u(U&&U.length>0?U:ze),typeof v.data=="string"&&p(v.data)})},[]);function k(w){const v=c.find(U=>U.id===w);v&&(p(w),J({type:"SETTINGS_SET",key:"activePresetId",value:w}),J({type:"SETTINGS_SET",key:"stateMatrix",value:v.matrix}))}const T=Xt(x,"storybookAutoIterate");h.useEffect(()=>{const w=le("ELEMENT_PICKED_EVENT",(U,O)=>{n(!1);const G=O.frameId;F(G),i({selector:U.selector,frameId:G})}),v=le("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{w(),v()}},[]);async function N(){const w=await oe();w&&(n(!0),await ue(w,{type:"PICKER_ACTIVATE_REQUEST",tabId:w}))}function E(){r&&(F(r.frameId),de({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function b(){if(!T){l("storybook:auto-iterate");return}F(),de({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function S(){F(),de({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function j(){F(),de({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function C(){F(),de({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function _(){F(),de({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function $(){J({type:"CANCEL_AUDIT"})}async function F(w){f.getState().setPinned(null);const v=await oe();if(v)try{await ue(v,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:v},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:y||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",T?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:w=>k(w.target.value),disabled:y||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))}),t==="single-element"?e.jsx(Oa,{picking:a,picked:r,isRunning:y,onPick:N,onRun:E,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:j,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Scan page"}):t==="quick-scan"?e.jsx("button",{onClick:C,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:y?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:_,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:y?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:S,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Audit all iframes"}):e.jsx("button",{onClick:b,disabled:y,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:y?"Auditing…":"Audit all stories"}),y&&e.jsx("button",{onClick:$,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!y&&g&&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&&!a&&!y&&e.jsx(_a,{selector:r.selector,onRepick:N,onClear:()=>i(null)})]}),e.jsx(be,{open:o!==null,onClose:()=>l(null),title:"Upgrade to continue",children:e.jsx($a,{feature:o??"",upgradeUrl:La})})]})}function Oa({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function _a({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Da={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Fa={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function Ma(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[o,l]=h.useState("off"),u=f(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await oe();g&&(l(x),x==="off"?await ue(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await ue(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function p(x){const g=await oe();if(g){if(t&&await ue(g,{type:Da[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await ue(g,{type:Fa[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await oe();if(x){if(a){await ue(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(u.length===0){i("Run an audit first.");return}try{const g=await Ie(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:u});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(ye,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(ye,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>p("tab-order")}),e.jsx(ye,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>p("reading-order")}),e.jsx(ye,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ye,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:m}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:o,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${o==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ye({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Pa(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 Ga(){const t=f(c=>c.status),s=f(c=>c.progress),a=f(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":Pa(s.currentState),o=n?100:s.current/s.total*100,l=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(At,{label:r,detail:i,pct:o,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),l&&e.jsx(At,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function At({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:o,fillClass:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${o}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${l}`,style:{width:`${a}%`}})})]})}const je={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Va(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const Wa={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 Ge({violation:t,alreadyAcknowledged:s}){const a=f(N=>N.pinnedMatchKey),n=f(N=>N.pinnedFound),r=f(N=>N.setPinned),i=f(N=>{var E;return(E=N.results[0])==null?void 0:E.frameId}),o=f(N=>{var E;return(E=N.results[0])==null?void 0:E.scope}),l=f(N=>N.results),c=f(N=>N.acknowledgedKeys.has(t.matchKey)),u=f(N=>N.markAcknowledged),d=f(N=>N.markUnacknowledged),p=s||c,m=a===t.matchKey,x=m&&!n;async function g(N){try{return(await Ie(N,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:N,selector:t.target.selector},i)).found}catch{return!0}}async function y(){const N=await oe();if(!N)return;if(m){r(null);try{await ue(N,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:N},i)}catch{}return}const E=await g(N);r(t.matchKey,E)}function k(N){N.stopPropagation(),t.currentState.breakpoint.width<=640&&as(),(async()=>{const E=await oe();if(!E)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:E,state:t.currentState,scope:o,frameId:i})}catch{}const b=await g(E);r(t.matchKey,b)})()}async function T(N){N.stopPropagation();const E=await oe();if(!E)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:E,state:Ka(),scope:o,frameId:i})}catch{J({type:"STATE_RESET_REQUEST",tabId:E})}const b=await g(E);r(t.matchKey,b)}return e.jsxs("button",{type:"button",onClick:y,"aria-pressed":m,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
- ${m?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Wa[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(qa,{violation:t}),e.jsx(Ja,{violation:t}),e.jsx(Ya,{violation:t}),e.jsx(Qa,{text:t.target.failureSummary}),e.jsx(Xa,{ruleId:t.ruleId}),m&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Ba(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:k,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k(N))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:T,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),T(N))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),x&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:N=>{N.stopPropagation(),d(t.matchKey),za(t,l)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:N=>{N.stopPropagation(),u(t.matchKey),Ha(t,l)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:N=>N.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Ba(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 Ha(t,s){await Os({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await cs(t.componentId,s)}async function za(t,s){await Us(t.componentId,t.matchKey),await cs(t.componentId,s)}async function cs(t,s){const a=s.flatMap(n=>n.violations);try{const n=await te({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function Ka(){const t=Zt.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function ds(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function qa({violation:t}){const s=ds(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]})]})}function Qa({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 Ya({violation:t}){const s=Va(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function Ja({violation:t}){const s=ds(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Ls(t.matchKey).then(o=>{o&&!i&&n({kind:"ready",suggestion:o})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",o=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),l=o.results.find(c=>c.matchKey===t.matchKey);l?(await _s(l),n({kind:"ready",suggestion:l})):n({kind:"empty",reason:o.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,o)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},o))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function Xa({ruleId:t}){const s=Ds(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const Ze=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function pt(t){const s=Ze.map(r=>en(r,t)),a=Za(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function Za(t){const s=t.filter(o=>o==="A").length,a=t.filter(o=>o==="C").length,n=t.filter(o=>o==="D").length,r=t.filter(o=>o==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function en(t,s){const a=new Set(t.axeRules),n=s.violations.filter(v=>a.has(v.ruleId)),r=s.manualRuns.filter(v=>t.igtWorkflowIds.includes(v.workflowId)),i=t.igtWorkflowIds.map(v=>s.workflows.find(U=>U.id===v)).filter(v=>v!=null);let o=i.length>0;for(const v of i){const U=r.find(G=>G.workflowId===v.id);if((U?Object.keys(U.steps).length:0)!==v.steps.length){o=!1;break}}const l=r.some(v=>Object.keys(v.steps).length>0),c=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(v=>c.includes(v.workflowId)),d=c.map(v=>s.workflows.find(U=>U.id===v)).filter(v=>v!=null);let p=c.length>0&&d.length===c.length;for(const v of d){const U=u.find(G=>G.workflowId===v.id);if((U?Object.keys(U.steps).length:0)!==v.steps.length){p=!1;break}}let m=null;if(p)for(const v of u)v.completedAt&&(m===null||v.completedAt>m)&&(m=v.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,y=s.interactiveAuditVerdicts,k=[];y&&(t.id==="tab-order"&&y.focusOrder&&k.push({verdict:y.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(y.keyboardTrap&&k.push({verdict:y.keyboardTrap,criterionId:"2.1.2"}),y.focusVisible&&k.push({verdict:y.focusVisible,criterionId:"2.4.7"})));const T=k.some(v=>v.verdict==="fail");if(k.length>0&&k.every(v=>v.verdict==="pass")&&c.length>0&&!p)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:k.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:k.map(v=>v.criterionId)};if(p&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const E=t.axeRules.length>0||t.heuristic!=null,b=t.igtWorkflowIds.length>0;if(E?!s.auditRan:!l)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:b||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const j={critical:0,serious:0,moderate:0,minor:0};for(const v of lt(n))j[v.impact]++;k.length>0&&k.every(v=>v.verdict==="pass")||(j.serious+=x),T&&(j.serious+=k.filter(v=>v.verdict==="fail").length);for(const v of r){const U=i.find(O=>O.id===v.workflowId);if(U)for(const O of U.steps){const G=v.steps[O.id];(G==null?void 0:G.status)==="fail"&&(O.severity==="required"?j.serious++:j.moderate++)}}const _=j.critical>0,$=j.serious>0;let F;j.critical>=5?F="F":j.critical>=1?F="D":j.serious>=1?F="C":j.moderate>=1?F="B":F="A";const w=F!=="A"&&(b&&!o||c.length>0&&!p);return{id:t.id,label:t.label,letter:F,untested:!1,needsIgt:w,igtCompleted:o,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:j,caps:{cappedAtC:_,cappedAtB:$}}}const et="dismissedFindings";function Be(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ge(t){return`reading-order::${t}`}function fe(t){return`tab-order::${t}`}async function He(){try{const t=await chrome.storage.local.get(et),s=t==null?void 0:t[et];if(s&&typeof s=="object")return s}catch{}return{}}async function mt(t){await chrome.storage.local.set({[et]:t})}async function Ve(t){return(await He())[Be(t)]??{}}async function us(t,s,a,n){const r=await He(),i=Be(t),o=r[i]??{};o[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=o,await mt(r)}async function Re(t,s){if(s.length===0)return;const a=await He(),n=Be(t),r=a[n]??{},i=new Date().toISOString();for(const o of s)r[o.key]={reason:o.reason,dismissedAt:i,snippet:o.snippet};a[n]=r,await mt(a)}async function ps(t,s){const a=await He(),n=Be(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await mt(a))}const Ji=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:us,addDismissals:Re,dismissalKeyForReadingOrder:ge,dismissalKeyForTabOrder:fe,getDismissalsForUrl:Ve,removeDismissal:ps},Symbol.toStringTag,{value:"Module"}));function ms(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function hs(t){return`${ct(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function tn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=hs(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Ct={critical:0,serious:1,moderate:2,minor:3};function sn(){var N,E,b,S;const t=f(j=>j.results),s=f(j=>j.componentId),a=f(j=>j.setView),n=((N=t[0])==null?void 0:N.pageUrl)??((E=t[0])==null?void 0:E.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(new Set),[c,u]=h.useState({});if(h.useEffect(()=>{if(!s){u({});return}let j=!1;const C=async()=>{const $=await qt(s);if(j)return;const F={};for(const w of $)w.criterionId==="2.4.3"?F.focusOrder=w.verdict:w.criterionId==="2.1.2"?F.keyboardTrap=w.verdict:w.criterionId==="2.4.7"?F.focusVisible=w.verdict:w.criterionId==="1.3.2"&&(F.readingOrder=w.verdict);u(F)};C();const _=$=>{$.interactiveAuditResults&&C()};return chrome.storage.local.onChanged.addListener(_),()=>{j=!0,chrome.storage.local.onChanged.removeListener(_)}},[s]),h.useEffect(()=>{if(!n)return;Ve(n).then(i);const j=()=>{document.visibilityState==="visible"&&n&&Ve(n).then(i)};return document.addEventListener("visibilitychange",j),()=>document.removeEventListener("visibilitychange",j)},[n]),h.useEffect(()=>{if(!s){l(new Set);return}let j=!1;const C=async()=>{const $=await chrome.storage.local.get("igtRuns");if(j)return;const w=(($==null?void 0:$.igtRuns)??{})[s]??{},v=new Set;for(const U of ee){const O=w[U.id];O&&Object.keys(O.steps).length===U.steps.length&&v.add(U.id)}l(v)};C();const _=()=>{document.visibilityState==="visible"&&C()};return document.addEventListener("visibilitychange",_),()=>{j=!0,document.removeEventListener("visibilitychange",_)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((j,C)=>j+C.durationMs,0),p=t.reduce((j,C)=>j+C.violations.length,0),m=tn(t);m.sort((j,C)=>{const _=Ct[j.representative.impact]??99,$=Ct[C.representative.impact]??99;return _!==$?_-$:C.states.length-j.states.length});const x=t.map(j=>ms(j.state)).join(`
4
- `),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",y=o.has("keyboard")||g?0:(((b=t[0])==null?void 0:b.tabOrderIssues)??[]).filter(j=>!(fe(j.selector)in r)).length,k=c.readingOrder!==void 0,T=o.has("page-structure")||k?0:(((S=t[0])==null?void 0:S.readingOrderIssues)??[]).filter(j=>!(ge(j.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(on,{violations:t.flatMap(j=>j.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(y>0||T>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[y>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:y})," tab-order issue",y===1?"":"s"," (WCAG 2.4.3)"]}),y>0&&T>0&&" · ",T>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:T})," reading-order issue",T===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:x,"aria-label":`${t.length} states tested: ${x.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",m.length," unique ",m.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(nn,{groups:m,totalStates:t.length,violations:t.flatMap(j=>j.violations),interactiveVerdicts:c})]})}const an={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function nn({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=pt({violations:a,auditRan:!0,manualRuns:[],workflows:ee,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,o=new Set;for(const c of Ze){for(const u of c.axeRules)o.add(u);i.set(c.id,[])}const l=[];for(const c of t){let u=!1;for(const d of Ze)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),u=!0;break}u||l.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const u=i.get(c.id)??[];return e.jsx(It,{subGrade:c,groups:u,totalStates:s},c.id)}),l.length>0&&e.jsx(It,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:l,totalStates:s})]})}function It({subGrade:t,groups:s,totalStates:a}){const[n,r]=h.useState(!1),[i,o]=h.useState("idle"),[l,c]=h.useState(null),[u,d]=h.useState(0),p=s.length>0,m=an[t.letter],x=s.filter(k=>k.representative.ruleId==="color-contrast"||k.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function y(k){k.stopPropagation(),o("loading"),c(null);try{const T=x.map(E=>{const b=E.representative.target.outerHTML,S=E.representative.target.failureSummary,j=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(S),C=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(S);if(!j||!C)return null;const _=E.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:E.representative.matchKey,foreground:j[1],background:C[1],fontSize:16,fontWeight:400,targetLevel:_,_html:b}}).filter(E=>E!==null);if(T.length===0){o("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const N=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:T.map(({_html:E,...b})=>b)});if(N.unavailableReason&&N.results.length===0){o("error"),c(N.unavailableReason);return}await Fs(N.results),o("done"),d(E=>E+1),n||r(!0)}catch(T){o("error"),c(T instanceof Error?T.message:String(T))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(k=>!k),"aria-expanded":n,disabled:!p,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${m}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:p?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:k=>void y(k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),y(k))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${x.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${x.length}`:`✨ Suggest for all ${x.length}`}),p&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&l&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:l}),n&&p&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(k=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ge,{violation:k.representative}),e.jsx(ln,{states:k.states,totalStates:a})]},`${hs(k.representative)}::${u}`))})]})}const rn={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function on({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=f(u=>u.setView),o=pt({violations:t,auditRan:!0,manualRuns:a,workflows:ee,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=lt(t).length;return e.jsx("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${rn[o]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:o})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function ln({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(ms))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
5
- `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const 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 ae,ne,re,I,H,X,W;const[a,n]=h.useState([]),[r,i]=h.useState([]),[o,l]=h.useState(new Set),[c,u]=h.useState(null),[d,p]=h.useState({}),[m,x]=h.useState(new Set),g=f(A=>A.status),y=f(A=>A.progress),k=f(A=>A.freshThisSession),T=f(A=>A.results),N=(ae=T[0])==null?void 0:ae.startedAt,E=((ne=T[0])==null?void 0:ne.pageUrl)??((re=T[0])==null?void 0:re.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let A=!1;return chrome.storage.local.get("igtRuns").then(M=>{if(A)return;const Q=((M==null?void 0:M.igtRuns)??{})[s]??{};n(Object.values(Q))}),()=>{A=!0}},[s]),h.useEffect(()=>{if(!E){i([]);return}let A=!1;return Ue(E).then(M=>{A||i(M)}),()=>{A=!0}},[E]),g==="running")return e.jsx(bn,{current:y==null?void 0:y.current,total:y==null?void 0:y.total});const b=pt({violations:t,auditRan:T.length>0,manualRuns:a,workflows:ee,heuristicCounts:{tabOrder:((H=(I=T[0])==null?void 0:I.tabOrderIssues)==null?void 0:H.length)??0,readingOrder:((W=(X=T[0])==null?void 0:X.readingOrderIssues)==null?void 0:W.length)??0}}),S=f(A=>A.acknowledgedKeys),j=T.length>0?Qt(T,{runs:a,workflows:ee},"2.1","AA",S,r):void 0,C=T.length>0?Ms(dt({audits:T,igtRuns:a,workflows:ee,acknowledgedMatchKeys:S,incompleteResolutions:r}),ee):void 0,_=j?j.failingCriteria.length>0||j.inconclusiveCriteria.length>0:!1,$=_&&b.overallLetter==="A"?"B":b.overallLetter;async function F(A){var me;if(!E||!((me=j==null?void 0:j.inconclusiveReasons)!=null&&me[A]))return;const Z=j.inconclusiveReasons[A].filter(se=>se.source==="axe-incomplete"&&se.elements&&se.elements.length>0);if(Z.length===0)return;l(se=>new Set(se).add(A)),u(null);const Q=[];let q=0;try{for(const Y of Z){const R=await J({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:Y.ruleOrStepId,pageUrl:Y.pageUrl??E,wcagCriterion:A,elements:Y.elements??[],targetLevel:"AA"});if(R!=null&&R.unavailableReason){u(R.unavailableReason);break}R!=null&&R.resolutions&&(Q.push(...R.resolutions),q+=R.totalCostUsd??0)}if(E){const Y=await Ue(E);i(Y)}const se={total:Q.length,pass:Q.filter(Y=>Y.verdict==="pass").length,fail:Q.filter(Y=>Y.verdict==="fail").length,uncertain:Q.filter(Y=>Y.verdict==="uncertain").length,costUsd:q,resolutions:Q};p(Y=>({...Y,[A]:se}))}finally{l(se=>{const Y=new Set(se);return Y.delete(A),Y})}}function w(A){x(M=>{const Z=new Set(M);return Z.has(A)?Z.delete(A):Z.add(A),Z})}async function v(A){var R,B;if(!E)return;const M=((R=j==null?void 0:j.inconclusiveReasons)==null?void 0:R[A])??[],Z=((B=j==null?void 0:j.failingReasons)==null?void 0:B[A])??[],Q=[],q=new Set;for(const D of M){if(D.source!=="axe-incomplete"||!D.elements)continue;const P=D.pageUrl??E;for(const z of D.elements){const K=`${P}::${D.ruleOrStepId}::${z.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:D.ruleOrStepId,pageUrl:P,selector:z.selector}))}}for(const D of Z){if(D.source!=="ai"||!D.selector)continue;const P=D.ruleOrStepId.startsWith("ai-resolved::")?D.ruleOrStepId.slice(13):D.ruleOrStepId,z=D.pageUrl??E,K=`${z}::${P}::${D.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:P,pageUrl:z,selector:D.selector}))}if(Q.length===0)return;const me=new Date().toISOString(),se=[];for(const D of Q){const P=r.find(z=>z.pageUrl===D.pageUrl&&z.ruleId===D.ruleId&&z.selector===D.selector);P&&P.verdict==="pass"&&P.reasoning.startsWith("Marked as visually verified")||se.push({pageUrl:D.pageUrl,ruleId:D.ruleId,selector:D.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${me.slice(0,10)}.`,resolvedAt:me,costUsd:0,wcagCriterion:A})}if(se.length===0)return;await Ps(se);const Y=await Ue(E);i(Y),p(D=>({...D,[A]:{total:se.length,pass:se.length,fail:0,uncertain:0,costUsd:0,resolutions:se}}))}const U=(()=>{if(!_||b.overallLetter!=="A"||!j)return null;const A=j.inconclusiveCriteria.length,M=j.failingCriteria.length,Z=[];M>0&&Z.push(`${M} WCAG ${j.targetLevel} ${M===1?"criterion":"criteria"} failing`),A>0&&Z.push(`${A} WCAG ${j.targetLevel} ${A===1?"criterion":"criteria"} inconclusive`);const Q=M>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${Z.join(" + ")}. ${Q}`})();let O=0;for(const A of ee){const M=a.find(Q=>Q.workflowId===A.id);if(!M)continue;A.steps.every(Q=>{const q=M.steps[Q.id];return(q==null?void 0:q.status)==="pass"||(q==null?void 0:q.status)==="fail"||(q==null?void 0:q.status)==="skip"||(q==null?void 0:q.status)==="not-applicable"})&&O++}const G=lt(t.filter(A=>!S.has(A.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!k&&N&&e.jsx(vn,{scannedAt:N}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${cn[$]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:$})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",b.subGrades.length," verification areas below. Untested areas count as F until verified."]}),U&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:U})]})]}),b.isLawsuitRisk&&e.jsx(hn,{areas:b.warningAreas}),e.jsx(xn,{grades:b.subGrades}),j&&e.jsx(pn,{coverage:j,onResolveWithAi:F,onMarkVisuallyVerified:v,resolving:o,resolveError:c,lastResolveResult:d,expandedResultFor:m,onToggleResultDetail:w}),C&&e.jsx(mn,{layers:C}),e.jsx(fn,{violationsRemaining:G,manualCompleted:O,manualTotal:ee.length}),O>0||T.length>0?e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Manual coverage (Guided Tests)"}),e.jsxs("div",{className:"text-[11px] text-slate-700 mb-1.5",children:[e.jsx("strong",{children:O})," of ",e.jsx("strong",{children:ee.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:`${O/ee.length*100}%`}})})]}):null]})}function pn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:o,onToggleResultDetail:l}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[u,d]=h.useState(c>0&&c<=3),p=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),m=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${m?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${m?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",p,"%)"]}),m&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!m&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const y=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",y,"."]})})(),!m&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!m&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!m&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:u?"hide":"show list"})]}),u&&!m&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(y=>{var C,_;const k=g.kind==="inconclusive"?(C=t.inconclusiveReasons)==null?void 0:C[y]:void 0,T=g.kind==="failing"?(_=t.failingReasons)==null?void 0:_[y]:void 0,N=k==null?void 0:k.some($=>$.source==="axe-incomplete"&&$.elements&&$.elements.length>0),E=T==null?void 0:T.some($=>$.source==="ai"),b=(n==null?void 0:n.has(y))??!1,S=i==null?void 0:i[y],j=(o==null?void 0:o.has(y))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",y]}),(g.kind==="inconclusive"&&N||g.kind==="failing"&&E)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:b,onClick:()=>s(y),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:b?"Resolving…":S?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:b,onClick:()=>a(y),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:g.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),S&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",S.total," ",S.total===1?"verdict":"verdicts",":",S.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",S.pass," pass"]}),S.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",S.fail," fail"]}),S.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",S.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",S.costUsd.toFixed(4)]}),l&&e.jsx("button",{type:"button",onClick:()=>l(y),className:"ml-auto text-[10px] underline text-brand-700",children:j?"hide reasoning":"show reasoning"})]}),S.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",S.uncertain," ",S.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),S.pass===S.total&&S.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),j&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:S.resolutions.map(($,F)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:$.verdict==="pass"?"text-emerald-700 font-semibold":$.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:$.verdict==="pass"?"✓":$.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:$.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:$.reasoning})]},F))})]}),T&&T.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:T.map(($,F)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[$.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),$.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," fail — "]}),$.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," fail — "]}),$.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:$.selector}),$.notes&&e.jsx("span",{className:"text-rose-700",children:$.notes})]},F))}),k&&k.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:k.map(($,F)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[$.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," — "]}),$.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," skipped — "]}),$.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," — "]}),$.resolutionHint,$.elements&&$.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",$.elements.length===1?"element":`${$.elements.length} elements`,":"," ",$.elements.slice(0,3).map((w,v,U)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:w.selector}),v<U.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},v)),$.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",$.elements.length-3," more"]})]})]},F))}):g.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},y)})})]},g.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const Rt={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function mn({layers:t}){const s=f(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,o=r.blocked.length,l=r.unevaluated.length,c=r.cleared,u=i>0&&o===0&&l===0,d=u?"text-emerald-700":o>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${u?"bg-emerald-500 text-white":o>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:u?"✓":o>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:Rt[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),o>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",o," blocked"]}),l>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",l," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:Rt[n].hint}),n==="human"&&l>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function hn({areas:t}){const s=t.map(a=>a.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((a,n)=>e.jsxs("span",{children:[e.jsx("strong",{children:a}),n<s.length-1?", ":""]},a)),". Fix these before relying on the overall grade."]})})]})}function xn({grades:t}){const s=f(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${dn[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(gn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function gn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=ee.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?xs(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",n?` ${n} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function fn({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(o=>o.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(o=>!o.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((o,l)=>{const c=l===i,u=o.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:u?"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:u?"✓":`${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:u?"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 bn({current:t,total:s}){return e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg bg-white p-4 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:typeof t=="number"&&typeof s=="number"?`State ${t} of ${s}. Grade will appear when the scan completes.`:"Grade will appear when the scan completes."})]})]})}function vn({scannedAt:t}){const s=Date.now()-new Date(t).getTime();return e.jsxs("div",{className:"bg-amber-50 border-b border-amber-200 px-3 py-1.5 text-[11px] text-amber-900 flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),e.jsxs("span",{children:["Showing a previous scan (",xs(s)," old). Re-scan to grade the current page state."]})]})}function xs(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}function yn(){const t=f(a=>a.results),s=f(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(un,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(jn,{})]})}function jn(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(we,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(we,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(we,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(we,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(we,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function we({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const 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[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,o=r.description,l=s.length;return l===1?e.jsx(Ge,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${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:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,u)=>e.jsx(Ge,{violation:c},u))})]})}function kn(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const Sn={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function gs({open:t,onClose:s,format:a,content:n,filename:r}){const i=Es(new Blob([n]).size);function o(){ot(n,r),s()}function l(){it(n),s()}return e.jsxs(be,{open:t,onClose:s,title:Sn[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Et=7800;function An(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`**Component:** \`${s??"unknown"}\``),o.push(""),o.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`### \`${d.ruleId}\` — ${d.impact}`),o.push(""),o.push(d.description),o.push(""),o.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),o.push(`- **Selector:** \`${d.target.selector}\``),o.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&o.push(`- **More info:** ${d.helpUrl}`),o.push(""),o.push("```html"),o.push(d.target.outerHTML),o.push("```"),o.push("");o.push("---"),o.push(""),o.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const l=o.join(`
6
- `),c=new URLSearchParams({title:i,body:l});let u=`${n}/issues/new?${c.toString()}`;return u.length>Et&&(u=u.slice(0,Et)),{url:u,title:i,body:l}}const Tt=7800;function Cn(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,o=[];o.push(`Component: ${s??"unknown"}`),o.push(""),o.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),o.push(""),o.push("---"),o.push("");for(const d of r)o.push(`Rule: ${d.ruleId} (${d.impact})`),o.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),o.push(`Description: ${d.description}`),o.push(`Selector: ${d.target.selector}`),o.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&o.push(`More info: ${d.helpUrl}`),o.push(""),o.push(`HTML: ${d.target.outerHTML}`),o.push(""),o.push("---"),o.push("");o.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const l=o.join(`
7
- `),c=new URLSearchParams({summary:i,description:l});let u=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return u.length>Tt&&(u=u.slice(0,Tt)),{url:u,summary:i,description:l}}const $t=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],In=["wcag-component-auditor","wcag-forensic-log"];async function Rn(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get($t);s=Object.keys(n).length,await chrome.storage.local.remove($t)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of In)try{await En(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function En(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const tt="accessibilityStatementInputs:v1";async function Tn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(tt))[tt];return s&&typeof s=="object"?s:null}async function $n(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[tt]:t})}function Ln({open:t,onClose:s,results:a}){const[n,r]=h.useState("eaa"),[i,o]=h.useState(""),[l,c]=h.useState(""),[u,d]=h.useState("partial"),[p,m]=h.useState(""),[x,g]=h.useState(""),[y,k]=h.useState(""),[T,N]=h.useState(""),[E,b]=h.useState("English"),[S,j]=h.useState("wcagcheckr (self-evaluation)"),[C,_]=h.useState("2.1"),[$,F]=h.useState("AA"),[w,v]=h.useState(!1),[U,O]=h.useState(null),G=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var H,X,W,A;const I=await Tn();if(I&&(I.framing&&r(I.framing),I.organizationName&&o(I.organizationName),I.siteUrl&&c(I.siteUrl),I.conformanceStatus&&d(I.conformanceStatus),(H=I.contact)!=null&&H.email&&m(I.contact.email),(X=I.contact)!=null&&X.phone&&g(I.contact.phone),(W=I.contact)!=null&&W.formUrl&&k(I.contact.formUrl),I.countryCode&&N(I.countryCode),I.language&&b(I.language),I.auditedBy&&j(I.auditedBy),I.wcagVersion&&_(I.wcagVersion),I.wcagLevel&&F(I.wcagLevel)),!(I!=null&&I.siteUrl)&&((A=a[0])!=null&&A.pageUrl))try{const M=new URL(a[0].pageUrl);c(`${M.protocol}//${M.host}/`)}catch{}I!=null&&I.conformanceStatus||d(Gs(a)),setTimeout(()=>{var M;return(M=G.current)==null?void 0:M.focus()},50)})()},[t,a]),!t)return null;function ae(){var W;const I=new Date().toISOString().slice(0,10),H=(W=a[0])!=null&&W.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):I,X={};return p.trim()&&(X.email=p.trim()),x.trim()&&(X.phone=x.trim()),y.trim()&&(X.formUrl=y.trim()),{framing:n,organizationName:i.trim(),siteUrl:l.trim(),conformanceStatus:u,preparedAt:I,evaluatedAt:H,contact:X,countryCode:T||null,language:E.trim()||"English",auditedBy:S.trim()||"wcagcheckr (self-evaluation)",wcagVersion:C,wcagLevel:$}}function ne(I){if(!I.organizationName)return"Organization name is required.";if(!I.siteUrl)return"Site URL is required.";try{new URL(I.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!I.contact.email&&!I.contact.phone&&!I.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function re(I){O(null);const H=ae(),X=ne(H);if(X){O(X);return}v(!0);try{await $n(H);const W=await te({type:"EXPORT_REQUEST",format:I==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:H}),A=(W==null?void 0:W.content)??"";if(!A||A.startsWith("# Accessibility statement — error")){O(A||"Export failed — no response.");return}try{await navigator.clipboard.writeText(A)}catch{}const M=new Blob([A],{type:I==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),Z=URL.createObjectURL(M);window.open(Z,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(Z),6e4),s()}catch(W){O(W instanceof Error?W.message:String(W))}finally{v(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:n==="eaa",onChange:()=>r("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:n==="wad",onChange:()=>r("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:G,type:"text",value:i,onChange:I=>o(I.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:l,onChange:I=>c(I.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:u,onChange:I=>d(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:C,onChange:I=>_(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:$,onChange:I=>F(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:p,onChange:I=>m(I.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:I=>g(I.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:y,onChange:I=>k(I.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:T,onChange:I=>N(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Vs).map(([I,H])=>e.jsxs("option",{value:I,children:[I," — ",H.name.replace(/^[A-Z]+\s*—\s*/,"")]},I))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:E,onChange:I=>b(I.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:S,onChange:I=>j(I.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),U&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:U})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void re("markdown"),disabled:w,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:w?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void re("html"),disabled:w,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:w?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:w,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function Un(){const t=f(w=>w.delta),s=f(w=>w.componentId),a=f(w=>w.results),n=f(w=>w.tier),r=f(w=>w.baselineList),i=f(w=>w.siteCrawlReport),[o,l]=h.useState(""),[c,u]=h.useState(""),[d,p]=h.useState(!1),[m,x]=h.useState(!1),[g,y]=h.useState(null),[k,T]=h.useState(null),[N,E]=h.useState(!1);h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"githubRepoUrl"}),te({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([w,v])=>{l(typeof w.data=="string"?w.data:""),u(typeof v.data=="string"?v.data:"")})},[]);const b=Xt(n,"exportJson"),S=es[n].maxBaselines,j=r.some(w=>w.componentId===s),C=j||r.length<S;if(!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit to see the delta against your baseline."});async function _(){if(!s||a.length===0)return;const w=a.flatMap(re=>re.violations),v=a.flatMap(re=>re.announcements??[]),U=a.flatMap(re=>re.focusEvents??[]),O=a[0],ae=(await te({type:"SETTINGS_GET",key:"stateMatrix"})).data??Zt;await J({type:"BASELINE_SET",componentId:s,violations:w,announcements:v,focusEvents:U,snapshotMeta:{url:window.location.href,axeVersion:O.axeVersion,matrixConfig:ae,capturedAt:new Date().toISOString()}});const ne=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:w,announcements:v,focusEvents:U,currentMatrix:ae});f.getState().setDelta(ne.delta),ce.polite(`Baseline saved for ${s}.`)}async function $(){if(!s||!j||!window.confirm(`Remove the saved baseline for "${s}"?
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/copy-ai-fixer-prompt-Ca9DEwvW.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Dc5lvxvY.js","assets/site-report-renderer--kSYqnJz.js","assets/scheduled-audit-runner-DHCThfcB.js","assets/ai-usage-log-DBBVxutJ.js"])))=>i.map(i=>d[i]);
2
+ var Ts=Object.defineProperty;var $s=(t,s,a)=>s in t?Ts(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var yt=(t,s,a)=>$s(t,typeof s!="symbol"?s+"":s,a);import{R as Ae,i as ce,r as h,j as e,M as be,C as Xe,l as Ls,o as it,t as lt,m as Qt,s as Yt,k as Ee}from"./styles-BFNj1zaE.js";import{s as Us,g as Ds,a as le,b as Os,u as _s,c as Fs,d as Ms,e as Ps,f as ot,h as Jt,A as ee,l as ct,i as Gs,j as Ue,k as Xt,m as Vs,n as dt,o as Ws,p as Bs,N as Hs,q as zs,O as Ks,r as qs,t as Qs,v as Ys,w as jt,x as Js,y as Zt,z as Xs,B as Zs,C as ea,D as ta,E as sa,F as aa,T as na,G as ra,H as ia,I as wt,J as Nt,K as la,L as kt,M as oa,P as ca,Q as da,R as ua,S as pa}from"./scheduled-audit-runner-DHCThfcB.js";import{_ as ut}from"./diff-DA41zYPc.js";import{o as oe,r as te,s as J,c as es,b as ue,d as Ie}from"./crash-reporter-Dc5lvxvY.js";import{B as ze,i as ts,f as ss,T as as}from"./ai-usage-log-DBBVxutJ.js";const St=t=>{let s;const a=new Set,n=(u,d)=>{const p=typeof u=="function"?u(s):u;if(!Object.is(p,s)){const m=s;s=d??(typeof p!="object"||p===null)?p:Object.assign({},s,p),a.forEach(x=>x(s,m))}},r=()=>s,o={setState:n,getState:r,getInitialState:()=>c,subscribe:u=>(a.add(u),()=>a.delete(u))},c=s=t(n,r,o);return o},ma=t=>t?St(t):St,ha=t=>t;function xa(t,s=ha){const a=Ae.useSyncExternalStore(t.subscribe,Ae.useCallback(()=>s(t.getState()),[t,s]),Ae.useCallback(()=>s(t.getInitialState()),[t,s]));return Ae.useDebugValue(a),a}const At=t=>{const s=ma(t),a=n=>xa(s,n);return Object.assign(a,s),a},ga=t=>t?At(t):At,f=ga(t=>({status:"idle",progress:null,results:[],delta:null,componentId:null,errorMessage:null,freshThisSession:!1,baselineList:[],tier:"trial",trialDaysRemaining:null,seatsUsed:null,seatsTotal:null,planCode:null,licenseDaysRemaining:null,pastDue:!1,messages:[],unreadMessageCount:0,criticalUnacked:!1,view:"matrix",userMode:null,siteCrawlStatus:"idle",siteCrawlProgress:null,siteCrawlReport:null,siteCrawlError:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null,acknowledgedKeys:new Set,setStatus:s=>t({status:s}),startNewScan:()=>t({status:"running",results:[],delta:null,errorMessage:null,progress:null,componentId:null,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setProgress:s=>t({progress:s}),setResults:(s,a,n)=>t({results:s,delta:a,componentId:n,status:"complete",errorMessage:null,freshThisSession:!0,aiProgress:null,pinnedMatchKey:null,pinnedFound:!0}),setDelta:s=>t({delta:s}),setError:s=>t({errorMessage:s,status:"failed"}),setBaselineList:s=>t({baselineList:s}),clearResults:()=>t({results:[],delta:null,componentId:null,errorMessage:null,progress:null,status:"idle",freshThisSession:!1,pinnedMatchKey:null,pinnedFound:!0,aiFailure:null,aiProgress:null}),setTier:(s,a)=>t({tier:s,trialDaysRemaining:(a==null?void 0:a.trialDaysRemaining)??null,seatsUsed:(a==null?void 0:a.seatsUsed)??null,seatsTotal:(a==null?void 0:a.seatsTotal)??null,planCode:(a==null?void 0:a.planCode)??null,licenseDaysRemaining:(a==null?void 0:a.licenseDaysRemaining)??null,pastDue:(a==null?void 0:a.pastDue)??!1}),setView:s=>t({view:s}),setUserMode:s=>t({userMode:s}),setSiteCrawlStatus:s=>t({siteCrawlStatus:s}),setSiteCrawlProgress:s=>t({siteCrawlProgress:s}),setSiteCrawlReport:s=>{t({siteCrawlReport:s}),Us(s)},setSiteCrawlError:s=>t({siteCrawlError:s}),setPinned:(s,a=!0)=>t({pinnedMatchKey:s,pinnedFound:a}),setAiFailure:s=>t({aiFailure:s}),clearAiFailure:()=>t({aiFailure:null}),setAiProgress:s=>t({aiProgress:s}),setAcknowledgedKeys:s=>t({acknowledgedKeys:s}),markAcknowledged:s=>t(a=>({acknowledgedKeys:new Set(a.acknowledgedKeys).add(s)})),markUnacknowledged:s=>t(a=>{const n=new Set(a.acknowledgedKeys);return n.delete(s),{acknowledgedKeys:n}}),setMessages:(s,a,n)=>t({messages:s,unreadMessageCount:a,criticalUnacked:n}),applyMessageAck:(s,a)=>t(n=>{const r=n.messages.map(o=>o.id!==s?o:a==="seen"?{...o,seen:!0}:a==="dismissed"?{...o,dismissed:!0}:a==="acknowledged"?{...o,acknowledged:!0}:a==="clicked"?{...o,clicked:!0}:o).filter(o=>o.severity==="critical"?!o.acknowledged:!o.dismissed),i=r.filter(o=>!o.seen).length,l=r.some(o=>o.severity==="critical"&&!o.acknowledged);return{messages:r,unreadMessageCount:i,criticalUnacked:l}})})),_e="sidePanel:lastAudit";function fa(){const t=[];return t.push(oe("AUDIT_PROGRESS_EVENT",s=>{const a=f.getState().status==="running";f.getState().setProgress({current:s.current,total:s.total,currentState:s.currentState}),f.getState().setStatus("running"),a||ce.polite(`Audit running, scanning ${s.total} state${s.total===1?"":"s"}.`)})),t.push(oe("AUDIT_COMPLETE_EVENT",s=>{var i;f.getState().setResults(s.results,s.delta,s.componentId);const a=s.results.reduce((l,o)=>l+o.violations.length,0),n=((i=s.delta)==null?void 0:i.newCount)??0,r=s.delta?`Audit complete. ${n} new violation${n===1?"":"s"} versus baseline.`:`Audit complete. ${a} violation${a===1?"":"s"} found across ${s.results.length} state${s.results.length===1?"":"s"}.`;ce.polite(r),ba({results:s.results,delta:s.delta,componentId:s.componentId})})),t.push(oe("AUDIT_FAILED_EVENT",s=>{f.getState().setError(s.error.message)})),t.push(oe("AI_AUGMENTATION_PROGRESS_EVENT",s=>{const a=f.getState().aiProgress;f.getState().setAiProgress({currentCheckLabel:s.currentCheckLabel,current:s.current,total:s.total,candidatesDone:s.candidatesDone,candidatesTotal:s.candidatesTotal}),a||ce.polite(`AI augmentation running ${s.total} check${s.total===1?"":"s"}.`)})),t.push(oe("AI_AUGMENTATION_FAILED_EVENT",s=>{f.getState().setAiFailure({severity:s.severity,reason:s.reason,checksAttempted:s.checksAttempted,checksSucceeded:s.checksSucceeded,checksErrored:s.checksErrored,errorDetails:s.errorDetails})})),t.push(oe("SCORECARD_UPDATED_EVENT",()=>{Fe()})),t.push(oe("LICENSE_CHANGED_EVENT",()=>{ns()})),t.push(oe("SITE_CRAWL_PROGRESS_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("running"),a.setSiteCrawlProgress({current:s.current,total:s.total,url:s.url,lastViolations:s.violations}),s.status==="auditing"&&s.current===1&&ce.polite(`Site crawl started, scanning up to ${s.total} pages.`)})),t.push(oe("SITE_CRAWL_COMPLETE_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("complete"),a.setSiteCrawlReport(s.report),a.setSiteCrawlProgress(null),ce.polite(`Site crawl complete. Grade ${s.report.siteGrade}, ${s.report.totalUniqueViolations} unique violation${s.report.totalUniqueViolations===1?"":"s"}.`)})),t.push(oe("SITE_CRAWL_FAILED_EVENT",s=>{const a=f.getState();a.setSiteCrawlStatus("failed"),a.setSiteCrawlError(s.error.message),a.setSiteCrawlProgress(null),ce.assertive(`Site crawl failed: ${s.error.message}`)})),()=>t.forEach(s=>s())}async function ba(t){const s={...t,results:t.results.map(({screenshotDataUrl:a,...n})=>n)};try{await chrome.storage.local.set({[_e]:s})}catch(a){console.warn("[wire-messaging] persistLastAudit failed; results stay in-memory only",a)}}async function va(){const s=(await chrome.storage.local.get(_e))[_e];s&&f.setState({results:s.results,delta:s.delta,componentId:s.componentId,status:"complete"})}async function ya(){await chrome.storage.local.remove(_e)}async function We(){f.getState().clearResults(),await ya()}async function Fe(){const t=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(t.items)}async function ns(t){const s=await te({type:"TIER_GET",forceRefresh:(t==null?void 0:t.forceRefresh)===!0});f.getState().setTier(s.tier,{trialDaysRemaining:s.trialDaysRemaining,seatsUsed:s.seatsUsed,seatsTotal:s.seatsTotal,planCode:s.planCode,licenseDaysRemaining:s.licenseDaysRemaining,pastDue:s.pastDue}),rs()}async function rs(){const{fetchMessages:t}=await ut(async()=>{const{fetchMessages:n}=await Promise.resolve().then(()=>Ra);return{fetchMessages:n}},void 0),s=f.getState().userMode,a=await t(s);a&&f.getState().setMessages(a.messages,a.unreadCount,a.criticalUnacked)}async function ja(){const s=(await te({type:"SETTINGS_GET",key:"userMode"})).data,a=s==="owner"||s==="dev"?s:null;f.getState().setUserMode(a)}function wa(){return chrome.runtime.connect({name:"audit-keepalive"})}let Me=null;async function Na(){if(Me===null)try{const t=await chrome.windows.getCurrent();typeof t.id=="number"&&(Me=t.id)}catch{}}function is(){if(Me===null)return;const t=chrome.sidePanel;!t||typeof t.open!="function"||t.open({windowId:Me}).catch(()=>{})}function de(t){is(),J(t)}function ka({onClose:t}){const[s,a]=h.useState(""),[n,r]=h.useState(""),[i,l]=h.useState(!0),[o,c]=h.useState(""),[u,d]=h.useState(!1),[p,m]=h.useState(null);async function x(g){var j;if(g.preventDefault(),!(!s.trim()||!n.trim())){d(!0),m(null);try{const b=await te({type:"SUPPORT_MESSAGE_REQUEST",subject:s.trim(),body:n.trim(),includeContext:i,replyEmail:o.trim()||void 0});b.success?(m({ok:!0,msg:`Sent (ref: ${b.ticketRef??"n/a"})`}),setTimeout(t,1200)):m({ok:!1,msg:((j=b.error)==null?void 0:j.message)??"Failed to send"})}finally{d(!1)}}}return e.jsxs("form",{onSubmit:x,className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-subject",className:"block text-xs font-medium mb-1",children:"Subject"}),e.jsx("input",{id:"support-subject",type:"text",value:s,onChange:g=>a(g.target.value),required:!0,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-body",className:"block text-xs font-medium mb-1",children:"Message"}),e.jsx("textarea",{id:"support-body",value:n,onChange:g=>r(g.target.value),required:!0,rows:6,className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"support-reply",className:"block text-xs font-medium mb-1",children:"Reply email (optional)"}),e.jsx("input",{id:"support-reply",type:"email",autoComplete:"email",value:o,onChange:g=>c(g.target.value),className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:g=>l(g.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-slate-600",children:"Include extension version, browser platform, and license tier (no URLs, page content, or audit data is sent)."})]}),p&&e.jsx("p",{id:"support-form-result",role:p.ok?"status":"alert",className:`text-xs ${p.ok?"text-green-700":"text-red-700"}`,children:p.msg}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:t,className:"text-xs px-3 py-1 hover:bg-slate-100 rounded",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:u?"Sending…":"Send"})]})]})}function Ct({onClick:t,ariaLabel:s,title:a,children:n,className:r}){return e.jsx("button",{onClick:t,"aria-label":s,title:a??s,className:`inline-flex items-center justify-center min-w-[24px] min-h-[24px] text-xs text-slate-500 hover:text-slate-900 ${r??""}`,children:n})}const Pe=es("messages-client"),Sa="https://api.wcagcheckr.com",ls="wcagcheckr",Aa=1e4;function Ca(){try{return chrome.runtime.getManifest().version}catch{return"0.0.0"}}async function os(t,s){const a=await Ds();if(!a)throw new Error("no_license_token");const n={...(s==null?void 0:s.headers)??{},Authorization:`Bearer ${a}`,"X-Extension-Version":Ca()};return s!=null&&s.userMode&&(n["X-User-Mode"]=s.userMode),fetch(`${Sa}${t}`,{...s,headers:n,signal:AbortSignal.timeout(Aa)})}async function Ia(t){try{const s=await os(`/v1/products/${ls}/messages`,{userMode:t??null});return s.ok?await s.json():(Pe.warn("fetchMessages http",s.status),null)}catch(s){return Pe.warn("fetchMessages failed",s),null}}async function xe(t,s){try{const a=await os(`/v1/products/${ls}/messages/${t}/ack`,{method:"POST",body:JSON.stringify({action:s}),headers:{"content-type":"application/json"}});return a.ok?!0:(Pe.warn("ackMessage http",a.status,"action",s),!1)}catch(a){return Pe.warn("ackMessage failed",a),!1}}const Ra=Object.freeze(Object.defineProperty({__proto__:null,ackMessage:xe,fetchMessages:Ia},Symbol.toStringTag,{value:"Module"})),Ea=["http:","https:"];function Ta(t){try{const s=new URL(t);return Ea.includes(s.protocol)}catch{return!1}}function It(t){const s=[];let a=0,n=0;for(;a<t.length;){if(t[a]==="["){const i=t.indexOf("]",a+1);if(i!==-1&&t[i+1]==="("){const l=t.indexOf(")",i+2);if(l!==-1){const o=t.slice(a+1,i),c=t.slice(i+2,l);Ta(c)?s.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener",className:"text-brand-700 underline",children:o},`l-${n++}`)):s.push(e.jsx(h.Fragment,{children:o},`l-${n++}`)),a=l+1;continue}}}if(t[a]==="*"&&t[a+1]==="*"){const i=t.indexOf("**",a+2);if(i!==-1){s.push(e.jsx("strong",{children:t.slice(a+2,i)},`b-${n++}`)),a=i+2;continue}}if(t[a]==="*"&&t[a+1]!=="*"){const i=t.indexOf("*",a+1);if(i!==-1&&t[i+1]!=="*"){s.push(e.jsx("em",{children:t.slice(a+1,i)},`i-${n++}`)),a=i+1;continue}}let r=a+1;for(;r<t.length&&t[r]!=="*"&&t[r]!=="[";)r++;s.push(e.jsx(h.Fragment,{children:t.slice(a,r)},`t-${n++}`)),a=r}return s}function cs({source:t}){const s=t.split(/\r?\n/),a=[];let n=[],r=[],i=0;function l(){if(r.length===0)return;const c=r.join(" ");a.push(e.jsx("p",{className:"leading-snug",children:It(c)},`p-${i++}`)),r=[]}function o(){n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 space-y-0.5",children:n.map((c,u)=>e.jsx("li",{children:It(c)},u))},`u-${i++}`)),n=[])}for(const c of s){const u=c.trimEnd();if(u===""){l(),o();continue}const d=/^[-*]\s+(.*)$/.exec(u);if(d){l(),n.push(d[1]);continue}o(),r.push(u)}return l(),o(),e.jsx("div",{className:"space-y-1.5",children:a})}const $a={info:"bg-blue-500",promo:"bg-purple-500",warning:"bg-amber-500",critical:"bg-rose-500"},La={critical:"bg-rose-50 border-rose-200"};function ds(){const t=f(m=>m.unreadMessageCount),s=f(m=>m.messages),a=f(m=>m.applyMessageAck),[n,r]=h.useState(!1),i=h.useRef(-1),[l,o]=h.useState(!1);h.useEffect(()=>{const m=s.filter(g=>!g.seen);if(m.length===0)return;const x=Math.max(...m.map(g=>g.id));if(x>i.current){i.current=x,o(!0);const g=setTimeout(()=>o(!1),1500);return()=>clearTimeout(g)}},[s]);async function c(){const m=s.filter(x=>!x.seen);if(m.length!==0)for(const x of m)a(x.id,"seen"),xe(x.id,"seen")}function u(){const m=!n;r(m),m&&c()}async function d(m){a(m.id,"dismissed"),await xe(m.id,"dismissed")}async function p(m){m.ctaUrl&&(a(m.id,"clicked"),xe(m.id,"clicked"),chrome.tabs.create({url:m.ctaUrl}).catch(()=>{window.open(m.ctaUrl,"_blank","noopener")}))}return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:u,"aria-label":t>0?`Notifications (${t} unread)`:"Notifications","aria-expanded":n,"aria-haspopup":"dialog",className:`relative grid place-items-center w-7 h-7 rounded text-slate-500 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500 ${l?"animate-bell-pulse":""}`,title:t>0?`${t} new message${t===1?"":"s"}`:"No new messages",children:[e.jsx(Ua,{active:t>0}),t>0&&e.jsx("span",{"aria-hidden":"true",className:"absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-rose-500 ring-2 ring-white"})]}),n&&e.jsx(Da,{messages:s,onClose:()=>r(!1),onDismiss:d,onCtaClick:p})]})}function Ua({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 Da({messages:t,onClose:s,onDismiss:a,onCtaClick:n}){const r=h.useRef(null);return h.useEffect(()=>{const i=o=>{r.current&&(r.current.contains(o.target)||s())},l=o=>{o.key==="Escape"&&s()};return document.addEventListener("mousedown",i),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",l)}},[s]),e.jsxs("div",{ref:r,role:"dialog","aria-label":"Notifications",className:"absolute right-0 top-full mt-1 w-80 max-h-[420px] overflow-y-auto bg-white border border-slate-200 rounded shadow-lg z-50 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-200",children:[e.jsx("span",{className:"font-medium",children:"Notifications"}),e.jsx("button",{type:"button",onClick:()=>{rs()},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 ${$a[i.severity]}`,"aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-slate-800",children:i.title}),i.dismissible&&i.severity!=="critical"&&e.jsx("button",{type:"button",onClick:()=>a(i),"aria-label":"Dismiss message",className:"text-slate-400 hover:text-slate-700 shrink-0",children:"✕"})]}),e.jsx("div",{className:"mt-1 text-slate-700",children:e.jsx(cs,{source:i.bodyMd})}),i.ctaLabel&&i.ctaUrl&&e.jsx("button",{type:"button",onClick:()=>n(i),className:"mt-2 text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:i.ctaLabel}),e.jsx("div",{className:"mt-1 text-[10px] text-slate-400",children:new Date(i.createdAt).toLocaleString()})]})]})},i.id))})]})}function us(){const t=f(i=>i.messages),s=f(i=>i.applyMessageAck),a=t.find(i=>i.severity==="critical"&&!i.acknowledged);if(!a)return null;async function n(){s(a.id,"acknowledged"),await xe(a.id,"acknowledged")}async function r(){a.ctaUrl&&(s(a.id,"clicked"),xe(a.id,"clicked"),chrome.tabs.create({url:a.ctaUrl}).catch(()=>{}))}return e.jsxs("div",{role:"alert",className:`border-y ${La.critical} px-3 py-2 text-xs flex items-start gap-2`,children:[e.jsx("span",{"aria-hidden":"true",className:"text-rose-600 text-sm leading-none mt-0.5",children:"⚠"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-rose-900",children:a.title}),e.jsx("div",{className:"mt-0.5 text-rose-900/90",children:e.jsx(cs,{source:a.bodyMd})}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[a.ctaLabel&&a.ctaUrl&&e.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:a.ctaLabel}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1 border border-rose-300 text-rose-800 rounded hover:bg-rose-100",children:"Acknowledge"})]})]})]})}const ve=["matrix","report","delta","activity","guided","flows","scorecard","crawl","schedules","forensic","compliance"];function Oa(t){if(!t)return null;try{return new URL(t).hostname}catch{return t}}function _a(){var p,m;const t=f(x=>x.view),s=f(x=>x.setView),a=f(x=>x.setUserMode),n=f(x=>x.results),r=f(x=>x.status),[i,l]=h.useState(!1),o=((p=n[0])==null?void 0:p.pageUrl)??((m=n[0])==null?void 0:m.scope),c=Oa(o),u=n.length>0&&r!=="running";function d(){a("owner"),J({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"wcagcheckr"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-tight font-mono",children:["v",chrome.runtime.getManifest().version]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick: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(ds,{}),e.jsx(Ct,{onClick:()=>void J({type:"OPEN_SETTINGS"}),ariaLabel:"Open settings",children:"⚙"}),e.jsx(Ct,{onClick:()=>l(!0),ariaLabel:"Send support message",children:"?"})]})]}),u&&c&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-brand-50 border border-brand-200 text-[11px]",title:o??"",children:[e.jsx("span",{className:"text-slate-500 shrink-0",children:"Audit:"}),e.jsx("span",{className:"font-mono font-medium text-slate-800 truncate flex-1","aria-label":`Showing audit results for ${c}`,children:c}),e.jsx("button",{type:"button",onClick:()=>void 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(Fa,{view:t,setView:s}),e.jsx(be,{open:i,onClose:()=>l(!1),title:"Send support message",children:e.jsx(ka,{onClose:()=>l(!1)})})]})}function Fa({view:t,setView:s}){const a=h.useRef([]);function n(i){var c;const l=(i+ve.length)%ve.length,o=ve[l];o&&(s(o),(c=a.current[l])==null||c.focus())}function r(i,l){switch(i.key){case"ArrowRight":i.preventDefault(),n(l+1);break;case"ArrowLeft":i.preventDefault(),n(l-1);break;case"Home":i.preventDefault(),n(0);break;case"End":i.preventDefault(),n(ve.length-1);break}}return e.jsx("nav",{className:"flex flex-wrap gap-1","aria-label":"Audit views",role:"tablist",children:ve.map((i,l)=>{const o=t===i;return e.jsx("button",{ref:c=>{a.current[l]=c},role:"tab","aria-selected":o,tabIndex:o?0:-1,onClick:()=>s(i),onKeyDown:c=>r(c,l),className:o?"text-xs px-3 py-1 rounded bg-brand-500 text-white":"text-xs px-3 py-1 rounded text-slate-600 hover:bg-slate-100",children:i[0].toUpperCase()+i.slice(1)},i)})})}function Ma({feature:t,upgradeUrl:s}){const[a,n]=h.useState(!1);return e.jsxs("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded",children:[e.jsxs("p",{className:"text-xs text-amber-900 mb-2",children:[e.jsx("strong",{children:t})," requires a higher tier."]}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-xs text-brand-600 hover:underline font-medium",children:"Upgrade →"}),e.jsx(Xe,{open:a,onClose:()=>n(!1)})]})}const Pa="https://wcagcheckr.com/upgrade";function Ga(){const[t,s]=h.useState("single-element"),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState(null),[c,u]=h.useState(ze),[d,p]=h.useState(ze[0].id),m=f(N=>N.status),x=f(N=>N.tier),g=f(N=>N.results.length>0),j=m==="running";h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"matrixPresets"}),te({type:"SETTINGS_GET",key:"activePresetId"})]).then(([N,y])=>{const U=Array.isArray(N.data)?N.data:null;u(U&&U.length>0?U:ze),typeof y.data=="string"&&p(y.data)})},[]);function b(N){const y=c.find(U=>U.id===N);y&&(p(N),J({type:"SETTINGS_SET",key:"activePresetId",value:N}),J({type:"SETTINGS_SET",key:"stateMatrix",value:y.matrix}))}const C=ts(x,"storybookAutoIterate");h.useEffect(()=>{const N=oe("ELEMENT_PICKED_EVENT",(U,D)=>{n(!1);const G=D.frameId;F(G),i({selector:U.selector,frameId:G})}),y=oe("PICKER_CANCELLED_EVENT",()=>n(!1));return()=>{N(),y()}},[]);async function k(){const N=await le();N&&(n(!0),await ue(N,{type:"PICKER_ACTIVATE_REQUEST",tabId:N}))}function T(){r&&(F(r.frameId),de({type:"START_AUDIT",mode:"single-element",scope:r.selector,frameId:r.frameId}),f.getState().startNewScan())}function v(){if(!C){o("storybook:auto-iterate");return}F(),de({type:"START_AUDIT",mode:"storybook-all"}),f.getState().startNewScan()}function S(){F(),de({type:"START_AUDIT",mode:"all-frames"}),f.getState().startNewScan()}function w(){F(),de({type:"START_AUDIT",mode:"full-page"}),f.getState().startNewScan()}function I(){F(),de({type:"START_AUDIT",mode:"quick-scan"}),f.getState().startNewScan()}function O(){F(),de({type:"START_AUDIT",mode:"parallel-scan"}),f.getState().startNewScan()}function $(){J({type:"CANCEL_AUDIT"})}async function F(N){f.getState().setPinned(null);const y=await le();if(y)try{await ue(y,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:y},N)}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:N=>s(N.target.value),disabled:j||a,className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:"single-element",children:"Single element"}),e.jsx("option",{value:"full-page",children:"Full page"}),e.jsx("option",{value:"quick-scan",children:"Quick scan (markup only, ~1s)"}),e.jsx("option",{value:"parallel-scan",children:"Parallel scan (experimental, ~2-4× faster)"}),e.jsx("option",{value:"all-frames",children:"All iframes"}),e.jsxs("option",{value:"storybook-all",children:["All stories (Storybook / Ladle)",C?"":" (paid)"]})]}),e.jsx("select",{"aria-label":"State-matrix preset",value:d,onChange:N=>b(N.target.value),disabled:j||a,title:"Switch the state-matrix preset used for the next audit",className:"text-xs border border-slate-300 rounded px-2 py-1",children:c.map(N=>e.jsx("option",{value:N.id,children:N.name},N.id))}),t==="single-element"?e.jsx(Va,{picking:a,picked:r,isRunning:j,onPick:k,onRun:T,onClearPick:()=>i(null)}):t==="full-page"?e.jsx("button",{onClick:w,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==="quick-scan"?e.jsx("button",{onClick:I,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"One-state audit (default · light · ltr · desktop). Catches markup-level findings in ~1 second. Run a Full page audit for hover-only contrast, mobile reflow, RTL bidi.",children:j?"Auditing…":"⚡ Quick scan"}):t==="parallel-scan"?e.jsx("button",{onClick:O,disabled:j,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",title:"Opens N hidden tabs and runs the matrix in parallel. Roughly 2-4× faster wall-clock on a typical matrix. Experimental: skips baseline diff + AI augmentation in rc.77.",children:j?"Auditing…":"⚡⚡ Parallel scan"}):t==="all-frames"?e.jsx("button",{onClick:S,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:v,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:$,className:"text-xs px-3 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-100",children:"Stop"}),!j&&g&&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&&!a&&!j&&e.jsx(Wa,{selector:r.selector,onRepick:k,onClear:()=>i(null)})]}),e.jsx(be,{open:l!==null,onClose:()=>o(null),title:"Upgrade to continue",children:e.jsx(Ma,{feature:l??"",upgradeUrl:Pa})})]})}function Va({picking:t,picked:s,isRunning:a,onPick:n,onRun:r,onClearPick:i}){return a?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded opacity-50",children:"Auditing…"}):t?e.jsx("button",{disabled:!0,className:"text-xs px-3 py-1 bg-brand-400 text-white rounded",children:"Click an element on the page"}):s?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Run audit"}):e.jsx("button",{onClick:n,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Pick element"})}function Wa({selector:t,onRepick:s,onClear:a}){return e.jsxs("div",{className:"text-[11px] text-slate-600 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:"Selected:"}),e.jsx("code",{className:"font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700 truncate max-w-[180px]",title:t,children:t}),e.jsx("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline",children:"Re-pick"}),e.jsx("span",{"aria-hidden":"true",className:"text-slate-300",children:"·"}),e.jsx("button",{type:"button",onClick:a,className:"text-slate-500 hover:text-slate-700 hover:underline",children:"Clear"})]})}const Ba={outline:"OUTLINE_HIDE_REQUEST","tab-order":"TAB_ORDER_HIDE_REQUEST","reading-order":"READING_ORDER_HIDE_REQUEST","target-size":"TARGET_SIZE_HIDE_REQUEST"},Ha={outline:"OUTLINE_SHOW_REQUEST","tab-order":"TAB_ORDER_SHOW_REQUEST","reading-order":"READING_ORDER_SHOW_REQUEST","target-size":"TARGET_SIZE_SHOW_REQUEST"};function za(){const[t,s]=h.useState(null),[a,n]=h.useState(!1),[r,i]=h.useState(null),[l,o]=h.useState("off"),u=f(x=>x.results).flatMap(x=>x.violations);async function d(x){const g=await le();g&&(o(x),x==="off"?await ue(g,{type:"VISION_SIMULATOR_CLEAR",tabId:g}).catch(()=>{}):await ue(g,{type:"VISION_SIMULATOR_APPLY",tabId:g,mode:x}).catch(()=>{}))}async function p(x){const g=await le();if(g){if(t&&await ue(g,{type:Ba[t],tabId:g}).catch(()=>{}),t===x){s(null);return}await ue(g,{type:Ha[x],tabId:g}).catch(()=>{}),s(x)}}async function m(){const x=await le();if(x){if(a){await ue(x,{type:"FIX_PREVIEW_HIDE_REQUEST",tabId:x}).catch(()=>{}),n(!1),i(null);return}if(u.length===0){i("Run an audit first.");return}try{const g=await Ie(x,{type:"FIX_PREVIEW_SHOW_REQUEST",tabId:x,violations:u});n(!0),i(`Previewing ${g.visualFixCount} visual fix${g.visualFixCount===1?"":"es"} + ${g.annotationCount} annotation${g.annotationCount===1?"":"s"}.`)}catch{i("Preview failed.")}}}return e.jsxs("div",{className:"px-3 py-2 border-b border-slate-200 bg-white flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wide text-slate-500 mr-1",title:"Page overlays — these draw information on the live page. They do NOT change what the audit detects.",children:"Visualizers"}),e.jsx(ye,{label:"Outline",title:"Show heading + landmark structure overlay",on:t==="outline",onClick:()=>p("outline")}),e.jsx(ye,{label:"Tab order",title:"Number focusables in tab sequence. Red = tab order doesn't follow visual layout (focus jumps around). Amber = positive tabindex reordered the DOM sequence.",on:t==="tab-order",onClick:()=>p("tab-order")}),e.jsx(ye,{label:"Reading order",title:"Number content in DOM order (what a screen reader reads). Red = element's DOM position differs from its visual position; badge shows DOM→Visual.",on:t==="reading-order",onClick:()=>p("reading-order")}),e.jsx(ye,{label:"Targets",title:"Show interactive-element dimensions vs WCAG 2.5.8 (24px AA) / 2.5.5 (44px AAA)",on:t==="target-size",onClick:()=>p("target-size")}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsx(ye,{label:"Preview fixes ✨",title:"Apply contrast/target-size/focus-ring fixes to the live page + annotate where labels and alt text are missing. Toggle off to revert.",on:a,onClick:m}),e.jsx("span",{className:"w-px h-4 bg-slate-200 mx-1","aria-hidden":"true"}),e.jsxs("label",{className:"text-[11px] text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{title:"Apply a CSS filter that simulates how the page looks for users with color-vision or low-vision impairments. Visual only — does NOT change what the audit detects.",children:"Vision sim:"}),e.jsxs("select",{"aria-label":"Vision-impairment simulator",value:l,onChange:x=>void d(x.target.value),className:`text-xs border rounded px-1.5 py-0.5 ${l==="off"?"border-slate-300 bg-white text-slate-700":"border-brand-500 bg-brand-50 text-brand-700 font-medium"}`,children:[e.jsx("option",{value:"off",children:"Off"}),e.jsxs("optgroup",{label:"Color blindness",children:[e.jsx("option",{value:"deuteranomaly",children:"Deuteranomaly (green-weak — most common)"}),e.jsx("option",{value:"deuteranopia",children:"Deuteranopia (green-blind)"}),e.jsx("option",{value:"protanomaly",children:"Protanomaly (red-weak)"}),e.jsx("option",{value:"protanopia",children:"Protanopia (red-blind)"}),e.jsx("option",{value:"tritanomaly",children:"Tritanomaly (blue-weak)"}),e.jsx("option",{value:"tritanopia",children:"Tritanopia (blue-blind)"}),e.jsx("option",{value:"achromatomaly",children:"Achromatomaly (partial color blindness)"}),e.jsx("option",{value:"achromatopsia",children:"Achromatopsia (no color)"})]}),e.jsxs("optgroup",{label:"Low vision",children:[e.jsx("option",{value:"cataract",children:"Cataract (blur)"}),e.jsx("option",{value:"low-contrast",children:"Low contrast sensitivity"}),e.jsx("option",{value:"glaucoma",children:"Glaucoma (tunnel vision)"}),e.jsx("option",{value:"macular",children:"Macular degeneration (central loss)"})]})]})]}),r&&e.jsx("span",{className:"text-[11px] text-slate-500 basis-full",children:r})]})}function ye({label:t,title:s,on:a,onClick:n}){return e.jsx("button",{type:"button",title:s,"aria-pressed":a,onClick:n,className:`text-xs px-2 py-1 rounded border transition-colors ${a?"bg-brand-500 text-white border-brand-500 hover:bg-brand-600":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}function Ka(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 qa(){const t=f(c=>c.status),s=f(c=>c.progress),a=f(c=>c.aiProgress);if(t!=="running"||!s)return null;const n=s.current>=s.total,r=n?"Running deep analyzers…":`Auditing… ${s.current}/${s.total}`,i=n?"reading order · tab order · typography · CSS vars · AI candidates":Ka(s.currentState),l=n?100:s.current/s.total*100,o=a!=null;return e.jsxs("div",{className:"px-3 py-2 bg-slate-100 border-b border-slate-200 space-y-2",children:[e.jsx(Rt,{label:r,detail:i,pct:l,valuenow:Math.min(s.current,s.total),valuemax:s.total,ariaLabel:n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${s.current} of ${s.total} states`,barClass:"bg-slate-200",fillClass:"bg-brand-500"}),o&&e.jsx(Rt,{label:`AI augmentation… ${a.current}/${a.total}`,detail:a.candidatesTotal&&a.candidatesTotal>0?`${a.currentCheckLabel} (${a.candidatesDone??0}/${a.candidatesTotal})`:a.currentCheckLabel,pct:a.current/a.total*100,valuenow:a.current,valuemax:a.total,ariaLabel:`AI augmentation: ${a.current} of ${a.total} checks. ${a.currentCheckLabel}`,barClass:"bg-violet-100",fillClass:"bg-violet-500"})]})}function Rt({label:t,detail:s,pct:a,valuenow:n,valuemax:r,ariaLabel:i,barClass:l,fillClass:o}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 text-xs text-slate-600 mb-1",children:[e.jsx("span",{className:"shrink-0",children:t}),e.jsx("span",{className:"text-slate-500 truncate flex-1 text-right",children:s})]}),e.jsx("div",{className:`h-1 rounded-full overflow-hidden ${l}`,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":r,"aria-label":i,children:e.jsx("div",{className:`h-full transition-all ${o}`,style:{width:`${a}%`}})})]})}const je={"ada-iii":{id:"ada-iii",name:"ADA Title III",region:"US",blurb:"US civil-rights law; courts treat WCAG 2.1 AA as the de facto digital standard."},508:{id:"508",name:"Section 508",region:"US federal",blurb:"US federal procurement requirement; references WCAG 2.0 AA via 36 CFR Part 1194."},eaa:{id:"eaa",name:"EAA",region:"EU",blurb:"European Accessibility Act, in force 2025-06-28; references EN 301 549 → WCAG 2.1 AA."},"en-301-549":{id:"en-301-549",name:"EN 301 549",region:"EU",blurb:"European harmonized accessibility standard, baseline WCAG 2.1 AA."},aoda:{id:"aoda",name:"AODA",region:"Ontario",blurb:"Accessibility for Ontarians with Disabilities Act; WCAG 2.0 AA required since 2021."}};function Qa(t){return/^wcag\d/.test(t.wcagCriterion)?[je["ada-iii"],je[508],je.eaa,je["en-301-549"],je.aoda]:[]}const Ya={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 Ge({violation:t,alreadyAcknowledged:s}){const a=f(k=>k.pinnedMatchKey),n=f(k=>k.pinnedFound),r=f(k=>k.setPinned),i=f(k=>{var T;return(T=k.results[0])==null?void 0:T.frameId}),l=f(k=>{var T;return(T=k.results[0])==null?void 0:T.scope}),o=f(k=>k.results),c=f(k=>k.acknowledgedKeys.has(t.matchKey)),u=f(k=>k.markAcknowledged),d=f(k=>k.markUnacknowledged),p=s||c,m=a===t.matchKey,x=m&&!n;async function g(k){try{return(await Ie(k,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:k,selector:t.target.selector},i)).found}catch{return!0}}async function j(){const k=await le();if(!k)return;if(m){r(null);try{await ue(k,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:k},i)}catch{}return}const T=await g(k);r(t.matchKey,T)}function b(k){k.stopPropagation(),t.currentState.breakpoint.width<=640&&is(),(async()=>{const T=await le();if(!T)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:T,state:t.currentState,scope:l,frameId:i})}catch{}const v=await g(T);r(t.matchKey,v)})()}async function C(k){k.stopPropagation();const T=await le();if(!T)return;try{await te({type:"STATE_DRIVE_REQUEST",tabId:T,state:en(),scope:l,frameId:i})}catch{J({type:"STATE_RESET_REQUEST",tabId:T})}const v=await g(T);r(t.matchKey,v)}return e.jsxs("button",{type:"button",onClick:j,"aria-pressed":m,className:`w-full text-left border rounded p-2 bg-white block transition-shadow
3
+ ${m?"border-rose-400 ring-2 ring-rose-300":"border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-1 gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-xs truncate",children:t.ruleId}),e.jsxs("div",{className:"text-xs text-slate-500",children:[t.wcagCriterion," · ",t.wcagLevel]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.flakyAcrossRuns&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700",title:"Did not appear in every audit run — likely a transient environment artifact",children:"flaky"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${Ya[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(tn,{violation:t}),e.jsx(nn,{violation:t}),e.jsx(an,{violation:t}),e.jsx(sn,{text:t.target.failureSummary}),e.jsx(rn,{ruleId:t.ruleId}),m&&e.jsxs("div",{className:"text-[11px] text-slate-600 mt-2 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("span",{children:["State: ",Ja(t.currentState)]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:b,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),b(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load state"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("a",{role:"button",tabIndex:0,onClick:C,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),C(k))},className:"text-brand-600 hover:underline cursor-pointer",children:"Load default"}),x&&e.jsx("span",{className:"text-amber-700 basis-full",children:"Couldn't find this element on the page. The story may have re-rendered or unmounted."})]}),t.needsReview&&e.jsx("div",{className:"mt-2 flex items-center gap-2 text-xs",children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800 font-semibold",children:"✓ Acknowledged"}),e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),d(t.matchKey),Za(t,o)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},className:"text-slate-600 hover:text-slate-900 hover:underline cursor-pointer",children:"Un-acknowledge"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:k=>{k.stopPropagation(),u(t.matchKey),Xa(t,o)},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),k.target.click())},title:"Mark this finding as 'reviewed, not an issue.' It won't appear in future audits unless the content changes.",className:"px-2 py-0.5 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 cursor-pointer",children:"Acknowledge as not an issue"})}),t.helpUrl&&e.jsx("a",{href:t.helpUrl,target:"_blank",rel:"noreferrer",onClick:k=>k.stopPropagation(),className:"text-xs text-brand-600 hover:underline mt-2 inline-block",children:"Learn more →"})]})}function Ja(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 Xa(t,s){await Fs({componentId:t.componentId,matchKey:t.matchKey,ruleId:t.ruleId}),await ps(t.componentId,s)}async function Za(t,s){await _s(t.componentId,t.matchKey),await ps(t.componentId,s)}async function ps(t,s){const a=s.flatMap(n=>n.violations);try{const n=await te({type:"BASELINE_COMPARE",componentId:t,currentViolations:a});f.getState().setDelta(n.delta)}catch{}}function en(){const t=ss.breakpointPresets;return{pseudoState:"default",ariaVariation:null,theme:"light",direction:"ltr",breakpoint:t.find(a=>a.id==="desktop")??t[0]}}function ms(t){if(t.ruleId!=="color-contrast"&&t.ruleId!=="color-contrast-enhanced")return null;const s=t.target.failureSummary||"",a=/contrast of (\d+(?:\.\d+)?)/i.exec(s),n=/Expected contrast ratio of (\d+(?:\.\d+)?):1/i.exec(s),r=/foreground color:\s*(#[0-9a-fA-F]+)/i.exec(s),i=/background color:\s*(#[0-9a-fA-F]+)/i.exec(s);return!a||!n?null:{ratio:parseFloat(a[1]),required:parseFloat(n[1]),fg:(r==null?void 0:r[1])??"#000000",bg:(i==null?void 0:i[1])??"#ffffff"}}function tn({violation:t}){const s=ms(t);if(!s)return null;const a=s.ratio>=s.required;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300",style:{background:s.bg,color:s.fg},title:`fg ${s.fg} on bg ${s.bg}`,children:"Aa"}),e.jsxs("span",{className:a?"text-green-700":"text-rose-700 font-medium",children:[s.ratio.toFixed(2)," : 1"]}),e.jsxs("span",{className:"text-slate-500",children:["needs ",s.required.toFixed(1)," : 1"]})]})}function sn({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 an({violation:t}){const s=Qa(t);return s.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.map(a=>e.jsx("span",{title:`${a.region} — ${a.blurb}`,className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-100 text-slate-600 border border-slate-200",children:a.name},a.id))})}function nn({violation:t}){const s=ms(t),[a,n]=h.useState({kind:"idle"});if(h.useEffect(()=>{let i=!1;return Os(t.matchKey).then(l=>{l&&!i&&n({kind:"ready",suggestion:l})}),()=>{i=!0}},[t.matchKey]),!s)return null;async function r(){n({kind:"loading"});try{const i=t.ruleId==="color-contrast-enhanced"?"AAA":"AA",l=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:[{matchKey:t.matchKey,foreground:s.fg,background:s.bg,fontSize:16,fontWeight:400,targetLevel:i}]}),o=l.results.find(c=>c.matchKey===t.matchKey);o?(await Ms(o),n({kind:"ready",suggestion:o})):n({kind:"empty",reason:l.unavailableReason??"AI returned no suggestions for this contrast pair."})}catch(i){n({kind:"empty",reason:i instanceof Error?i.message:String(i)})}}return e.jsxs("div",{className:"mt-2",children:[a.kind==="idle"&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),r()},className:"text-[11px] px-2 py-1 rounded border border-brand-300 bg-brand-50 text-brand-700 hover:bg-brand-100 font-medium",title:"Ask the configured AI for in-palette color replacements that pass WCAG contrast.",children:"✨ AI fix suggestions"}),a.kind==="loading"&&e.jsx("span",{className:"text-[11px] text-slate-500",children:"Asking AI for color suggestions…"}),a.kind==="empty"&&e.jsx("p",{className:"text-[11px] text-slate-500 bg-slate-50 border border-slate-200 rounded p-2",children:a.reason}),a.kind==="ready"&&e.jsxs("div",{className:"border border-brand-200 rounded bg-brand-50 p-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-brand-900 font-medium",children:["AI suggestions (",a.suggestion.suggestions.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:a.suggestion.suggestions.map((i,l)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("div",{className:"flex items-center justify-center w-9 h-6 rounded border border-slate-300 shrink-0",style:{background:i.background,color:i.foreground},title:`fg ${i.foreground} on bg ${i.background}`,children:"Aa"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[e.jsx("code",{className:"font-mono",children:i.foreground}),e.jsx("span",{className:"text-slate-500",children:"on"}),e.jsx("code",{className:"font-mono",children:i.background}),e.jsxs("span",{className:"text-emerald-700 font-medium",children:[i.contrast.toFixed(2)," : 1"]})]}),i.rationale&&e.jsx("p",{className:"text-slate-600 mt-0.5",children:i.rationale})]})]},l))}),a.suggestion.reasoning&&e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:a.suggestion.reasoning})]})]})}function rn({ruleId:t}){const s=Ps(t);return s?e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[11px] text-emerald-700 cursor-pointer hover:text-emerald-900 font-medium",children:"How to fix"}),e.jsxs("div",{className:"mt-1 bg-emerald-50 border border-emerald-200 rounded p-2 space-y-2",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-relaxed",children:s.summary}),s.snippet&&e.jsx("pre",{className:"text-[11px] text-slate-700 bg-white p-1.5 rounded border border-emerald-100 overflow-x-auto",children:e.jsx("code",{children:s.snippet})})]})]}):null}const Ze=[{id:"contrast",label:"Color & contrast",axeRules:["color-contrast","color-contrast-enhanced","link-in-text-block"],igtWorkflowIds:["visual-indicators"]},{id:"alt-text",label:"Alt text",axeRules:["image-alt","input-image-alt","object-alt","svg-img-alt","area-alt","role-img-alt"],igtWorkflowIds:[]},{id:"forms",label:"Forms",axeRules:["label","select-name","aria-input-field-name","aria-toggle-field-name","form-field-multiple-labels","label-content-name-mismatch","autocomplete-valid","label-title-only","wcc-onfocus-context-change","wcc-oninput-context-change","wcc-cognitive-auth-challenge"],igtWorkflowIds:["forms"]},{id:"keyboard",label:"Keyboard",axeRules:["nested-interactive","tabindex","frame-focusable-content","no-focusable-content","focus-order-semantics","wcc-gesture-no-alternative","wcc-drag-no-alternative"],igtWorkflowIds:["keyboard","focus-management"]},{id:"tab-order",label:"Tab order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["keyboard"],heuristic:"tab-order"},{id:"screen-reader",label:"Screen reader / ARIA",axeRules:["aria-allowed-attr","aria-required-attr","aria-required-children","aria-required-parent","aria-roles","aria-valid-attr-value","aria-valid-attr","aria-hidden-body","aria-hidden-focus","button-name","input-button-name","link-name","frame-title","presentation-role-conflict","aria-allowed-role","aria-prohibited-attr","aria-text","aria-deprecated-role","aria-conditional-attr","aria-braille-equivalent","empty-button","empty-heading","empty-link"],igtWorkflowIds:["screen-reader"]},{id:"reading-order",label:"Reading order",axeRules:[],igtWorkflowIds:[],verifiedByWorkflowIds:["page-structure"],heuristic:"reading-order"},{id:"page-structure",label:"Page structure",axeRules:["heading-order","page-has-heading-one","landmark-one-main","landmark-no-duplicate-banner","landmark-no-duplicate-contentinfo","landmark-no-duplicate-main","region","bypass","empty-table-header","landmark-banner-is-top-level","landmark-complementary-is-top-level","landmark-contentinfo-is-top-level","landmark-main-is-top-level","landmark-unique"],igtWorkflowIds:["page-structure"]}];function pt(t){const s=Ze.map(r=>on(r,t)),a=ln(s.map(r=>r.letter)),n=s.filter(r=>r.letter==="D"||r.letter==="F");return{overallLetter:a,subGrades:s,warningAreas:n,isLawsuitRisk:n.length>0}}function ln(t){const s=t.filter(l=>l==="A").length,a=t.filter(l=>l==="C").length,n=t.filter(l=>l==="D").length,r=t.filter(l=>l==="F").length,i=t.length-s;return s===0&&n+r>a?"F":i===0?"A":i<=3?"B":i<=6?"C":"D"}function on(t,s){const a=new Set(t.axeRules),n=s.violations.filter(y=>a.has(y.ruleId)),r=s.manualRuns.filter(y=>t.igtWorkflowIds.includes(y.workflowId)),i=t.igtWorkflowIds.map(y=>s.workflows.find(U=>U.id===y)).filter(y=>y!=null);let l=i.length>0;for(const y of i){const U=r.find(G=>G.workflowId===y.id);if((U?Object.keys(U.steps).length:0)!==y.steps.length){l=!1;break}}const o=r.some(y=>Object.keys(y.steps).length>0),c=t.verifiedByWorkflowIds??[],u=s.manualRuns.filter(y=>c.includes(y.workflowId)),d=c.map(y=>s.workflows.find(U=>U.id===y)).filter(y=>y!=null);let p=c.length>0&&d.length===c.length;for(const y of d){const U=u.find(G=>G.workflowId===y.id);if((U?Object.keys(U.steps).length:0)!==y.steps.length){p=!1;break}}let m=null;if(p)for(const y of u)y.completedAt&&(m===null||y.completedAt>m)&&(m=y.completedAt);const x=t.heuristic==="tab-order"?s.heuristicCounts.tabOrder??0:t.heuristic==="reading-order"?s.heuristicCounts.readingOrder??0:0,g=c[0]??t.igtWorkflowIds[0]??null,j=s.interactiveAuditVerdicts,b=[];j&&(t.id==="tab-order"&&j.focusOrder&&b.push({verdict:j.focusOrder,criterionId:"2.4.3"}),t.id==="keyboard"&&(j.keyboardTrap&&b.push({verdict:j.keyboardTrap,criterionId:"2.1.2"}),j.focusVisible&&b.push({verdict:j.focusVisible,criterionId:"2.4.7"})));const C=b.some(y=>y.verdict==="fail");if(b.length>0&&b.every(y=>y.verdict==="pass")&&c.length>0&&!p)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:b.length>0?new Date().toISOString():null,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1},aiVerifiedCriteria:b.map(y=>y.criterionId)};if(p&&c.length>0)return{id:t.id,label:t.label,letter:"A",untested:!1,needsIgt:!1,igtCompleted:!0,verifiedByIgt:!0,verifiedAt:m,suppressedHeuristicCount:x,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const T=t.axeRules.length>0||t.heuristic!=null,v=t.igtWorkflowIds.length>0;if(T?!s.auditRan:!o)return{id:t.id,label:t.label,letter:"F",untested:!0,needsIgt:v||c.length>0,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}};const w={critical:0,serious:0,moderate:0,minor:0};for(const y of ot(n))w[y.impact]++;b.length>0&&b.every(y=>y.verdict==="pass")||(w.serious+=x),C&&(w.serious+=b.filter(y=>y.verdict==="fail").length);for(const y of r){const U=i.find(D=>D.id===y.workflowId);if(U)for(const D of U.steps){const G=y.steps[D.id];(G==null?void 0:G.status)==="fail"&&(D.severity==="required"?w.serious++:w.moderate++)}}const O=w.critical>0,$=w.serious>0;let F;w.critical>=5?F="F":w.critical>=1?F="D":w.serious>=1?F="C":w.moderate>=1?F="B":F="A";const N=F!=="A"&&(v&&!l||c.length>0&&!p);return{id:t.id,label:t.label,letter:F,untested:!1,needsIgt:N,igtCompleted:l,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:g,counts:w,caps:{cappedAtC:O,cappedAtB:$}}}const et="dismissedFindings";function Be(t){try{const s=new URL(t);return`${s.origin}${s.pathname.replace(/\/+$/,"")}`}catch{return t}}function ge(t){return`reading-order::${t}`}function fe(t){return`tab-order::${t}`}async function He(){try{const t=await chrome.storage.local.get(et),s=t==null?void 0:t[et];if(s&&typeof s=="object")return s}catch{}return{}}async function mt(t){await chrome.storage.local.set({[et]:t})}async function Ve(t){return(await He())[Be(t)]??{}}async function hs(t,s,a,n){const r=await He(),i=Be(t),l=r[i]??{};l[s]={reason:a,dismissedAt:new Date().toISOString(),snippet:n},r[i]=l,await mt(r)}async function Re(t,s){if(s.length===0)return;const a=await He(),n=Be(t),r=a[n]??{},i=new Date().toISOString();for(const l of s)r[l.key]={reason:l.reason,dismissedAt:i,snippet:l.snippet};a[n]=r,await mt(a)}async function xs(t,s){const a=await He(),n=Be(t),r=a[n];!r||!(s in r)||(delete r[s],Object.keys(r).length===0?delete a[n]:a[n]=r,await mt(a))}const cl=Object.freeze(Object.defineProperty({__proto__:null,addDismissal:hs,addDismissals:Re,dismissalKeyForReadingOrder:ge,dismissalKeyForTabOrder:fe,getDismissalsForUrl:Ve,removeDismissal:xs},Symbol.toStringTag,{value:"Module"}));function gs(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function fs(t){return`${ct(t.ruleId,t.target.selector)}::${t.target.outerHTML.slice(0,64)}`}function cn(t){const s=new Map;for(const a of t)for(const n of a.violations){const r=fs(n),i=s.get(r);i?i.states.push(n.currentState):s.set(r,{representative:n,states:[n.currentState]})}return Array.from(s.values())}const Et={critical:0,serious:1,moderate:2,minor:3};function dn(){var k,T,v,S;const t=f(w=>w.results),s=f(w=>w.componentId),a=f(w=>w.setView),n=((k=t[0])==null?void 0:k.pageUrl)??((T=t[0])==null?void 0:T.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(new Set),[c,u]=h.useState({});if(h.useEffect(()=>{if(!s){u({});return}let w=!1;const I=async()=>{const $=await Jt(s);if(w)return;const F={};for(const N of $)N.criterionId==="2.4.3"?F.focusOrder=N.verdict:N.criterionId==="2.1.2"?F.keyboardTrap=N.verdict:N.criterionId==="2.4.7"?F.focusVisible=N.verdict:N.criterionId==="1.3.2"&&(F.readingOrder=N.verdict);u(F)};I();const O=$=>{$.interactiveAuditResults&&I()};return chrome.storage.local.onChanged.addListener(O),()=>{w=!0,chrome.storage.local.onChanged.removeListener(O)}},[s]),h.useEffect(()=>{if(!n)return;Ve(n).then(i);const w=()=>{document.visibilityState==="visible"&&n&&Ve(n).then(i)};return document.addEventListener("visibilitychange",w),()=>document.removeEventListener("visibilitychange",w)},[n]),h.useEffect(()=>{if(!s){o(new Set);return}let w=!1;const I=async()=>{const $=await chrome.storage.local.get("igtRuns");if(w)return;const N=(($==null?void 0:$.igtRuns)??{})[s]??{},y=new Set;for(const U of ee){const D=N[U.id];D&&Object.keys(D.steps).length===U.steps.length&&y.add(U.id)}o(y)};I();const O=()=>{document.visibilityState==="visible"&&I()};return document.addEventListener("visibilitychange",O),()=>{w=!0,document.removeEventListener("visibilitychange",O)}},[s]),t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element to start."});const d=t.reduce((w,I)=>w+I.durationMs,0),p=t.reduce((w,I)=>w+I.violations.length,0),m=cn(t);m.sort((w,I)=>{const O=Et[w.representative.impact]??99,$=Et[I.representative.impact]??99;return O!==$?O-$:I.states.length-w.states.length});const x=t.map(w=>gs(w.state)).join(`
4
+ `),g=c.focusOrder!==void 0||c.keyboardTrap==="pass",j=l.has("keyboard")||g?0:(((v=t[0])==null?void 0:v.tabOrderIssues)??[]).filter(w=>!(fe(w.selector)in r)).length,b=c.readingOrder!==void 0,C=l.has("page-structure")||b?0:(((S=t[0])==null?void 0:S.readingOrderIssues)??[]).filter(w=>!(ge(w.selector)in r)).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx(hn,{violations:t.flatMap(w=>w.violations),componentId:s,manualRuns:[],interactiveVerdicts:c}),(j>0||C>0)&&e.jsxs("button",{type:"button",onClick:()=>a("activity"),className:"w-full text-left border border-rose-200 rounded bg-rose-50 px-3 py-2 hover:bg-rose-100 transition-colors",children:[e.jsx("p",{className:"text-xs font-semibold text-rose-900",children:"⚠ Keyboard / screen-reader concerns axe-core can't see"}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug mt-0.5",children:[j>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:j})," tab-order issue",j===1?"":"s"," (WCAG 2.4.3)"]}),j>0&&C>0&&" · ",C>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:C})," reading-order issue",C===1?"":"s"," (WCAG 1.3.2)"]})," ","— click to view in ",e.jsx("span",{className:"underline",children:"Activity"})," tab."]})]}),e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[e.jsxs("span",{title:x,"aria-label":`${t.length} states tested: ${x.replace(/\n/g,", ")}`,className:"underline decoration-dotted decoration-slate-400 cursor-help",children:[t.length," ",t.length===1?"state":"states"]})," · ",m.length," unique ",m.length===1?"violation":"violations"," ",e.jsxs("span",{className:"text-slate-500",children:["(",p," across all states)"]})," · ",(d/1e3).toFixed(1),"s"]}),e.jsx(pn,{groups:m,totalStates:t.length,violations:t.flatMap(w=>w.violations),interactiveVerdicts:c})]})}const un={A:"bg-emerald-500 text-white",B:"bg-lime-500 text-white",C:"bg-yellow-500 text-slate-900",D:"bg-orange-500 text-white",F:"bg-rose-600 text-white"};function pn({groups:t,totalStates:s,violations:a,interactiveVerdicts:n}){const r=pt({violations:a,auditRan:!0,manualRuns:[],workflows:ee,heuristicCounts:{},interactiveAuditVerdicts:n}),i=new Map,l=new Set;for(const c of Ze){for(const u of c.axeRules)l.add(u);i.set(c.id,[])}const o=[];for(const c of t){let u=!1;for(const d of Ze)if(d.axeRules.includes(c.representative.ruleId)){i.get(d.id).push(c),u=!0;break}u||o.push(c)}return e.jsxs("div",{className:"space-y-1.5",children:[r.subGrades.map(c=>{const u=i.get(c.id)??[];return e.jsx(Tt,{subGrade:c,groups:u,totalStates:s},c.id)}),o.length>0&&e.jsx(Tt,{subGrade:{id:"other",label:"Other findings (AI judgments, custom rules)",letter:"C",untested:!1,needsIgt:!1,igtCompleted:!1,verifiedByIgt:!1,verifiedAt:null,suppressedHeuristicCount:0,primaryVerifierWorkflowId:null,counts:{critical:0,serious:0,moderate:0,minor:0},caps:{cappedAtC:!1,cappedAtB:!1}},groups:o,totalStates:s})]})}function Tt({subGrade:t,groups:s,totalStates:a}){const[n,r]=h.useState(!1),[i,l]=h.useState("idle"),[o,c]=h.useState(null),[u,d]=h.useState(0),p=s.length>0,m=un[t.letter],x=s.filter(b=>b.representative.ruleId==="color-contrast"||b.representative.ruleId==="color-contrast-enhanced"),g=x.length>=2;async function j(b){b.stopPropagation(),l("loading"),c(null);try{const C=x.map(T=>{const v=T.representative.target.outerHTML,S=T.representative.target.failureSummary,w=/Foreground color:\s*(#[0-9a-f]{3,8})/i.exec(S),I=/Background color:\s*(#[0-9a-f]{3,8})/i.exec(S);if(!w||!I)return null;const O=T.representative.ruleId==="color-contrast-enhanced"?"AAA":"AA";return{matchKey:T.representative.matchKey,foreground:w[1],background:I[1],fontSize:16,fontWeight:400,targetLevel:O,_html:v}}).filter(T=>T!==null);if(C.length===0){l("error"),c("Could not parse fg/bg colors from the violation failure summaries.");return}const k=await te({type:"AI_COLOR_SUGGEST_REQUEST",inputs:C.map(({_html:T,...v})=>v)});if(k.unavailableReason&&k.results.length===0){l("error"),c(k.unavailableReason);return}await Gs(k.results),l("done"),d(T=>T+1),n||r(!0)}catch(C){l("error"),c(C instanceof Error?C.message:String(C))}}return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>r(b=>!b),"aria-expanded":n,disabled:!p,className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-slate-50 disabled:cursor-default disabled:hover:bg-white",children:[e.jsx("span",{className:`shrink-0 w-7 h-7 inline-flex items-center justify-center rounded text-sm font-bold ${m}`,"aria-label":`Grade ${t.letter}`,children:t.letter}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-xs font-medium text-slate-900",children:t.label}),e.jsx("span",{className:"block text-[11px] text-slate-500",children:p?`${s.length} ${s.length===1?"issue":"issues"} to fix`:"No issues found"})]}),g&&e.jsx("span",{role:"button",tabIndex:0,onClick:b=>void j(b),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),j(b))},className:"shrink-0 text-[11px] font-medium px-2 py-1 bg-brand-50 text-brand-700 border border-brand-300 rounded hover:bg-brand-100 cursor-pointer",title:`Ask AI for color suggestions on all ${x.length} contrast issues at once`,children:i==="loading"?"Asking AI…":i==="done"?`✓ Suggested for all ${x.length}`:`✨ Suggest for all ${x.length}`}),p&&e.jsx("span",{className:"text-slate-400 text-sm shrink-0","aria-hidden":"true",children:n?"−":"+"})]}),i==="error"&&o&&e.jsx("div",{className:"px-3 py-1.5 border-t border-rose-200 bg-rose-50 text-[11px] text-rose-800",children:o}),n&&p&&e.jsx("div",{className:"border-t border-slate-100 p-2 space-y-1.5 bg-slate-50",children:s.map(b=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ge,{violation:b.representative}),e.jsx(xn,{states:b.states,totalStates:a})]},`${fs(b.representative)}::${u}`))})]})}const mn={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 hn({violations:t,componentId:s,manualRuns:a,interactiveVerdicts:n}){const r=f(u=>u.setView),l=pt({violations:t,auditRan:!0,manualRuns:a,workflows:ee,heuristicCounts:{},interactiveAuditVerdicts:n}).overallLetter,c=ot(t).length;return e.jsx("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`flex items-center justify-center w-20 shrink-0 ${mn[l]}`,children:e.jsx("span",{className:"text-4xl font-bold leading-none",children:l})}),e.jsxs("div",{className:"flex-1 p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:c===0?"No issues found by automation":`${c} issue${c===1?"":"s"} to fix`}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Grade is the mean of 9 verification areas."," ","See the Report tab for the full breakdown."]})]}),e.jsx("button",{type:"button",onClick:()=>r("report"),className:"shrink-0 text-[11px] font-medium px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"View Full Report →"})]})]})})}function xn({states:t,totalStates:s}){if(t.length===s)return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",children:["Found in ",e.jsxs("span",{className:"font-medium",children:["all ",s," states"]}),"."]});const a=Array.from(new Set(t.map(gs))),n=a.slice(0,3).join(", "),r=a.length>3?`, +${a.length-3} more`:"",i=a.join(`
5
+ `);return e.jsxs("p",{className:"text-[11px] text-slate-500 px-1",title:i,children:["Found in ",a.length," of ",s," states:"," ",e.jsxs("span",{className:"text-slate-600",children:[n,r]})]})}const gn={A:"bg-emerald-500",B:"bg-lime-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},fn={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 bn({violations:t,componentId:s}){var ae,ne,re,R,H,X,W;const[a,n]=h.useState([]),[r,i]=h.useState([]),[l,o]=h.useState(new Set),[c,u]=h.useState(null),[d,p]=h.useState({}),[m,x]=h.useState(new Set),g=f(A=>A.status),j=f(A=>A.progress),b=f(A=>A.freshThisSession),C=f(A=>A.results),k=(ae=C[0])==null?void 0:ae.startedAt,T=((ne=C[0])==null?void 0:ne.pageUrl)??((re=C[0])==null?void 0:re.scope)??null;if(h.useEffect(()=>{if(!s){n([]);return}let A=!1;return chrome.storage.local.get("igtRuns").then(M=>{if(A)return;const Q=((M==null?void 0:M.igtRuns)??{})[s]??{};n(Object.values(Q))}),()=>{A=!0}},[s]),h.useEffect(()=>{if(!T){i([]);return}let A=!1;return Ue(T).then(M=>{A||i(M)}),()=>{A=!0}},[T]),g==="running")return e.jsx(Sn,{current:j==null?void 0:j.current,total:j==null?void 0:j.total});const v=pt({violations:t,auditRan:C.length>0,manualRuns:a,workflows:ee,heuristicCounts:{tabOrder:((H=(R=C[0])==null?void 0:R.tabOrderIssues)==null?void 0:H.length)??0,readingOrder:((W=(X=C[0])==null?void 0:X.readingOrderIssues)==null?void 0:W.length)??0}}),S=f(A=>A.acknowledgedKeys),w=C.length>0?Xt(C,{runs:a,workflows:ee},"2.1","AA",S,r):void 0,I=C.length>0?Vs(dt({audits:C,igtRuns:a,workflows:ee,acknowledgedMatchKeys:S,incompleteResolutions:r}),ee):void 0,O=w?w.failingCriteria.length>0||w.inconclusiveCriteria.length>0:!1,$=O&&v.overallLetter==="A"?"B":v.overallLetter;async function F(A){var me;if(!T||!((me=w==null?void 0:w.inconclusiveReasons)!=null&&me[A]))return;const Z=w.inconclusiveReasons[A].filter(se=>se.source==="axe-incomplete"&&se.elements&&se.elements.length>0);if(Z.length===0)return;o(se=>new Set(se).add(A)),u(null);const Q=[];let q=0;try{for(const Y of Z){const E=await J({type:"AI_RESOLVE_INCOMPLETE_REQUEST",ruleId:Y.ruleOrStepId,pageUrl:Y.pageUrl??T,wcagCriterion:A,elements:Y.elements??[],targetLevel:"AA"});if(E!=null&&E.unavailableReason){u(E.unavailableReason);break}E!=null&&E.resolutions&&(Q.push(...E.resolutions),q+=E.totalCostUsd??0)}if(T){const Y=await Ue(T);i(Y)}const se={total:Q.length,pass:Q.filter(Y=>Y.verdict==="pass").length,fail:Q.filter(Y=>Y.verdict==="fail").length,uncertain:Q.filter(Y=>Y.verdict==="uncertain").length,costUsd:q,resolutions:Q};p(Y=>({...Y,[A]:se}))}finally{o(se=>{const Y=new Set(se);return Y.delete(A),Y})}}function N(A){x(M=>{const Z=new Set(M);return Z.has(A)?Z.delete(A):Z.add(A),Z})}async function y(A){var E,B;if(!T)return;const M=((E=w==null?void 0:w.inconclusiveReasons)==null?void 0:E[A])??[],Z=((B=w==null?void 0:w.failingReasons)==null?void 0:B[A])??[],Q=[],q=new Set;for(const _ of M){if(_.source!=="axe-incomplete"||!_.elements)continue;const P=_.pageUrl??T;for(const z of _.elements){const K=`${P}::${_.ruleOrStepId}::${z.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:_.ruleOrStepId,pageUrl:P,selector:z.selector}))}}for(const _ of Z){if(_.source!=="ai"||!_.selector)continue;const P=_.ruleOrStepId.startsWith("ai-resolved::")?_.ruleOrStepId.slice(13):_.ruleOrStepId,z=_.pageUrl??T,K=`${z}::${P}::${_.selector}`;q.has(K)||(q.add(K),Q.push({ruleId:P,pageUrl:z,selector:_.selector}))}if(Q.length===0)return;const me=new Date().toISOString(),se=[];for(const _ of Q){const P=r.find(z=>z.pageUrl===_.pageUrl&&z.ruleId===_.ruleId&&z.selector===_.selector);P&&P.verdict==="pass"&&P.reasoning.startsWith("Marked as visually verified")||se.push({pageUrl:_.pageUrl,ruleId:_.ruleId,selector:_.selector,verdict:"pass",reasoning:`Marked as visually verified by user on ${me.slice(0,10)}.`,resolvedAt:me,costUsd:0,wcagCriterion:A})}if(se.length===0)return;await Ws(se);const Y=await Ue(T);i(Y),p(_=>({..._,[A]:{total:se.length,pass:se.length,fail:0,uncertain:0,costUsd:0,resolutions:se}}))}const U=(()=>{if(!O||v.overallLetter!=="A"||!w)return null;const A=w.inconclusiveCriteria.length,M=w.failingCriteria.length,Z=[];M>0&&Z.push(`${M} WCAG ${w.targetLevel} ${M===1?"criterion":"criteria"} failing`),A>0&&Z.push(`${A} WCAG ${w.targetLevel} ${A===1?"criterion":"criteria"} inconclusive`);const Q=M>0?"Fix the failing items OR Mark visually verified if AI was wrong about them.":"Resolve axe-incomplete + IGT-skip items to claim conformance.";return`Capped at B — ${Z.join(" + ")}. ${Q}`})();let D=0;for(const A of ee){const M=a.find(Q=>Q.workflowId===A.id);if(!M)continue;A.steps.every(Q=>{const q=M.steps[Q.id];return(q==null?void 0:q.status)==="pass"||(q==null?void 0:q.status)==="fail"||(q==null?void 0:q.status)==="skip"||(q==null?void 0:q.status)==="not-applicable"})&&D++}const G=ot(t.filter(A=>!S.has(A.matchKey))).length;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white overflow-hidden",children:[!b&&k&&e.jsx(An,{scannedAt:k}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${gn[$]} text-white shrink-0`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:$})}),e.jsxs("div",{className:"flex-1 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-900",children:"Overall grade"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Mean of ",v.subGrades.length," verification areas below. Untested areas count as F until verified."]}),U&&e.jsx("p",{className:"text-[11px] text-amber-800 leading-snug mt-1 bg-amber-50 border border-amber-200 rounded px-2 py-1",children:U})]})]}),v.isLawsuitRisk&&e.jsx(jn,{areas:v.warningAreas}),e.jsx(wn,{grades:v.subGrades}),w&&e.jsx(vn,{coverage:w,onResolveWithAi:F,onMarkVisuallyVerified:y,resolving:l,resolveError:c,lastResolveResult:d,expandedResultFor:m,onToggleResultDetail:N}),I&&e.jsx(yn,{layers:I}),e.jsx(kn,{violationsRemaining:G,manualCompleted:D,manualTotal:ee.length}),D>0||C.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:ee.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/ee.length*100}%`}})})]}):null]})}function vn({coverage:t,onResolveWithAi:s,onMarkVisuallyVerified:a,resolving:n,resolveError:r,lastResolveResult:i,expandedResultFor:l,onToggleResultDetail:o}){const c=t.untestedCriteria.length+t.inconclusiveCriteria.length,[u,d]=h.useState(c>0&&c<=3),p=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100),m=t.canClaimConformance,x=[];return t.failingCriteria.length>0&&x.push({kind:"failing",ids:t.failingCriteria}),t.inconclusiveCriteria.length>0&&x.push({kind:"inconclusive",ids:t.inconclusiveCriteria}),t.untestedCriteria.length>0&&x.push({kind:"untested",ids:t.untestedCriteria}),e.jsxs("div",{className:`border-t ${m?"border-emerald-200 bg-emerald-50":"border-amber-200 bg-amber-50"} px-3 py-2 text-[11px] leading-snug`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-2 ${m?"text-emerald-900":"text-amber-900"}`,children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-semibold",children:["WCAG ",t.targetVersion," ",t.targetLevel," coverage:"," ",t.evaluated," of ",t.totalApplicable," criteria evaluated (",p,"%)"]}),m&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:["Every applicable criterion has been evaluated and either passes or is N/A. This audit can be presented as a conformance-claim for ",t.targetVersion," ",t.targetLevel," for the audited URL(s)."]}),!m&&(()=>{const g=[];t.failingCriteria.length>0&&g.push("failing"),t.inconclusiveCriteria.length>0&&g.push("inconclusive"),t.untestedCriteria.length>0&&g.push("untested");const j=g.length===0?"unresolved":g.length===1?g[0]:g.length===2?`${g[0]} or ${g[1]}`:`${g.slice(0,-1).join(", ")}, or ${g[g.length-1]}`;return e.jsxs("p",{className:"text-[11px] mt-0.5 font-semibold",children:["Cannot claim ",t.targetLevel," conformance — applicable criteria remain ",j,"."]})})(),!m&&t.untestedCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.untestedCriteria.length," untested"]})," ",t.untestedCriteria.length===1?"criterion":"criteria"," — mark Pass / Fail / N/A in Guided Tests below."]}),!m&&t.inconclusiveCriteria.length>0&&e.jsxs("p",{className:"text-[11px] mt-0.5",children:[e.jsxs("strong",{children:[t.inconclusiveCriteria.length," inconclusive"]})," ",t.inconclusiveCriteria.length===1?"criterion":"criteria"," — axe couldn't fully determine OR an IGT step was skipped. Resolve before claiming conformance."]})]}),!m&&x.length>0&&e.jsx("button",{type:"button",onClick:()=>d(g=>!g),className:"text-[11px] underline shrink-0 self-start",children:u?"hide":"show list"})]}),u&&!m&&e.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[x.map(g=>e.jsxs("div",{children:[e.jsxs("div",{className:`text-[10.5px] font-semibold uppercase tracking-wide ${g.kind==="failing"?"text-rose-900":"text-amber-900"}`,children:[g.kind==="untested"?"Untested":g.kind==="inconclusive"?"Inconclusive":"Failing"," (",g.ids.length,")"]}),e.jsx("ul",{className:"text-[10.5px] text-amber-900 space-y-1",children:g.ids.map(j=>{var I,O;const b=g.kind==="inconclusive"?(I=t.inconclusiveReasons)==null?void 0:I[j]:void 0,C=g.kind==="failing"?(O=t.failingReasons)==null?void 0:O[j]:void 0,k=b==null?void 0:b.some($=>$.source==="axe-incomplete"&&$.elements&&$.elements.length>0),T=C==null?void 0:C.some($=>$.source==="ai"),v=(n==null?void 0:n.has(j))??!1,S=i==null?void 0:i[j],w=(l==null?void 0:l.has(j))??!1;return e.jsxs("li",{className:"leading-snug",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("code",{className:"font-mono text-[11px]",children:["· ",j]}),(g.kind==="inconclusive"&&k||g.kind==="failing"&&T)&&(s||a)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[g.kind==="inconclusive"&&s&&e.jsx("button",{type:"button",disabled:v,onClick:()=>s(j),className:"text-[11px] font-semibold px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 shadow-sm",title:"Ask AI to determine pass/fail for the specific elements axe couldn't sample.",children:v?"Resolving…":S?"✨ Resolve again →":"✨ Resolve with AI →"}),a&&e.jsx("button",{type:"button",disabled:v,onClick:()=>a(j),className:"text-[11px] font-semibold px-2 py-1 bg-white text-emerald-700 border border-emerald-500 rounded hover:bg-emerald-50 disabled:opacity-50",title:g.kind==="failing"?"Override AI's fail determination — your human visual judgment is the highest authority per WCAG-EM.":"Mark all unresolved elements as visually verified by you. Same semantic weight as Acknowledge on a violation — closes the loop for items only a human can judge (text over images, gradients, etc.).",children:"✓ Mark visually verified"})]})]}),S&&e.jsxs("div",{className:"ml-3 mt-1 p-1.5 bg-white/60 border border-amber-200 rounded text-[10.5px]",children:[e.jsxs("div",{className:"font-semibold text-amber-900 flex items-center gap-2 flex-wrap",children:["AI returned ",S.total," ",S.total===1?"verdict":"verdicts",":",S.pass>0&&e.jsxs("span",{className:"text-emerald-700",children:["✓ ",S.pass," pass"]}),S.fail>0&&e.jsxs("span",{className:"text-rose-700",children:["✗ ",S.fail," fail"]}),S.uncertain>0&&e.jsxs("span",{className:"text-amber-700",children:["? ",S.uncertain," uncertain"]}),e.jsxs("span",{className:"text-slate-500 font-normal",children:["· $",S.costUsd.toFixed(4)]}),o&&e.jsx("button",{type:"button",onClick:()=>o(j),className:"ml-auto text-[10px] underline text-brand-700",children:w?"hide reasoning":"show reasoning"})]}),S.uncertain>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-amber-800",children:["AI couldn't determine ",S.uncertain," ",S.uncertain===1?"element":"elements"," ","(typically text over images/gradients — needs visual review). These keep the criterion inconclusive."]}),S.pass===S.total&&S.total>0&&e.jsxs("p",{className:"mt-0.5 text-[10px] text-emerald-800",children:["All elements passed contrast — criterion above will flip to"," ",e.jsx("strong",{children:"pass"})," on next render."]}),w&&e.jsx("ul",{className:"mt-1.5 space-y-1 max-h-40 overflow-y-auto",children:S.resolutions.map(($,F)=>e.jsxs("li",{className:"text-[10px] leading-snug",children:[e.jsx("span",{className:$.verdict==="pass"?"text-emerald-700 font-semibold":$.verdict==="fail"?"text-rose-700 font-semibold":"text-amber-700 font-semibold",children:$.verdict==="pass"?"✓":$.verdict==="fail"?"✗":"?"})," ",e.jsx("code",{className:"font-mono bg-slate-100 px-1 rounded",children:$.selector}),e.jsx("div",{className:"ml-4 text-slate-600",children:$.reasoning})]},F))})]}),C&&C.length>0&&e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:C.map(($,F)=>e.jsxs("li",{className:"text-[10px] text-rose-800",children:[$.source==="ai"&&e.jsxs(e.Fragment,{children:["AI verdict ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId.replace(/^ai-resolved::/,"")})," fail — "]}),$.source==="axe"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," fail — "]}),$.source==="igt"&&e.jsxs(e.Fragment,{children:["Guided Test ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," fail — "]}),$.selector&&e.jsx("code",{className:"font-mono bg-rose-100 px-1 rounded mr-1",children:$.selector}),$.notes&&e.jsx("span",{className:"text-rose-700",children:$.notes})]},F))}),b&&b.length>0?e.jsx("ul",{className:"ml-3 mt-0.5 space-y-0.5",children:b.map(($,F)=>e.jsxs("li",{className:"text-[10px] text-amber-800",children:[$.source==="axe-incomplete"&&e.jsxs(e.Fragment,{children:["axe rule ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," — "]}),$.source==="igt-skip"&&e.jsxs(e.Fragment,{children:["Guided Test step ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," skipped — "]}),$.source==="ai-uncertain"&&e.jsxs(e.Fragment,{children:["AI rule ",e.jsx("code",{className:"font-mono",children:$.ruleOrStepId})," — "]}),$.resolutionHint,$.elements&&$.elements.length>0&&e.jsxs("span",{className:"block ml-1 mt-0.5 text-[10px] text-amber-700",children:["on ",$.elements.length===1?"element":`${$.elements.length} elements`,":"," ",$.elements.slice(0,3).map((N,y,U)=>e.jsxs("span",{children:[e.jsx("code",{className:"font-mono bg-amber-100 px-1 rounded",children:N.selector}),y<U.length-1&&e.jsx("span",{className:"text-amber-600",children:", "})]},y)),$.elements.length>3&&e.jsxs("span",{className:"text-amber-600",children:[", +",$.elements.length-3," more"]})]})]},F))}):g.kind==="inconclusive"&&e.jsx("p",{className:"ml-3 mt-0.5 text-[10px] text-amber-800 italic",children:"Re-run the audit to see the specific axe rule or Guided Test step responsible. (Cached data from a pre-rc.53 build doesn't carry the reason metadata.)"})]},j)})})]},g.kind)),r&&e.jsx("p",{className:"text-[10px] text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-1 mt-1",children:r})]})]})}const $t={automation:{label:"Automation",hint:"axe-core rules — runs on every scan."},ai:{label:"AI judgment",hint:"wcagcheckr AI analyzers (alt-text, contrast, vision)."},human:{label:"Human verification",hint:"Independent Guided Tests — manual checks."}};function yn({layers:t}){const s=f(n=>n.setView),a=["automation","ai","human"];return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Evidence layers"}),e.jsx("ul",{className:"space-y-1",children:a.map(n=>{const r=t[n],i=r.coveredCriteria.length,l=r.blocked.length,o=r.unevaluated.length,c=r.cleared,u=i>0&&l===0&&o===0,d=u?"text-emerald-700":l>0?"text-rose-700":"text-amber-700";return e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:`w-5 h-5 inline-flex items-center justify-center rounded text-[10px] font-bold shrink-0 ${u?"bg-emerald-500 text-white":l>0?"bg-rose-500 text-white":"bg-amber-500 text-white"}`,"aria-hidden":"true",children:u?"✓":l>0?"!":"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-slate-800",children:$t[n].label}),e.jsx("span",{className:`font-mono text-[10px] ${d}`,children:i===0?"no coverage yet":`${c}/${i}`}),l>0&&e.jsxs("span",{className:"text-[10px] text-rose-700",children:["· ",l," blocked"]}),o>0&&e.jsxs("span",{className:"text-[10px] text-amber-700",children:["· ",o," pending"]})]}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-snug",children:$t[n].hint}),n==="human"&&o>0&&e.jsx("button",{type:"button",onClick:()=>s("guided"),className:"text-[10px] text-brand-600 hover:underline mt-0.5",children:"Open Guided Tests →"})]})]},n)})})]})}function jn({areas:t}){const s=t.map(a=>a.label);return e.jsxs("div",{className:"border-t border-rose-200 bg-rose-50 px-3 py-2 text-[11px] text-rose-900 leading-snug",children:[e.jsx("p",{className:"font-semibold mb-0.5",children:"⚠ Not lawsuit-safe"}),e.jsx("p",{children:s.length===1?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s[0]})," scored ",t[0].letter,". Even a high overall grade doesn't help if one area is failing — demand-letter mills target the weakest link."]}):e.jsxs(e.Fragment,{children:[s.length," areas are at lawsuit-risk:"," ",s.map((a,n)=>e.jsxs("span",{children:[e.jsx("strong",{children:a}),n<s.length-1?", ":""]},a)),". Fix these before relying on the overall grade."]})})]})}function wn({grades:t}){const s=f(a=>a.setView);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-2",children:"Verification areas"}),e.jsx("ul",{className:"grid grid-cols-1 gap-1.5",children:t.map(a=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`w-6 h-6 inline-flex items-center justify-center rounded text-xs font-bold ${fn[a.letter]}`,"aria-label":`Grade ${a.letter}`,children:a.letter}),e.jsx("span",{className:"font-medium text-slate-800 flex-1 min-w-0",children:a.label}),e.jsx(Nn,{grade:a,onOpenGuided:()=>s("guided")})]},a.id))})]})}function Nn({grade:t,onOpenGuided:s}){const a=n=>{if(!n)return"";const r=ee.find(i=>i.id===n);return(r==null?void 0:r.name)??n};if(t.untested)return e.jsxs("span",{className:"text-slate-500 text-[10px] italic",children:["not graded —"," ",t.primaryVerifierWorkflowId?e.jsxs("button",{type:"button",onClick:s,className:"text-brand-600 hover:underline not-italic",children:["run ",a(t.primaryVerifierWorkflowId)," →"]}):"no data yet"]});if(t.verifiedByIgt){const n=t.verifiedAt?bs(Date.now()-new Date(t.verifiedAt).getTime()):null;return e.jsxs("span",{className:"text-emerald-700 text-[10px]",title:t.suppressedHeuristicCount>0?`Heuristic flagged ${t.suppressedHeuristicCount} issue${t.suppressedHeuristicCount===1?"":"s"}, but you verified this area in Guided Tests — those are treated as noise unless you re-verify.`:"Verified via Guided Tests",children:["✓ verified",n?` ${n} ago`:""]})}return t.needsIgt?e.jsxs("button",{type:"button",onClick:s,className:"text-amber-700 hover:underline text-[10px]",title:"Verify this area by running the relevant Guided Tests workflow",children:["verify with ",a(t.primaryVerifierWorkflowId)," →"]}):t.counts.critical>0||t.counts.serious>0?e.jsxs("span",{className:"text-slate-500 text-[10px]",children:[t.counts.critical>0&&e.jsxs("span",{className:"text-rose-700",children:[t.counts.critical," critical"]}),t.counts.critical>0&&t.counts.serious>0&&" · ",t.counts.serious>0&&e.jsxs("span",{className:"text-orange-700",children:[t.counts.serious," serious"]})]}):e.jsx("span",{className:"text-emerald-700 text-[10px]",children:"clean"})}function kn({violationsRemaining:t,manualCompleted:s,manualTotal:a}){const n=f(l=>l.setView),r=[{done:t===0,label:t===0?"Automated checks pass":`Fix ${t} automated violation${t===1?"":"s"}`,action:void 0,tooltip:void 0},{done:!0,label:`Optional: deep-check via Guided Tests (${s}/${a} done)`,action:()=>n("guided"),tooltip:"Guided Tests are opt-in. The audit's automated checks + AI analyzers already produce a binary pass/fail for every WCAG criterion. Run these workflows if you want belt-and-suspenders confidence on top of automation."},{done:!1,label:"Export AI fix prompt + complete manual checklist",action:()=>n("delta"),tooltip:`Switches to the Delta tab. Click the Export menu and pick "AI fix prompt" — markdown for ChatGPT/Claude/Copilot, with manual checklist for the WCAG criteria automation can't detect.`}],i=r.findIndex(l=>!l.done);return e.jsxs("div",{className:"border-t border-slate-200 px-3 py-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Path to full WCAG compliance"}),e.jsx("ol",{className:"space-y-1 text-[11px]",children:r.map((l,o)=>{const c=o===i,u=l.done;return e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:u?"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:u?"✓":`${o+1}.`}),l.action?e.jsxs("button",{type:"button",onClick:l.action,title:l.tooltip,className:c?"text-brand-700 font-semibold underline-offset-2 hover:underline text-left leading-snug":"text-slate-600 underline-offset-2 hover:underline hover:text-slate-900 text-left leading-snug",children:[l.label," →"]}):e.jsx("span",{className:u?"text-slate-500 line-through leading-snug":c?"text-slate-900 font-medium leading-snug":"text-slate-500 leading-snug",children:l.label})]},o)})})]})}function Sn({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 An({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 (",bs(s)," old). Re-scan to grade the current page state."]})]})}function bs(t){const s=Math.floor(t/1e3);if(s<60)return"less than a minute";if(s<120)return"1 minute";if(s<3600)return`${Math.floor(s/60)} minutes`;if(s<7200)return"1 hour";if(s<86400)return`${Math.floor(s/3600)} hours`;const a=Math.floor(s/86400);return a===1?"1 day":`${a} days`}function Cn(){const t=f(a=>a.results),s=f(a=>a.componentId);return t.length===0?e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Run a scan from the controls above."}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("header",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Full report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"Detailed breakdown of the audit — verification areas, WCAG coverage, evidence layers, and your path to full compliance. Plain-language explanations under each section."})]}),e.jsx(bn,{violations:t.flatMap(a=>a.violations),componentId:s}),e.jsx(In,{})]})}function In(){return e.jsxs("div",{className:"border-t border-slate-200 pt-4 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-600",children:"How to read this report"}),e.jsx(we,{title:"The big letter (Overall grade)",body:"The grade is the average of the 9 verification areas below. A = all areas clean. B = some moderate issues. C = at least one serious issue (high lawsuit-mill risk). D/F = critical failures. The grade is capped at B when any criterion is failing or inconclusive — those need to be resolved (fixed or marked verified) before claiming A."}),e.jsx(we,{title:"Verification areas",body:`Nine categories grouped by lawsuit-mill priority. Each gets its own letter so a single bad area can't hide behind a high overall mean. Click "verify with X →" on an area below A to open the relevant Guided Test workflow — but note that automated + AI checks already cover most criteria; manual verification is optional for confidence.`}),e.jsx(we,{title:"WCAG 2.1 AA coverage",body:`Of 50 applicable Level AA criteria for the audited URL(s), how many have a definite verdict (pass, fail, or N/A). The remaining "untested" criteria are gaps in tool coverage — they don't cap your grade (automation did everything it could), but for a formal WCAG conformance claim, those need explicit evaluation.`}),e.jsx(we,{title:"Evidence layers",body:"Where each verdict came from. Automation = axe-core rules + DOM analyzers. AI judgment = our AI checks (alt-text appropriateness, images-of-text, contrast over images, etc.). Human verification = the Guided Tests workflows you've completed manually. All three feed into the verdict map so any one layer can clear a criterion."}),e.jsx(we,{title:"Path to full WCAG compliance",body:"The shortest sequence of actions to reach AA conformance: fix the automated violations below, optionally double-check with Guided Tests, export the AI fix prompt for code-level walkthroughs of each issue. When all steps are done, the audit can be presented as a conformance claim via the Compliance tab (which generates a WCAG-EM-format report)."})]})}function we({title:t,body:s}){return e.jsxs("details",{className:"border border-slate-200 rounded-lg bg-slate-50",children:[e.jsx("summary",{className:"px-3 py-2 text-[12px] font-medium text-slate-800 cursor-pointer hover:bg-slate-100 rounded-lg",children:t}),e.jsx("p",{className:"px-3 pb-3 text-[11px] text-slate-700 leading-snug",children:s})]})}const Rn={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 En({ruleId:t,violations:s}){const[a,n]=h.useState(s.length===1),r=s[0];if(!r)return null;const i=r.impact,l=r.description,o=s.length;return o===1?e.jsx(Ge,{violation:r}):e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"w-full text-left p-2 hover:bg-slate-50 flex items-center justify-between gap-2","aria-expanded":a,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${Rn[i]}`,children:i}),e.jsx("span",{className:"text-[11px] font-mono text-slate-500 shrink-0",children:t}),e.jsx("span",{className:"text-xs text-slate-700 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-slate-600",children:["×",o]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▾":"▸"})]})]}),a&&e.jsx("div",{className:"border-t border-slate-200 p-2 space-y-1.5 bg-slate-50/50",children:s.map((c,u)=>e.jsx(Ge,{violation:c},u))})]})}function Tn(t){const s=[],a=new Map;for(const n of t)a.has(n.ruleId)||(s.push(n.ruleId),a.set(n.ruleId,[])),a.get(n.ruleId).push(n);return s.map(n=>({ruleId:n,violations:a.get(n)}))}const $n={"defense-bundle":"Defense report ready","evidence-bundle":"Evidence bundle ready"};function vs({open:t,onClose:s,format:a,content:n,filename:r}){const i=Ls(new Blob([n]).size);function l(){lt(n,r),s()}function o(){it(n),s()}return e.jsxs(be,{open:t,onClose:s,title:$n[a],description:`Generated bundle — ${i}. Save to your Downloads folder, or open in a new tab to preview.`,children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsxs("p",{children:["File: ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-[11px]",children:r})]}),e.jsxs("p",{className:"text-slate-500",children:["Tip: open the report and press Ctrl+P (Cmd+P on Mac) → ",e.jsx("em",{children:"Save as PDF"})," if you want a sealed-format version for legal use."]}),e.jsxs("p",{className:"text-[10px] text-slate-400",children:["To skip this prompt and download immediately on future exports, enable",e.jsx("em",{children:' "Skip the download confirmation"'})," in Settings → Advanced."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:s,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1.5 rounded border border-slate-300 text-slate-700 hover:bg-slate-50",children:"Open preview"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Download HTML"})]})]})}const Lt=7800;function Ln(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`**Component:** \`${s??"unknown"}\``),l.push(""),l.push("Detected by WCAG Component Auditor as **new** vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`### \`${d.ruleId}\` — ${d.impact}`),l.push(""),l.push(d.description),l.push(""),l.push(`- **WCAG:** ${d.wcagCriterion} (${d.wcagLevel})`),l.push(`- **Selector:** \`${d.target.selector}\``),l.push(`- **Found in state(s):** ${d._states.join(", ")}`),d.helpUrl&&l.push(`- **More info:** ${d.helpUrl}`),l.push(""),l.push("```html"),l.push(d.target.outerHTML),l.push("```"),l.push("");l.push("---"),l.push(""),l.push("_Filed via WCAG Component Auditor (delta-only — inherited debt not included)._");const o=l.join(`
6
+ `),c=new URLSearchParams({title:i,body:o});let u=`${n}/issues/new?${c.toString()}`;return u.length>Lt&&(u=u.slice(0,Lt)),{url:u,title:i,body:o}}const Ut=7800;function Un(t,s,a){const n=t.replace(/\/$/,""),r=[];for(const d of a){const p=`${d.ruleId}::${d.target.selector}`,m=`:${d.currentState.pseudoState} · ${d.currentState.theme} · ${d.currentState.direction}`,x=r.find(g=>`${g.ruleId}::${g.target.selector}`===p);if(x){x._states.includes(m)||x._states.push(m);continue}r.push({...d,_states:[m]})}const i=`a11y: ${r.length} new violation${r.length===1?"":"s"} in ${s??"audited component"}`,l=[];l.push(`Component: ${s??"unknown"}`),l.push(""),l.push("Detected by WCAG Component Auditor as NEW vs the saved baseline — these are violations introduced since the last accepted baseline."),l.push(""),l.push("---"),l.push("");for(const d of r)l.push(`Rule: ${d.ruleId} (${d.impact})`),l.push(`WCAG: ${d.wcagCriterion} ${d.wcagLevel}`),l.push(`Description: ${d.description}`),l.push(`Selector: ${d.target.selector}`),l.push(`Found in state(s): ${d._states.join(", ")}`),d.helpUrl&&l.push(`More info: ${d.helpUrl}`),l.push(""),l.push(`HTML: ${d.target.outerHTML}`),l.push(""),l.push("---"),l.push("");l.push("Filed via WCAG Component Auditor (delta-only — inherited debt not included).");const o=l.join(`
7
+ `),c=new URLSearchParams({summary:i,description:o});let u=`${n}/secure/CreateIssue!default.jspa?${c.toString()}`;return u.length>Ut&&(u=u.slice(0,Ut)),{url:u,summary:i,description:o}}const Dt=["sidePanel:lastAudit","acknowledgedFindings","dismissedFindings","aiColorSuggestions","incompleteResolutions","igtRuns","inflight:audit","aiUsageLog","aiDiagnosticLatest","auditAttestations","spotAuditReviews","interactiveAuditResults"],Dn=["wcag-component-auditor","wcag-forensic-log"];async function On(){const t=[];let s=0;const a=[];try{const n=await chrome.storage.local.get(Dt);s=Object.keys(n).length,await chrome.storage.local.remove(Dt)}catch(n){t.push(`chrome.storage.local: ${n instanceof Error?n.message:String(n)}`)}for(const n of Dn)try{await _n(n),a.push(n)}catch(r){t.push(`IndexedDB ${n}: ${r instanceof Error?r.message:String(r)}`)}return{chromeStorageKeysCleared:s,indexedDbsCleared:a,errors:t}}function _n(t){return new Promise((s,a)=>{const n=indexedDB.deleteDatabase(t);n.onsuccess=()=>s(),n.onerror=()=>{var r;return a(new Error(((r=n.error)==null?void 0:r.message)??"unknown delete error"))},n.onblocked=()=>a(new Error("blocked — close any open audit tabs and retry"))})}const tt="accessibilityStatementInputs:v1";async function Fn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return null;const s=(await chrome.storage.local.get(tt))[tt];return s&&typeof s=="object"?s:null}async function Mn(t){var s;typeof chrome>"u"||!((s=chrome.storage)!=null&&s.local)||await chrome.storage.local.set({[tt]:t})}function Pn({open:t,onClose:s,results:a}){const[n,r]=h.useState("eaa"),[i,l]=h.useState(""),[o,c]=h.useState(""),[u,d]=h.useState("partial"),[p,m]=h.useState(""),[x,g]=h.useState(""),[j,b]=h.useState(""),[C,k]=h.useState(""),[T,v]=h.useState("English"),[S,w]=h.useState("wcagcheckr (self-evaluation)"),[I,O]=h.useState("2.1"),[$,F]=h.useState("AA"),[N,y]=h.useState(!1),[U,D]=h.useState(null),G=h.useRef(null);if(h.useEffect(()=>{t&&(async()=>{var H,X,W,A;const R=await Fn();if(R&&(R.framing&&r(R.framing),R.organizationName&&l(R.organizationName),R.siteUrl&&c(R.siteUrl),R.conformanceStatus&&d(R.conformanceStatus),(H=R.contact)!=null&&H.email&&m(R.contact.email),(X=R.contact)!=null&&X.phone&&g(R.contact.phone),(W=R.contact)!=null&&W.formUrl&&b(R.contact.formUrl),R.countryCode&&k(R.countryCode),R.language&&v(R.language),R.auditedBy&&w(R.auditedBy),R.wcagVersion&&O(R.wcagVersion),R.wcagLevel&&F(R.wcagLevel)),!(R!=null&&R.siteUrl)&&((A=a[0])!=null&&A.pageUrl))try{const M=new URL(a[0].pageUrl);c(`${M.protocol}//${M.host}/`)}catch{}R!=null&&R.conformanceStatus||d(Bs(a)),setTimeout(()=>{var M;return(M=G.current)==null?void 0:M.focus()},50)})()},[t,a]),!t)return null;function ae(){var W;const R=new Date().toISOString().slice(0,10),H=(W=a[0])!=null&&W.startedAt?new Date(a[0].startedAt).toISOString().slice(0,10):R,X={};return p.trim()&&(X.email=p.trim()),x.trim()&&(X.phone=x.trim()),j.trim()&&(X.formUrl=j.trim()),{framing:n,organizationName:i.trim(),siteUrl:o.trim(),conformanceStatus:u,preparedAt:R,evaluatedAt:H,contact:X,countryCode:C||null,language:T.trim()||"English",auditedBy:S.trim()||"wcagcheckr (self-evaluation)",wcagVersion:I,wcagLevel:$}}function ne(R){if(!R.organizationName)return"Organization name is required.";if(!R.siteUrl)return"Site URL is required.";try{new URL(R.siteUrl)}catch{return"Site URL must be a valid URL (e.g. https://example.com/)."}return!R.contact.email&&!R.contact.phone&&!R.contact.formUrl?"At least one contact method (email, phone, or web form) is required — WAD + EAA both require an accessible feedback channel.":null}async function re(R){D(null);const H=ae(),X=ne(H);if(X){D(X);return}y(!0);try{await Mn(H);const W=await te({type:"EXPORT_REQUEST",format:R==="html"?"accessibility-statement-html":"accessibility-statement-markdown",results:a,statementInputs:H}),A=(W==null?void 0:W.content)??"";if(!A||A.startsWith("# Accessibility statement — error")){D(A||"Export failed — no response.");return}try{await navigator.clipboard.writeText(A)}catch{}const M=new Blob([A],{type:R==="html"?"text/html;charset=utf-8":"text/markdown;charset=utf-8"}),Z=URL.createObjectURL(M);window.open(Z,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(Z),6e4),s()}catch(W){D(W instanceof Error?W.message:String(W))}finally{y(!1)}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40",role:"dialog","aria-modal":"true","aria-labelledby":"statement-dialog-title",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[90vh] overflow-y-auto m-4",onClick:R=>R.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-slate-200 flex items-center justify-between",children:[e.jsx("h2",{id:"statement-dialog-title",className:"text-sm font-semibold",children:"Generate accessibility statement"}),e.jsx("button",{type:"button",onClick:s,className:"text-slate-400 hover:text-slate-700 text-xl leading-none","aria-label":"Close",children:"×"})]}),e.jsxs("div",{className:"p-4 space-y-3 text-xs",children:[e.jsx("p",{className:"text-slate-600 leading-snug",children:"Generates an EU-compliant accessibility statement. EAA (private-sector EU) has been enforceable since 28 June 2025; WAD (public-sector EU) since 2018. The statement is built from your most recent audit + the info below. Inputs persist between sessions."}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsx("legend",{className:"font-medium",children:"Regulatory framing"}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"eaa",checked:n==="eaa",onChange:()=>r("eaa"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"EAA"})," (Directive 2019/882) — private sector. E-commerce, banking, transport, telecom, e-readers, media. Enforceable June 2025."]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"framing",value:"wad",checked:n==="wad",onChange:()=>r("wad"),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("strong",{children:"WAD"})," (Directive 2016/2102) — EU public sector. Government, public bodies, education."]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-org",className:"block font-medium mb-1",children:["Organization name ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-org",ref:G,type:"text",value:i,onChange:R=>l(R.target.value),placeholder:"Acme E-commerce GmbH",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"statement-url",className:"block font-medium mb-1",children:["Site URL ",e.jsx("span",{className:"text-rose-600",children:"*"})]}),e.jsx("input",{id:"statement-url",type:"url",value:o,onChange:R=>c(R.target.value),placeholder:"https://acme.example/",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-conformance",className:"block font-medium mb-1",children:"Conformance status"}),e.jsxs("select",{id:"statement-conformance",value:u,onChange:R=>d(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"full",children:"Fully conformant"}),e.jsx("option",{value:"partial",children:"Partially conformant"}),e.jsx("option",{value:"non-conformant",children:"Non-conformant"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1 leading-snug",children:'This is a LEGAL self-declaration. "Partial" is the honest default for most sites with any open findings.'})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-version",className:"block font-medium mb-1",children:"WCAG version"}),e.jsxs("select",{id:"statement-wcag-version",value:I,onChange:R=>O(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"2.1",children:"2.1"}),e.jsx("option",{value:"2.2",children:"2.2"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-wcag-level",className:"block font-medium mb-1",children:"WCAG level"}),e.jsxs("select",{id:"statement-wcag-level",value:$,onChange:R=>F(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"A",children:"A"}),e.jsx("option",{value:"AA",children:"AA"}),e.jsx("option",{value:"AAA",children:"AAA"})]})]})]}),e.jsxs("fieldset",{className:"space-y-1.5",children:[e.jsxs("legend",{className:"font-medium",children:["Feedback contact ",e.jsx("span",{className:"text-rose-600",children:"*"})," ",e.jsx("span",{className:"text-slate-500 font-normal",children:"(at least one required)"})]}),e.jsx("input",{type:"email",value:p,onChange:R=>m(R.target.value),placeholder:"accessibility@acme.example",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Email"}),e.jsx("input",{type:"tel",value:x,onChange:R=>g(R.target.value),placeholder:"+49 30 12345678 (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Phone"}),e.jsx("input",{type:"url",value:j,onChange:R=>b(R.target.value),placeholder:"https://acme.example/contact (optional)",className:"w-full border border-slate-300 rounded px-2 py-1.5","aria-label":"Web form URL"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-country",className:"block font-medium mb-1",children:"Country (for WAD enforcement link)"}),e.jsxs("select",{id:"statement-country",value:C,onChange:R=>k(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"",children:"— Not specified —"}),Object.entries(Hs).map(([R,H])=>e.jsxs("option",{value:R,children:[R," — ",H.name.replace(/^[A-Z]+\s*—\s*/,"")]},R))]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Used only for WAD framing. EAA enforcement is handled per member state's market- surveillance authority and the statement uses a generic line."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-language",className:"block font-medium mb-1",children:"Statement language"}),e.jsx("input",{id:"statement-language",type:"text",value:T,onChange:R=>v(R.target.value),placeholder:"English / Deutsch / Français / …",className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"statement-audited-by",className:"block font-medium mb-1",children:"Audited by"}),e.jsx("input",{id:"statement-audited-by",type:"text",value:S,onChange:R=>w(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5"})]}),U&&e.jsx("div",{className:"text-xs text-rose-800 bg-rose-50 border border-rose-200 rounded p-2",role:"alert",children:U})]}),e.jsxs("div",{className:"p-4 border-t border-slate-200 flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>void re("markdown"),disabled:N,className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:N?"Generating…":"📄 Generate Markdown"}),e.jsx("button",{type:"button",onClick:()=>void re("html"),disabled:N,className:"text-xs px-3 py-1.5 border border-brand-500 text-brand-700 hover:bg-brand-50 rounded disabled:opacity-50 font-medium",children:N?"Generating…":"🌐 Generate HTML"}),e.jsx("button",{type:"button",onClick:s,disabled:N,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 hover:bg-slate-50 rounded disabled:opacity-50 ml-auto",children:"Cancel"})]})]})})}function Gn(){const t=f(N=>N.delta),s=f(N=>N.componentId),a=f(N=>N.results),n=f(N=>N.tier),r=f(N=>N.baselineList),i=f(N=>N.siteCrawlReport),[l,o]=h.useState(""),[c,u]=h.useState(""),[d,p]=h.useState(!1),[m,x]=h.useState(!1),[g,j]=h.useState(null),[b,C]=h.useState(null),[k,T]=h.useState(!1);h.useEffect(()=>{Promise.all([te({type:"SETTINGS_GET",key:"githubRepoUrl"}),te({type:"SETTINGS_GET",key:"jiraInstanceUrl"})]).then(([N,y])=>{o(typeof N.data=="string"?N.data:""),u(typeof y.data=="string"?y.data:"")})},[]);const v=ts(n,"exportJson"),S=as[n].maxBaselines,w=r.some(N=>N.componentId===s),I=w||r.length<S;if(!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit to see the delta against your baseline."});async function O(){if(!s||a.length===0)return;const N=a.flatMap(re=>re.violations),y=a.flatMap(re=>re.announcements??[]),U=a.flatMap(re=>re.focusEvents??[]),D=a[0],ae=(await te({type:"SETTINGS_GET",key:"stateMatrix"})).data??ss;await J({type:"BASELINE_SET",componentId:s,violations:N,announcements:y,focusEvents:U,snapshotMeta:{url:window.location.href,axeVersion:D.axeVersion,matrixConfig:ae,capturedAt:new Date().toISOString()}});const ne=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:N,announcements:y,focusEvents:U,currentMatrix:ae});f.getState().setDelta(ne.delta),ce.polite(`Baseline saved for ${s}.`)}async function $(){if(!s||!w||!window.confirm(`Remove the saved baseline for "${s}"?
8
8
 
9
- Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await J({type:"BASELINE_DELETE",componentId:s});const v=a.flatMap(ne=>ne.violations),U=a.flatMap(ne=>ne.announcements??[]),O=a.flatMap(ne=>ne.focusEvents??[]),G=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:v,announcements:U,focusEvents:O});f.getState().setDelta(G.delta);const ae=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(ae.items),ce.polite(`Baseline cleared for ${s}.`)}async function F(w,v=!1){if(a.length===0)return;if(w==="ai-prompt"){const{copyAiFixerPrompt:W}=await ut(async()=>{const{copyAiFixerPrompt:A}=await import("./copy-ai-fixer-prompt-CO6FY4Hi.js");return{copyAiFixerPrompt:A}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:v?void 0:t,siteCrawlReport:i});return}let U;if((w==="defense-bundle"||w==="evidence-bundle")&&s){const W=await chrome.storage.local.get("igtRuns"),M=((W==null?void 0:W.igtRuns)??{})[s]??{};U=Object.values(M)}const ae=await te({type:"EXPORT_REQUEST",format:w,results:a,delta:v?void 0:t??void 0,manualRuns:U,dismissedKeys:void 0,incompleteResolutions:void 0});if(w==="defense-bundle"||w==="evidence-bundle"){const W=zt(w,s);await Kt()?ot(ae.content,W):T({open:!0,format:w,content:ae.content,filename:W});return}if(w==="html-print"||w==="vpat"){it(ae.content);return}const ne=w==="json"?"application/json":w==="sarif"?"application/sarif+json":"application/xml",re=w==="junit"?"xml":w,I=new Blob([ae.content],{type:ne}),H=URL.createObjectURL(I),X=document.createElement("a");X.href=H,X.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${re}`,X.click(),URL.revokeObjectURL(H)}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:_,disabled:!C,title:C?void 0:`Free tier limits you to ${S} 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"}),j&&e.jsx("button",{onClick:$,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>p(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx(Fn,{disabled:!b,onExport:F,onAccessibilityStatement:()=>E(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!C&&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 w=Ke(t.new),v=Ke(t.persistent),U=Ke(t.fixed),O=[...w.review,...v.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{title:"New",violations:w.findings,count:w.findings.length,accent:"red",actions:[...o&&w.findings.length>0?[{label:"File GitHub issue",onClick:()=>_n(o,s,w.findings)}]:[],...c&&w.findings.length>0?[{label:"File Jira issue",onClick:()=>Dn(c,s,w.findings)}]:[]]}),e.jsx(Ne,{title:"Persistent",violations:v.findings,count:v.findings.length,accent:"slate"}),e.jsx(Ne,{title:"Fixed",violations:U.findings,count:t.fixedCount,accent:"green"}),O.length>0&&e.jsx(Ne,{title:"Needs review (does not affect grade)",violations:O,count:O.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ne,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),k&&e.jsx(gs,{open:k.open,onClose:()=>T(null),format:k.format,content:k.content,filename:k.filename}),e.jsx(Ln,{open:N,onClose:()=>E(!1),results:a}),d&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{p(!1),y(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>p(!1),disabled:m,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{x(!0);try{const w=await Rn();y(w),await We(),ce.polite("Audit data reset. Ready for a fresh scan.")}catch(w){y({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[w instanceof Error?w.message:String(w)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const On={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ke(t){const s=[],a=[];for(const n of t)n.needsReview?a.push(n):s.push(n);return{findings:s,review:a,fixed:0}}function Ne({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[o,l]=h.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${On[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>l(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:o?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),o?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,u)=>e.jsx(Ge,{violation:c,alreadyAcknowledged:!0},u)):kn(s).map(c=>e.jsx(Nn,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function _n(t,s,a){if(a.length===0)return;const{url:n}=An(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Dn(t,s,a){if(a.length===0)return;const{url:n}=Cn(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Fn({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[o,l]=h.useState(!1);function c(u){i(!1),s(u,o)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:u=>l(u.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(pe,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(pe,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(pe,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(pe,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(pe,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(pe,{onClick:()=>c("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(pe,{onClick:()=>c("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(pe,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(pe,{onClick:()=>{i(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function pe({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const Lt="igtRuns";async function Mn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Lt))[Lt];return s&&typeof s=="object"?s:{}}async function Pn(t,s){var o,l;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await Mn())[t];if(i)for(const c of ee){const u=i[c.id];if(u)for(const d of c.steps){if(!d.autoDismissActivity||((l=(o=u.steps)==null?void 0:o[d.id])==null?void 0:l.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:ge(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const Gn=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"]),Vn=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 Wn(t){return Gn.has(t.ruleId)}function Bn(t){return Vn.has(t.ruleId)}function Hn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function zn(){var _,$,F,w;const t=f(v=>v.results),s=f(v=>v.delta),a=f(v=>v.componentId),n=((_=t[0])==null?void 0:_.pageUrl)??(($=t[0])==null?void 0:$.scope)??"",[r,i]=h.useState({}),[o,l]=h.useState(0);h.useEffect(()=>{if(!n)return;let v=!1;return(async()=>{if(a&&t.length>0)try{await Pn(a,t)}catch{}if(v)return;const U=await Ve(n);v||i(U)})(),()=>{v=!0}},[n,o,a,t]);async function c(v,U){if(!n)return;const O=window.prompt(`Why is this finding a false positive?
9
+ Future audits will treat every detected violation as new (no delta filtering). This cannot be undone.`))return;await J({type:"BASELINE_DELETE",componentId:s});const y=a.flatMap(ne=>ne.violations),U=a.flatMap(ne=>ne.announcements??[]),D=a.flatMap(ne=>ne.focusEvents??[]),G=await te({type:"BASELINE_COMPARE",componentId:s,currentViolations:y,announcements:U,focusEvents:D});f.getState().setDelta(G.delta);const ae=await te({type:"BASELINE_LIST"});f.getState().setBaselineList(ae.items),ce.polite(`Baseline cleared for ${s}.`)}async function F(N,y=!1){if(a.length===0)return;if(N==="ai-prompt"){const{copyAiFixerPrompt:W}=await ut(async()=>{const{copyAiFixerPrompt:A}=await import("./copy-ai-fixer-prompt-Ca9DEwvW.js");return{copyAiFixerPrompt:A}},__vite__mapDeps([0,1,2]));await W({results:a,componentId:s,delta:y?void 0:t,siteCrawlReport:i});return}let U;if((N==="defense-bundle"||N==="evidence-bundle")&&s){const W=await chrome.storage.local.get("igtRuns"),M=((W==null?void 0:W.igtRuns)??{})[s]??{};U=Object.values(M)}const ae=await te({type:"EXPORT_REQUEST",format:N,results:a,delta:y?void 0:t??void 0,manualRuns:U,dismissedKeys:void 0,incompleteResolutions:void 0});if(N==="defense-bundle"||N==="evidence-bundle"){const W=Qt(N,s);await Yt()?lt(ae.content,W):C({open:!0,format:N,content:ae.content,filename:W});return}if(N==="html-print"||N==="vpat"){it(ae.content);return}const ne=N==="json"?"application/json":N==="sarif"?"application/sarif+json":"application/xml",re=N==="junit"?"xml":N,R=new Blob([ae.content],{type:ne}),H=URL.createObjectURL(R),X=document.createElement("a");X.href=H,X.download=`audit-${(s==null?void 0:s.replace(/[^a-z0-9]/gi,"-"))??"export"}.${re}`,X.click(),URL.revokeObjectURL(H)}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:O,disabled:!I,title:I?void 0:`Free tier limits you to ${S} 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"}),w&&e.jsx("button",{onClick:$,title:"Remove the saved baseline so every detected violation counts as new again.",className:"text-xs px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear baseline"}),e.jsx("button",{onClick:()=>p(!0),title:"Wipe ALL audit-derived state (baselines, history, IGT runs, dismissals, AI cache). User settings + custom rules + license are preserved. Use after a major site rebuild.",className:"text-xs px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Reset all audit data"}),e.jsx(Hn,{disabled:!v,onExport:F,onAccessibilityStatement:()=>T(!0),hasBaselineDelta:!!(t!=null&&t.baselineSnapshotMeta)}),!I&&e.jsx("span",{className:"text-xs text-amber-700",children:"Free tier · 1 baseline limit reached."})]}),t.matrixMismatchWarning&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["⚠ ",t.matrixMismatchWarning]}),(()=>{const N=Ke(t.new),y=Ke(t.persistent),U=Ke(t.fixed),D=[...N.review,...y.review];return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{title:"New",violations:N.findings,count:N.findings.length,accent:"red",actions:[...l&&N.findings.length>0?[{label:"File GitHub issue",onClick:()=>Wn(l,s,N.findings)}]:[],...c&&N.findings.length>0?[{label:"File Jira issue",onClick:()=>Bn(c,s,N.findings)}]:[]]}),e.jsx(Ne,{title:"Persistent",violations:y.findings,count:y.findings.length,accent:"slate"}),e.jsx(Ne,{title:"Fixed",violations:U.findings,count:t.fixedCount,accent:"green"}),D.length>0&&e.jsx(Ne,{title:"Needs review (does not affect grade)",violations:D,count:D.length,accent:"amber"}),t.acknowledged&&t.acknowledged.length>0&&e.jsx(Ne,{title:"Acknowledged",violations:t.acknowledged,count:t.acknowledged.length,accent:"slate",renderAsAcknowledged:!0})]})})(),b&&e.jsx(vs,{open:b.open,onClose:()=>C(null),format:b.format,content:b.content,filename:b.filename}),e.jsx(Pn,{open:k,onClose:()=>T(!1),results:a}),d&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"reset-confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-3",children:e.jsxs("div",{className:"bg-white border border-slate-300 rounded-lg shadow-xl max-w-sm w-full p-4 space-y-3",children:[e.jsx("h2",{id:"reset-confirm-title",className:"text-sm font-semibold text-slate-900",children:"Reset all audit data?"}),e.jsx("p",{className:"text-xs text-slate-700 leading-snug",children:"Wipes everything derived from your audits — for a true fresh start after a site rebuild."}),e.jsxs("div",{className:"text-[11px] text-slate-700 space-y-1",children:[e.jsx("p",{className:"font-medium text-slate-800",children:"Will be deleted:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"All baselines + audit history"}),e.jsx("li",{children:"Forensic log entries (the anchored receipts stay anchored to their public TSAs, but the local mirror is gone)"}),e.jsx("li",{children:"Guided Tests workflow answers"}),e.jsx("li",{children:"Acknowledged findings + dismissals"}),e.jsx("li",{children:"AI color suggestions + incomplete resolutions cache"}),e.jsx("li",{children:"Last persisted audit"})]}),e.jsx("p",{className:"font-medium text-slate-800 mt-2",children:"Preserved:"}),e.jsxs("ul",{className:"list-disc list-inside text-slate-600 space-y-0.5",children:[e.jsx("li",{children:"Your AI API key + cost cap + check toggles"}),e.jsx("li",{children:"Matrix presets + disabled-rule list"}),e.jsx("li",{children:"Custom rules"}),e.jsx("li",{children:"License + tier"}),e.jsx("li",{children:"Owner / Developer mode"})]})]}),g&&e.jsxs("div",{className:"text-[11px] bg-emerald-50 border border-emerald-200 rounded p-2 text-emerald-900",children:["✓ Cleared ",g.chromeStorageKeysCleared," chrome.storage key",g.chromeStorageKeysCleared===1?"":"s"," + ",g.indexedDbsCleared.length," database",g.indexedDbsCleared.length===1?"":"s",".",g.errors.length>0&&e.jsxs("div",{className:"mt-1 text-rose-800",children:["Partial: ",g.errors.join("; ")]})]}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:g?e.jsx("button",{type:"button",onClick:()=>{p(!1),j(null)},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>p(!1),disabled:m,className:"text-xs px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:async()=>{x(!0);try{const N=await On();j(N),await We(),ce.polite("Audit data reset. Ready for a fresh scan.")}catch(N){j({chromeStorageKeysCleared:0,indexedDbsCleared:[],errors:[N instanceof Error?N.message:String(N)]})}finally{x(!1)}},disabled:m,className:"text-xs px-3 py-1.5 bg-rose-600 text-white rounded hover:bg-rose-700 disabled:opacity-50",children:m?"Resetting…":"Reset everything"})]})})]})})]})}const Vn={red:"text-red-700",slate:"text-slate-700",green:"text-green-700",amber:"text-amber-700"};function Ke(t){const s=[],a=[];for(const n of t)n.needsReview?a.push(n):s.push(n);return{findings:s,review:a,fixed:0}}function Ne({title:t,violations:s,count:a,accent:n,actions:r,renderAsAcknowledged:i}){const[l,o]=h.useState(!i);return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2 flex-wrap",children:[e.jsxs("h2",{className:`text-xs font-semibold ${Vn[n]} ${i?"cursor-pointer select-none":""}`,onClick:i?()=>o(c=>!c):void 0,children:[i&&e.jsx("span",{className:"mr-1 text-slate-400",children:l?"▾":"▸"}),t," (",a,")"]}),r&&r.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.map(c=>e.jsx("button",{type:"button",onClick:c.onClick,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:c.label},c.label))})]}),l?s.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"none"}):e.jsx("div",{className:"space-y-1.5",children:i?s.map((c,u)=>e.jsx(Ge,{violation:c,alreadyAcknowledged:!0},u)):Tn(s).map(c=>e.jsx(En,{ruleId:c.ruleId,violations:c.violations},c.ruleId))}):null]})}function Wn(t,s,a){if(a.length===0)return;const{url:n}=Ln(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Bn(t,s,a){if(a.length===0)return;const{url:n}=Un(t,s,a);window.open(n,"_blank","noopener,noreferrer")}function Hn({disabled:t,onExport:s,onAccessibilityStatement:a,hasBaselineDelta:n}){const[r,i]=h.useState(!1),[l,o]=h.useState(!1);function c(u){i(!1),s(u,l)}return e.jsxs("div",{className:"relative inline-block",children:[e.jsx("button",{type:"button",disabled:t,onClick:()=>i(u=>!u),title:t?"Export requires a paid tier.":"Choose an export format",className:"text-xs px-2 py-1 bg-slate-200 hover:bg-slate-300 rounded disabled:opacity-50 disabled:cursor-not-allowed",children:"Export ▾"}),r&&!t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-[200px] bg-white border border-slate-200 rounded shadow-md py-1",role:"menu",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-2 px-3 py-2 text-[11px] cursor-pointer hover:bg-slate-50",title:"By default, delta-aware formats (AI prompt, SARIF, JUnit) emit only NEW violations vs. the saved baseline. Enable this to include every detected violation regardless of baseline.",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:u=>o(u.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(pe,{onClick:()=>c("json"),title:"Native format with full audit detail.",children:"JSON"}),e.jsx(pe,{onClick:()=>c("sarif"),title:"SARIF for GitHub code-scanning + most CI tools.",children:"SARIF"}),e.jsx(pe,{onClick:()=>c("junit"),title:"JUnit XML for Jenkins / GitLab CI test reporters.",children:"JUnit XML"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(pe,{onClick:()=>c("html-print"),title:"Opens a print-ready HTML report in a new tab. Use Ctrl+P / Cmd+P → Save as PDF.",children:"Print report (PDF)"}),e.jsx(pe,{onClick:()=>c("vpat"),title:"VPAT 2.5 conformance report — opens in a new tab for review and printing.",children:"VPAT 2.5"}),e.jsx(pe,{onClick:()=>c("defense-bundle"),title:"One-document attorney-ready bundle for site owners: exec summary + risk grade + per-category breakdown + full findings + screenshots + VPAT + remediation plan + methodology + disclaimer.",children:"Defense bundle 📄"}),e.jsx(pe,{onClick:()=>c("evidence-bundle"),title:"Same content as defense bundle, reframed as objective audit evidence (for compliance documentation, complaints, or third-party review).",children:"Evidence bundle 📄"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(pe,{onClick:()=>c("ai-prompt"),title:"Generate a structured prompt to paste into Claude / Cursor / Copilot. Auto-copies to clipboard.",children:"AI fix prompt ✨"}),e.jsx("div",{className:"border-t border-slate-100 my-1"}),e.jsx(pe,{onClick:()=>{i(!1),a()},title:"EAA / WAD accessibility statement (EU directives). Opens a form to enter org info, then generates Markdown or HTML for your site. EAA enforceable since 28 June 2025.",children:"EAA / WAD statement 🇪🇺"})]})]})]})}function pe({onClick:t,title:s,children:a}){return e.jsx("button",{type:"button",role:"menuitem",onClick:t,title:s,className:"block w-full text-left text-xs px-3 py-1 hover:bg-slate-100",children:a})}const Ot="igtRuns";async function zn(){var a;if(typeof chrome>"u"||!((a=chrome.storage)!=null&&a.local))return{};const s=(await chrome.storage.local.get(Ot))[Ot];return s&&typeof s=="object"?s:{}}async function Kn(t,s){var l,o;const a=s[0];if(!(a!=null&&a.pageUrl))return;const n=a.pageUrl,i=(await zn())[t];if(i)for(const c of ee){const u=i[c.id];if(u)for(const d of c.steps){if(!d.autoDismissActivity||((o=(l=u.steps)==null?void 0:l[d.id])==null?void 0:o.status)!=="pass")continue;const m=`Auto-dismissed by Guided test: "${d.id}" marked pass`;if(d.autoDismissActivity==="tab-order"){const x=a.tabOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:fe(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}else if(d.autoDismissActivity==="reading-order"){const x=a.readingOrderIssues??[];if(x.length===0)continue;await Re(n,x.map(g=>({key:ge(g.selector),reason:m,snippet:`${g.selector} — ${g.textSnippet||"(no text)"}`})))}}}}const qn=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"]),Qn=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 Yn(t){return qn.has(t.ruleId)}function Jn(t){return Qn.has(t.ruleId)}function Xn(t){return[t.pseudoState,t.theme,t.direction,t.breakpoint.id].join(" · ")}function Zn(){var O,$,F,N;const t=f(y=>y.results),s=f(y=>y.delta),a=f(y=>y.componentId),n=((O=t[0])==null?void 0:O.pageUrl)??(($=t[0])==null?void 0:$.scope)??"",[r,i]=h.useState({}),[l,o]=h.useState(0);h.useEffect(()=>{if(!n)return;let y=!1;return(async()=>{if(a&&t.length>0)try{await Kn(a,t)}catch{}if(y)return;const U=await Ve(n);y||i(U)})(),()=>{y=!0}},[n,l,a,t]);async function c(y,U){if(!n)return;const D=window.prompt(`Why is this finding a false positive?
10
10
 
11
- (Recorded with the dismissal so future you remembers the reasoning.)`,"");O!==null&&(await us(n,v,O||"(no reason given)",U),l(G=>G+1))}async function u(v){n&&(await ps(n,v),l(U=>U+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((v,U)=>{var O;return v+(((O=U.announcements)==null?void 0:O.length)??0)},0),p=t.reduce((v,U)=>{var O;return v+(((O=U.focusEvents)==null?void 0:O.length)??0)},0),m=t.reduce((v,U)=>{var O;return v+(((O=U.focusEvents)==null?void 0:O.filter(G=>G.isFocusReset).length)??0)},0),x=Ut(t,Wn),g=Ut(t,Bn),y=x.length,k=g.length,T=((F=t[0])==null?void 0:F.readingOrderIssues)??[],N=((w=t[0])==null?void 0:w.tabOrderIssues)??[],E=T.filter(v=>!(ge(v.selector)in r)),b=T.filter(v=>ge(v.selector)in r),S=N.filter(v=>!(fe(v.selector)in r)),j=N.filter(v=>fe(v.selector)in r);if(d===0&&p===0&&y===0&&k===0&&E.length===0&&S.length===0&&b.length===0&&j.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const C=b.length+j.length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2",children:[y," structural · ",k," form ·"," ",S.length," tab-order ·"," ",E.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",p," focus ",p===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),C>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",C," dismissed"]})]}),S.length>0&&e.jsx(Qn,{issues:S,onDismiss:c}),E.length>0&&e.jsx(Yn,{issues:E,onDismiss:c}),C>0&&e.jsx(Jn,{dismissedReadingOrder:b,dismissedTabOrder:j,dismissals:r,onRestore:u}),y>0&&e.jsx(Ot,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),k>0&&e.jsx(Ot,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(Kn,{delta:s}),t.map((v,U)=>{const O=v.announcements??[],G=v.focusEvents??[];return O.length===0&&G.length===0?null:e.jsx(qn,{state:v.state,announcements:O,focusEvents:G},U)})]})}function Kn({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function Ut(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ct(r.ruleId,r.target.selector),o=a.get(i);o?o.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Ot({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function qn({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Hn(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function Qn({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Yn({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function Jn({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),o=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",o,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(l=>{const c=`tab-order::${l.selector}`,u=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(l=>{const c=`reading-order::${l.selector}`,u=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:l.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:l.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const st="igtRuns";async function Xn(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const o=n.tabOrderIssues??[];if(o.length===0)return;await Re(r,o.map(l=>({key:fe(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const o=n.readingOrderIssues??[];if(o.length===0)return;await Re(r,o.map(l=>({key:ge(l.selector),reason:i,snippet:`${l.selector} — ${l.textSnippet||"(no text)"}`})))}}const Zn={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"}},er={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"}},tr={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function _t(t,s){const a=await oe();if(!a)return;const n=s?Zn[t]:er[t];try{await ue(a,n)}catch{}}async function sr(){const s=(await chrome.storage.local.get(st))[st];return s&&typeof s=="object"?s:{}}async function Dt(t){await chrome.storage.local.set({[st]:t})}function ar(t,s){if(!t.relatedAxeRule||s.length===0)return null;const a=s.flatMap(n=>n.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(a.length>0){const n=Array.from(new Set(a.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:a.length,states:n}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function nr(){const t=f(d=>d.componentId),s=f(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{sr().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const o=a[t]??{};function l(d,p,m){var g;const x={...a,[t]:{...o,[d]:{...o[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=o[d])==null?void 0:g.steps)??{},[p]:m},completedAt:new Date().toISOString()}}};if(n(x),Dt(x),m.status==="pass"){const y=ee.find(T=>T.id===d),k=y==null?void 0:y.steps.find(T=>T.id===p);k!=null&&k.autoDismissActivity&&Xn(k.autoDismissActivity,s,p)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...o};delete p[d];const m={...a,[t]:p};n(m),Dt(m)}const u=ee.find(d=>d.id===r);if(u){const d=o[u.id];return e.jsx(rr,{workflow:u,run:d,results:s,onAnswer:(p,m)=>l(u.id,p,m),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),ee.map(d=>{const p=o[d.id],m=p?Ws(p,d):null,x=p?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",g={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),p&&e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function rr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const u of t.steps)c[u.id]=ar(u,a);return c},[t,a]);function o(){for(const c of t.steps){const u=i[c.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const l=t.steps.filter(c=>{var u;return((u=i[c.id])==null?void 0:u.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,u)=>{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:[u+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 p=i[c.id];return p?p.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void _t(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",tr[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void _t(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:p=>n(c.id,{status:d.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const ir={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Te({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?ir[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const Oe="savedFlows";async function or(){const t=await chrome.storage.local.get(Oe);return Array.isArray(t[Oe])?t[Oe]:[]}async function Ft(t){await chrome.storage.local.set({[Oe]:t})}function lr(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{or().then(s)},[]);async function o(){const d=await oe();if(!d){i("No audit-target tab found.");return}try{await ue(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function l(){const d=await oe();if(d)try{const p=await Ie(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${p.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:p.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Ft(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function c(d){const p=await oe();if(p){i(`Replaying "${d.name}"…`);try{const m=await Ie(p,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function u(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(m=>m.id!==d);s(p),await Ft(p)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(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:()=>u(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function cr(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),o=n.slice(r+1);return i==="story"?{primary:o.split("--").map(c=>c.split("-").map(dr).join(" ")).join(" / "),secondary:"storybook"}:{primary:o,secondary:a||i}}function dr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function ur(){const t=f(l=>l.baselineList),s=f(l=>l.tier),a=es[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(l=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},l))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function o(l){await J({type:"BASELINE_DELETE",componentId:l}),await Fe()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(l=>{const c=cr(l.componentId),u=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()]}),u&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[l.seenOnUrlsCount&&l.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",l.seenOnUrlsCount," pages"]}),u.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${u.criticalCount} critical violations`,children:[u.criticalCount," critical"]}),u.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${u.seriousCount} serious violations`,children:[u.seriousCount," serious"]}),u.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${u.focusResetCount} focus resets observed`,children:[u.focusResetCount," focus reset",u.focusResetCount===1?"":"s"]}),u.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[u.targetSizeFailCount," small targets"]}),u.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),u.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[u.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 pr={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${pr[t]}`,children:a})}const mr={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"},hr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},xr={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 fs({onBack:t}){const s=f(p=>p.siteCrawlStatus),a=f(p=>p.siteCrawlProgress),n=f(p=>p.siteCrawlReport),r=f(p=>p.siteCrawlError),[i,o]=h.useState(""),[l,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(p=>{var x;const m=(x=p[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&o(m)});function u(){i&&(l>=5&&!window.confirm(`Each of the ${l} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${l*5} minutes. Proceed?`)||(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),de({type:"START_SITE_CRAWL",startUrl:i,maxPages:l})))}function d(){J({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:p=>o(p.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:l,onChange:p=>c(Math.min(200,Math.max(1,parseInt(p.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your full single-page audit pipeline (matrix + analyzers + AI)."})]}),e.jsx("button",{type:"button",onClick:u,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(gr,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function gr({report:t}){function s(){ut(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer-cCg8cDS3.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,2,5])).then(({renderSiteReportHtml:i})=>{const o=i(t),l=new Blob([o],{type:"text/html"}),c=URL.createObjectURL(l);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=h.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),o=(i==null?void 0:i.content)??"";if(!o){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(o)}catch{}const l=new Blob([o],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(l);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${mr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${hr[t.siteRisk]}`,children:Bs[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsx("button",{type:"button",onClick:r,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(i=>{const o=Hs(i.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${xr[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:o.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void fr(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function fr(t){try{const s=await zs(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){f.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}f.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const qe="onboardingDismissed",Qe=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function br(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(qe).then(l=>{l[qe]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[qe]:!0}),s(!1),n(0)}const i=a===Qe.length-1,o=Qe[a];return e.jsxs(be,{open:t,onClose:r,title:o.title,children:[e.jsx("div",{children:o.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Qe.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(l=>l-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(l=>l+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function vr(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function yr(){const t=f(c=>c.aiFailure),s=f(c=>c.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",o="⚠",l=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:o})," ",l]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,u)=>e.jsx("li",{children:c},u))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Mt(){const[t,s]=h.useState(!1);return h.useEffect(()=>le("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(be,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function jr(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{Ks().then(o=>{o&&o.state==="interrupted"&&s(o)})},[]),!t)return null;async function a(){t&&(await jt(),f.getState().startNewScan(),t.mode==="storybook-all"?de({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&de({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await jt(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Ye="storybook:hintDismissed";function wr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var l;if((await chrome.storage.local.get(Ye))[Ye])return;const o=await oe();if(o)try{const u=(await chrome.scripting.executeScript({target:{tabId:o,allFrames:!0},world:"MAIN",func:()=>{var p;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(p=d.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(d=>{var p;return(p=d.result)==null?void 0:p.detected});u&&(n((l=u.result)==null?void 0:l.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Nr(){var i;const t=f(o=>o.results),s=f(o=>o.baselineList),a=f(o=>o.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${kr(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function kr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const o=Math.round(i/60);if(o<24)return`${o}h ago`;const l=Math.round(o/24);return l<7?`${l}d ago`:a.toLocaleDateString()}function Sr(){const t=f(l=>l.results),s=f(l=>l.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let l=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(l)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{l=!0}},[s]),t.length===0)return null;const r=t.flatMap(l=>l.violations),i=qs(r,a.length>0?{runs:a,workflows:ee}: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 Ar(){const t=f(a=>a.setUserMode);function s(a){t(a),J({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Cr=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],Ir={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function Rr(t){const s=new Set(Cr),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,u])=>({ruleId:c,instanceCount:u})).sort((c,u)=>u.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,u)=>c+u,0);let o;return r===0?o="low":r===1?o="moderate":r<=3?o="high":o="critical",{tier:o,letter:o==="low"?"A":o==="moderate"?"C":o==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Ir[o]}}const bs={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},Er={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[bs]},Tr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[bs]};function ht(t){return t==="thorough"?Tr:Er}function Pt(t){const s=ht(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const _e="wcagcheckr";function V(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ce(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 $r(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Lr(t){if(t.length===0)return null;const s=[...t].sort((a,n)=>a.capturedAt.localeCompare(n.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function Ur(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function Or(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 _r(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${V(t.receipt.tsaName)}) — anchored ${V(Ce(t.receipt.anchoredAt))}</td></tr>
11
+ (Recorded with the dismissal so future you remembers the reasoning.)`,"");D!==null&&(await hs(n,y,D||"(no reason given)",U),o(G=>G+1))}async function u(y){n&&(await xs(n,y),o(U=>U+1))}if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No audit results yet. Pick an element and run an audit to see live-region announcements and focus paths captured per state."});const d=t.reduce((y,U)=>{var D;return y+(((D=U.announcements)==null?void 0:D.length)??0)},0),p=t.reduce((y,U)=>{var D;return y+(((D=U.focusEvents)==null?void 0:D.length)??0)},0),m=t.reduce((y,U)=>{var D;return y+(((D=U.focusEvents)==null?void 0:D.filter(G=>G.isFocusReset).length)??0)},0),x=_t(t,Yn),g=_t(t,Jn),j=x.length,b=g.length,C=((F=t[0])==null?void 0:F.readingOrderIssues)??[],k=((N=t[0])==null?void 0:N.tabOrderIssues)??[],T=C.filter(y=>!(ge(y.selector)in r)),v=C.filter(y=>ge(y.selector)in r),S=k.filter(y=>!(fe(y.selector)in r)),w=k.filter(y=>fe(y.selector)in r);if(d===0&&p===0&&j===0&&b===0&&T.length===0&&S.length===0&&v.length===0&&w.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No live-region announcements, focus events, structural issues, form issues, or reading/tab-order concerns captured during this audit."});const I=v.length+w.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:[j," structural · ",b," form ·"," ",S.length," tab-order ·"," ",T.length," reading-order ·"," ",d," ",d===1?"announcement":"announcements"," ·"," ",p," focus ",p===1?"event":"events",m>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[" · ",m," focus reset",m===1?"":"s"]}),I>0&&e.jsxs("span",{className:"text-slate-400",children:[" · ",I," dismissed"]})]}),S.length>0&&e.jsx(sr,{issues:S,onDismiss:c}),T.length>0&&e.jsx(ar,{issues:T,onDismiss:c}),I>0&&e.jsx(nr,{dismissedReadingOrder:v,dismissedTabOrder:w,dismissals:r,onRestore:u}),j>0&&e.jsx(Ft,{title:"Structural issues",subtitle:"Heading hierarchy, landmarks, ID uniqueness, skip-nav. Toggle the Outline visualizer above to see these positioned on the page.",groups:x}),b>0&&e.jsx(Ft,{title:"Form issues",subtitle:"Label association, autocomplete, ARIA names + required state. Pairs with the audit's :disabled / aria-invalid matrix coverage.",groups:g}),e.jsx(er,{delta:s}),t.map((y,U)=>{const D=y.announcements??[],G=y.focusEvents??[];return D.length===0&&G.length===0?null:e.jsx(tr,{state:y.state,announcements:D,focusEvents:G},U)})]})}function er({delta:t}){if(!t||!t.baselineSnapshotMeta)return null;const s=t.newAnnouncements??[],a=t.newFocusEvents??[],n=a.filter(r=>r.isFocusReset);return s.length===0&&a.length===0?null:e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-rose-800",children:"Behavioral regressions vs baseline"}),e.jsx("p",{className:"text-[11px] text-rose-700",children:"Announcements / focus transitions that didn't exist when this baseline was captured. These represent NEW behavior since the baseline — likely a regression worth investigating."}),n.length>0&&e.jsxs("p",{className:"text-[11px] font-medium text-rose-800",children:["⚠ ",n.length," new focus reset",n.length===1?"":"s"," (focus jumped to body/html unexpectedly)."]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px]",children:[e.jsxs("span",{className:"font-mono text-rose-700",children:["[",r.role??r.politeness,"]"]})," ",e.jsx("span",{children:r.text})]},i))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wide text-rose-600 mb-1",children:["New focus transitions (",a.length,")"]}),e.jsx("ul",{className:"space-y-1",children:a.slice(0,10).map((r,i)=>e.jsxs("li",{className:"text-[11px] font-mono",children:[r.fromSelector??"(none)"," → ",r.toSelector,r.isFocusReset&&e.jsx("span",{className:"text-rose-700 ml-1",children:"(reset)"})]},i))})]})]})}function _t(t,s){const a=new Map;for(const n of t)for(const r of n.violations){if(!s(r))continue;const i=ct(r.ruleId,r.target.selector),l=a.get(i);l?l.states.push(r.currentState):a.set(i,{violation:r,states:[r.currentState]})}return Array.from(a.values()).sort((n,r)=>{const i={critical:0,serious:1,moderate:2,minor:3};return(i[n.violation.impact]??99)-(i[r.violation.impact]??99)})}function Ft({title:t,subtitle:s,groups:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:t}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s}),e.jsx("ul",{className:"space-y-1.5",children:a.map((n,r)=>e.jsxs("li",{className:"text-xs border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsx("span",{className:"font-mono font-medium",children:n.violation.ruleId}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded shrink-0 ${n.violation.impact==="critical"||n.violation.impact==="serious"?"bg-rose-100 text-rose-700":"bg-yellow-100 text-yellow-700"}`,children:n.violation.impact})]}),e.jsx("p",{className:"text-[11px] text-slate-700 mb-1",children:n.violation.description}),e.jsx("code",{className:"text-[10px] font-mono text-slate-500 break-all",children:n.violation.target.selector})]},r))})]})}function tr({state:t,announcements:s,focusEvents:a}){return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-white space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-slate-700",children:Xn(t)}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Announcements (",s.length,")"]}),e.jsx("ul",{className:"space-y-1",children:s.map((n,r)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border-l-2 pl-2",style:{borderColor:n.politeness==="assertive"?"rgb(244,63,94)":"rgb(99,102,241)"},children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${n.politeness==="assertive"?"bg-rose-100 text-rose-700":"bg-indigo-100 text-indigo-700"}`,children:n.role??n.politeness}),e.jsx("span",{className:"text-slate-700 break-all",children:n.text})]},r))})]}),a.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1",children:["Focus path (",a.length,")"]}),e.jsx("ol",{className:"space-y-1",children:a.map((n,r)=>e.jsxs("li",{className:`text-[11px] flex items-start gap-2 ${n.isFocusReset?"text-rose-700 font-medium":"text-slate-700"}`,children:[e.jsxs("span",{className:"font-mono text-slate-500 shrink-0",children:["+",n.msSinceArm,"ms"]}),n.fromSelector&&e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"font-mono text-slate-500",children:n.fromSelector}),e.jsx("span",{className:"text-slate-500",children:"→"})]}),e.jsx("code",{className:"font-mono",children:n.toSelector}),n.isFocusReset&&e.jsx("span",{className:"text-[10px] bg-rose-100 px-1 rounded",children:"reset"})]},r))})]})]})}function sr({issues:t,onDismiss:s}){const a=t.filter(r=>r.flag==="visual"||r.flag==="both").length,n=t.filter(r=>r.flag==="tabindex"||r.flag==="both").length;return e.jsxs("section",{className:"border border-rose-200 rounded p-2 bg-rose-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-rose-900",children:["Tab-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-rose-800 leading-snug",children:["Keyboard users tab through the page in this order; sighted users scan the page in a different order. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 2.4.3 Focus Order (A)"}),". Toggle the ",e.jsx("strong",{children:"Tab order"})," ","visualizer above to see the badges positioned on the page."]}),e.jsxs("p",{className:"text-[11px] text-rose-700",children:[a>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," visual mismatch",a===1?"":"es",n>0&&" · "]}),n>0&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:n})," positive-tabindex reordering",n===1?"":"s"]})]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((r,i)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-rose-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] ${r.flag==="visual"||r.flag==="both"?"bg-rose-600 text-white":"bg-amber-500 text-slate-900"}`,title:r.flag==="visual"?"Tab order does not match visual layout — focus jumps around":r.flag==="tabindex"?"Positive tabindex reordered the DOM source sequence":"Both: tab order doesn't match visual AND tabindex reordering",children:["tab",r.tabPosition,"→vis",r.visualPosition,(r.flag==="tabindex"||r.flag==="both")&&` (DOM${r.domPosition})`]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:r.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:r.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`tab-order::${r.selector}`,`${r.selector} — ${r.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-rose-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional skip-link, portal-rendered modal). You'll be asked for a reason.",children:"dismiss"})]},i)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-rose-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function ar({issues:t,onDismiss:s}){return e.jsxs("section",{className:"border border-amber-200 rounded p-2 bg-amber-50 space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-900",children:["Reading-order concerns (",t.length,")"]}),e.jsxs("p",{className:"text-[11px] text-amber-800 leading-snug",children:["Screen readers read the DOM in source order. CSS that visually rearranges things (",e.jsx("code",{className:"font-mono",children:"flex-direction: row-reverse"}),","," ",e.jsx("code",{className:"font-mono",children:"order:"}),", absolute positioning) does NOT reorder what the SR sees. axe-core does not detect this. Maps to"," ",e.jsx("strong",{children:"WCAG 1.3.2 Meaningful Sequence (A)"}),". Heuristic — multi-column layouts and skip-links produce legitimate mismatches. Toggle the"," ",e.jsx("strong",{children:"Reading order"})," visualizer above to see the badges positioned on the page."]}),e.jsxs("ul",{className:"space-y-1",children:[t.slice(0,20).map((a,n)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-amber-200 rounded bg-white p-1.5",children:[e.jsxs("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-amber-500 text-slate-900",title:"DOM index → Visual index",children:["dom",a.domIndex,"→vis",a.visualIndex]}),e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all shrink-0",children:a.selector}),e.jsx("span",{className:"text-slate-700 break-words flex-1",children:a.textSnippet||e.jsx("em",{children:"(no text)"})}),e.jsx("button",{type:"button",onClick:()=>void s(`reading-order::${a.selector}`,`${a.selector} — ${a.textSnippet||"(no text)"}`),className:"text-[10px] text-slate-400 hover:text-amber-700 shrink-0 underline-offset-2 hover:underline",title:"Dismiss as false positive (e.g. intentional multi-column layout). You'll be asked for a reason.",children:"dismiss"})]},n)),t.length>20&&e.jsxs("li",{className:"text-[10px] text-amber-700 italic px-1",children:["+",t.length-20," more — see the AI-fix-prompt export for the full list."]})]})]})}function nr({dismissedReadingOrder:t,dismissedTabOrder:s,dismissals:a,onRestore:n}){const[r,i]=h.useState(!1),l=t.length+s.length;return e.jsxs("section",{className:"border border-slate-200 rounded p-2 bg-slate-50",children:[e.jsxs("button",{type:"button",onClick:()=>i(!r),"aria-expanded":r,className:"w-full text-left text-xs font-semibold text-slate-700 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:r?"▼":"▶"}),e.jsxs("span",{children:["Dismissed (",l,")"]}),e.jsxs("span",{className:"text-[10px] font-normal text-slate-500 ml-auto",children:["click to ",r?"collapse":"review"]})]}),r&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Findings you previously marked as false positives for this URL. They're excluded from the displayed counts, the Matrix banner, and the AI fix prompt. Click ",e.jsx("strong",{children:"restore"})," ","to put one back into the active findings list."]}),e.jsxs("ul",{className:"space-y-1",children:[s.map(o=>{const c=`tab-order::${o.selector}`,u=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"tab-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)}),t.map(o=>{const c=`reading-order::${o.selector}`,u=a[c];return e.jsxs("li",{className:"text-[11px] flex items-start gap-2 border border-slate-200 rounded bg-white p-1.5",children:[e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] bg-slate-300 text-slate-700",children:"reading-order"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("code",{className:"font-mono text-slate-600 text-[10px] break-all",children:o.selector}),e.jsx("p",{className:"text-slate-700 mt-0.5 break-words",children:o.textSnippet||e.jsx("em",{children:"(no text)"})}),u&&e.jsxs("p",{className:"text-[10px] text-slate-500 mt-0.5 italic",children:["Reason: ",u.reason]})]}),e.jsx("button",{type:"button",onClick:()=>void n(c),className:"text-[10px] text-brand-700 hover:underline shrink-0",children:"restore"})]},c)})]})]})]})}const st="igtRuns";async function rr(t,s,a){const n=s[0];if(!n)return;const r=n.pageUrl;if(!r)return;const i=`Auto-dismissed by Guided test: "${a}" marked pass`;if(t==="tab-order"){const l=n.tabOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:fe(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}else if(t==="reading-order"){const l=n.readingOrderIssues??[];if(l.length===0)return;await Re(r,l.map(o=>({key:ge(o.selector),reason:i,snippet:`${o.selector} — ${o.textSnippet||"(no text)"}`})))}}const ir={outline:{type:"OUTLINE_SHOW_REQUEST"},"tab-order":{type:"TAB_ORDER_SHOW_REQUEST"},"reading-order":{type:"READING_ORDER_SHOW_REQUEST"},targets:{type:"TARGET_SIZE_SHOW_REQUEST"},"fix-preview":{type:"FIX_PREVIEW_SHOW_REQUEST"}},lr={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"}},or={outline:"Outline","tab-order":"Tab order","reading-order":"Reading order",targets:"Targets","fix-preview":"Fix preview"};async function Mt(t,s){const a=await le();if(!a)return;const n=s?ir[t]:lr[t];try{await ue(a,n)}catch{}}async function cr(){const s=(await chrome.storage.local.get(st))[st];return s&&typeof s=="object"?s:{}}async function Pt(t){await chrome.storage.local.set({[st]:t})}function dr(t,s){if(!t.relatedAxeRule||s.length===0)return null;const a=s.flatMap(n=>n.violations.filter(r=>r.ruleId===t.relatedAxeRule));if(a.length>0){const n=Array.from(new Set(a.map(r=>`${r.currentState.pseudoState}·${r.currentState.theme}·${r.currentState.direction}`)));return{kind:"flagged",ruleId:t.relatedAxeRule,violationCount:a.length,states:n}}return{kind:"clean",ruleId:t.relatedAxeRule,statesAudited:s.length}}function ur(){const t=f(d=>d.componentId),s=f(d=>d.results),[a,n]=h.useState({}),[r,i]=h.useState(null);if(h.useEffect(()=>{cr().then(n)},[]),!t)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Run an audit on a component first, then run guided tests against it. Results are per-component and persist across sessions."});const l=a[t]??{};function o(d,p,m){var g;const x={...a,[t]:{...l,[d]:{...l[d]??{componentId:t,workflowId:d,steps:{},completedAt:new Date().toISOString()},steps:{...((g=l[d])==null?void 0:g.steps)??{},[p]:m},completedAt:new Date().toISOString()}}};if(n(x),Pt(x),m.status==="pass"){const j=ee.find(C=>C.id===d),b=j==null?void 0:j.steps.find(C=>C.id===p);b!=null&&b.autoDismissActivity&&rr(b.autoDismissActivity,s,p)}}function c(d){if(typeof confirm=="function"&&!confirm("Clear all answers for this workflow?"))return;const p={...l};delete p[d];const m={...a,[t]:p};n(m),Pt(m)}const u=ee.find(d=>d.id===r);if(u){const d=l[u.id];return e.jsx(pr,{workflow:u,run:d,results:s,onAnswer:(p,m)=>o(u.id,p,m),onBack:()=>i(null)})}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:"Guided manual checks for the accessibility concerns automation can't fully cover. Walk through each step, record pass/fail/skip, and the results persist per-component."}),ee.map(d=>{const p=l[d.id],m=p?zs(p,d):null,x=p?m!=null&&m.failed&&m.failed>0?"failed":m!=null&&m.unanswered&&m.unanswered>0?"in-progress":"done":"unstarted",g={unstarted:"border-slate-200 bg-white hover:bg-slate-50","in-progress":"border-amber-300 bg-amber-50 hover:bg-amber-100",failed:"border-rose-300 bg-rose-50 hover:bg-rose-100",done:"border-emerald-300 bg-emerald-50 hover:bg-emerald-100"}[x];return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:`w-full text-left border rounded p-2 block transition-colors ${g}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"font-medium text-xs",children:d.name}),x==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-700",children:"✓"}),x==="in-progress"&&m&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-200 text-amber-900 font-semibold",children:[m.unanswered," unanswered"]})]}),m&&e.jsxs("span",{className:"text-[10px] text-slate-600 shrink-0",children:[e.jsxs("span",{className:"text-emerald-700",children:[m.passed," pass"]}),m.failed>0&&e.jsxs("span",{className:"text-rose-700",children:[" · ",m.failed," fail"]}),m.notApplicable>0&&e.jsxs("span",{children:[" · ",m.notApplicable," N/A"]}),m.skipped>0&&e.jsxs("span",{children:[" · ",m.skipped," skip"]})," / ",m.total]})]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:d.blurb}),p&&e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c(d.id)},className:"text-[11px] text-slate-500 hover:text-rose-600 mt-1",children:"Clear answers"})]},d.id)})]})}function pr({workflow:t,run:s,results:a,onAnswer:n,onBack:r}){const i=h.useMemo(()=>{const c={};for(const u of t.steps)c[u.id]=dr(u,a);return c},[t,a]);function l(){for(const c of t.steps){const u=i[c.id];(u==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.id])&&n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${u.ruleId}, ${u.statesAudited} states).`})}}const o=t.steps.filter(c=>{var u;return((u=i[c.id])==null?void 0:u.kind)==="clean"&&!(s!=null&&s.steps[c.id])}).length;return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-xs text-brand-600 hover:underline",children:"← Back to workflows"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:t.name}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:t.blurb}),o>0&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 border border-emerald-300 bg-emerald-50 rounded p-2",children:[e.jsxs("span",{className:"text-[11px] text-emerald-900",children:[o," step",o===1?"":"s"," have a matching axe rule that ran clean across the audit — you can mark them pass in one click and only do the genuinely manual checks."]}),e.jsxs("button",{type:"button",onClick:l,className:"text-[11px] px-2 py-1 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:["Auto-mark ",o," →"]})]})]}),e.jsx("div",{className:"space-y-3",children:t.steps.map((c,u)=>{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:[u+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 p=i[c.id];return p?p.kind==="clean"?e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["✓ Auto-evidence: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," ran clean across ",p.statesAudited," state",p.statesAudited===1?"":"s",". Quick visual check, then mark pass."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"pass",notes:`Auto-marked via axe-clean evidence (${p.ruleId}, ${p.statesAudited} states).`}),className:"text-[10px] px-1.5 py-0.5 bg-emerald-600 text-white rounded hover:bg-emerald-700 shrink-0",children:"Mark pass"})]}):e.jsxs("div",{className:"text-[11px] mb-2 p-1.5 rounded border border-rose-200 bg-rose-50 text-rose-900 flex items-start justify-between gap-2",children:[e.jsxs("span",{children:["⚠ Auto-flag: axe rule ",e.jsx("code",{className:"font-mono",children:p.ruleId})," already found ",p.violationCount," violation",p.violationCount===1?"":"s"," in"," ",p.states.length," state",p.states.length===1?"":"s",". Verify and mark fail."]}),!d&&e.jsx("button",{type:"button",onClick:()=>n(c.id,{status:"fail",notes:`Auto-flagged via axe violations (${p.ruleId}, ${p.violationCount} hits in: ${p.states.join(", ")}).`}),className:"text-[10px] px-1.5 py-0.5 bg-rose-600 text-white rounded hover:bg-rose-700 shrink-0",children:"Mark fail"})]}):null})(),c.visualizer&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Mt(c.visualizer,!0),className:"text-[11px] px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:["Show ",or[c.visualizer]]}),e.jsx("button",{type:"button",onClick:()=>void Mt(c.visualizer,!1),className:"text-[11px] px-2 py-0.5 border border-slate-300 text-slate-600 rounded hover:bg-slate-100",children:"Hide"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Helps verify this step on the target page."})]}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx(Te,{label:"Pass",active:(d==null?void 0:d.status)==="pass",tone:"emerald",onClick:()=>n(c.id,{status:"pass",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Fail",active:(d==null?void 0:d.status)==="fail",tone:"rose",onClick:()=>n(c.id,{status:"fail",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"N/A",active:(d==null?void 0:d.status)==="not-applicable",tone:"slate",onClick:()=>n(c.id,{status:"not-applicable",notes:d==null?void 0:d.notes})}),e.jsx(Te,{label:"Skip",active:(d==null?void 0:d.status)==="skip",tone:"slate",onClick:()=>n(c.id,{status:"skip",notes:d==null?void 0:d.notes})})]}),d&&e.jsx("textarea",{placeholder:"Notes (optional)",value:d.notes??"",onChange:p=>n(c.id,{status:d.status,notes:p.target.value}),rows:2,className:"w-full mt-2 text-[11px] border border-slate-200 rounded p-1.5"})]},c.id)})})]})}const mr={emerald:"bg-emerald-500 text-white border-emerald-500",rose:"bg-rose-500 text-white border-rose-500",slate:"bg-slate-300 text-slate-800 border-slate-300"};function Te({label:t,active:s,tone:a,onClick:n}){return e.jsx("button",{type:"button",onClick:n,className:`text-[11px] px-2 py-1 rounded border ${s?mr[a]:"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:t})}const De="savedFlows";async function hr(){const t=await chrome.storage.local.get(De);return Array.isArray(t[De])?t[De]:[]}async function Gt(t){await chrome.storage.local.set({[De]:t})}function xr(){const[t,s]=h.useState([]),[a,n]=h.useState(!1),[r,i]=h.useState(null);h.useEffect(()=>{hr().then(s)},[]);async function l(){const d=await le();if(!d){i("No audit-target tab found.");return}try{await ue(d,{type:"FLOW_RECORD_START_REQUEST"}),n(!0),i("Recording. Switch to the page and perform actions, then come back and Stop.")}catch{i("Failed to start recording.")}}async function o(){const d=await le();if(d)try{const p=await Ie(d,{type:"FLOW_RECORD_STOP_REQUEST"});if(n(!1),p.steps.length===0){i("Recording stopped — no steps captured.");return}const m=typeof prompt=="function"?prompt(`Captured ${p.steps.length} steps. Name this flow:`,"")??"":`Flow ${new Date().toLocaleTimeString()}`;if(!m.trim()){i("Save canceled.");return}const x={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:m.trim(),steps:p.steps,savedAt:new Date().toISOString()},g=[x,...t];s(g),await Gt(g),i(`Saved "${x.name}" with ${x.steps.length} steps.`)}catch(p){i(`Stop failed: ${p instanceof Error?p.message:String(p)}`)}}async function c(d){const p=await le();if(p){i(`Replaying "${d.name}"…`);try{const m=await Ie(p,{type:"FLOW_PLAY_REQUEST",steps:d.steps});i(`Replayed ${m.played} step${m.played===1?"":"s"}`+(m.errored?`, ${m.errored} errored (selector not found)`:"")+".")}catch(m){i(`Replay failed: ${m instanceof Error?m.message:String(m)}`)}}}async function u(d){if(typeof confirm=="function"&&!confirm("Delete this flow?"))return;const p=t.filter(m=>m.id!==d);s(p),await Gt(p)}return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Record click/input/keydown sequences on the audited page, then replay them later. Useful for auditing journeys (login → navigate → form) instead of static pages. After replay, run an audit on the resulting state."}),e.jsx("div",{className:"flex gap-2",children:a?e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 bg-slate-700 text-white rounded hover:bg-slate-800",children:"■ Stop & save"}):e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 bg-rose-500 text-white rounded hover:bg-rose-600",children:"● Record flow"})}),r&&e.jsx("p",{className:"text-[11px] text-slate-600 italic",children:r}),t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"No saved flows yet."}):e.jsx("div",{className:"space-y-2",children:t.map(d=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs",children:d.name}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-0.5",children:[d.steps.length," step",d.steps.length===1?"":"s"," ·"," ",new Date(d.savedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>c(d),className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Replay"}),e.jsx("button",{onClick:()=>u(d.id),className:"text-[11px] text-slate-500 hover:text-rose-600 px-1",title:"Delete flow",children:"✕"})]})]},d.id))})]})}function gr(t){const s=t.indexOf("::");if(s===-1)return{primary:t};const a=t.slice(0,s),n=t.slice(s+2),r=n.indexOf(":");if(r===-1)return{primary:n};const i=n.slice(0,r),l=n.slice(r+1);return i==="story"?{primary:l.split("--").map(c=>c.split("-").map(fr).join(" ")).join(" / "),secondary:"storybook"}:{primary:l,secondary:a||i}}function fr(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function br(){const t=f(o=>o.baselineList),s=f(o=>o.tier),a=as[s].maxBaselines,n=t.length>=a&&Number.isFinite(a),[r,i]=h.useState(!1);if(h.useEffect(()=>{Fe().finally(()=>i(!0))},[]),!r)return e.jsx("div",{className:"p-3 space-y-2","aria-label":"Loading scorecard",children:[0,1,2].map(o=>e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white animate-pulse",children:[e.jsx("div",{className:"h-3 bg-slate-200 rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-2 bg-slate-100 rounded w-1/3"})]},o))});if(t.length===0)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"No baselines yet. After your first audit, accept the result as a baseline to track only NEW violations going forward."});async function l(o){await J({type:"BASELINE_DELETE",componentId:o}),await Fe()}return e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500 mb-2",children:[t.length," ",t.length===1?"component":"components"," tracked",Number.isFinite(a)&&e.jsxs("span",{className:"text-amber-700",children:[" · ",s," tier limit: ",a]})]}),n&&e.jsxs("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:["You've hit the ",s,"-tier baseline limit. Upgrade for unlimited tracked components."]}),t.map(o=>{const c=gr(o.componentId),u=o.metrics;return e.jsxs("div",{className:"border border-slate-200 rounded p-2 bg-white flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-xs truncate",title:o.componentId,children:c.primary}),c.secondary&&e.jsx("div",{className:"text-[11px] text-slate-500 truncate",title:c.secondary,children:c.secondary}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[o.violationCount," ",o.violationCount===1?"violation":"violations"," ·"," ",new Date(o.lastUpdated).toLocaleDateString()]}),u&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[o.seenOnUrlsCount&&o.seenOnUrlsCount>1&&e.jsxs(he,{tone:"indigo",title:"This component pattern has been audited on multiple URLs",children:["seen on ",o.seenOnUrlsCount," pages"]}),u.criticalCount>0&&e.jsxs(he,{tone:"rose",title:`${u.criticalCount} critical violations`,children:[u.criticalCount," critical"]}),u.seriousCount>0&&e.jsxs(he,{tone:"orange",title:`${u.seriousCount} serious violations`,children:[u.seriousCount," serious"]}),u.focusResetCount>0&&e.jsxs(he,{tone:"rose",title:`${u.focusResetCount} focus resets observed`,children:[u.focusResetCount," focus reset",u.focusResetCount===1?"":"s"]}),u.targetSizeFailCount>0&&e.jsxs(he,{tone:"amber",title:"Targets smaller than WCAG 2.5.8 minimum",children:[u.targetSizeFailCount," small targets"]}),u.hoverContrastFail&&e.jsx(he,{tone:"amber",title:"Contrast failure on :hover state",children:"hover-contrast"}),u.announcementCount>0&&e.jsxs(he,{tone:"indigo",title:"aria-live announcements observed",children:[u.announcementCount," announce"]})]})]}),e.jsx("button",{onClick:()=>l(o.componentId),className:"text-xs text-slate-500 hover:text-red-600 shrink-0",title:"Reset baseline",children:"Reset"})]},o.componentId)})]})}const vr={rose:"bg-rose-100 text-rose-700",orange:"bg-orange-100 text-orange-700",amber:"bg-amber-100 text-amber-700",indigo:"bg-indigo-100 text-indigo-700"};function he({tone:t,title:s,children:a}){return e.jsx("span",{title:s,className:`text-[10px] px-1.5 py-0.5 rounded ${vr[t]}`,children:a})}const yr={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"},jr={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},wr={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 ys({onBack:t}){const s=f(p=>p.siteCrawlStatus),a=f(p=>p.siteCrawlProgress),n=f(p=>p.siteCrawlReport),r=f(p=>p.siteCrawlError),[i,l]=h.useState(""),[o,c]=h.useState(25);i===""&&chrome.tabs.query({active:!0,currentWindow:!0}).then(p=>{var x;const m=(x=p[0])==null?void 0:x.url;m&&/^https?:\/\//.test(m)&&i===""&&l(m)});function u(){i&&(o>=5&&!window.confirm(`Each of the ${o} crawled pages runs your full single-page audit pipeline (same matrix + analyzers + AI walkthroughs you've configured). If your single-page audits take ~5 minutes, expect this crawl to take roughly ${o*5} minutes. Proceed?`)||(f.getState().setSiteCrawlStatus("running"),f.getState().setSiteCrawlReport(null),f.getState().setSiteCrawlError(null),de({type:"START_SITE_CRAWL",startUrl:i,maxPages:o})))}function d(){J({type:"CANCEL_SITE_CRAWL"})}return e.jsxs("div",{className:"p-4 space-y-3",children:[t&&e.jsx("button",{type:"button",onClick:t,className:"text-xs text-brand-600 hover:underline",children:"← Back to single-page scan"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Audit my whole site"}),e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"We'll start at the URL below and follow internal links to audit each page. Same-origin only — we won't crawl off-site."}),s!=="running"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-start-url",className:"block text-[11px] text-slate-500 mb-1",children:"Starting URL"}),e.jsx("input",{id:"crawl-start-url",type:"url",value:i,onChange:p=>l(p.target.value),placeholder:"https://yoursite.com",className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"crawl-max-pages",className:"block text-[11px] text-slate-500 mb-1",children:"Maximum pages (cap)"}),e.jsx("input",{id:"crawl-max-pages",type:"number",min:1,max:200,value:o,onChange:p=>c(Math.min(200,Math.max(1,parseInt(p.target.value,10)||25))),className:"w-full text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Higher = more thorough but slower. 25 is a good default. Each page runs your full single-page audit pipeline (matrix + analyzers + AI)."})]}),e.jsx("button",{type:"button",onClick:u,disabled:!i,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"Start whole-site audit"})]}),s==="running"&&a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Auditing your site…"}),e.jsxs("div",{className:"bg-slate-100 border border-slate-200 rounded p-2.5 space-y-2",children:[e.jsx("p",{className:"text-xs font-mono break-all",children:a.url}),e.jsx("div",{className:"h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-brand-500 transition-all",style:{width:`${a.current/Math.max(1,a.total)*100}%`},role:"progressbar","aria-valuenow":a.current,"aria-valuemin":0,"aria-valuemax":a.total,"aria-label":`Page ${a.current} of ${a.total}`})}),e.jsxs("p",{className:"text-[11px] text-slate-600",children:["Page ",a.current," of ",a.total,a.lastViolations!==void 0&&` · last had ${a.lastViolations} issue${a.lastViolations===1?"":"s"}`]})]}),e.jsx("button",{type:"button",onClick:d,className:"w-full text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",children:"Cancel"})]}),s==="complete"&&n&&e.jsx(Nr,{report:n}),s==="failed"&&r&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-3 text-xs text-rose-800",children:[e.jsx("strong",{children:"Audit failed:"})," ",r]})]})}function Nr({report:t}){function s(){ut(async()=>{const{renderSiteReportHtml:i}=await import("./site-report-renderer--kSYqnJz.js");return{renderSiteReportHtml:i}},__vite__mapDeps([3,4,1,2,5])).then(({renderSiteReportHtml:i})=>{const l=i(t),o=new Blob([l],{type:"text/html"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)})}const[a,n]=h.useState(!1);async function r(){n(!0);try{const i=await chrome.runtime.sendMessage({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[]}),l=(i==null?void 0:i.content)??"";if(!l){window.alert("No crawl results available to export.");return}try{await navigator.clipboard.writeText(l)}catch{}const o=new Blob([l],{type:"text/markdown;charset=utf-8"}),c=URL.createObjectURL(o);window.open(c,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(c),6e4)}finally{n(!1)}}return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`border rounded-lg p-4 ${yr[t.siteRisk]}`,children:[e.jsx("p",{className:`text-base font-semibold ${jr[t.siteRisk]}`,children:Ks[t.siteRisk]}),e.jsxs("p",{className:"text-xs mt-1",children:[e.jsx("strong",{children:t.pagesAudited})," page",t.pagesAudited===1?"":"s"," audited ·"," ",e.jsx("strong",{children:t.totalUniqueViolations})," unique issue",t.totalUniqueViolations===1?"":"s"," site-wide",t.pagesFailed>0&&` · ${t.pagesFailed} failed`]})]}),e.jsx("button",{type:"button",onClick:s,className:"w-full text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"📊 Open full site report"}),e.jsx("button",{type:"button",onClick:r,disabled:a,className:"w-full text-sm px-4 py-2.5 border border-brand-500 text-brand-700 rounded hover:bg-brand-50 disabled:opacity-50 font-medium",title:"Generate an AI-ready markdown doc covering EVERY crawled page's violations + fix recipes (not just the current page).",children:a?"Building…":"🤖 Export AI fix prompt (all crawled pages)"}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug border-l-2 border-brand-300 pl-2.5 bg-brand-50 py-2 rounded-r",children:[e.jsx("strong",{children:"Two ways to use this report."}),' The crawl above is for triage + bulk AI hand-off — knock out the big stuff across the whole site in one shot. For granular control on any single page (acknowledge individual findings, run guided manual checks, preview fixes on the live page, run interactive walkthroughs), click that page in the "Pages, worst first" list below.']}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Top issues across the site"}),e.jsx("ul",{className:"space-y-2",children:t.topViolations.slice(0,8).map(i=>{const l=qs(i.ruleId);return e.jsx("li",{className:"border border-slate-200 rounded p-2.5 bg-white text-xs",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${wr[i.impact]}`,children:i.impact}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:l.whatsWrong}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Found on ",e.jsx("strong",{children:i.urlsAffected})," page",i.urlsAffected===1?"":"s"," · ",i.totalOccurrences," total spot",i.totalOccurrences===1?"":"s"]})]})]})},i.ruleId)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500 mb-2",children:"Pages, worst first"}),e.jsxs("p",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:["The crawl is for triage + bulk AI fix-prompt generation. ",e.jsx("strong",{children:"Click any page"})," to open it in the active tab and load its crawl results into the single-page view — there you get per-finding acknowledgements, visualizers, guided manual checks, and fix-preview overlays."]}),e.jsx("ul",{className:"space-y-1 text-xs",children:t.pages.slice(0,15).map(i=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void kr(i.url),className:"w-full flex items-center gap-2 text-left px-1.5 py-1 rounded hover:bg-slate-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-500",title:"Open this page in the active tab and load its crawl results into the single-page view for granular fix work",children:[e.jsx("span",{className:`font-mono w-5 text-center font-semibold ${i.grade==="A"?"text-emerald-700":i.grade==="B"?"text-lime-700":i.grade==="C"?"text-yellow-700":i.grade==="D"?"text-orange-700":"text-rose-700"}`,children:i.grade}),e.jsx("span",{className:"font-mono text-[11px] text-slate-700 break-all flex-1",children:i.url}),e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:i.uniqueViolations}),e.jsx("span",{className:"text-[10px] text-brand-600 shrink-0","aria-hidden":"true",children:"→"})]})},i.url))})]})]})}async function kr(t){try{const s=await Qs(),a=s==null?void 0:s.find(n=>n.url===t);try{const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];r!=null&&r.id?await chrome.tabs.update(r.id,{url:t,active:!0}):await chrome.tabs.create({url:t,active:!0})}catch{}if(a&&a.results.length>0&&a.componentId){f.getState().setResults(a.results,a.delta,a.componentId);try{await chrome.storage.local.set({"sidePanel:lastAudit":{results:a.results.map(({screenshotDataUrl:n,...r})=>r),delta:a.delta,componentId:a.componentId}})}catch{}}f.getState().setView("matrix")}catch(s){console.warn("[site-crawl-panel] openPageInSinglePageView failed",s)}}const qe="onboardingDismissed",Qe=[{title:"Welcome",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsx("p",{children:"The WCAG Component Auditor finds accessibility violations that other tools miss — by driving your component through every visual state your users actually encounter."}),e.jsx("p",{children:"Three steps. ~30 seconds."})]})},{title:"Step 1 — Pick an element",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click ",e.jsx("strong",{children:"Pick element"})," in the side panel, then click any element on the page. The auditor scopes its analysis to that component — not the whole page."]}),e.jsxs("p",{children:["(For full-page scans, switch the dropdown to ",e.jsx("strong",{children:"Full page"}),".)"]})]})},{title:"Step 2 — Watch the matrix run",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["When you click ",e.jsx("strong",{children:"Run audit"}),", the auditor drives your element through every combination of ",e.jsx("code",{children:":hover"}),", ",e.jsx("code",{children:":focus"}),", ",e.jsx("code",{children:":focus-visible"}),",",e.jsx("code",{children:":disabled"}),", dark mode, forced-colors, RTL, and breakpoint sizes — auditing at each."]}),e.jsxs("p",{children:["A yellow ",e.jsx("em",{children:'"is debugging this browser"'})," banner appears during runs. That's how we drive the states. It disappears when the audit finishes."]})]})},{title:"Step 3 — Find and replay",body:e.jsxs("div",{className:"space-y-2 text-xs text-slate-700",children:[e.jsxs("p",{children:["Click any violation to highlight it on the page. Click ",e.jsx("strong",{children:"Load state"})," to re-drive the page back to the exact state where the violation was found — see what the auditor saw."]}),e.jsxs("p",{children:["The ",e.jsx("strong",{children:"Delta"})," tab filters to NEW debt vs. your accepted baseline — file a GitHub issue for only what you introduced, not inherited mess."]})]})}];function Sr(){const[t,s]=h.useState(!1),[a,n]=h.useState(0);h.useEffect(()=>{chrome.storage.local.get(qe).then(o=>{o[qe]||s(!0)})},[]);async function r(){await chrome.storage.local.set({[qe]:!0}),s(!1),n(0)}const i=a===Qe.length-1,l=Qe[a];return e.jsxs(be,{open:t,onClose:r,title:l.title,children:[e.jsx("div",{children:l.body}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsxs("span",{className:"text-[11px] text-slate-500",children:[a+1," / ",Qe.length]}),e.jsxs("div",{className:"flex gap-2",children:[a>0&&e.jsx("button",{onClick:()=>n(o=>o-1),className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Back"}),i?e.jsx("button",{onClick:r,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Got it"}):e.jsx("button",{onClick:()=>n(o=>o+1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Next"})]})]})]})}function Ar(){const t=f(n=>n.status),s=f(n=>n.errorMessage),a=f(n=>n.setStatus);return t!=="failed"||!s?null:e.jsxs("div",{role:"alert",className:"px-3 py-2 bg-red-50 border-b border-red-200 text-xs text-red-800 flex items-center justify-between",children:[e.jsx("span",{children:s}),e.jsx("button",{onClick:()=>a("idle"),className:"text-red-600 hover:text-red-900 ml-2","aria-label":"Dismiss error",children:"×"})]})}function Cr(){const t=f(c=>c.aiFailure),s=f(c=>c.clearAiFailure),[a,n]=h.useState(!1);if(!t)return null;const r=t.severity==="total",i=r?"bg-orange-50 border-orange-300 text-orange-900":"bg-amber-50 border-amber-300 text-amber-900",l="⚠",o=r?"AI fixer didn't run on this audit":`AI fixer partially completed (${t.checksSucceeded}/${t.checksAttempted} checks ran)`;return e.jsx("div",{role:"alert",className:`px-3 py-2 border-b text-xs flex flex-col gap-1 ${i}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[e.jsx("span",{"aria-hidden":"true",children:l})," ",o]}),e.jsxs("div",{className:"mt-0.5",children:[t.reason,t.errorDetails.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{onClick:()=>n(c=>!c),className:"underline hover:no-underline","aria-expanded":a,children:a?"Hide details":`Show ${t.errorDetails.length} error${t.errorDetails.length===1?"":"s"}`})]})]}),a&&t.errorDetails.length>0&&e.jsx("ul",{className:"mt-1 pl-4 list-disc font-mono text-[11px] leading-snug",children:t.errorDetails.map((c,u)=>e.jsx("li",{children:c},u))})]}),e.jsx("button",{onClick:s,className:"hover:opacity-70 leading-none","aria-label":"Dismiss AI failure notice",children:"×"})]})})}function Vt(){const[t,s]=h.useState(!1);return h.useEffect(()=>oe("AUDIT_FAILED_EVENT",a=>{a.error.code==="DEBUGGER_BUSY"&&(s(!0),f.getState().setStatus("idle"))}),[]),e.jsxs(be,{open:t,onClose:()=>s(!1),title:"Close DevTools to continue",children:[e.jsxs("div",{className:"space-y-3 text-xs text-slate-700",children:[e.jsx("p",{children:"The audit can't run because Chrome DevTools is open on the target tab. We use the same debugging API DevTools uses, and only one consumer can be attached at a time."}),e.jsxs("p",{children:[e.jsx("strong",{children:"To continue:"})," close DevTools on the target tab, then start the audit again."]}),e.jsx("p",{className:"text-slate-500",children:"Why we need it: without the debugger API, we can't drive components through hover, focus, dark-mode, and other states screen readers care about."})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:()=>s(!1),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded",children:"Got it"})})]})}function Ir(){var i;const[t,s]=h.useState(null);if(h.useEffect(()=>{Ys().then(l=>{l&&l.state==="interrupted"&&s(l)})},[]),!t)return null;async function a(){t&&(await jt(),f.getState().startNewScan(),t.mode==="storybook-all"?de({type:"START_AUDIT",mode:"storybook-all"}):t.scope&&de({type:"START_AUDIT",mode:"single-element",scope:t.scope}),s(null))}async function n(){await jt(),s(null)}const r=t.mode==="storybook-all"?`Story ${((i=t.completedStories)==null?void 0:i.length)??0}/${t.totalStories??"?"}`:"Single-element audit";return e.jsxs("div",{role:"status",className:"px-3 py-2 bg-amber-50 border-b border-amber-200 text-xs text-amber-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["A previous audit was interrupted (",r,")."]}),e.jsxs("span",{className:"flex gap-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Resume"}),e.jsx("button",{onClick:n,className:"px-2 py-0.5 hover:bg-amber-100 rounded",children:"Discard"})]})]})}const Ye="storybook:hintDismissed";function Rr(){const[t,s]=h.useState(!1),[a,n]=h.useState();h.useEffect(()=>{(async()=>{var o;if((await chrome.storage.local.get(Ye))[Ye])return;const l=await le();if(l)try{const u=(await chrome.scripting.executeScript({target:{tabId:l,allFrames:!0},world:"MAIN",func:()=>{var p;const d=window;return{detected:typeof d.__STORYBOOK_PREVIEW__=="object",version:(p=d.__STORYBOOK_PREVIEW__)==null?void 0:p.version}}})).find(d=>{var p;return(p=d.result)==null?void 0:p.detected});u&&(n((o=u.result)==null?void 0:o.version),s(!0))}catch{}})()},[]);async function r(){await chrome.storage.local.set({[Ye]:!0}),s(!1)}return t?e.jsxs("div",{className:"px-3 py-2 bg-blue-50 border-b border-blue-200 text-xs text-blue-900 flex items-center justify-between gap-2",children:[e.jsxs("span",{children:["Storybook ",a??""," detected. Switch to ",e.jsx("strong",{children:"All stories"})," to audit every story in one pass."]}),e.jsx("button",{onClick:r,className:"text-blue-700 hover:text-blue-900 ml-2","aria-label":"Dismiss hint",children:"×"})]}):null}function Er(){var i;const t=f(l=>l.results),s=f(l=>l.baselineList),a=f(l=>l.status),n=(i=t[0])==null?void 0:i.startedAt,r=s.length;return e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[e.jsx("span",{children:r>0?`${r} ${r===1?"component":"components"} tracked`:"no baselines yet"}),e.jsx("span",{children:a==="running"?"auditing…":n?`last audit ${Tr(n)}`:"idle"})]}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})}function Tr(t,s=new Date){const a=new Date(t),n=s.getTime()-a.getTime(),r=Math.round(n/1e3);if(r<60)return"just now";const i=Math.round(r/60);if(i<60)return`${i}m ago`;const l=Math.round(i/60);if(l<24)return`${l}h ago`;const o=Math.round(l/24);return o<7?`${o}d ago`:a.toLocaleDateString()}function $r(){const t=f(o=>o.results),s=f(o=>o.componentId),[a,n]=h.useState([]);if(h.useEffect(()=>{if(!s){n([]);return}let o=!1;return chrome.storage.local.get("igtRuns").then(c=>{if(o)return;const d=((c==null?void 0:c.igtRuns)??{})[s]??{};n(Object.values(d))}),()=>{o=!0}},[s]),t.length===0)return null;const r=t.flatMap(o=>o.violations),i=Js(r,a.length>0?{runs:a,workflows:ee}:void 0),l=i.manual!==void 0&&i.manual.workflowsCompleted===i.manual.workflowsTotal;return e.jsxs("div",{className:"border-t border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:"Not a compliance certificate."})," ",l?"All Guided Tests workflows are complete and folded into this grade.":"Automation covers ~50% of WCAG. The Guided Tests workflows + the manual checklist in the AI fix prompt cover the rest. The grade above only reflects what automation can verify."]})}function Lr(){const t=f(a=>a.setUserMode);function s(a){t(a),J({type:"SETTINGS_SET",key:"userMode",value:a})}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsxs("main",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold mb-1",children:"Welcome."}),e.jsx("p",{className:"text-sm text-slate-600",children:"One quick question — pick the mode that fits your role. You can switch later from Settings."})]}),e.jsx("button",{type:"button",onClick:()=>s("owner"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"🏪"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a site owner"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I bought or built this site (maybe with a template) and want to make sure it's accessible — and not at risk of an ADA lawsuit."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Plain-language audit results"}),e.jsx("li",{children:"· One-click whole-site scan"}),e.jsx("li",{children:'· "Send this to my web developer" report'}),e.jsx("li",{children:"· No code or technical knowledge required"})]})]})]})}),e.jsx("button",{type:"button",onClick:()=>s("dev"),className:"w-full text-left border border-slate-300 rounded-lg p-4 bg-white hover:border-brand-500 hover:bg-brand-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"text-2xl","aria-hidden":"true",children:"⚙️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"font-semibold text-sm mb-1",children:"I'm a developer or agency"}),e.jsx("p",{className:"text-[12px] text-slate-600 leading-snug",children:"I build or maintain web apps. I want full audit features, exports, AI-driven fix workflows, baselines, and defense-grade legal documentation."}),e.jsxs("ul",{className:"text-[11px] text-slate-500 mt-2 space-y-0.5",children:[e.jsx("li",{children:"· Multi-state matrix audits (108 state combinations)"}),e.jsx("li",{children:"· AI fix prompt, SARIF/JUnit/VPAT exports, baselines + delta"}),e.jsx("li",{children:"· Guided Tests workflows (12 manual checks)"}),e.jsx("li",{children:"· Defense + evidence bundles, site-wide CLI crawler"})]})]})]})}),e.jsxs("p",{className:"text-[11px] text-slate-500 text-center pt-2",children:["You can switch modes anytime from ",e.jsx("strong",{children:"Settings → User mode"}),"."]})]})})}const Ur=["image-alt","input-image-alt","role-img-alt","svg-img-alt","area-alt","label","label-title-only","form-field-multiple-labels","select-name","button-name","link-name","empty-heading","color-contrast","document-title","html-has-lang","html-lang-valid","page-has-heading-one","region","landmark-one-main","bypass","aria-required-attr","aria-roles","aria-valid-attr","aria-valid-attr-value","aria-allowed-attr","aria-hidden-body","aria-hidden-focus","table-fake-caption","td-headers-attr","th-has-data-cells","scope-attr-valid","frame-title","frame-title-unique","list","listitem","definition-list","dlitem"],Dr={low:"Low risk. Your site is clean on every check that automated lawsuit-targeting tools run. They look for easy targets — you aren't one.",moderate:"Moderate risk. A demand-letter scanner would flag at least one issue. Fix these to drop off the easy-target list.",high:"High risk. Multiple findings here are the exact patterns demand-letter mills target. Fix these before the next scanner sweep.",critical:"Critical risk. Your site has many of the high-frequency patterns ADA-targeting firms scan for. You're a likely target. Fix the items below."};function Or(t){const s=new Set(Ur),a=new Map;for(const c of t)s.has(c.ruleId)&&a.set(c.ruleId,(a.get(c.ruleId)??0)+1);const n=Array.from(a.entries()).map(([c,u])=>({ruleId:c,instanceCount:u})).sort((c,u)=>u.instanceCount-c.instanceCount),r=n.length,i=Array.from(a.values()).reduce((c,u)=>c+u,0);let l;return r===0?l="low":r===1?l="moderate":r<=3?l="high":l="critical",{tier:l,letter:l==="low"?"A":l==="moderate"?"C":l==="high"?"D":"F",flaggedRuleCount:r,flaggedInstanceCount:i,flaggedRules:n,headline:Dr[l]}}const js={id:"desktop",label:"Desktop",width:1280,height:800,deviceScaleFactor:1,mobile:!1},_r={pseudoStates:["default"],ariaVariations:[],themes:["light"],directions:["ltr"],breakpoints:["desktop"],breakpointPresets:[js]},Fr={pseudoStates:["default","hover","focus"],ariaVariations:[],themes:["light","dark"],directions:["ltr","rtl"],breakpoints:["desktop"],breakpointPresets:[js]};function ht(t){return t==="thorough"?Fr:_r}function Wt(t){const s=ht(t);return s.pseudoStates.length*s.themes.length*s.directions.length*s.breakpoints.length}const Oe="wcagcheckr";function V(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ce(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 Mr(t){return Array.from(new Set(t.map(s=>s.axeVersion).filter(Boolean))).sort()}function Pr(t){if(t.length===0)return null;const s=[...t].sort((a,n)=>a.capturedAt.localeCompare(n.capturedAt));return{earliest:s[0].capturedAt,latest:s[s.length-1].capturedAt}}function Gr(t){const s=new Map;for(const a of t){const n=s.get(a.componentId);n?(n.entries.push(a),a.receipt&&n.anchoredCount++,a.capturedAt>n.latest.capturedAt&&(n.latest=a,n.pageUrl=a.pageUrl)):s.set(a.componentId,{componentId:a.componentId,pageUrl:a.pageUrl,entries:[a],latest:a,anchoredCount:a.receipt?1:0})}for(const a of s.values())a.entries.sort((n,r)=>r.capturedAt.localeCompare(n.capturedAt));return Array.from(s.values()).sort((a,n)=>n.latest.capturedAt.localeCompare(a.latest.capturedAt))}function Vr(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 Wr(t){const s=t.totals,a=[s.critical?`<span class="sev-crit">${s.critical} critical</span>`:"",s.serious?`<span class="sev-serious">${s.serious} serious</span>`:"",s.moderate?`<span class="sev-mod">${s.moderate} moderate</span>`:"",s.minor?`<span class="sev-minor">${s.minor} minor</span>`:""].filter(Boolean).join(" · ")||'<span class="sev-clean">No violations recorded</span>',n=t.receipt?`<tr><th>Trusted timestamp</th><td>RFC 3161 (${V(t.receipt.tsaName)}) — anchored ${V(Ce(t.receipt.anchoredAt))}</td></tr>
12
12
  <tr><th>Server signature</th><td>ed25519 over (audit hash + anchor time + TSA name${t.receipt.prevAuditHash?" + previous anchor hash":""}) — key fingerprint <code>${V(t.receipt.serverKeyFingerprint)}</code></td></tr>
13
- ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${V(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${V(_e)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
13
+ ${t.receipt.prevAuditHash?`<tr><th>Chain predecessor</th><td><code class="hash">${V(t.receipt.prevAuditHash)}</code></td></tr>`:""}`:`<tr><th>Trusted timestamp</th><td class="local-only">Local-only entry. Self-attested by ${V(Oe)}; not anchored to a public TSA. Lower evidentiary weight than RFC 3161-anchored entries.</td></tr>`;return`
14
14
  <article class="entry">
15
15
  <header class="entry-header">
16
- <span class="grade-badge ${Or(t.grade)}">${V(t.grade)}</span>
16
+ <span class="grade-badge ${Vr(t.grade)}">${V(t.grade)}</span>
17
17
  <div class="entry-headline">
18
18
  <div class="entry-time">${V(Ce(t.capturedAt))}</div>
19
19
  <div class="entry-states">${t.statesAudited} state${t.statesAudited===1?"":"s"} audited · ${(t.durationMs/1e3).toFixed(1)}s</div>
@@ -27,15 +27,15 @@ Future audits will treat every detected violation as new (no delta filtering). T
27
27
  <tr><th>Severity breakdown</th><td class="sev-row">${a}</td></tr>
28
28
  ${n}
29
29
  </table>
30
- </article>`}function Dr(t){return`
30
+ </article>`}function Br(t){return`
31
31
  <section class="component-section">
32
32
  <h2>
33
33
  <span class="component-id">${V(t.componentId)}</span>
34
34
  <span class="component-stats">${t.entries.length} audit${t.entries.length===1?"":"s"} · ${t.anchoredCount} RFC 3161-anchored</span>
35
35
  </h2>
36
36
  <p class="component-url"><strong>Page audited:</strong> <code>${V(t.pageUrl)}</code></p>
37
- ${t.entries.map(_r).join("")}
38
- </section>`}function Fr(t){const{entries:s,extensionVersion:a}=t,n=Ur(s),r=Lr(s),i=(t.axeVersions??$r(s)).join(", "),o=s.length,l=s.filter(d=>d.receipt).length,c=o-l,u=Ce(new Date().toISOString());return`<!doctype html>
37
+ ${t.entries.map(Wr).join("")}
38
+ </section>`}function Hr(t){const{entries:s,extensionVersion:a}=t,n=Gr(s),r=Pr(s),i=(t.axeVersions??Mr(s)).join(", "),l=s.length,o=s.filter(d=>d.receipt).length,c=l-o,u=Ce(new Date().toISOString());return`<!doctype html>
39
39
  <html lang="en">
40
40
  <head>
41
41
  <meta charset="utf-8" />
@@ -190,21 +190,21 @@ Future audits will treat every detected violation as new (no delta filtering). T
190
190
 
191
191
  <aside class="attestation">
192
192
  <h3>Attestation</h3>
193
- <p>The audit records summarized below were captured by the <strong>${V(_e)}</strong> Chrome extension, version <strong>${V(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${V(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
193
+ <p>The audit records summarized below were captured by the <strong>${V(Oe)}</strong> Chrome extension, version <strong>${V(a)}</strong>, running <strong>axe-core</strong> ${i?`version(s) ${V(i)}`:"a versioned ruleset"}. Each audit's identifying fields (component, URL, grade, severity totals, axe-core version, capture timestamp, and state-matrix size) were serialized to canonical JSON and hashed with SHA-256 at the moment of capture. Same input always produces the same hash; any alteration of the audit record would render the hash inconsistent.</p>
194
194
  <p>Audits marked <strong>RFC 3161</strong> carry an additional independently-witnessed trusted timestamp from a public Time Stamping Authority (TSA) and an ed25519 server signature over the combined audit hash, anchor time, TSA name, and (where present) the preceding anchor's hash. RFC 3161-anchored audits cannot be backdated and form a tamper-evident chain.</p>
195
195
  <p>Audits marked <strong>local-only</strong> are tamper-resistant client-side via the same SHA-256 mechanism but were not anchored to a public TSA at capture time. They carry lower evidentiary weight than RFC 3161-anchored audits.</p>
196
196
  </aside>
197
197
 
198
198
  <table class="summary-table">
199
- <tr><th>Total audits recorded</th><td>${o}</td></tr>
200
- <tr><th>RFC 3161-anchored audits</th><td>${l}</td></tr>
199
+ <tr><th>Total audits recorded</th><td>${l}</td></tr>
200
+ <tr><th>RFC 3161-anchored audits</th><td>${o}</td></tr>
201
201
  <tr><th>Local-only audits</th><td>${c}</td></tr>
202
202
  <tr><th>Distinct components / scopes</th><td>${n.length}</td></tr>
203
203
  <tr><th>axe-core version(s) observed</th><td>${V(i||"n/a")}</td></tr>
204
- <tr><th>Tool</th><td>${V(_e)} ${V(a)}</td></tr>
204
+ <tr><th>Tool</th><td>${V(Oe)} ${V(a)}</td></tr>
205
205
  </table>
206
206
 
207
- ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Dr).join("")}
207
+ ${n.length===0?'<p style="font-style: italic; color: var(--muted);">No audit records to report.</p>':n.map(Br).join("")}
208
208
 
209
209
  <section class="methodology">
210
210
  <h2>Methodology</h2>
@@ -228,16 +228,16 @@ Future audits will treat every detected violation as new (no delta filtering). T
228
228
  </section>
229
229
 
230
230
  <footer>
231
- <span>Generated ${V(u)} by ${V(_e)} ${V(a)}</span>
232
- <span>${o} audit${o===1?"":"s"} · ${l} anchored · ${n.length} component${n.length===1?"":"s"}</span>
231
+ <span>Generated ${V(u)} by ${V(Oe)} ${V(a)}</span>
232
+ <span>${l} audit${l===1?"":"s"} · ${o} anchored · ${n.length} component${n.length===1?"":"s"}</span>
233
233
  </footer>
234
234
  </body>
235
- </html>`}async function Mr(t){const s=Fr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function vs(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[o,l]=h.useState(!1),[c,u]=h.useState(""),[d,p]=h.useState(""),[m,x]=h.useState(""),[g,y]=h.useState(!1);if(h.useEffect(()=>{let b=!1;return s(null),n(null),Yt().then(S=>{b||s(S)}).catch(S=>{b||n(S instanceof Error?S.message:String(S))}),()=>{b=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const k=t.length,T=t.filter(b=>b.receipt).length;async function N(){if(!(!t||t.length===0)){y(!0);try{await Mr({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:m.trim()||void 0}),l(!1)}finally{y(!1)}}}async function E(){if(!t||t.length===0)return;const b={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},S=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),j=URL.createObjectURL(S),C=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,_=document.createElement("a");_.href=j,_.download=C,_.click(),setTimeout(()=>URL.revokeObjectURL(j),1e3)}return k===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[k," ",k===1?"entry":"entries",T>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[T," RFC 3161-anchored"]})]}),T===0&&k>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>l(b=>!b),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:o?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void E(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(b=>b+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),o&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:b=>u(b.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:d,onChange:b=>p(b.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:m,onChange:b=>x(b.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||k===0,onClick:N,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(b=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${b.grade==="A"?"bg-emerald-100 text-emerald-700":b.grade==="B"?"bg-lime-100 text-lime-700":b.grade==="C"?"bg-yellow-100 text-yellow-700":b.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:b.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:b.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${b.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:b.receipt?`Anchored to ${b.receipt.tsaName} at ${b.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:b.receipt?`RFC 3161 (${b.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:b.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:b.capturedAt}),(b.totals.critical>0||b.totals.serious>0)&&e.jsxs("span",{children:[b.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[b.totals.critical," crit"]}),b.totals.critical>0&&b.totals.serious>0&&" · ",b.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[b.totals.serious," sev"]})]}),e.jsxs("span",{children:[b.statesAudited," ",b.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:b.hash,children:[b.hash.slice(0,12),"…"]})]})]},`${b.componentId}::${b.capturedAt}`))})]})}function Pr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let c=!1;return Yt().then(u=>{c||s(u)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],o=t.slice(0,3),l=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),l>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[l," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:o.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(be,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(vs,{})})})]})}function Gr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Vr={eyebrow:"You're on a trial",headline:"Full features unlocked while you evaluate.",body:"When your trial ends, a paid plan keeps RFC 3161 trusted-timestamp anchoring, AI fix suggestions, and audit-history evidence active for every scan."},Wr={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},Br={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Hr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function ys(){const t=f(p=>p.tier),s=f(p=>p.trialDaysRemaining),a=f(p=>p.seatsUsed),n=f(p=>p.seatsTotal),r=f(p=>p.planCode),i=f(p=>p.licenseDaysRemaining),o=f(p=>p.pastDue),[l,c]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,m=p!==null&&p<=7,x=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} days left`;return e.jsxs("aside",{"aria-label":"License status",className:m?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:m?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:m?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:m?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:m?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Xe,{open:l,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?Hr:Br,m=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,y=o?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${y.bg} border-b ${y.border} px-3 py-2 space-y-1 text-[11px] ${y.shadow}`,children:[e.jsxs("div",{className:y.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:y.subtitle,children:[" · ",m]})]}),o&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),g&&!x&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:y.link,children:"Manage license →"})})]})}const u=t==="trial"?Vr:Wr,d=t==="trial"?Gr(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:u.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:u.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:u.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Xe,{open:l,onClose:()=>c(!1)})]})}const zr={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"},Kr={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Gt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},qr={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"},Vt={critical:0,serious:1,moderate:2,minor:3};function Qr(){const t=f(p=>p.setUserMode),s=f(p=>p.status),a=f(p=>p.setStatus),n=f(p=>p.errorMessage),r=f(p=>p.setError),[i,o]=h.useState(!1),[l,c]=h.useState(!1),u=h.useRef(s);h.useEffect(()=>{if(u.current==="running"&&s==="complete"){c(!0);const p=setTimeout(()=>c(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{f.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[s,a,r]);function d(){t("dev"),J({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(ys,{}),e.jsx(ls,{}),e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(os,{}),e.jsx("button",{type:"button",onClick:d,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(Yr,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{f.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(fs,{onBack:()=>o(!1)}):e.jsx(Xr,{onPickCrawl:()=>o(!0)}),l&&e.jsx(Jr,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use. Automated checks catch ~30–50% of accessibility issues; a human review covers the rest."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function Yr(){const t=f(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void J({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function Jr(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function Xr({onPickCrawl:t}){const s=f(p=>p.status),a=f(p=>p.results),[n,r]=h.useState("quick"),[i,o]=h.useState("all"),l=s==="running",c=a.flatMap(p=>p.violations),u=a.length>0;function d(){de({type:"START_AUDIT",mode:"full-page",matrixOverride:ht(n)}),f.getState().startNewScan(),ce.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:l,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:l?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:l,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(ei,{depth:n,onChange:r,disabled:l})]}),!u&&!l&&e.jsx(Zr,{}),u&&e.jsx(ti,{violations:c,severityFilter:i,onSeverityFilterChange:o,scanDepth:n})]})}function Zr(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function ei({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(Wt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Pt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(Wt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Pt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function Wt({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:i})]})}function ti({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var j;const r=f(C=>C.status),i=f(C=>C.results),o=f(C=>C.freshThisSession),l=f(C=>C.componentId),c=(j=i[0])==null?void 0:j.startedAt,u=Rr(t),d=r==="running",[p,m]=h.useState([]);h.useEffect(()=>{if(!l){m([]);return}let C=!1;return chrome.storage.local.get("igtRuns").then(_=>{if(C)return;const F=((_==null?void 0:_.igtRuns)??{})[l]??{};m(Object.values(F))}),()=>{C=!0}},[l]);const x=f(C=>C.acknowledgedKeys),g=i.length>0?Qt(i,{runs:p,workflows:ee},"2.1","AA",x):void 0;function y(){de({type:"START_AUDIT",mode:"full-page",matrixOverride:ht(n)}),f.getState().startNewScan(),ce.polite("Re-scanning this page now.")}const k=s==="lawsuit-risk"?t.filter(C=>C.impact==="critical"||C.impact==="serious"):t,T=new Map;for(const C of k){const _=ct(C.ruleId,C.target.selector);T.has(_)||T.set(_,C)}const N=Array.from(T.values()),E=new Map;for(const C of N){const _=E.get(C.ruleId)??[];_.push(C),E.set(C.ruleId,_)}const b=Array.from(E.entries()).sort((C,_)=>(Vt[C[1][0].impact]??99)-(Vt[_[1][0].impact]??99)),S=t.filter(C=>C.impact==="critical"||C.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(oi,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void We(),disabled:d,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:y,disabled:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${zr[u.tier]}`,children:[!o&&c&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${Kr[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Gt[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Gt[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(si,{coverage:g}),!d&&g&&g.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",g.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(ii,{}),e.jsx(Pr,{}),t.length>0&&e.jsx(ai,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:S}),e.jsxs("div",{className:"space-y-2",children:[b.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),b.map(([C,_])=>e.jsx(ni,{ruleId:C,violations:_},C))]})]})}function si({coverage:t}){const s=f(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),J({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function ai({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function ni({ruleId:t,violations:s}){var p;const[a,n]=h.useState(!1),r=(p=s.find(m=>m.target.opacityContext))==null?void 0:p.target.opacityContext,i=Qs(t,r),o=s[0].impact,l=s[0],u=i.whatsWrong==="An accessibility rule failed on this page."&&l.description?l.description:i.whatsWrong,d=l.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${qr[o]}`,children:o}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:u}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(ri,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function ri({violation:t}){const s=f(i=>{var o;return(o=i.results[0])==null?void 0:o.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const o=await oe();if(o)try{const l=await Ie(o,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:o,selector:t.target.selector},s);n(l.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const $e=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function ii(){const t=f(d=>d.results),s=f(d=>d.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[o,l]=h.useState(null);async function c(d,p){if(t.length!==0){n(d);try{const m=await te({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=zt(d,s);await Kt()?ot(m.content,x):l({open:!0,format:d,content:m.content,filename:x})}else if(p)it(m.content);else{try{await navigator.clipboard.writeText(m.content),ce.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
235
+ </html>`}async function zr(t){const s=Hr(t),a=new Blob([s],{type:"text/html;charset=utf-8"}),n=URL.createObjectURL(a);await chrome.tabs.create({url:n})}function ws(){const[t,s]=h.useState(null),[a,n]=h.useState(null),[r,i]=h.useState(0),[l,o]=h.useState(!1),[c,u]=h.useState(""),[d,p]=h.useState(""),[m,x]=h.useState(""),[g,j]=h.useState(!1);if(h.useEffect(()=>{let v=!1;return s(null),n(null),Zt().then(S=>{v||s(S)}).catch(S=>{v||n(S instanceof Error?S.message:String(S))}),()=>{v=!0}},[r]),t===null&&a===null)return e.jsx("div",{className:"p-4 text-center text-slate-500 text-sm",children:"Loading audit history…"});if(a!==null)return e.jsxs("div",{className:"p-4 text-center text-rose-700 text-sm",children:["Failed to load audit history: ",a]});const b=t.length,C=t.filter(v=>v.receipt).length;async function k(){if(!(!t||t.length===0)){j(!0);try{await zr({entries:t,extensionVersion:chrome.runtime.getManifest().version,matterReference:c.trim()||void 0,preparedBy:d.trim()||void 0,jurisdiction:m.trim()||void 0}),o(!1)}finally{j(!1)}}}async function T(){if(!t||t.length===0)return;const v={schemaVersion:1,tool:{name:"wcagcheckr",version:chrome.runtime.getManifest().version},exportedAt:new Date().toISOString(),hashInputFields:["componentId","pageUrl","scope","grade","totals","axeVersion","capturedAt","statesAudited"],entries:t},S=new Blob([JSON.stringify(v,null,2)],{type:"application/json"}),w=URL.createObjectURL(S),I=`wcagcheckr-forensic-log-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,O=document.createElement("a");O.href=w,O.download=I,O.click(),setTimeout(()=>URL.revokeObjectURL(w),1e3)}return b===0?e.jsxs("div",{className:"p-4 text-center text-slate-500 text-sm space-y-2",children:[e.jsx("p",{children:"No audits recorded yet."}),e.jsx("p",{className:"text-xs",children:"Every audit you run is logged here automatically with a SHA-256 hash of its identifying fields. The log feeds the chronological audit-history section of the defense / evidence bundle exports."})]}):e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"text-xs text-slate-500 border-b border-slate-200 pb-2 flex items-center justify-between",children:[e.jsxs("span",{children:[b," ",b===1?"entry":"entries",C>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700 font-medium",children:[C," RFC 3161-anchored"]})]}),C===0&&b>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-slate-500",children:"all local-only"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>o(v=>!v),className:"text-[11px] text-brand-700 hover:underline",title:"Generate a printable pre-litigation report from this audit history",children:l?"cancel report":"pre-litigation report →"}),e.jsx("button",{type:"button",onClick:()=>void T(),className:"text-[11px] text-brand-700 hover:underline",title:"Download the forensic log as a JSON file that the wcagcheckr-ci verify command can validate offline",children:"export JSON →"}),e.jsx("button",{type:"button",onClick:()=>i(v=>v+1),className:"text-[11px] text-brand-700 hover:underline",children:"refresh"})]})]}),l&&e.jsxs("div",{className:"border border-slate-200 rounded p-2 space-y-2 bg-slate-50",children:[e.jsx("p",{className:"text-[11px] text-slate-700 leading-snug",children:"Pre-litigation report: a printable HTML document summarizing every audit in this log with hashes, RFC 3161 trust-status, severity totals, and a verification walkthrough. Opens in a new tab — use Ctrl+P / Cmd+P to save as PDF."}),e.jsxs("div",{className:"grid grid-cols-1 gap-1.5 text-[11px]",children:[e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Matter reference (optional)"}),e.jsx("input",{value:c,onChange:v=>u(v.target.value),placeholder:"e.g. Smith v. Acme — case no. 24-CV-1234",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Prepared by (optional)"}),e.jsx("input",{value:d,onChange:v=>p(v.target.value),placeholder:"Your name / firm",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]}),e.jsxs("label",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-medium text-slate-600",children:"Jurisdiction (optional)"}),e.jsx("input",{value:m,onChange:v=>x(v.target.value),placeholder:"e.g. Texas, USA",className:"border border-slate-300 rounded px-1.5 py-1 text-xs"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-2 py-1 rounded border border-slate-300 hover:bg-white",children:"Cancel"}),e.jsx("button",{type:"button",disabled:g||b===0,onClick:k,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:g?"Generating…":"Generate report"})]})]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-snug",children:["Every audit's identity (component, page URL, grade, severity totals, axe version, capture time, state-matrix size) is hashed with SHA-256 over a canonical JSON serialization. Same audit input always produces the same hash, deterministically. Local entries are tamper-resistant client-side; entries marked ",e.jsx("strong",{children:"RFC 3161"})," additionally carry a third-party trusted timestamp and cannot be backdated."]}),e.jsx("ul",{className:"space-y-1.5",children:t.map(v=>e.jsxs("li",{className:"border border-slate-200 rounded bg-white p-2 text-xs space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${v.grade==="A"?"bg-emerald-100 text-emerald-700":v.grade==="B"?"bg-lime-100 text-lime-700":v.grade==="C"?"bg-yellow-100 text-yellow-700":v.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:v.grade}),e.jsx("span",{className:"font-mono text-slate-600 break-all",children:v.componentId})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded ${v.receipt?"bg-emerald-100 text-emerald-700":"bg-slate-100 text-slate-600"}`,title:v.receipt?`Anchored to ${v.receipt.tsaName} at ${v.receipt.anchoredAt}`:"Local-only — not yet anchored to a public TSA",children:v.receipt?`RFC 3161 (${v.receipt.tsaName})`:"Local"})]}),e.jsx("div",{className:"text-[11px] text-slate-700 break-all",children:v.pageUrl}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-500",children:[e.jsx("span",{children:v.capturedAt}),(v.totals.critical>0||v.totals.serious>0)&&e.jsxs("span",{children:[v.totals.critical>0&&e.jsxs("span",{className:"text-rose-700 font-medium",children:[v.totals.critical," crit"]}),v.totals.critical>0&&v.totals.serious>0&&" · ",v.totals.serious>0&&e.jsxs("span",{className:"text-amber-700 font-medium",children:[v.totals.serious," sev"]})]}),e.jsxs("span",{children:[v.statesAudited," ",v.statesAudited===1?"state":"states"]}),e.jsxs("span",{className:"font-mono",title:v.hash,children:[v.hash.slice(0,12),"…"]})]})]},`${v.componentId}::${v.capturedAt}`))})]})}function Kr(){const[t,s]=h.useState(null),[a,n]=h.useState(!1);if(h.useEffect(()=>{let c=!1;return Zt().then(u=>{c||s(u)}).catch(()=>{c||s([])}),()=>{c=!0}},[a]),t===null||t.length===0)return null;const r=t.length,i=t[t.length-1],l=t.slice(0,3),o=t.filter(c=>c.receipt).length;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Audit history"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[11px] text-brand-600 hover:underline",children:"View all →"})]}),e.jsxs("p",{className:"text-xs text-slate-700",children:[e.jsx("strong",{children:r})," ",r===1?"audit":"audits"," on record",i&&e.jsxs(e.Fragment,{children:[" ","since"," ",e.jsx("span",{className:"text-slate-500",children:i.capturedAt.slice(0,10)})]}),o>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{className:"text-emerald-700",children:[o," anchored to a public TSA"]})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug",children:'Each entry is hashed for cryptographic integrity. This history feeds the chronological "Audit history" section of the lawsuit-defense report — useful evidence of ongoing remediation effort.'}),e.jsx("ul",{className:"space-y-1 pt-1",children:l.map(c=>e.jsxs("li",{className:"flex items-center gap-2 text-[11px] border-t border-slate-100 pt-1",children:[e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold ${c.grade==="A"?"bg-emerald-100 text-emerald-700":c.grade==="B"?"bg-lime-100 text-lime-700":c.grade==="C"?"bg-yellow-100 text-yellow-700":c.grade==="D"?"bg-orange-100 text-orange-700":"bg-rose-100 text-rose-700"}`,children:c.grade}),e.jsx("span",{className:"text-slate-500 shrink-0",children:c.capturedAt.slice(0,10)}),e.jsx("span",{className:"text-slate-700 truncate flex-1",children:c.pageUrl}),c.receipt&&e.jsx("span",{className:"shrink-0 text-[10px] text-emerald-700",title:`Anchored to ${c.receipt.tsaName}`,children:"✓ anchored"})]},`${c.componentId}::${c.capturedAt}`))}),e.jsx(be,{open:a,onClose:()=>n(!1),title:"Audit history",description:"Chronological record of every audit you've run, with cryptographic hashes proving the entries haven't been tampered with.",children:e.jsx("div",{className:"-m-4 max-h-[60vh] overflow-y-auto",children:e.jsx(ws,{})})})]})}function qr(t){return t===null?"Trial":t===0?"Trial · expires today":t===1?"Trial · 1 day left":`Trial · ${t} days left`}const Qr={eyebrow:"You're on a trial",headline:"Full features unlocked while you evaluate.",body:"When your trial ends, a paid plan keeps RFC 3161 trusted-timestamp anchoring, AI fix suggestions, and audit-history evidence active for every scan."},Yr={eyebrow:"You're on the free tier",headline:"Audits run locally — but no forensic record is being kept.",body:"Upgrade to anchor every audit with court-grade trusted timestamps, unlock AI-powered fix suggestions, and build a third-party-verifiable history of your remediation effort."},Jr={label:"Solo plan",perks:"forensic anchoring + AI features unlocked"},Xr={label:"Team plan",perks:"forensic anchoring + AI + team seats"};function Ns(){const t=f(p=>p.tier),s=f(p=>p.trialDaysRemaining),a=f(p=>p.seatsUsed),n=f(p=>p.seatsTotal),r=f(p=>p.planCode),i=f(p=>p.licenseDaysRemaining),l=f(p=>p.pastDue),[o,c]=h.useState(!1);if(t==="solo"&&r==="solo-single-month"){const p=i,m=p!==null&&p<=7,x=p===null?"":p===0?"expires today":p===1?"1 day left":`${p} days left`;return e.jsxs("aside",{"aria-label":"License status",className:m?"relative z-20 bg-amber-50 border-b border-amber-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]":"relative z-20 bg-emerald-50 border-b border-emerald-200 px-3 py-2 space-y-1 text-[11px] shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",children:[e.jsxs("div",{className:m?"text-amber-900":"text-emerald-800",children:[e.jsx("span",{className:"font-medium",children:"✓ Solo · single-month pass"}),x&&e.jsxs("span",{className:m?"text-amber-900 font-semibold":"text-emerald-700",children:[" ","· ",x]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:m?"text-amber-900 font-medium hover:underline":"text-emerald-800 font-medium hover:underline",title:"Switch to a recurring monthly subscription — auto-renews, no need to re-buy each month",children:"Upgrade to monthly →"}),e.jsx("span",{className:m?"text-amber-300":"text-emerald-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:m?"text-amber-700 hover:underline":"text-emerald-700 hover:underline",children:"Manage license"})]}),e.jsx(Xe,{open:o,onClose:()=>c(!1)})]})}if(t==="solo"||t==="team"){const p=t==="team"?Xr:Jr,m=t==="team"&&a!==null&&n!==null?`${a} of ${n} seats used`:p.perks,x=t==="team"&&a!==null&&n!==null&&a>n,g=t==="team"&&a!==null&&n!==null&&a===n,j=l?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:x?{bg:"bg-rose-50",border:"border-rose-200",shadow:"shadow-[0_2px_8px_-2px_rgba(159,18,57,0.16)]",title:"text-rose-900",subtitle:"text-rose-700",link:"text-rose-700 hover:underline"}:g?{bg:"bg-amber-50",border:"border-amber-200",shadow:"shadow-[0_2px_8px_-2px_rgba(120,53,15,0.12)]",title:"text-amber-900",subtitle:"text-amber-800",link:"text-amber-700 hover:underline"}:{bg:"bg-emerald-50",border:"border-emerald-200",shadow:"shadow-[0_2px_8px_-2px_rgba(6,78,59,0.12)]",title:"text-emerald-800",subtitle:"text-emerald-700",link:"text-emerald-700 hover:underline"};return e.jsxs("aside",{"aria-label":"License status",className:`relative z-20 ${j.bg} border-b ${j.border} px-3 py-2 space-y-1 text-[11px] ${j.shadow}`,children:[e.jsxs("div",{className:j.title,children:[e.jsxs("span",{className:"font-medium",children:["✓ ",p.label]}),e.jsxs("span",{className:j.subtitle,children:[" · ",m]})]}),l&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Payment failed — update your card in Settings → License before access cuts off."}),x&&e.jsx("div",{className:"text-[11px] text-rose-900 font-medium",children:"Over capacity — release a seat or upgrade. New devices will be blocked."}),g&&!x&&e.jsx("div",{className:"text-[11px] text-amber-900",children:"At capacity — next device that activates will be rejected."}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:j.link,children:"Manage license →"})})]})}const u=t==="trial"?Qr:Yr,d=t==="trial"?qr(s):"Free";return e.jsxs("aside",{"aria-label":"Upgrade prompt",className:"relative z-20 border-b border-brand-200 bg-gradient-to-br from-brand-50 via-white to-white px-3 py-2.5 space-y-2 shadow-[0_4px_16px_-4px_rgba(31,41,55,0.14)]",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.06em] text-brand-700 font-medium",children:u.eyebrow}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-brand-100 text-brand-700",children:d})]}),e.jsx("p",{className:"text-xs font-medium text-slate-900 leading-snug",children:u.headline}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug",children:u.body}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade →"}),e.jsx("button",{type:"button",onClick:()=>void J({type:"OPEN_SETTINGS"}),className:"text-xs px-2.5 py-1.5 text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"})]}),e.jsx(Xe,{open:o,onClose:()=>c(!1)})]})}const Zr={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"},ei={A:"bg-emerald-500",C:"bg-yellow-500",D:"bg-orange-500",F:"bg-rose-600"},Bt={low:"text-emerald-800",moderate:"text-yellow-800",high:"text-orange-800",critical:"text-rose-800"},ti={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"},Ht={critical:0,serious:1,moderate:2,minor:3};function si(){const t=f(p=>p.setUserMode),s=f(p=>p.status),a=f(p=>p.setStatus),n=f(p=>p.errorMessage),r=f(p=>p.setError),[i,l]=h.useState(!1),[o,c]=h.useState(!1),u=h.useRef(s);h.useEffect(()=>{if(u.current==="running"&&s==="complete"){c(!0);const p=setTimeout(()=>c(!1),3500);return u.current=s,()=>clearTimeout(p)}u.current=s},[s]),h.useEffect(()=>{if(s!=="running")return;const p=setTimeout(()=>{f.getState().status==="running"&&(a("idle"),r("The scan didn't complete in time. The page may not be ready, or the audit hit an error. Try clicking Scan again."))},9e4);return()=>clearTimeout(p)},[s,a,r]);function d(){t("dev"),J({type:"SETTINGS_SET",key:"userMode",value:"dev"})}return e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx(Ns,{}),e.jsx(us,{}),e.jsxs("header",{className:"border-b border-slate-200 bg-white px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm leading-tight",children:"Lawsuit-target screener"}),e.jsx("p",{className:"text-[10px] text-slate-500 leading-tight",children:"Find out if your site is on the ADA-targeting bots' radar"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ds,{}),e.jsx("button",{type:"button",onClick:d,className:"text-[11px] px-2 py-1 border border-slate-300 rounded text-slate-600 hover:bg-slate-50",title:"Switch to the full developer feature set",children:"I'm a developer"})]})]}),s==="running"&&e.jsx(ai,{}),s==="failed"&&n&&e.jsxs("div",{role:"alert",className:"bg-rose-50 border-b border-rose-200 px-3 py-2 flex items-start gap-2 text-xs text-rose-800",children:[e.jsx("span",{className:"text-base leading-none mt-0.5","aria-hidden":"true",children:"⚠"}),e.jsx("div",{className:"flex-1",children:n}),e.jsx("button",{type:"button",onClick:()=>{f.setState({errorMessage:null,status:"idle"})},className:"text-rose-600 hover:text-rose-900 shrink-0","aria-label":"Dismiss error",children:"×"})]}),e.jsxs("main",{className:"flex-1 overflow-y-auto relative","aria-label":"Accessibility checker",children:[i?e.jsx(ys,{onBack:()=>l(!1)}):e.jsx(ri,{onPickCrawl:()=>l(!0)}),o&&e.jsx(ni,{})]}),e.jsxs("footer",{className:"border-t border-slate-200 bg-white text-[10px] text-slate-500",children:[e.jsx("div",{className:"px-3 py-1.5 text-center leading-tight",children:"Risk indicator based on the same automated WCAG checks ADA-targeting tools use. Automated checks catch ~30–50% of accessibility issues; a human review covers the rest."}),e.jsxs("div",{className:"border-t border-slate-100 bg-slate-50 px-3 py-1 text-center",children:["Powered by"," ",e.jsx("a",{href:"https://locustware.com",target:"_blank",rel:"noopener noreferrer",className:"font-medium text-slate-600 hover:text-brand-600 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-brand-500",children:"Locustware"})]})]})]})}function ai(){const t=f(s=>s.progress);return e.jsxs("div",{role:"status","aria-live":"polite",className:"bg-brand-50 border-b border-brand-200 px-3 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-brand-900",children:"Scanning your page…"}),t?e.jsxs("p",{className:"text-[11px] text-slate-600 truncate",children:["State ",t.current," of ",t.total,t.currentState&&` · ${t.currentState.pseudoState} · ${t.currentState.theme}`]}):e.jsx("p",{className:"text-[11px] text-slate-600",children:"Just a moment — this typically takes a few seconds."})]}),e.jsx("button",{type:"button",onClick:()=>void J({type:"CANCEL_AUDIT"}),className:"text-[11px] px-2.5 py-1 border border-brand-300 bg-white text-brand-700 rounded hover:bg-brand-50 shrink-0",children:"Stop"})]})}function ni(){return e.jsxs("div",{role:"status",className:"absolute top-3 left-1/2 -translate-x-1/2 bg-emerald-600 text-white text-xs font-medium px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 pointer-events-none",style:{zIndex:50},children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsx("span",{children:"Scan complete"})]})}function ri({onPickCrawl:t}){const s=f(p=>p.status),a=f(p=>p.results),[n,r]=h.useState("quick"),[i,l]=h.useState("all"),o=s==="running",c=a.flatMap(p=>p.violations),u=a.length>0;function d(){de({type:"START_AUDIT",mode:"full-page",matrixOverride:ht(n)}),f.getState().startNewScan(),ce.polite(`${n==="thorough"?"Thorough":"Quick"} scan of this page started.`)}return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:d,disabled:o,className:"flex-1 text-sm px-4 py-2.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:o?"Scanning…":"🔍 Scan this page"}),e.jsx("button",{type:"button",onClick:t,disabled:o,className:"text-sm px-4 py-2.5 border border-slate-300 bg-white rounded hover:bg-slate-50 disabled:opacity-50 font-medium",children:"🌐 Whole site"})]}),e.jsx(li,{depth:n,onChange:r,disabled:o})]}),!u&&!o&&e.jsx(ii,{}),u&&e.jsx(oi,{violations:c,severityFilter:i,onSeverityFilterChange:l,scanDepth:n})]})}function ii(){return e.jsx("div",{className:"border border-slate-200 rounded-lg overflow-hidden bg-white",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"flex items-center justify-center w-24 bg-slate-300 text-white shrink-0","aria-label":"Not yet audited",children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:"X"})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"Not yet audited"}),e.jsxs("p",{className:"text-xs mt-1 leading-snug text-slate-600",children:["WCAG compliance level unknown. Open the page you want to check in this tab, then click ",e.jsx("strong",{children:"Scan this page"})," above. Use",e.jsx("strong",{children:" Whole site"})," for a multi-page report."]})]})]})})}function li({depth:t,onChange:s,disabled:a}){return e.jsxs("fieldset",{className:"mt-2",children:[e.jsx("legend",{className:"sr-only",children:"Scan depth"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsx(zt,{active:t==="quick",disabled:a,onClick:()=>s("quick"),title:"Quick scan",subtitle:`${Wt("quick")} state · ~2 sec`,desc:"Default page state only — fastest"}),e.jsx(zt,{active:t==="thorough",disabled:a,onClick:()=>s("thorough"),title:"Thorough scan",subtitle:`${Wt("thorough")} states · ~10 sec`,desc:"Includes hover, focus, dark mode, RTL"})]})]})}function zt({active:t,disabled:s,onClick:a,title:n,subtitle:r,desc:i}){return e.jsxs("button",{type:"button",onClick:a,disabled:s,"aria-pressed":t,className:`text-left rounded p-2 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"} disabled:opacity-50`,children:[e.jsx("div",{className:"font-medium text-slate-900",children:n}),e.jsx("div",{className:"text-slate-600 text-[10px]",children:r}),e.jsx("div",{className:"text-slate-600 text-[10px] mt-0.5",children:i})]})}function oi({violations:t,severityFilter:s,onSeverityFilterChange:a,scanDepth:n}){var w;const r=f(I=>I.status),i=f(I=>I.results),l=f(I=>I.freshThisSession),o=f(I=>I.componentId),c=(w=i[0])==null?void 0:w.startedAt,u=Or(t),d=r==="running",[p,m]=h.useState([]);h.useEffect(()=>{if(!o){m([]);return}let I=!1;return chrome.storage.local.get("igtRuns").then(O=>{if(I)return;const F=((O==null?void 0:O.igtRuns)??{})[o]??{};m(Object.values(F))}),()=>{I=!0}},[o]);const x=f(I=>I.acknowledgedKeys),g=i.length>0?Xt(i,{runs:p,workflows:ee},"2.1","AA",x):void 0;function j(){de({type:"START_AUDIT",mode:"full-page",matrixOverride:ht(n)}),f.getState().startNewScan(),ce.polite("Re-scanning this page now.")}const b=s==="lawsuit-risk"?t.filter(I=>I.impact==="critical"||I.impact==="serious"):t,C=new Map;for(const I of b){const O=ct(I.ruleId,I.target.selector);C.has(O)||C.set(O,I)}const k=Array.from(C.values()),T=new Map;for(const I of k){const O=T.get(I.ruleId)??[];O.push(I),T.set(I.ruleId,O)}const v=Array.from(T.entries()).sort((I,O)=>(Ht[I[1][0].impact]??99)-(Ht[O[1][0].impact]??99)),S=t.filter(I=>I.impact==="critical"||I.impact==="serious").length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-slate-600",children:[c&&e.jsxs("span",{children:["Last scanned: ",e.jsx(hi,{iso:c})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("button",{type:"button",onClick:()=>void We(),disabled:d,className:"text-[11px] text-slate-500 hover:text-slate-800 hover:underline disabled:opacity-50",title:"Clear current results — they'll come back next time you scan",children:"Clear"}),e.jsx("button",{type:"button",onClick:j,disabled:d,className:"text-[11px] px-2.5 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:d?"Scanning…":"↻ Scan again"})]})]}),d?e.jsxs("div",{role:"status","aria-live":"polite",className:"border border-slate-200 rounded-lg p-4 bg-white flex items-center gap-3",children:[e.jsx("span",{className:"inline-block w-5 h-5 border-2 border-brand-500 border-t-transparent rounded-full animate-spin motion-reduce:animate-none","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Scanning this page…"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Risk level will update when the scan completes."})]})]}):e.jsxs("div",{className:`border rounded-lg overflow-hidden ${Zr[u.tier]}`,children:[!l&&c&&e.jsxs("p",{className:"text-[11px] text-amber-900 bg-amber-50 border-b border-amber-200 px-3 py-1.5 flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",children:"↻"}),"Showing a previous scan. Click ",e.jsx("strong",{children:"Scan again"})," to refresh."]}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:`flex items-center justify-center w-24 ${ei[u.letter]} text-white shrink-0`,"aria-label":`Lawsuit-target safety grade ${u.letter}`,children:e.jsx("span",{className:"text-5xl font-bold leading-none",children:u.letter})}),e.jsxs("div",{className:"flex-1 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide font-semibold text-slate-500 mb-1",children:"Lawsuit-target safety grade"}),e.jsxs("p",{className:`text-base font-semibold ${Bt[u.tier]} capitalize`,children:[u.tier," risk"]}),e.jsx("p",{className:`text-xs mt-1 leading-snug ${Bt[u.tier]}`,children:u.headline}),u.flaggedRuleCount>0&&e.jsxs("p",{className:"text-xs mt-2 text-slate-700",children:[e.jsx("strong",{children:u.flaggedRuleCount})," ",u.flaggedRuleCount===1?"issue type":"issue types"," flagged",u.flaggedInstanceCount>u.flaggedRuleCount&&e.jsxs(e.Fragment,{children:[" across ",e.jsx("strong",{children:u.flaggedInstanceCount})," instances"]}),". See list below for fixes."]}),e.jsxs("p",{className:"text-[10px] mt-2 text-slate-500 leading-snug border-t border-slate-200 pt-1.5",children:[e.jsx("strong",{children:"What this grade is:"})," exposure to automated lawsuit-targeting scanners. ",e.jsx("strong",{children:"What it is not:"})," a WCAG conformance grade. See the Path-to-Full-Compliance card below to claim AA."]})]})]})]}),!d&&g&&!g.canClaimConformance&&e.jsx(ci,{coverage:g}),!d&&g&&g.canClaimConformance&&e.jsxs("div",{className:"border border-emerald-200 bg-emerald-50 rounded-lg p-3 text-xs text-emerald-900",children:[e.jsxs("p",{className:"font-semibold mb-0.5",children:["✓ Full WCAG ",g.targetLevel," compliance achieved."]}),e.jsx("p",{children:"Every applicable criterion passes or is N/A. You can present this audit as a conformance claim for the audited URL(s)."})]}),e.jsx(mi,{}),e.jsx(Kr,{}),t.length>0&&e.jsx(di,{filter:s,onChange:a,totalCount:t.length,lawsuitRiskCount:S}),e.jsxs("div",{className:"space-y-2",children:[v.length===0&&s==="lawsuit-risk"&&e.jsxs("div",{className:"text-xs text-slate-500 text-center py-4",children:["No critical or serious issues — switch to ",e.jsx("strong",{children:"Show all"})," to see lower-priority findings."]}),v.map(([I,O])=>e.jsx(ui,{ruleId:I,violations:O},I))]})]})}function ci({coverage:t}){const s=f(n=>n.setUserMode),a=t.totalApplicable===0?0:Math.round(t.evaluated/t.totalApplicable*100);return e.jsxs("div",{className:"border border-slate-200 bg-white rounded-lg p-3 text-xs text-slate-800 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"font-semibold text-slate-900",children:["Path to full WCAG ",t.targetLevel," compliance"]}),e.jsxs("span",{className:"text-[11px] text-slate-500",children:[t.evaluated," of ",t.totalApplicable," criteria (",a,"%)"]})]}),e.jsx("div",{className:"flex h-1.5 bg-slate-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand-500",style:{width:`${a}%`},"aria-label":`${a}% coverage`})}),e.jsxs("p",{className:"text-[11px] text-slate-600 leading-snug",children:["Lawsuit-target scanners only check a subset of WCAG. To claim full ",t.targetLevel," conformance, resolve the remaining items:",t.untestedCriteria.length>0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:t.untestedCriteria.length})," untested (mark Pass/Fail/N/A in Guided Tests)"]}),t.inconclusiveCriteria.length>0&&e.jsxs(e.Fragment,{children:[t.untestedCriteria.length>0&&", "," ",e.jsx("strong",{children:t.inconclusiveCriteria.length})," inconclusive (axe couldn't determine, or a Guided Test step was skipped — re-answer with Pass/Fail/N/A)"]}),". Many criteria don't apply to your site (e.g., captions if you have no videos) — mark them ",e.jsx("strong",{children:"N/A"})," to clear them."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsx("button",{type:"button",onClick:()=>{s("dev"),J({type:"SETTINGS_SET",key:"userMode",value:"dev"})},className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Switch to Dev mode for full workflow"})})]})}function di({filter:t,onChange:s,totalCount:a,lawsuitRiskCount:n}){return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 mb-1.5",children:"Show"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("button",{type:"button",onClick:()=>s("all"),"aria-pressed":t==="all",className:`text-left rounded p-2 border transition-colors ${t==="all"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"All issues"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[a," total"]})]}),e.jsxs("button",{type:"button",onClick:()=>s("lawsuit-risk"),"aria-pressed":t==="lawsuit-risk",className:`text-left rounded p-2 border transition-colors ${t==="lawsuit-risk"?"border-brand-500 bg-brand-50 ring-1 ring-brand-500/30":"border-slate-300 bg-white hover:bg-slate-50"}`,children:[e.jsx("div",{className:"font-medium",children:"Lawsuit risk only"}),e.jsxs("div",{className:"text-slate-600 text-[10px]",children:[n," critical/serious"]})]})]})]})}function ui({ruleId:t,violations:s}){var p;const[a,n]=h.useState(!1),r=(p=s.find(m=>m.target.opacityContext))==null?void 0:p.target.opacityContext,i=Xs(t,r),l=s[0].impact,o=s[0],u=i.whatsWrong==="An accessibility rule failed on this page."&&o.description?o.description:i.whatsWrong,d=o.helpUrl||`https://dequeuniversity.com/rules/axe/4.11/${t}`;return e.jsxs("div",{className:"border border-slate-200 rounded bg-white",children:[e.jsxs("button",{type:"button",onClick:()=>n(!a),className:"w-full text-left p-3 hover:bg-slate-50 flex items-start gap-2","aria-expanded":a,children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-semibold uppercase tracking-wide shrink-0 ${ti[l]}`,children:l}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium leading-snug",children:u}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:[e.jsx("span",{className:"font-mono",children:t})," · ",s.length," ",s.length===1?"spot":"spots"," on this page"," · click to expand"]})]}),e.jsx("span",{className:"text-slate-400 text-xs",children:a?"▲":"▼"})]}),a&&e.jsxs("div",{className:"border-t border-slate-200 p-3 space-y-2 text-xs leading-snug",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"Why this matters:"})," ",i.whyItMatters]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-slate-700",children:"How to fix:"})," ",i.howToFix]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:s.map((m,x)=>e.jsx(pi,{violation:m},x))}),e.jsx("div",{className:"pt-2",children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",onClick:m=>m.stopPropagation(),className:"text-brand-600 hover:underline text-[11px]",children:"Full technical guidance →"})})]})]})}function pi({violation:t}){const s=f(i=>{var l;return(l=i.results[0])==null?void 0:l.frameId}),[a,n]=h.useState(null);async function r(i){i.stopPropagation();const l=await le();if(l)try{const o=await Ie(l,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:l,selector:t.target.selector},s);n(o.found)}catch{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 bg-slate-50 rounded px-2 py-1.5 text-[11px]",children:[e.jsx("code",{className:"font-mono text-slate-700 break-all",children:t.target.selector}),e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:r,className:"text-brand-600 hover:underline",children:"Highlight on page"}),a===!1&&e.jsx("span",{className:"text-amber-700",children:"Element not currently visible — may need to re-audit."}),a===!0&&e.jsx("span",{className:"text-emerald-700",children:"✓ Highlighted"})]})]})}const $e=[{id:"owner-report",emoji:"📄",title:"Plain-language report",desc:"Saveable, printable. Good for your records or to share internally.",isHtml:!0},{id:"developer-letter",emoji:"✉",title:"Send to my developer",desc:"Friendly note explaining what to fix, with one-line descriptions per issue.",isHtml:!0},{id:"ai-prompt-owner",emoji:"🤖",title:"Get AI summary",desc:"Paste into ChatGPT, Claude, or another AI to get personalized fix advice for your platform.",isHtml:!1},{id:"defense-bundle",emoji:"⚖",title:"Lawsuit defense report",desc:"Legal-grade report documenting your audit. Saved as HTML — open it and use Ctrl+P → Save as PDF for a sealed file.",isHtml:!0}];function mi(){const t=f(d=>d.results),s=f(d=>d.componentId),[a,n]=h.useState(null),[r,i]=h.useState(!1),[l,o]=h.useState(null);async function c(d,p){if(t.length!==0){n(d);try{const m=await te({type:"EXPORT_REQUEST",format:d,results:t});if(d==="defense-bundle"||d==="evidence-bundle"){const x=Qt(d,s);await Yt()?lt(m.content,x):o({open:!0,format:d,content:m.content,filename:x})}else if(p)it(m.content);else{try{await navigator.clipboard.writeText(m.content),ce.polite("AI summary copied to clipboard. Paste into your AI assistant.")}catch{}const g=`<!doctype html><meta charset="utf-8"><title>AI summary</title>
236
236
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
237
237
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
238
238
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}</style>
239
239
  <div class="banner"><strong>✓ Copied to clipboard.</strong> Paste this into ChatGPT, Claude, or your favorite AI assistant. The AI will walk you through fixes for your specific situation.</div>
240
- <pre>${m.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,y=new Blob([g],{type:"text/html"}),k=URL.createObjectURL(y);window.open(k,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(k),6e4)}}finally{n(null)}}}const u=r?$e:$e.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:u.map(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),o&&e.jsx(gs,{open:o.open,onClose:()=>l(null),format:o.format,content:o.content,filename:o.filename})]})}function oi({iso:t}){const[,s]=h.useState(0);h.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function li(t,s,a){const n=new Set,r=[];let i=!1;for(const[o,l]of s)for(const c of l){for(const d of c.violations)if(d.wcagCriterion===t){if(a!=null&&a.has(d.matchKey)){n.add(d.ruleId);continue}if(d.needsReview){n.add(d.ruleId),i=!0;continue}n.add(d.ruleId),r.push({source:"axe",ruleOrStepId:d.ruleId,description:d.description||d.ruleId,pageUrl:o,selector:d.target.selector})}const u=c.axeRulesEvaluated;if(u){for(const d of u.passed)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of u.inapplicable)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of u.incomplete)d.wcagCriterion===t&&(n.add(d.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function ci(t,s,a){const n=[];let r=0,i=0,o=0,l=0;for(const u of a){const d=u.steps.filter(p=>p.wcag===t);if(d.length!==0){r+=d.length;for(const[p,m]of s){const x=m[u.id];if(!x){i+=d.length;continue}for(const g of d){const y=x.steps[g.id];if(!y){i++;continue}y.status==="fail"?(o++,n.push({source:"igt",ruleOrStepId:`${u.id}.${g.id}`,description:g.question,pageUrl:p,notes:y.notes})):y.status==="skip"?i++:y.status==="not-applicable"?(o++,l++):o++}}}}const c=o>0&&l===o;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function di(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function ui(t,s,a){switch(s){case"pass":return`${a.axeRulesFiringForCriterion+a.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${a.axeFailures.length} automated finding(s), ${a.igtFailures.length} manual finding(s) failed this criterion.`;case"inconclusive":return"Some manual checks for this criterion are unanswered or skipped; rerun the relevant IGT workflow to resolve.";case"not-evaluated":return"No automated rule and no guided-test step in the wcagcheckr ruleset maps to this criterion. Manual review required.";case"not-applicable":return"Marked not applicable by the evaluator."}}function pi(t,s){var p;const a=[];for(const m of s.auditsByUrl.values())a.push(...m);const n=[];for(const m of s.igtRunsByUrl.values())n.push(...Object.values(m));const r=dt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Ys(t.targetVersion,t.targetLevel),o=[];for(const m of i){const x=li(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=ci(m.id,s.igtRunsByUrl,s.workflows),y=x.rulesFiring.size===0&&g.stepsCovering===0,k={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:y},T=(p=t.overrides)==null?void 0:p[m.id];let N,E,b=!1;if(T)N=T.verdict,E=T.rationale,b=!0;else{const S=r.get(m.id);S?N=S.state:N=di(k,g.unanswered,x.hasIncomplete,g.allNotApplicable),E=ui(m,N,k)}o.push({criterion:m,understandingUrl:Js(m,t.targetVersion),verdict:N,signals:k,overridden:b,rationale:E})}const l={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of o)m.verdict==="pass"?l.pass++:m.verdict==="fail"?l.fail++:m.verdict==="inconclusive"?l.inconclusive++:m.verdict==="not-applicable"?l.notApplicable++:m.verdict==="not-evaluated"&&l.notEvaluated++;function c(m){const x={A:1,AA:2,AAA:3},g=x[m];return o.every(y=>x[y.criterion.level]>g?!0:y.verdict==="pass"||y.verdict==="not-applicable")}let u=null;c("AAA")?u="AAA":c("AA")?u="AA":c("A")&&(u="A");const d=u===t.targetLevel||u==="AAA"&&t.targetLevel==="AA"||u==="AAA"&&t.targetLevel==="A"||u==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:o,summary:{totalCriteria:o.length,pass:l.pass,fail:l.fail,inconclusive:l.inconclusive,notApplicable:l.notApplicable,notEvaluated:l.notEvaluated,levelAchieved:u,meetsTarget:d}}}const mi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Bt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function L(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ke(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function hi(t,s,a,n){const{inputs:r,rows:i,summary:o,generatedAt:l}=t,c=o.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,u=new Map;for(const p of i){const m=p.criterion.id.split(".").slice(0,2).join("."),x=u.get(m)??[];x.push(p),u.set(m,x)}const d=Array.from(u.entries()).sort(([p],[m])=>p.localeCompare(m,void 0,{numeric:!0})).map(([p,m])=>`
240
+ <pre>${m.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`,j=new Blob([g],{type:"text/html"}),b=URL.createObjectURL(j);window.open(b,"_blank","noopener,noreferrer"),setTimeout(()=>URL.revokeObjectURL(b),6e4)}}finally{n(null)}}}const u=r?$e:$e.slice(0,2);return e.jsxs("div",{className:"border border-slate-200 rounded bg-white p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500",children:"Reports"}),e.jsx("div",{className:"space-y-1.5",children:u.map(d=>e.jsx("button",{type:"button",onClick:()=>void c(d.id,d.isHtml),disabled:a!==null,className:"w-full text-left p-2 rounded border border-slate-200 bg-white hover:bg-slate-50 disabled:opacity-50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg leading-none mt-0.5","aria-hidden":"true",children:d.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-xs",children:d.title}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug",children:d.desc})]}),a===d.id&&e.jsx("span",{className:"text-[11px] text-slate-500 shrink-0",children:"Generating…"})]})},d.id))}),!r&&e.jsxs("button",{type:"button",onClick:()=>i(!0),className:"text-[11px] text-brand-600 hover:underline",children:["Show ",$e.length-2," more report option",$e.length-2===1?"":"s"," ↓"]}),l&&e.jsx(vs,{open:l.open,onClose:()=>o(null),format:l.format,content:l.content,filename:l.filename})]})}function hi({iso:t}){const[,s]=h.useState(0);h.useEffect(()=>{const n=setInterval(()=>s(r=>r+1),3e4);return()=>clearInterval(n)},[]);const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<5?e.jsx("span",{children:"just now"}):a<60?e.jsxs("span",{children:[a," seconds ago"]}):a<120?e.jsx("span",{children:"1 minute ago"}):a<3600?e.jsxs("span",{children:[Math.floor(a/60)," minutes ago"]}):a<7200?e.jsx("span",{children:"1 hour ago"}):e.jsxs("span",{children:[Math.floor(a/3600)," hours ago"]})}function xi(t,s,a){const n=new Set,r=[];let i=!1;for(const[l,o]of s)for(const c of o){for(const d of c.violations)if(d.wcagCriterion===t){if(a!=null&&a.has(d.matchKey)){n.add(d.ruleId);continue}if(d.needsReview){n.add(d.ruleId),i=!0;continue}n.add(d.ruleId),r.push({source:"axe",ruleOrStepId:d.ruleId,description:d.description||d.ruleId,pageUrl:l,selector:d.target.selector})}const u=c.axeRulesEvaluated;if(u){for(const d of u.passed)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of u.inapplicable)d.wcagCriterion===t&&n.add(d.ruleId);for(const d of u.incomplete)d.wcagCriterion===t&&(n.add(d.ruleId),i=!0)}}return{rulesFiring:n,failures:r,hasIncomplete:i}}function gi(t,s,a){const n=[];let r=0,i=0,l=0,o=0;for(const u of a){const d=u.steps.filter(p=>p.wcag===t);if(d.length!==0){r+=d.length;for(const[p,m]of s){const x=m[u.id];if(!x){i+=d.length;continue}for(const g of d){const j=x.steps[g.id];if(!j){i++;continue}j.status==="fail"?(l++,n.push({source:"igt",ruleOrStepId:`${u.id}.${g.id}`,description:g.question,pageUrl:p,notes:j.notes})):j.status==="skip"?i++:j.status==="not-applicable"?(l++,o++):l++}}}}const c=l>0&&o===l;return{stepsCovering:r,failures:n,unanswered:i,allNotApplicable:c}}function fi(t,s,a,n){return t.unmapped?"not-evaluated":t.axeFailures.length>0||t.igtFailures.length>0?"fail":s>0||a?"inconclusive":n&&t.axeRulesFiringForCriterion===0?"not-applicable":"pass"}function bi(t,s,a){switch(s){case"pass":return`${a.axeRulesFiringForCriterion+a.igtStepsCoveringCriterion} signal(s) covered this criterion; no failures recorded.`;case"fail":return`${a.axeFailures.length} automated finding(s), ${a.igtFailures.length} manual finding(s) failed this criterion.`;case"inconclusive":return"Some manual checks for this criterion are unanswered or skipped; rerun the relevant IGT workflow to resolve.";case"not-evaluated":return"No automated rule and no guided-test step in the wcagcheckr ruleset maps to this criterion. Manual review required.";case"not-applicable":return"Marked not applicable by the evaluator."}}function vi(t,s){var p;const a=[];for(const m of s.auditsByUrl.values())a.push(...m);const n=[];for(const m of s.igtRunsByUrl.values())n.push(...Object.values(m));const r=dt({audits:a,igtRuns:n,workflows:s.workflows,acknowledgedMatchKeys:s.acknowledgedMatchKeys??new Set,incompleteResolutions:s.incompleteResolutions,interactiveAuditResults:s.interactiveAuditResults}),i=Zs(t.targetVersion,t.targetLevel),l=[];for(const m of i){const x=xi(m.id,s.auditsByUrl,s.acknowledgedMatchKeys),g=gi(m.id,s.igtRunsByUrl,s.workflows),j=x.rulesFiring.size===0&&g.stepsCovering===0,b={axeRulesFiringForCriterion:x.rulesFiring.size,axeFailures:x.failures,igtStepsCoveringCriterion:g.stepsCovering,igtFailures:g.failures,unmapped:j},C=(p=t.overrides)==null?void 0:p[m.id];let k,T,v=!1;if(C)k=C.verdict,T=C.rationale,v=!0;else{const S=r.get(m.id);S?k=S.state:k=fi(b,g.unanswered,x.hasIncomplete,g.allNotApplicable),T=bi(m,k,b)}l.push({criterion:m,understandingUrl:ea(m,t.targetVersion),verdict:k,signals:b,overridden:v,rationale:T})}const o={pass:0,fail:0,inconclusive:0,notApplicable:0,notEvaluated:0};for(const m of l)m.verdict==="pass"?o.pass++:m.verdict==="fail"?o.fail++:m.verdict==="inconclusive"?o.inconclusive++:m.verdict==="not-applicable"?o.notApplicable++:m.verdict==="not-evaluated"&&o.notEvaluated++;function c(m){const x={A:1,AA:2,AAA:3},g=x[m];return l.every(j=>x[j.criterion.level]>g?!0:j.verdict==="pass"||j.verdict==="not-applicable")}let u=null;c("AAA")?u="AAA":c("AA")?u="AA":c("A")&&(u="A");const d=u===t.targetLevel||u==="AAA"&&t.targetLevel==="AA"||u==="AAA"&&t.targetLevel==="A"||u==="AA"&&t.targetLevel==="A";return{generatedAt:new Date().toISOString(),inputs:t,rows:l,summary:{totalCriteria:l.length,pass:o.pass,fail:o.fail,inconclusive:o.inconclusive,notApplicable:o.notApplicable,notEvaluated:o.notEvaluated,levelAchieved:u,meetsTarget:d}}}const yi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not evaluated","not-applicable":"Not applicable"},Kt={pass:"verdict-pass",fail:"verdict-fail",inconclusive:"verdict-incomplete","not-evaluated":"verdict-incomplete","not-applicable":"verdict-na"};function L(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ke(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function ji(t,s,a,n){const{inputs:r,rows:i,summary:l,generatedAt:o}=t,c=l.meetsTarget?`MEETS WCAG ${r.targetVersion} Level ${r.targetLevel}`:`DOES NOT MEET WCAG ${r.targetVersion} Level ${r.targetLevel}`,u=new Map;for(const p of i){const m=p.criterion.id.split(".").slice(0,2).join("."),x=u.get(m)??[];x.push(p),u.set(m,x)}const d=Array.from(u.entries()).sort(([p],[m])=>p.localeCompare(m,void 0,{numeric:!0})).map(([p,m])=>`
241
241
  <h3 class="guideline-h">Guideline ${L(p)}</h3>
242
242
  <table class="criteria-table">
243
243
  <thead>
@@ -247,11 +247,11 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
247
247
  </thead>
248
248
  <tbody>
249
249
  ${m.map(x=>`
250
- <tr class="${Bt[x.verdict]}">
250
+ <tr class="${Kt[x.verdict]}">
251
251
  <td><a href="${L(x.understandingUrl)}" target="_blank" rel="noopener">${L(x.criterion.id)}</a></td>
252
252
  <td>${L(x.criterion.title)}</td>
253
253
  <td>${L(x.criterion.level)}</td>
254
- <td><span class="verdict-badge ${Bt[x.verdict]}">${mi[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
254
+ <td><span class="verdict-badge ${Kt[x.verdict]}">${yi[x.verdict]}</span>${x.overridden?' <span class="override-tag" title="Evaluator override">override</span>':""}</td>
255
255
  <td class="rationale">${L(x.rationale)}</td>
256
256
  </tr>
257
257
  ${x.signals.axeFailures.length>0||x.signals.igtFailures.length>0?`
@@ -385,16 +385,16 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
385
385
  <p class="eyebrow">WCAG ${L(r.targetVersion)} Conformance Evaluation Report</p>
386
386
  <h1>${L(r.siteName)}</h1>
387
387
  <p style="margin: 4pt 0 0; font-size: 11pt; color: #475569;"><code>${L(r.siteUrl)}</code></p>
388
- <div class="conformance-banner ${o.meetsTarget?"met":"not-met"}">
388
+ <div class="conformance-banner ${l.meetsTarget?"met":"not-met"}">
389
389
  ${L(c)}
390
390
  </div>
391
391
  <dl class="meta">
392
392
  <dt>Highest level fully satisfied</dt>
393
- <dd>${o.levelAchieved?`WCAG ${L(r.targetVersion)} Level ${L(o.levelAchieved)}`:"None (target level not met)"}</dd>
393
+ <dd>${l.levelAchieved?`WCAG ${L(r.targetVersion)} Level ${L(l.levelAchieved)}`:"None (target level not met)"}</dd>
394
394
  <dt>Target conformance level</dt>
395
395
  <dd>WCAG ${L(r.targetVersion)} Level ${L(r.targetLevel)}</dd>
396
396
  <dt>Report generated</dt>
397
- <dd>${L(ke(l))}</dd>
397
+ <dd>${L(ke(o))}</dd>
398
398
  <dt>Evaluator</dt>
399
399
  <dd>
400
400
  ${L(r.evaluator.name)}
@@ -405,12 +405,12 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
405
405
  </section>
406
406
 
407
407
  <table class="summary-table">
408
- <tr><th>Criteria evaluated</th><td>${o.totalCriteria}</td></tr>
409
- <tr><th>Pass</th><td>${o.pass}</td></tr>
410
- <tr><th>Fail</th><td>${o.fail}</td></tr>
411
- <tr><th>Inconclusive</th><td>${o.inconclusive}</td></tr>
412
- <tr><th>Not applicable</th><td>${o.notApplicable}</td></tr>
413
- <tr><th>Not evaluated (manual review required)</th><td>${o.notEvaluated}</td></tr>
408
+ <tr><th>Criteria evaluated</th><td>${l.totalCriteria}</td></tr>
409
+ <tr><th>Pass</th><td>${l.pass}</td></tr>
410
+ <tr><th>Fail</th><td>${l.fail}</td></tr>
411
+ <tr><th>Inconclusive</th><td>${l.inconclusive}</td></tr>
412
+ <tr><th>Not applicable</th><td>${l.notApplicable}</td></tr>
413
+ <tr><th>Not evaluated (manual review required)</th><td>${l.notEvaluated}</td></tr>
414
414
  </table>
415
415
 
416
416
  <h2>1 — Evaluation scope</h2>
@@ -477,7 +477,7 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
477
477
 
478
478
  <section class="attestation">
479
479
  <h3>Conformance claim</h3>
480
- <p>${o.meetsTarget?`Based on the evidence collected, <strong>${L(r.siteName)}</strong> meets the success criteria required for <strong>WCAG ${L(r.targetVersion)} Level ${L(r.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${L(r.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${L(r.targetVersion)} Level ${L(r.targetLevel)} conformance. ${o.fail>0?`${o.fail} criterion failure${o.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
480
+ <p>${l.meetsTarget?`Based on the evidence collected, <strong>${L(r.siteName)}</strong> meets the success criteria required for <strong>WCAG ${L(r.targetVersion)} Level ${L(r.targetLevel)}</strong> conformance, with respect to the accessibility-support baseline declared above and within the page sample evaluated.`:`Based on the evidence collected, <strong>${L(r.siteName)}</strong> <strong>does not</strong> meet the success criteria required for WCAG ${L(r.targetVersion)} Level ${L(r.targetLevel)} conformance. ${l.fail>0?`${l.fail} criterion failure${l.fail===1?"":"s"}`:"Unresolved manual checks"} prevent the claim. See the detailed findings table above.`}</p>
481
481
  <p style="font-size: 9.5pt; color: #475569;">This conformance claim is the responsibility of the named evaluator. The wcagcheckr tooling assembled the per-criterion evidence; the evaluator's signature attests that the methodology was followed and the verdicts reflect the site under evaluation.</p>
482
482
  </section>
483
483
 
@@ -535,10 +535,10 @@ pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px sol
535
535
  `}
536
536
 
537
537
  <footer class="report-footer">
538
- <span>Generated ${L(ke(l))} by wcagcheckr</span>
539
- <span>${o.totalCriteria} criteria · ${o.pass} pass · ${o.fail} fail · ${o.inconclusive} inconclusive</span>
538
+ <span>Generated ${L(ke(o))} by wcagcheckr</span>
539
+ <span>${l.totalCriteria} criteria · ${l.pass} pass · ${l.fail} fail · ${l.inconclusive} inconclusive</span>
540
540
  </footer>
541
541
  </body>
542
- </html>`}async function xi(t,s,a,n){const r=hi(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(i);await chrome.tabs.create({url:o})}const Je=Jt("wcag-em-anchor"),gi="https://api.wcagcheckr.com",fi="wcagcheckr",bi=15e3;function js(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function vi(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function yi(t){return vi(Xs(js(t)))}function ji(t){if(typeof t!="object"||t===null)return!1;const s=t;return s.schemaVersion!==1&&s.schemaVersion!==2||!(typeof s.anchoredAt=="string"&&typeof s.tsaName=="string"&&typeof s.rfc3161TokenBase64=="string"&&s.rfc3161TokenBase64.length>0&&typeof s.serverSignatureBase64=="string"&&s.serverSignatureBase64.length>0&&typeof s.serverKeyFingerprint=="string"&&s.serverKeyFingerprint.length>0)?!1:s.schemaVersion===2?typeof s.prevAuditHash=="string"&&/^[0-9a-f]{64}$/.test(s.prevAuditHash):!0}async function wi(t,s){const a=await yi(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${gi}/v1/products/${fi}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(bi)});if(!i.ok)return Je.warn(`anchor HTTP ${i.status}`),null;const o=await i.json();return ji(o)?{reportHash:a,capturedAt:t.generatedAt,receipt:o}:(Je.warn("anchor returned malformed receipt",o),null)}catch(i){return Je.warn("anchor request failed",i),null}}function Ni(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:js(t)}}const at="auditAttestations",nt="auditAttestation:defaultSigner";function xt(t,s){return`${t}::${s}`}async function gt(){try{const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:{}}catch{return{}}}async function ws(t){await chrome.storage.local.set({[at]:t})}async function ki(t){const s=await gt();s[xt(t.componentId,t.auditCapturedAt)]=t,await ws(s)}async function Ns(t,s){return(await gt())[xt(t,s)]??null}async function Si(t,s){const a=await gt();delete a[xt(t,s)],await ws(a)}async function Ai(){try{const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:null}catch{return null}}async function Ci(t){await chrome.storage.local.set({[nt]:t})}function Ii(t,s){return t.auditCapturedAt!==s}function Ri(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function Ei(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(""),[u,d]=h.useState(""),[p,m]=h.useState(""),[x,g]=h.useState(""),[y,k]=h.useState("");h.useEffect(()=>{let S=!1;return Promise.all([Ns(t.componentId,t.auditCapturedAt),Ai()]).then(([j,C])=>{S||(a(j),j?(c(j.signerName),d(j.signerEmail),m(j.signerOrganization??""),g(j.signerQualifications??""),k(j.claim)):C&&(c(C.signerName),d(C.signerEmail),m(C.signerOrganization??""),g(C.signerQualifications??"")),k(_=>_||Ri({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{S=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function T(){if(!l.trim()||!u.trim())return;const S={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:l.trim(),signerEmail:u.trim(),signerOrganization:p.trim()||void 0,signerQualifications:x.trim()||void 0,claim:y.trim(),scope:t.scope};await ki(S),await Ci({signerName:S.signerName,signerEmail:S.signerEmail,signerOrganization:S.signerOrganization,signerQualifications:S.signerQualifications}),a(S),o(!1)}async function N(){await Si(t.componentId,t.auditCapturedAt),a(null),o(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const E=s&&Ii(s,t.auditCapturedAt);if(s&&!E&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void N(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&E&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const b=l.trim().length>0&&u.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:l,onChange:S=>c(S.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:u,onChange:S=>d(S.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:p,onChange:S=>m(S.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:x,onChange:S=>g(S.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:y,onChange:S=>k(S.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!b,onClick:()=>void T(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const rt="spotAuditReviews";function ks(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function ft(){try{const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ss(t){await chrome.storage.local.set({[rt]:t})}async function Ti(t){const s=await ft();s[t.key]=t,await Ss(s)}async function $i(t){const s=await ft();delete s[t],await Ss(s)}async function As(){const t=await ft();return Object.values(t)}function Cs(t,s){const a=new Map(s.map(o=>[o.key,o]));let n=0,r=0,i=0;for(const o of t){const l=a.get(o);l&&(n++,l.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Li(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function Ui(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const o=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,l=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${o}::${i.selector}`):void 0;n.push({key:ks({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:l})}return n}const Oi={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},_i={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function Di({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Ui(t,s),[t,s]),[n,r]=h.useState([]),[i,o]=h.useState(!0),[l,c]=h.useState(null),[u,d]=h.useState(5),[p,m]=h.useState(!1);h.useEffect(()=>{let b=!1;return As().then(S=>{b||(r(S),o(!1))}),()=>{b=!0}},[]);const x=h.useMemo(()=>a.map(b=>b.key),[a]),g=h.useMemo(()=>Cs(x,n),[x,n]),k=(p?x:l||n.filter(b=>x.includes(b.key)).map(b=>b.key)).map(b=>a.find(S=>S.key===b)).filter(b=>!!b);async function T(b,S,j){const C={key:b.key,criterionId:b.criterionId,ruleOrStepId:b.ruleOrStepId,pageUrl:b.pageUrl,selector:b.selector,verdict:S,correction:(j==null?void 0:j.trim())||void 0,reviewedAt:new Date().toISOString()};await Ti(C),r(_=>[C,..._.filter($=>$.key!==C.key)])}async function N(b){await $i(b.key),r(S=>S.filter(j=>j.key!==b.key))}function E(){c(Li(x,u)),m(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(Le,{label:"AI determinations",value:g.total}),e.jsx(Le,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Le,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Le,{label:"Disagreed",value:g.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:u,onChange:b=>d(Math.max(1,Math.min(a.length,Number(b.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:E,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{m(b=>!b),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),l&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):k.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:k.map(b=>e.jsx(Fi,{row:b,review:n.find(S=>S.key===b.key)??null,onAgree:()=>void T(b,"agreed"),onDisagree:S=>void T(b,"disagreed",S),onClear:()=>void N(b)},b.key))})]})}function Le({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function Fi(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,o]=h.useState((a==null?void 0:a.correction)??""),l=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${l==="agreed"?"border-emerald-300 bg-emerald-50/50":l==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Oi[s.outcome]}`,children:_i[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${l==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${l==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),l&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&l==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>o(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),o((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Se(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(null);h.useEffect(()=>{let p=!1;return Zs(t.componentId,t.criterionId).then(m=>{p||(a(m),r(!1))}),()=>{p=!0}},[t.componentId,t.criterionId]);async function u(){o(!0),c(null);try{const m=await J({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});m.ok?m.result&&a(m.result):c(m.error??"Audit failed.")}catch(p){c(p instanceof Error?p.message:String(p))}finally{o(!1)}}async function d(){await ea(t.componentId,t.criterionId),a(null)}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!l&&e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),l&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:l}),e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:["AI: ",s.verdict]}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug",children:s.reasoning}),(()=>{const p=(s.steps??[]).filter(m=>m.action!=="initial").length;return p===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",p," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(m=>m.action!=="initial").map(m=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",m.focused.role||m.focused.tag,"]"]})," ",m.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:m.focused.selector})]},m.ordinal))})]})})(),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function Mi(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return oe().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const Ht="igtRuns",Pi={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",inconclusive:"bg-amber-100 text-amber-800","not-evaluated":"bg-slate-100 text-slate-700","not-applicable":"bg-slate-50 text-slate-500"},Gi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Vi(){var me,se,Y;const t=f(R=>R.results),s=f(R=>R.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),o=sa,l=ta,[c,u]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,p]=h.useState(""),[m,x]=h.useState(""),[g,y]=h.useState(""),[k,T]=h.useState(""),[N,E]=h.useState(""),[b,S]=h.useState(""),[j,C]=h.useState({}),[_,$]=h.useState(!1),[F,w]=h.useState([]),[v,U]=h.useState([]),[O,G]=h.useState(null),[ae,ne]=h.useState(!1),[re,I]=h.useState(null);h.useEffect(()=>{let R=!1;return chrome.storage.local.get(Ht).then(B=>{if(R)return;const D=B[Ht]??{};C(D),$(!0)}).catch(()=>{R||$(!0)}),()=>{R=!0}},[]),h.useEffect(()=>{var z;const R=(z=t[0])==null?void 0:z.componentId;if(!R)return;let B=!1;const D=()=>{qt(R).then(K=>{B||U(K.map(ie=>({criterionId:ie.criterionId,ruleId:`ai-interactive::${ie.criterionId}`,pageUrl:ie.pageUrl,verdict:ie.verdict,reasoning:ie.reasoning})))})};D();const P=K=>{K.interactiveAuditResults&&D()};return chrome.storage.local.onChanged.addListener(P),()=>{B=!0,chrome.storage.local.onChanged.removeListener(P)}},[t]),h.useEffect(()=>{var R;if(!a&&((R=t[0])!=null&&R.pageUrl))try{const B=new URL(t[0].pageUrl);n(B.hostname),i(B.origin)}catch{}},[t,a]),h.useEffect(()=>{const R=new Set;for(const D of t)R.add(D.pageUrl??D.scope);if(R.size===0){w([]);return}let B=!1;return Promise.all(Array.from(R).map(D=>Ue(D))).then(D=>{B||w(D.flat())}).catch(()=>{}),()=>{B=!0}},[t]);const H=h.useMemo(()=>{const R=new Map,B=new Map;for(const P of t){const z=P.pageUrl??P.scope,K=R.get(z)??[];K.push(P),R.set(z,K)}const D=new Map;for(const P of t){const z=P.pageUrl??P.scope;D.set(P.componentId,z)}for(const[P,z]of Object.entries(j)){const K=D.get(P);if(!K)continue;const ie=B.get(K)??{};Object.assign(ie,z),B.set(K,ie)}return{auditsByUrl:R,igtRunsByUrl:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:F,interactiveAuditResults:v}},[t,j,s,F,v]),X=h.useMemo(()=>{const R=[],B=new Set;for(const D of H.auditsByUrl.keys())B.has(D)||(B.add(D),R.push({url:D,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const D of b.split(`
543
- `).map(P=>P.trim()).filter(Boolean))B.has(D)||(B.add(D),R.push({url:D,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return R},[H,b]),W=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:o,targetLevel:l,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(R=>R.trim()).filter(Boolean),pageSample:X,evaluator:{name:m||"(evaluator name pending)",organization:g||void 0,qualifications:k||void 0,contact:N||void 0}}),[a,r,o,l,c,d,X,m,g,k,N]),A=h.useMemo(()=>_?pi(W,H):null,[W,H,_]),M=h.useMemo(()=>{const R=Array.from(H.auditsByUrl.values()).flat(),B=Object.values(j).flatMap(D=>Object.values(D));return dt({audits:R,igtRuns:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:F,interactiveAuditResults:v})},[H,j,s,F,v]);async function Z(){if(!A)return;const R=t[0],B=R!=null&&R.componentId&&(R!=null&&R.startedAt)?await Ns(R.componentId,R.startedAt):null,D=await As(),P=[];for(const K of M.values())for(const ie of K.evidence)ie.source==="ai"&&P.push(ks({criterionId:K.criterionId,ruleOrStepId:ie.ruleOrStepId,pageUrl:ie.pageUrl,selector:ie.selector}));const z=Cs(P,D);await xi(A,O,B,z)}async function Q(){if(A){ne(!0),I(null);try{const R=await wi(A);if(!R){I("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}G(R)}finally{ne(!1)}}}function q(){var ie,bt,vt;if(!A||!O)return;const R=((vt=(bt=(ie=chrome.runtime).getManifest)==null?void 0:bt.call(ie))==null?void 0:vt.version)??"0.0.0",B=Ni(A,O,R),D=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),P=URL.createObjectURL(D),z=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,K=document.createElement("a");K.href=P,K.download=z,K.click(),setTimeout(()=>URL.revokeObjectURL(P),1e3)}return h.useEffect(()=>{G(null),I(null)},[a,r,c,d,m,g,k,N,b]),_?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),A&&A.summary.totalCriteria>0&&e.jsx(Wi,{totalCriteria:A.summary.totalCriteria,pass:A.summary.pass,fail:A.summary.fail,inconclusive:A.summary.inconclusive,notEvaluated:A.summary.notEvaluated,notApplicable:A.summary.notApplicable,levelAchieved:A.summary.levelAchieved,meetsTarget:A.summary.meetsTarget,targetVersion:o,targetLevel:l,auditedUrlCount:H.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:R=>n(R.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:R=>i(R.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",o," Level ",l]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:c,onChange:R=>u(R.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:d,onChange:R=>p(R.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",H.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:H.auditsByUrl.size})," URL",H.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:b,onChange:R=>S(R.target.value),rows:3,placeholder:`https://app.example.com/checkout
544
- https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:m,onChange:R=>x(R.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:g,onChange:R=>y(R.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:k,onChange:R=>T(R.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:N,onChange:R=>E(R.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),A&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",A.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:A.rows.map(R=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[R.criterion.id," · ",R.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:R.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Pi[R.verdict]}`,children:Gi[R.verdict]})]},R.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),O?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[O.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",O.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),re&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:re}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!A||!a||!m||ae,onClick:()=>void Q(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:ae?"Anchoring…":O?"Re-anchor":"Anchor this report"}),O&&e.jsx("button",{type:"button",onClick:q,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),A&&((me=t[0])==null?void 0:me.componentId)&&e.jsx(Mi,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),A&&e.jsx(Di,{verdicts:M,incompleteResolutions:F}),A&&((se=t[0])==null?void 0:se.componentId)&&((Y=t[0])==null?void 0:Y.startedAt)&&e.jsx(Ei,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:o,targetLevel:l,evaluatedCount:A.summary.pass+A.summary.fail+A.summary.inconclusive+A.summary.notApplicable,totalCount:A.summary.totalCriteria,canClaimConformance:A.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!A||!a||!m,onClick:()=>void Z(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function Wi({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:o,meetsTarget:l,targetVersion:c,targetLevel:u,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${l?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${l?"text-emerald-900":"text-amber-900"}`,children:l?`Currently meeting WCAG ${c} Level ${u}`:`Does not currently meet WCAG ${c} Level ${u}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:o??"none"})," · ",t," applicable criteria across ",d," audited URL",d===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}function Bi(){const[t,s]=h.useState(""),[a,n]=h.useState(!1),[r,i]=h.useState(null);async function o(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const l=await J({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(l!=null&&l.validated)){const c=l!=null&&l.seatClaim&&"reason"in l.seatClaim?l.seatClaim.reason:null,u=l!=null&&l.seatClaim&&"hint"in l.seatClaim?l.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${l!=null&&l.seatClaim&&"message"in l.seatClaim?l.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(l){i(l instanceof Error?l.message:String(l))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:l=>s(l.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void o(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function Xi(){const t=f(o=>o.view),s=f(o=>o.userMode),a=f(o=>o.tier),[n,r]=h.useState(!1);h.useEffect(()=>{const o=setTimeout(()=>r(!0),600);return()=>clearTimeout(o)},[]);const i=n&&ra(a);return h.useEffect(()=>{const o=xa(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=da();ts({forceRefresh:!0}).catch(()=>{}),Fe().catch(()=>{}),ha().catch(()=>{}),ga().catch(()=>{}),pa().catch(()=>{}),aa().then(p=>{f.getState().setAcknowledgedKeys(new Set(p.map(m=>m.matchKey)))}).catch(()=>{}),na().then(p=>{p&&f.setState({siteCrawlReport:p})}).catch(()=>{});const d=p=>{if(p.key!=="Escape")return;const{pinnedMatchKey:m,setPinned:x,results:g}=f.getState();m&&(x(null),oe().then(y=>{var k;y&&ue(y,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:y},(k=g[0])==null?void 0:k.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{u(),o.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(Bi,{}),e.jsx(Ee,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Ar,{}),e.jsx(Ee,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(Qr,{}),e.jsx(Mt,{}),e.jsx(Ee,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(ys,{}),e.jsx(ls,{}),e.jsx(Ea,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ua,{}),e.jsx(Ma,{}),e.jsx(wr,{}),e.jsx(jr,{}),e.jsx(Ga,{}),e.jsx(vr,{}),e.jsx(yr,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(sn,{}),t==="report"&&e.jsx(yn,{}),t==="delta"&&e.jsx(Un,{}),t==="activity"&&e.jsx(zn,{}),t==="guided"&&e.jsx(nr,{}),t==="flows"&&e.jsx(lr,{}),t==="scorecard"&&e.jsx(ur,{}),t==="crawl"&&e.jsx(fs,{}),t==="forensic"&&e.jsx(vs,{}),t==="compliance"&&e.jsx(Vi,{})]})]}),e.jsx(Sr,{}),e.jsx(Nr,{}),e.jsx(br,{}),e.jsx(Mt,{}),e.jsx(Ee,{})]})}class Zi extends Ae.Component{constructor(){super(...arguments);yt(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{Xi as A,Zi as E,Ji as d};
542
+ </html>`}async function wi(t,s,a,n){const r=ji(t,s,a,n),i=new Blob([r],{type:"text/html;charset=utf-8"}),l=URL.createObjectURL(i);await chrome.tabs.create({url:l})}const Je=es("wcag-em-anchor"),Ni="https://api.wcagcheckr.com",ki="wcagcheckr",Si=15e3;function ks(t){return{scope:{siteName:t.inputs.siteName,siteUrl:t.inputs.siteUrl,targetVersion:t.inputs.targetVersion,targetLevel:t.inputs.targetLevel,accessibilitySupportBaseline:t.inputs.accessibilitySupportBaseline,additionalStandards:t.inputs.additionalStandards??[]},evaluator:{name:t.inputs.evaluator.name,organization:t.inputs.evaluator.organization??null,qualifications:t.inputs.evaluator.qualifications??null,contact:t.inputs.evaluator.contact??null},sample:{pages:t.inputs.pageSample.map(s=>({url:s.url,type:s.pageType,selectionType:s.selectionType,hasAuditData:s.hasAuditData}))},verdicts:t.rows.map(s=>({sc:s.criterion.id,level:s.criterion.level,verdict:s.verdict,overridden:s.overridden,axeFailureCount:s.signals.axeFailures.length,igtFailureCount:s.signals.igtFailures.length})),summary:{totalCriteria:t.summary.totalCriteria,pass:t.summary.pass,fail:t.summary.fail,inconclusive:t.summary.inconclusive,notApplicable:t.summary.notApplicable,notEvaluated:t.summary.notEvaluated,levelAchieved:t.summary.levelAchieved,meetsTarget:t.summary.meetsTarget},generatedAt:t.generatedAt}}async function Ai(t){const s=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",s);return Array.from(new Uint8Array(a)).map(n=>n.toString(16).padStart(2,"0")).join("")}async function Ci(t){return Ai(ta(ks(t)))}function Ii(t){if(typeof t!="object"||t===null)return!1;const s=t;return s.schemaVersion!==1&&s.schemaVersion!==2||!(typeof s.anchoredAt=="string"&&typeof s.tsaName=="string"&&typeof s.rfc3161TokenBase64=="string"&&s.rfc3161TokenBase64.length>0&&typeof s.serverSignatureBase64=="string"&&s.serverSignatureBase64.length>0&&typeof s.serverKeyFingerprint=="string"&&s.serverKeyFingerprint.length>0)?!1:s.schemaVersion===2?typeof s.prevAuditHash=="string"&&/^[0-9a-f]{64}$/.test(s.prevAuditHash):!0}async function Ri(t,s){const a=await Ci(t),n={auditHash:a,pageUrl:t.inputs.siteUrl,capturedAt:t.generatedAt},r=`${Ni}/v1/products/${ki}/forensic/anchor`;try{const i=await fetch(r,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(Si)});if(!i.ok)return Je.warn(`anchor HTTP ${i.status}`),null;const l=await i.json();return Ii(l)?{reportHash:a,capturedAt:t.generatedAt,receipt:l}:(Je.warn("anchor returned malformed receipt",l),null)}catch(i){return Je.warn("anchor request failed",i),null}}function Ei(t,s,a){return{schemaVersion:1,tool:{name:"wcagcheckr",version:a},productSlug:"wcagcheckr",bundledAt:new Date().toISOString(),reportHash:s.reportHash,receipt:s.receipt,canonicalPayload:ks(t)}}const at="auditAttestations",nt="auditAttestation:defaultSigner";function xt(t,s){return`${t}::${s}`}async function gt(){try{const s=(await chrome.storage.local.get(at))[at];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Ss(t){await chrome.storage.local.set({[at]:t})}async function Ti(t){const s=await gt();s[xt(t.componentId,t.auditCapturedAt)]=t,await Ss(s)}async function As(t,s){return(await gt())[xt(t,s)]??null}async function $i(t,s){const a=await gt();delete a[xt(t,s)],await Ss(a)}async function Li(){try{const s=(await chrome.storage.local.get(nt))[nt];return s&&typeof s=="object"?s:null}catch{return null}}async function Ui(t){await chrome.storage.local.set({[nt]:t})}function Di(t,s){return t.auditCapturedAt!==s}function Oi(t){return`I attest that this audit, dated [DATE], represents a good-faith evaluation of ${t.scope} for WCAG ${t.targetVersion} Level ${t.targetLevel} conformance. The methodology relied on automated analysis + AI-assisted determinations, covering ${t.evaluatedCount} of ${t.totalCount} applicable criteria. I have reviewed the findings + spot-audit verifications and take responsibility for the conclusions presented.`}function _i(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,l]=h.useState(!1),[o,c]=h.useState(""),[u,d]=h.useState(""),[p,m]=h.useState(""),[x,g]=h.useState(""),[j,b]=h.useState("");h.useEffect(()=>{let S=!1;return Promise.all([As(t.componentId,t.auditCapturedAt),Li()]).then(([w,I])=>{S||(a(w),w?(c(w.signerName),d(w.signerEmail),m(w.signerOrganization??""),g(w.signerQualifications??""),b(w.claim)):I&&(c(I.signerName),d(I.signerEmail),m(I.signerOrganization??""),g(I.signerQualifications??"")),b(O=>O||Oi({scope:t.scope,targetVersion:t.targetVersion,targetLevel:t.targetLevel,evaluatedCount:t.evaluatedCount,totalCount:t.totalCount})),r(!1))}),()=>{S=!0}},[t.componentId,t.auditCapturedAt,t.scope,t.targetVersion,t.targetLevel,t.evaluatedCount,t.totalCount]);async function C(){if(!o.trim()||!u.trim())return;const S={componentId:t.componentId,auditCapturedAt:t.auditCapturedAt,signedAt:new Date().toISOString(),signerName:o.trim(),signerEmail:u.trim(),signerOrganization:p.trim()||void 0,signerQualifications:x.trim()||void 0,claim:j.trim(),scope:t.scope};await Ti(S),await Ui({signerName:S.signerName,signerEmail:S.signerEmail,signerOrganization:S.signerOrganization,signerQualifications:S.signerQualifications}),a(S),l(!1)}async function k(){await $i(t.componentId,t.auditCapturedAt),a(null),l(!1)}if(n)return e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading attestation state…"});const T=s&&Di(s,t.auditCapturedAt);if(s&&!T&&!i)return e.jsxs("div",{className:"border-2 border-emerald-300 bg-emerald-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-900",children:"Signed and sealed"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-900 space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:s.signerName}),s.signerOrganization?` · ${s.signerOrganization}`:""," · ",e.jsx("span",{className:"font-mono",children:s.signerEmail})]}),s.signerQualifications&&e.jsx("p",{className:"text-emerald-800 italic",children:s.signerQualifications}),e.jsxs("p",{className:"text-emerald-700",children:["Signed at ",new Date(s.signedAt).toLocaleString()]})]}),e.jsxs("details",{className:"text-[11px]",children:[e.jsx("summary",{className:"cursor-pointer text-emerald-800 hover:text-emerald-900 font-medium",children:"View attestation text"}),e.jsx("p",{className:"mt-1 p-2 bg-white border border-emerald-200 rounded text-emerald-900 leading-snug whitespace-pre-wrap",children:s.claim})]}),e.jsxs("div",{className:"flex gap-2 pt-1 border-t border-emerald-200",children:[e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-2 py-1 border border-emerald-400 bg-white text-emerald-700 rounded hover:bg-emerald-50",children:"Edit + re-sign"}),e.jsx("button",{type:"button",onClick:()=>void k(),className:"text-[11px] px-2 py-1 border border-rose-300 bg-white text-rose-700 rounded hover:bg-rose-50",children:"Un-sign"})]})]});if(s&&T&&!i)return e.jsxs("div",{className:"border-2 border-amber-300 bg-amber-50 rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"⚠"}),e.jsx("p",{className:"text-sm font-semibold text-amber-900",children:"Prior signature is stale"})]}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-snug",children:[e.jsx("strong",{children:s.signerName})," signed an earlier capture of this audit on"," ",new Date(s.signedAt).toLocaleString(),". A re-audit has changed the underlying findings; the prior signature no longer applies. Re-sign to attest the current audit."]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Sign current audit →"})]});const v=o.trim().length>0&&u.trim().length>0;return e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔏"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Sign and seal this audit"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"Records your attestation that the audit's conclusions are accurate. Required for formal WCAG conformance claims. AI did the work; your signature takes legal responsibility."})]}),!t.canClaimConformance&&e.jsx("p",{className:"text-[11px] bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"The audit currently has unresolved failures or inconclusive items. Signing now attests to an incomplete state. Most users either (a) resolve the items before signing, or (b) acknowledge them as not-applicable + sign."}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Name *"}),e.jsx("input",{type:"text",value:o,onChange:S=>c(S.target.value),placeholder:"Jane Doe",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Email *"}),e.jsx("input",{type:"email",value:u,onChange:S=>d(S.target.value),placeholder:"jane@example.com",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Organization"}),e.jsx("input",{type:"text",value:p,onChange:S=>m(S.target.value),placeholder:"Acme Corp",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Qualifications"}),e.jsx("input",{type:"text",value:x,onChange:S=>g(S.target.value),placeholder:"IAAP CPACC, 7 yrs a11y",className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1"})]})]}),e.jsxs("label",{className:"block text-[11px]",children:[e.jsx("span",{className:"block font-medium text-slate-700",children:"Attestation text"}),e.jsx("textarea",{value:j,onChange:S=>b(S.target.value),rows:5,className:"w-full mt-0.5 border border-slate-300 rounded px-2 py-1 resize-y leading-snug"}),e.jsx("span",{className:"block text-[10px] text-slate-500 mt-0.5",children:"Edit to match your organization's preferred wording."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:[i&&e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-[11px] px-3 py-1.5 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>void C(),className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:"🔏 Sign and seal"})]})]})}const rt="spotAuditReviews";function Cs(t){return`${t.criterionId}::${t.ruleOrStepId}::${t.pageUrl??""}::${t.selector??""}`}async function ft(){try{const s=(await chrome.storage.local.get(rt))[rt];return s&&typeof s=="object"?s:{}}catch{return{}}}async function Is(t){await chrome.storage.local.set({[rt]:t})}async function Fi(t){const s=await ft();s[t.key]=t,await Is(s)}async function Mi(t){const s=await ft();delete s[t],await Is(s)}async function Rs(){const t=await ft();return Object.values(t)}function Es(t,s){const a=new Map(s.map(l=>[l.key,l]));let n=0,r=0,i=0;for(const l of t){const o=a.get(l);o&&(n++,o.verdict==="agreed"?r++:i++)}return{total:t.length,reviewed:n,agreed:r,disagreed:i}}function Pi(t,s){const a=t.slice();for(let n=a.length-1;n>0;n--){const r=Math.floor(Math.random()*(n+1)),i=a[n];a[n]=a[r],a[r]=i}return a.slice(0,Math.min(s,a.length))}function Gi(t,s){const a=new Map;for(const r of s)a.set(`${r.pageUrl}::${r.ruleId}::${r.selector}`,r.reasoning);const n=[];for(const r of t.values())for(const i of r.evidence){if(i.source!=="ai")continue;const l=i.ruleOrStepId.startsWith("ai-resolved::")?i.ruleOrStepId.slice(13):i.ruleOrStepId,o=i.pageUrl&&i.selector?a.get(`${i.pageUrl}::${l}::${i.selector}`):void 0;n.push({key:Cs({criterionId:r.criterionId,ruleOrStepId:i.ruleOrStepId,pageUrl:i.pageUrl,selector:i.selector}),criterionId:r.criterionId,criterionTitle:r.title,ruleOrStepId:i.ruleOrStepId,outcome:i.outcome,pageUrl:i.pageUrl,selector:i.selector,resolutionHint:i.resolutionHint,aiReasoning:o})}return n}const Vi={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",incomplete:"bg-amber-100 text-amber-800",inapplicable:"bg-slate-100 text-slate-700",ack:"bg-sky-100 text-sky-800",skip:"bg-slate-100 text-slate-700","n/a":"bg-slate-100 text-slate-700"},Wi={pass:"AI: pass",fail:"AI: fail",incomplete:"AI: uncertain",inapplicable:"AI: n/a",ack:"AI flagged · user acked",skip:"AI: skip","n/a":"AI: n/a"};function Bi({verdicts:t,incompleteResolutions:s}){const a=h.useMemo(()=>Gi(t,s),[t,s]),[n,r]=h.useState([]),[i,l]=h.useState(!0),[o,c]=h.useState(null),[u,d]=h.useState(5),[p,m]=h.useState(!1);h.useEffect(()=>{let v=!1;return Rs().then(S=>{v||(r(S),l(!1))}),()=>{v=!0}},[]);const x=h.useMemo(()=>a.map(v=>v.key),[a]),g=h.useMemo(()=>Es(x,n),[x,n]),b=(p?x:o||n.filter(v=>x.includes(v.key)).map(v=>v.key)).map(v=>a.find(S=>S.key===v)).filter(v=>!!v);async function C(v,S,w){const I={key:v.key,criterionId:v.criterionId,ruleOrStepId:v.ruleOrStepId,pageUrl:v.pageUrl,selector:v.selector,verdict:S,correction:(w==null?void 0:w.trim())||void 0,reviewedAt:new Date().toISOString()};await Fi(I),r(O=>[I,...O.filter($=>$.key!==I.key)])}async function k(v){await Mi(v.key),r(S=>S.filter(w=>w.key!==v.key))}function T(){c(Pi(x,u)),m(!1)}return a.length===0?e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"mt-2 leading-snug",children:"This audit has no AI determinations yet. Spot-auditing becomes available once AI judgment runs against ambiguous findings (alt-text, color-only meaning, axe-incomplete, etc.)."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🧪"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Spot-audit AI determinations"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI did the determination work. You can audit a sample — pick a random N, review what the AI decided, and mark whether you agree. Your spot-check rate is included in the report."})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center bg-slate-50 border border-slate-200 rounded p-2",children:[e.jsx(Le,{label:"AI determinations",value:g.total}),e.jsx(Le,{label:"Reviewed",value:g.reviewed,accent:"text-slate-900"}),e.jsx(Le,{label:"Agreed",value:g.agreed,accent:"text-emerald-700"}),e.jsx(Le,{label:"Disagreed",value:g.disagreed,accent:"text-rose-700"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-slate-700",children:["Pick",e.jsx("input",{type:"number",min:1,max:a.length,value:u,onChange:v=>d(Math.max(1,Math.min(a.length,Number(v.target.value)||1))),className:"w-14 border border-slate-300 rounded px-1.5 py-0.5 text-[11px]"}),"at random"]}),e.jsx("button",{type:"button",onClick:T,className:"text-[11px] px-2 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Draw sample"}),e.jsx("button",{type:"button",onClick:()=>{m(v=>!v),c(null)},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:p?"Hide list":`Show all (${a.length})`}),o&&e.jsx("button",{type:"button",onClick:()=>c(null),className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-600 rounded hover:bg-slate-50",children:"Clear sample"})]}),i?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Loading reviews…"}):b.length===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:'Draw a sample or "Show all" to begin reviewing AI determinations.'}):e.jsx("ul",{className:"space-y-2",children:b.map(v=>e.jsx(Hi,{row:v,review:n.find(S=>S.key===v.key)??null,onAgree:()=>void C(v,"agreed"),onDisagree:S=>void C(v,"disagreed",S),onClear:()=>void k(v)},v.key))})]})}function Le({label:t,value:s,accent:a="text-slate-900"}){return e.jsxs("div",{children:[e.jsx("p",{className:`text-base font-bold ${a}`,children:s}),e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-500",children:t})]})}function Hi(t){const{row:s,review:a}=t,[n,r]=h.useState(!1),[i,l]=h.useState((a==null?void 0:a.correction)??""),o=a==null?void 0:a.verdict;return e.jsxs("li",{className:`border rounded p-2 text-[11px] ${o==="agreed"?"border-emerald-300 bg-emerald-50/50":o==="disagreed"?"border-rose-300 bg-rose-50/50":"border-slate-200 bg-white"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-mono text-slate-700 font-semibold",children:s.criterionId}),e.jsx("span",{className:"text-slate-500",children:"·"}),e.jsx("span",{className:"text-slate-700",children:s.criterionTitle})]}),e.jsxs("p",{className:"mt-0.5 text-slate-600",children:[e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",children:s.ruleOrStepId}),s.selector&&e.jsxs(e.Fragment,{children:[" on ",e.jsx("code",{className:"bg-slate-100 px-1 rounded text-[10px]",title:s.selector,children:s.selector.length>60?s.selector.slice(0,57)+"…":s.selector})]})]})]}),e.jsx("span",{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-medium ${Vi[s.outcome]}`,children:Wi[s.outcome]})]}),(s.aiReasoning||s.resolutionHint)&&e.jsxs("details",{className:"mt-1.5",children:[e.jsx("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:"AI reasoning ↓"}),e.jsx("div",{className:"mt-1 p-2 bg-white border border-slate-200 rounded text-slate-800 leading-snug",children:s.aiReasoning??s.resolutionHint})]}),s.pageUrl&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-500 truncate",children:["on ",e.jsx("code",{children:s.pageUrl})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[e.jsx("button",{type:"button",onClick:t.onAgree,className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="agreed"?"bg-emerald-600 text-white border-emerald-600":"bg-white border-emerald-400 text-emerald-700 hover:bg-emerald-50"}`,children:"✓ Agree"}),e.jsx("button",{type:"button",onClick:()=>r(!0),className:`text-[11px] px-2 py-1 rounded border font-medium ${o==="disagreed"?"bg-rose-600 text-white border-rose-600":"bg-white border-rose-400 text-rose-700 hover:bg-rose-50"}`,children:"✗ Disagree"}),o&&e.jsx("button",{type:"button",onClick:t.onClear,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear"}),(a==null?void 0:a.correction)&&o==="disagreed"&&!n&&e.jsxs("span",{className:"text-[11px] text-rose-700 italic",children:['"',a.correction,'"']})]}),n&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-700",children:"Correction (optional but recommended)"}),e.jsx("textarea",{value:i,onChange:c=>l(c.target.value),placeholder:"What did the AI miss or get wrong?",rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-[11px] leading-snug resize-y"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{t.onDisagree(i),r(!1)},className:"text-[11px] px-2 py-1 bg-rose-600 text-white rounded hover:bg-rose-700",children:"Record disagreement"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),l((a==null?void 0:a.correction)??"")},className:"text-[11px] px-2 py-1 border border-slate-300 text-slate-700 rounded hover:bg-slate-50",children:"Cancel"})]})]})]})}function Se(t){const[s,a]=h.useState(null),[n,r]=h.useState(!0),[i,l]=h.useState(!1),[o,c]=h.useState(null);h.useEffect(()=>{let p=!1;return sa(t.componentId,t.criterionId).then(m=>{p||(a(m),r(!1))}),()=>{p=!0}},[t.componentId,t.criterionId]);async function u(){l(!0),c(null);try{const m=await J({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterionId,tabId:t.tabId,componentId:t.componentId,pageUrl:t.pageUrl});m.ok?m.result&&a(m.result):c(m.error??"Audit failed.")}catch(p){c(p instanceof Error?p.message:String(p))}finally{l(!1)}}async function d(){await aa(t.componentId,t.criterionId),a(null)}return n?e.jsx("div",{className:"p-3 text-[11px] text-slate-500",children:"Loading audit state…"}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-base font-bold text-slate-700",children:t.criterionId}),e.jsx("span",{className:"text-sm font-semibold text-slate-900",children:t.criterionTitle})]}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:t.description})]}),!s&&!o&&e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:i?"Running AI walkthrough…":"Run AI walkthrough"}),o&&e.jsxs("div",{className:"border border-rose-300 bg-rose-50 rounded p-2 text-[11px] text-rose-900 space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Audit failed."})}),e.jsx("p",{children:o}),e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-rose-400 bg-white text-rose-700 rounded hover:bg-rose-100 disabled:opacity-50",children:i?"Retrying…":"Try again"})]}),s&&e.jsxs("div",{className:`rounded p-2 text-[11px] space-y-1.5 ${s.verdict==="pass"?"border border-emerald-300 bg-emerald-50":s.verdict==="fail"?"border border-rose-300 bg-rose-50":"border border-amber-300 bg-amber-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide font-bold ${s.verdict==="pass"?"bg-emerald-200 text-emerald-900":s.verdict==="fail"?"bg-rose-200 text-rose-900":"bg-amber-200 text-amber-900"}`,children:["AI: ",s.verdict]}),e.jsxs("span",{className:"text-[10px] text-slate-600",children:["confidence ",Math.round(s.confidence*100),"%"]})]}),e.jsx("p",{className:"leading-snug",children:s.reasoning}),(()=>{const p=(s.steps??[]).filter(m=>m.action!=="initial").length;return p===0?e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"Step-replay data not retained for past audits (saves storage). Re-run the walkthrough to see the live step recording."}):e.jsxs("details",{children:[e.jsxs("summary",{className:"cursor-pointer text-slate-600 hover:text-slate-900 select-none",children:["Tab sequence (",p," steps)"]}),e.jsx("ol",{className:"mt-1 pl-4 space-y-0.5 list-decimal",children:(s.steps??[]).filter(m=>m.action!=="initial").map(m=>e.jsxs("li",{className:"text-slate-700",children:[e.jsxs("span",{className:"text-slate-500",children:["[",m.focused.role||m.focused.tag,"]"]})," ",m.focused.name||e.jsx("em",{className:"text-slate-400",children:"(no name)"})," ",e.jsx("code",{className:"text-[10px] bg-white px-1 rounded",children:m.focused.selector})]},m.ordinal))})]})})(),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-slate-200",children:[e.jsx("button",{type:"button",onClick:()=>void u(),disabled:i,className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Re-running…":"Re-run"}),e.jsx("button",{type:"button",onClick:()=>void d(),className:"text-[11px] px-2 py-1 border border-slate-300 bg-white text-slate-700 rounded hover:bg-slate-50",children:"Clear result"}),e.jsxs("span",{className:"text-[10px] text-slate-500 ml-auto",children:["$",s.costUsd.toFixed(4)," · ",new Date(s.finishedAt).toLocaleTimeString()]})]})]})]})}function zi(t){const[s,a]=h.useState(null);return h.useEffect(()=>{let n=!1;return le().then(r=>{n||a(r??null)}),()=>{n=!0}},[]),s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"text-[11px] text-slate-600 leading-snug mt-1",children:"AI drives a keyboard user through the page to evaluate criteria that require lived-experience judgment. Each walkthrough produces an AI verdict that flows into the conformance report. You can spot-check the AI's reasoning in the panel below."})]}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.3",criterionTitle:"Focus Order",description:"AI walks the page Tab-by-Tab, comparing the focus sequence to the visible layout. Verdict: does the order follow a logical reading sequence?"}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.1.2",criterionTitle:"No keyboard trap",description:"AI Tab-walks forward then Shift-Tab-walks backward, checking for traps: elements where focus gets stuck, or where Shift-Tab can't reverse out of a region. Verdict: can the user always leave?"}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"2.4.7",criterionTitle:"Focus visible",description:"AI Tab-walks the page and captures a screenshot at each focused element. Vision then judges whether a visible focus indicator (outline, ring, or compensating treatment) is present on every sampled element."}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.3.2",criterionTitle:"Meaningful Sequence (reading order)",description:"AI vision judges whether the heuristic-flagged DOM-vs-visual order divergences are real reading-order breaks or normal multi-column / banked layout patterns. Looks at the page screenshot + the flagged element list."}),e.jsx(Se,{componentId:t.componentId,pageUrl:t.pageUrl,tabId:s,criterionId:"1.4.11",criterionTitle:"Non-text Contrast",description:"AI vision judges whether UI components (button borders, form input borders, icons, focus indicators) and graphical objects have at least 3:1 contrast against adjacent colors. Covers what axe's color-contrast rule can't see."})]}):e.jsxs("div",{className:"border border-slate-200 rounded-lg bg-white p-3 text-[11px] text-slate-600",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Interactive AI walkthroughs"}),e.jsx("p",{className:"mt-1 text-amber-700",children:"No active audit-target tab. Open the page you want to audit in a tab, then click the extension icon there to set it as the target."})]})}const qt="igtRuns",Ki={pass:"bg-emerald-100 text-emerald-800",fail:"bg-rose-100 text-rose-800",inconclusive:"bg-amber-100 text-amber-800","not-evaluated":"bg-slate-100 text-slate-700","not-applicable":"bg-slate-50 text-slate-500"},qi={pass:"Pass",fail:"Fail",inconclusive:"Inconclusive","not-evaluated":"Not eval","not-applicable":"N/A"};function Qi(){var me,se,Y;const t=f(E=>E.results),s=f(E=>E.acknowledgedKeys),[a,n]=h.useState(""),[r,i]=h.useState(""),l=ra,o=na,[c,u]=h.useState("Latest two stable versions of Chrome, Safari, Firefox, and Edge on Windows + macOS, paired with NVDA, JAWS, and VoiceOver."),[d,p]=h.useState(""),[m,x]=h.useState(""),[g,j]=h.useState(""),[b,C]=h.useState(""),[k,T]=h.useState(""),[v,S]=h.useState(""),[w,I]=h.useState({}),[O,$]=h.useState(!1),[F,N]=h.useState([]),[y,U]=h.useState([]),[D,G]=h.useState(null),[ae,ne]=h.useState(!1),[re,R]=h.useState(null);h.useEffect(()=>{let E=!1;return chrome.storage.local.get(qt).then(B=>{if(E)return;const _=B[qt]??{};I(_),$(!0)}).catch(()=>{E||$(!0)}),()=>{E=!0}},[]),h.useEffect(()=>{var z;const E=(z=t[0])==null?void 0:z.componentId;if(!E)return;let B=!1;const _=()=>{Jt(E).then(K=>{B||U(K.map(ie=>({criterionId:ie.criterionId,ruleId:`ai-interactive::${ie.criterionId}`,pageUrl:ie.pageUrl,verdict:ie.verdict,reasoning:ie.reasoning})))})};_();const P=K=>{K.interactiveAuditResults&&_()};return chrome.storage.local.onChanged.addListener(P),()=>{B=!0,chrome.storage.local.onChanged.removeListener(P)}},[t]),h.useEffect(()=>{var E;if(!a&&((E=t[0])!=null&&E.pageUrl))try{const B=new URL(t[0].pageUrl);n(B.hostname),i(B.origin)}catch{}},[t,a]),h.useEffect(()=>{const E=new Set;for(const _ of t)E.add(_.pageUrl??_.scope);if(E.size===0){N([]);return}let B=!1;return Promise.all(Array.from(E).map(_=>Ue(_))).then(_=>{B||N(_.flat())}).catch(()=>{}),()=>{B=!0}},[t]);const H=h.useMemo(()=>{const E=new Map,B=new Map;for(const P of t){const z=P.pageUrl??P.scope,K=E.get(z)??[];K.push(P),E.set(z,K)}const _=new Map;for(const P of t){const z=P.pageUrl??P.scope;_.set(P.componentId,z)}for(const[P,z]of Object.entries(w)){const K=_.get(P);if(!K)continue;const ie=B.get(K)??{};Object.assign(ie,z),B.set(K,ie)}return{auditsByUrl:E,igtRunsByUrl:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:F,interactiveAuditResults:y}},[t,w,s,F,y]),X=h.useMemo(()=>{const E=[],B=new Set;for(const _ of H.auditsByUrl.keys())B.has(_)||(B.add(_),E.push({url:_,selectionType:"critical",pageType:"audited",hasAuditData:!0}));for(const _ of v.split(`
543
+ `).map(P=>P.trim()).filter(Boolean))B.has(_)||(B.add(_),E.push({url:_,selectionType:"structured",pageType:"unaudited",hasAuditData:!1}));return E},[H,v]),W=h.useMemo(()=>({siteName:a||"Untitled site",siteUrl:r||"https://example.com",targetVersion:l,targetLevel:o,accessibilitySupportBaseline:c,additionalStandards:d.split(",").map(E=>E.trim()).filter(Boolean),pageSample:X,evaluator:{name:m||"(evaluator name pending)",organization:g||void 0,qualifications:b||void 0,contact:k||void 0}}),[a,r,l,o,c,d,X,m,g,b,k]),A=h.useMemo(()=>O?vi(W,H):null,[W,H,O]),M=h.useMemo(()=>{const E=Array.from(H.auditsByUrl.values()).flat(),B=Object.values(w).flatMap(_=>Object.values(_));return dt({audits:E,igtRuns:B,workflows:ee,acknowledgedMatchKeys:s,incompleteResolutions:F,interactiveAuditResults:y})},[H,w,s,F,y]);async function Z(){if(!A)return;const E=t[0],B=E!=null&&E.componentId&&(E!=null&&E.startedAt)?await As(E.componentId,E.startedAt):null,_=await Rs(),P=[];for(const K of M.values())for(const ie of K.evidence)ie.source==="ai"&&P.push(Cs({criterionId:K.criterionId,ruleOrStepId:ie.ruleOrStepId,pageUrl:ie.pageUrl,selector:ie.selector}));const z=Es(P,_);await wi(A,D,B,z)}async function Q(){if(A){ne(!0),R(null);try{const E=await Ri(A);if(!E){R("Anchor request failed. The server may be unreachable, or the license tier may not include forensic anchoring. Report is still generatable without anchoring.");return}G(E)}finally{ne(!1)}}}function q(){var ie,bt,vt;if(!A||!D)return;const E=((vt=(bt=(ie=chrome.runtime).getManifest)==null?void 0:bt.call(ie))==null?void 0:vt.version)??"0.0.0",B=Ei(A,D,E),_=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),P=URL.createObjectURL(_),z=`wcagcheckr-wcag-em-bundle-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,K=document.createElement("a");K.href=P,K.download=z,K.click(),setTimeout(()=>URL.revokeObjectURL(P),1e3)}return h.useEffect(()=>{G(null),R(null)},[a,r,c,d,m,g,b,k,v]),O?e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"WCAG-EM Conformance Report"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Generate a W3C-EM-format report combining your axe audit data + Independent Guided Test results into a per-criterion conformance verdict. Output is a printable HTML page you can save as PDF."})]}),A&&A.summary.totalCriteria>0&&e.jsx(Yi,{totalCriteria:A.summary.totalCriteria,pass:A.summary.pass,fail:A.summary.fail,inconclusive:A.summary.inconclusive,notEvaluated:A.summary.notEvaluated,notApplicable:A.summary.notApplicable,levelAchieved:A.summary.levelAchieved,meetsTarget:A.summary.meetsTarget,targetVersion:l,targetLevel:o,auditedUrlCount:H.auditsByUrl.size}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Scope"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site / app name"}),e.jsx("input",{type:"text",value:a,onChange:E=>n(E.target.value),placeholder:"Acme Web App",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Site URL"}),e.jsx("input",{type:"url",value:r,onChange:E=>i(E.target.value),placeholder:"https://app.example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Conformance target"}),e.jsxs("div",{className:"inline-flex items-center gap-2 mt-0.5 px-2 py-1 bg-slate-50 border border-slate-200 rounded text-xs",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:["WCAG ",l," Level ",o]}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"— locked target"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"AA is the legal-protection bar (ADA / Section 508 / EN 301 549). Level A is insufficient for lawsuit defence; AAA is unachievable for most production sites. wcagcheckr grades against AA only."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Accessibility-support baseline"}),e.jsx("textarea",{value:c,onChange:E=>u(E.target.value),rows:2,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Per W3C-EM §2.b — the AT / browser combos your claim covers."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional standards (comma-separated, optional)"}),e.jsx("input",{type:"text",value:d,onChange:E=>p(E.target.value),placeholder:"Section 508 (Revised 2017), EN 301 549 v3.2.1, ADA Title III",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Page sample"}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Audited pages are auto-included.",H.auditsByUrl.size>0?e.jsxs(e.Fragment,{children:[" Current audit covers ",e.jsx("strong",{children:H.auditsByUrl.size})," URL",H.auditsByUrl.size===1?"":"s","."]}):e.jsx(e.Fragment,{children:" No audited URL data in the store yet — run an audit first."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Additional sample URLs (one per line, optional)"}),e.jsx("textarea",{value:v,onChange:E=>S(E.target.value),rows:3,placeholder:`https://app.example.com/checkout
544
+ https://app.example.com/account`,className:"w-full border border-slate-300 rounded px-2 py-1 text-xs resize-y"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:'Pages without audit data will be listed in the report as "no audit data" — audit each then regenerate.'})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Evaluator"}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Name"}),e.jsx("input",{type:"text",value:m,onChange:E=>x(E.target.value),placeholder:"Jane Doe",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Organization (optional)"}),e.jsx("input",{type:"text",value:g,onChange:E=>j(E.target.value),className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Qualifications (optional)"}),e.jsx("input",{type:"text",value:b,onChange:E=>C(E.target.value),placeholder:"IAAP CPACC; 7 years a11y consulting",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[11px] font-medium text-slate-600",children:"Contact (optional)"}),e.jsx("input",{type:"text",value:k,onChange:E=>T(E.target.value),placeholder:"jane@example.com",className:"w-full border border-slate-300 rounded px-2 py-1 text-xs"})]})]}),A&&e.jsxs("details",{className:"border border-slate-200 rounded",children:[e.jsxs("summary",{className:"px-2 py-1.5 cursor-pointer font-medium text-slate-700",children:["Per-criterion verdicts (",A.rows.length,")"]}),e.jsx("ul",{className:"divide-y divide-slate-100 max-h-96 overflow-y-auto",children:A.rows.map(E=>e.jsxs("li",{className:"px-2 py-1.5 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-mono text-[10px] text-slate-500",children:[E.criterion.id," · ",E.criterion.level]}),e.jsx("div",{className:"text-[11px] text-slate-700 truncate",children:E.criterion.title})]}),e.jsx("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] font-semibold ${Ki[E.verdict]}`,children:qi[E.verdict]})]},E.criterion.id))})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-2 space-y-2",children:[e.jsx("legend",{className:"px-1 text-[11px] font-medium text-slate-700",children:"Forensic anchor"}),D?e.jsxs("div",{className:"text-[11px] bg-sky-50 border border-sky-200 rounded p-2 text-sky-900",children:[e.jsx("div",{className:"font-medium",children:"✓ Anchored"}),e.jsxs("div",{className:"mt-0.5",children:["Hash: ",e.jsxs("code",{className:"font-mono text-[10px]",children:[D.reportHash.slice(0,24),"…"]})]}),e.jsxs("div",{className:"mt-0.5",children:["RFC 3161 timestamp from ",D.receipt.tsaName,", ed25519 signed."]}),e.jsx("div",{className:"mt-1 text-[10px] text-sky-700",children:"Any edit to the form will clear this anchor — re-anchor before generating the final report."})]}):e.jsx("p",{className:"text-[11px] text-slate-500",children:`Anchoring attaches an RFC 3161 trusted timestamp + ed25519 signature to this report's content hash, defending against later-altered claims of the form "this report dated X said Y." Paid feature.`}),re&&e.jsx("p",{className:"text-[11px] text-rose-700 bg-rose-50 border border-rose-200 rounded p-1.5",children:re}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!A||!a||!m||ae,onClick:()=>void Q(),className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:ae?"Anchoring…":D?"Re-anchor":"Anchor this report"}),D&&e.jsx("button",{type:"button",onClick:q,className:"text-xs px-3 py-1.5 border border-slate-300 rounded hover:bg-slate-50",title:"Download a JSON file containing the canonical report + receipt; verify offline via wcagcheckr-ci verify",children:"Download verification bundle"})]})]}),A&&((me=t[0])==null?void 0:me.componentId)&&e.jsx(zi,{componentId:t[0].componentId,pageUrl:r||t[0].pageUrl||t[0].scope||""}),A&&e.jsx(Bi,{verdicts:M,incompleteResolutions:F}),A&&((se=t[0])==null?void 0:se.componentId)&&((Y=t[0])==null?void 0:Y.startedAt)&&e.jsx(_i,{componentId:t[0].componentId,auditCapturedAt:t[0].startedAt,scope:r||t[0].pageUrl||t[0].scope||"this audit",targetVersion:l,targetLevel:o,evaluatedCount:A.summary.pass+A.summary.fail+A.summary.inconclusive+A.summary.notApplicable,totalCount:A.summary.totalCriteria,canClaimConformance:A.summary.meetsTarget}),e.jsx("div",{className:"flex justify-end gap-2 pt-1 border-t border-slate-200",children:e.jsx("button",{type:"button",disabled:!A||!a||!m,onClick:()=>void Z(),className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50",children:"Generate WCAG-EM report →"})})]}):e.jsx("div",{className:"p-3 text-xs text-slate-500",children:"Loading IGT runs…"})}function Yi({totalCriteria:t,pass:s,fail:a,inconclusive:n,notEvaluated:r,notApplicable:i,levelAchieved:l,meetsTarget:o,targetVersion:c,targetLevel:u,auditedUrlCount:d}){return e.jsxs("div",{className:`border rounded p-2 ${o?"border-emerald-300 bg-emerald-50":"border-amber-300 bg-amber-50"}`,children:[e.jsx("div",{className:`text-xs font-semibold ${o?"text-emerald-900":"text-amber-900"}`,children:o?`Currently meeting WCAG ${c} Level ${u}`:`Does not currently meet WCAG ${c} Level ${u}`}),e.jsxs("div",{className:"text-[11px] mt-1 text-slate-700",children:["Highest fully-satisfied: ",e.jsx("strong",{children:l??"none"})," · ",t," applicable criteria across ",d," audited URL",d===1?"":"s"]}),e.jsxs("div",{className:"text-[10px] mt-1 text-slate-600",children:["Pass ",s," · Fail ",a," · Inconclusive ",n,i>0&&e.jsxs(e.Fragment,{children:[" · N/A ",i]})," · ","Not evaluated ",r]})]})}const Ji={hourly:"Hourly","every-4-hours":"Every 4 hours",daily:"Daily",weekly:"Weekly"};function Xi(t){if(!t)return"never";const s=Date.now()-new Date(t).getTime();if(s<0)return"in the future";const a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function Zi(t){if(!t.enabled)return"paused";const n=(t.lastRunAt?new Date(t.lastRunAt).getTime():Date.now())+la[t.cadence]*6e4-Date.now();if(n<0)return"imminent";const r=Math.floor(n/6e4);return r<60?`in ${r} min`:`in ${Math.floor(r/60)}h`}function el(){return crypto.randomUUID()}function tl(){const[t,s]=h.useState([]),[a,n]=h.useState(!0),[r,i]=h.useState(""),[l,o]=h.useState("daily"),[c,u]=h.useState(null),[d,p]=h.useState(!1);async function m(){n(!0);try{const b=await ia();b.sort((C,k)=>C.enabled!==k.enabled?C.enabled?-1:1:k.createdAt.localeCompare(C.createdAt)),s(b)}finally{n(!1)}}h.useEffect(()=>{m()},[]);async function x(){u(null);const b=r.trim();if(!b){u("URL is required.");return}try{new URL(b)}catch{u("Must be a valid URL (e.g. https://example.com/).");return}p(!0);try{const C={id:el(),url:b,cadence:l,enabled:!0,createdAt:new Date().toISOString(),lastResult:"pending"};await wt(C),await Nt(C),i(""),o("daily"),await m()}finally{p(!1)}}async function g(b){const C={...b,enabled:!b.enabled};await wt(C),C.enabled?await Nt(C):await kt(b.id),await m()}async function j(b){window.confirm(`Remove the scheduled audit for ${b.url}? Run history for this schedule will also be deleted.`)&&(await kt(b.id),await oa(b.id),await ca(b.id),await m())}return e.jsxs("div",{className:"p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Scheduled audits"}),e.jsx("p",{className:"text-slate-600 leading-snug",children:"Re-audit a URL on a cadence. Each scheduled run opens a background tab, runs the audit, compares to the saved baseline, and records the result. New violations vs. baseline trigger alerts (when configured — coming in a follow-up release)."})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-url",className:"block font-medium mb-1",children:"URL to audit"}),e.jsx("input",{id:"sched-url",type:"url",value:r,onChange:b=>i(b.target.value),placeholder:"https://example.com/checkout",className:"w-full border border-slate-300 rounded px-2 py-1.5 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sched-cadence",className:"block font-medium mb-1",children:"Cadence"}),e.jsxs("select",{id:"sched-cadence",value:l,onChange:b=>o(b.target.value),className:"w-full border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"hourly",children:"Hourly"}),e.jsx("option",{value:"every-4-hours",children:"Every 4 hours"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),c&&e.jsx("div",{className:"text-rose-700",role:"alert",children:c}),e.jsx("button",{type:"button",onClick:()=>void x(),disabled:d||!r.trim(),className:"text-xs px-3 py-1.5 bg-brand-500 hover:bg-brand-600 text-white rounded disabled:opacity-50 font-medium",children:d?"Adding…":"+ Schedule audit"})]}),a?e.jsx("p",{className:"text-slate-500",children:"Loading schedules…"}):t.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No scheduled audits yet. Add one above to start monitoring a URL."}):e.jsx("ul",{className:"space-y-2",children:t.map(b=>e.jsx("li",{className:`border rounded p-2.5 ${b.enabled?"border-slate-200 bg-white":"border-slate-200 bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"font-mono text-[11px] text-slate-700 break-all",children:b.url}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[Ji[b.cadence]," · last run ",Xi(b.lastRunAt)," ·"," ","next ",Zi(b)]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[b.lastResult==="ok"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:["✓ ok · ",b.lastTotalViolations??0," violation",(b.lastTotalViolations??0)===1?"":"s"]}),b.lastResult==="failed"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",title:b.lastError??"",children:"✗ failed"}),b.lastResult==="running"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-800",children:"⟳ running"}),b.lastResult==="pending"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-700",children:"pending first run"}),(b.lastNewViolationCount??0)>0&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-900",title:"New violations vs. saved baseline",children:["⚠ ",b.lastNewViolationCount," new vs baseline"]}),!b.enabled&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-slate-200 text-slate-600",children:"paused"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>void g(b),className:"text-[10px] px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50",children:b.enabled?"Pause":"Resume"}),e.jsx("button",{type:"button",onClick:()=>void j(b),className:"text-[10px] px-2 py-0.5 border border-rose-300 text-rose-700 rounded hover:bg-rose-50",children:"Delete"})]})]})},b.id))})]})}function sl(){const[t,s]=h.useState(""),[a,n]=h.useState(!1),[r,i]=h.useState(null);async function l(){if(!t.trim()){i("Paste a license token first.");return}n(!0),i(null);try{const o=await J({type:"LICENSE_SET_REQUEST",token:t.trim()});if(!(o!=null&&o.validated)){const c=o!=null&&o.seatClaim&&"reason"in o.seatClaim?o.seatClaim.reason:null,u=o!=null&&o.seatClaim&&"hint"in o.seatClaim?o.seatClaim.hint:void 0;i(c==="cap-reached"?`License is at seat capacity. ${u??"Release a seat from another device or contact support."}`:c==="not-found"?"License not found. Check the token and try again.":c==="network"?`Network error: ${o!=null&&o.seatClaim&&"message"in o.seatClaim?o.seatClaim.message:"check connection."}`:"Could not validate this license. Check the token and try again.");return}window.location.reload()}catch(o){i(o instanceof Error?o.message:String(o))}finally{n(!1)}}return e.jsx("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full bg-white border border-slate-200 rounded-lg shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Private build phase"}),e.jsx("p",{className:"text-xs text-slate-600 leading-relaxed",children:"wcagcheckr is still in private development. Access is currently limited to issued team licenses. If you've been given a license token, paste it below to activate."}),e.jsxs("p",{className:"text-xs text-slate-600 leading-relaxed",children:["If you don't have a license and would like beta access, email"," ",e.jsx("a",{href:"mailto:cliff@locustware.com?subject=wcagcheckr%20beta%20access",className:"text-brand-700 hover:underline",children:"cliff@locustware.com"}),". The public launch is coming."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"lockout-license-token",className:"block text-xs font-medium text-slate-700",children:"License token"}),e.jsx("textarea",{id:"lockout-license-token",value:t,onChange:o=>s(o.target.value),placeholder:"Paste your team license token here",rows:3,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 focus:outline focus:outline-2 focus:outline-brand-500",disabled:a}),r&&e.jsx("p",{className:"text-xs text-rose-700",role:"alert",children:r}),e.jsx("button",{type:"button",onClick:()=>void l(),disabled:a||!t.trim(),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 disabled:opacity-50 font-medium",children:a?"Activating…":"Activate license"})]}),e.jsxs("p",{className:"text-[10px] text-slate-400 text-center pt-2 border-t border-slate-100",children:["Already activated? The page should have updated. Try"," ",e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"text-brand-700 hover:underline",children:"reloading"})," ","if you don't see the main UI."]})]})})})}function dl(){const t=f(l=>l.view),s=f(l=>l.userMode),a=f(l=>l.tier),[n,r]=h.useState(!1);h.useEffect(()=>{const l=setTimeout(()=>r(!0),600);return()=>clearTimeout(l)},[]);const i=n&&pa(a);return h.useEffect(()=>{const l=wa(),c=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),u=fa();ns({forceRefresh:!0}).catch(()=>{}),Fe().catch(()=>{}),ja().catch(()=>{}),Na().catch(()=>{}),va().catch(()=>{}),da().then(p=>{f.getState().setAcknowledgedKeys(new Set(p.map(m=>m.matchKey)))}).catch(()=>{}),ua().then(p=>{p&&f.setState({siteCrawlReport:p})}).catch(()=>{});const d=p=>{if(p.key!=="Escape")return;const{pinnedMatchKey:m,setPinned:x,results:g}=f.getState();m&&(x(null),le().then(j=>{var b;j&&ue(j,{type:"HIGHLIGHT_CLEAR_REQUEST",tabId:j},(b=g[0])==null?void 0:b.frameId).catch(()=>{})}))};return window.addEventListener("keydown",d),()=>{u(),l.disconnect(),c==null||c.disconnect(),window.removeEventListener("keydown",d)}},[]),i?e.jsxs(e.Fragment,{children:[e.jsx(sl,{}),e.jsx(Ee,{})]}):s===null?e.jsxs(e.Fragment,{children:[e.jsx(Lr,{}),e.jsx(Ee,{})]}):s==="owner"?e.jsxs(e.Fragment,{children:[e.jsx(si,{}),e.jsx(Vt,{}),e.jsx(Ee,{})]}):e.jsxs("div",{className:"flex flex-col h-screen bg-slate-50 text-slate-900 text-sm",children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50 focus:bg-white focus:text-slate-900 focus:px-3 focus:py-1.5 focus:rounded focus:shadow focus:outline focus:outline-2 focus:outline-brand-500",children:"Skip to main content"}),e.jsx(Ns,{}),e.jsx(us,{}),e.jsx(_a,{}),e.jsxs("main",{id:"main-content",className:"flex-1 flex flex-col overflow-hidden","aria-label":"wcagcheckr",children:[e.jsx(Ga,{}),e.jsx(za,{}),e.jsx(Rr,{}),e.jsx(Ir,{}),e.jsx(qa,{}),e.jsx(Ar,{}),e.jsx(Cr,{}),e.jsxs("div",{className:"flex-1 overflow-y-auto",role:"region","aria-label":`${t} view`,children:[t==="matrix"&&e.jsx(dn,{}),t==="report"&&e.jsx(Cn,{}),t==="delta"&&e.jsx(Gn,{}),t==="activity"&&e.jsx(Zn,{}),t==="guided"&&e.jsx(ur,{}),t==="flows"&&e.jsx(xr,{}),t==="scorecard"&&e.jsx(br,{}),t==="crawl"&&e.jsx(ys,{}),t==="forensic"&&e.jsx(ws,{}),t==="compliance"&&e.jsx(Qi,{}),t==="schedules"&&e.jsx(tl,{})]})]}),e.jsx($r,{}),e.jsx(Er,{}),e.jsx(Sr,{}),e.jsx(Vt,{}),e.jsx(Ee,{})]})}class ul extends Ae.Component{constructor(){super(...arguments);yt(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,n){console.error("[side-panel] render crashed",a,n.componentStack)}render(){return this.state.error?e.jsxs("div",{className:"p-4 text-sm bg-red-50 text-red-900 h-full flex flex-col",children:[e.jsx("h2",{className:"font-semibold mb-2",children:"Side panel crashed"}),e.jsx("p",{className:"text-xs mb-3",children:this.state.error.message}),e.jsx("button",{onClick:()=>location.reload(),className:"text-xs px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700 self-start",children:"Reload"})]}):this.props.children}}export{dl as A,ul as E,cl as d};