@wcag-checkr/ci 1.0.0-rc.310 → 1.0.0-rc.312

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ai-usage-log-BX3L6bKl.js","assets/crash-reporter-Bu2p8K-p.js","assets/scheduled-audit-runner-DyKpb3zg.js","assets/diff-DA41zYPc.js"])))=>i.map(i=>d[i]);
2
- import{m as D,_ as F}from"./diff-DA41zYPc.js";import{ah as ae,ai as ne,aj as W,ak as j,g as oe,D as se,al as ie,am as ce,an as le,ao as ue,ap as de,aq as fe,ar as ge,as as Ee,at as pe,au as he,av as Te,aw as Se,ax as me,ay as Ie,ab as Re,az as we,aA as Ae,aB as ye,aC as _e,aD as Ce,aE as be,u as _,aF as O,aG as Oe,aH as ve,aI as Q,aJ as Pe}from"./scheduled-audit-runner-DyKpb3zg.js";import{v as R,T as $,w as X}from"./ai-usage-log-BX3L6bKl.js";import{c as T,o as E,f as Ue,g as Ne,i as ke,h as xe,d as q,e as Le}from"./crash-reporter-Bu2p8K-p.js";const P="tierConfig:cache",De=60*60*1e3,Fe=24*60*60*1e3,$e=7*24*60*60*1e3;async function Me(){return(await chrome.storage.local.get(P))[P]??null}async function Ve(e){await chrome.storage.local.set({[P]:e})}function He(e,t=Date.now()){const r=t-e.fetchedAt;return r<De?"fresh":r<Fe?"stale":r<$e?"grace":"expired"}function Ge(e,t){const r={...e},a=g=>{if(typeof g=="number")return g===-1?1/0:g},n=g=>typeof g=="boolean"?g:void 0,o=g=>{if(g==="all"||g==="configurable"||g==="default-only")return g},s=a(t.maxComponents);s!==void 0&&(r.maxComponents=s);const i=a(t.maxBaselines);i!==void 0&&(r.maxBaselines=i);const c=o(t.stateMatrix);c!==void 0&&(r.stateMatrix=c);const l=n(t.storybookAutoIterate);l!==void 0&&(r.storybookAutoIterate=l);const u=n(t.exportJson);u!==void 0&&(r.exportJson=u);const d=n(t.exportSarif);d!==void 0&&(r.exportSarif=d);const p=n(t.exportJunit);p!==void 0&&(r.exportJunit=p);const C=n(t.cloudSync);C!==void 0&&(r.cloudSync=C);const h=n(t.forensicAnchoring);return h!==void 0&&(r.forensicAnchoring=h),r}function Be(e,t){var a;if(e==="trial")return((a=t.trial)==null?void 0:a.features)??null;const r=t.plans.find(n=>n.code===e||n.code.startsWith(e+"-"));return(r==null?void 0:r.features)??null}const w=T("tier-config-client"),Ke="wcagcheckr",We=`https://api.wcagcheckr.com/v1/products/${Ke}/tier-config`,je=1e4,M="tier-config-refresh",Qe=60,Xe=["trial","free","solo","team"];function Y(e){const t={};for(const r of Xe){const a=Be(r,e);t[r]=a?Ge($[r],a):{...$[r]}}return t}async function qe(){const e=await Me();if(!e){R(null);return}if(He(e)==="expired"){w.warn("cached tier-config is expired (>7d); using hardcoded defaults"),R(null);return}R(Y(e.config))}async function z(){try{const e=await fetch(We,{signal:AbortSignal.timeout(je),headers:{accept:"application/json"}});if(!e.ok)throw new Error(`http ${e.status}`);const t=await e.json();await Ve({fetchedAt:Date.now(),config:t}),R(Y(t));const r=t.wcagTargetVersion;if(r==="2.1"||r==="2.2")try{await chrome.storage.local.set({wcagTargetVersion:r}),ae(r)}catch(a){w.warn("failed to persist wcagTargetVersion",a)}w.info("tier-config refreshed from server")}catch(e){w.warn("tier-config refresh failed; keeping prior cache",e)}}function Ye(){chrome.alarms.create(M,{periodInMinutes:Qe}),chrome.alarms.onAlarm.addListener(e=>{e.name===M&&z()})}const ze=T("support-messenger"),Je="https://api.wcagcheckr.com/v1/products/wcagcheckr/support",v="support:rate-window",Ze=5,et=10*60*1e3,tt=2,rt="wcagcheckr",V="storybook:lastDetected";async function at(e){if(!e)return;const t=await chrome.runtime.getPlatformInfo(),a=(await chrome.storage.local.get(V))[V];return{extensionVersion:chrome.runtime.getManifest().version,platform:t,storybookDetected:a!=null&&a.detected?a.version??"detected":"none",licenseTier:await ne(),logTail:Ue(Ne())}}async function nt(e=Date.now()){const r=((await chrome.storage.local.get(v))[v]??[]).filter(a=>e-a<et);return r.length>=Ze?!1:(r.push(e),await chrome.storage.local.set({[v]:r}),!0)}async function J(e,t=0){try{const r=await fetch(Je,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`http ${r.status}`);const a=await r.json();if(!a.success)throw new Error(a.error??"server returned success=false");return{ticketRef:a.ticketRef??""}}catch(r){if(t<tt){const a=(t+1)*1e3;return await new Promise(n=>setTimeout(n,a)),J(e,t+1)}throw r}}function ot(){return E("SUPPORT_MESSAGE_REQUEST",async e=>{if(!await nt())return{type:"SUPPORT_MESSAGE_RESPONSE",success:!1,error:D("NETWORK","Rate limit reached. Try again in 10 minutes.",!0)};try{const t=await at(e.includeContext);return{type:"SUPPORT_MESSAGE_RESPONSE",success:!0,ticketRef:(await J({productSlug:rt,subject:e.subject,body:e.body,replyEmail:e.replyEmail,context:t,extensionVersion:chrome.runtime.getManifest().version,timestamp:new Date().toISOString()})).ticketRef}}catch(t){ze.error("send failed",t);const r=t instanceof Error?t.message:String(t);return{type:"SUPPORT_MESSAGE_RESPONSE",success:!1,error:D("NETWORK",r,!0)}}})}const Z=T("ai-color-suggester");async function st(e,t,r=[]){if(!t.enabled||e.length===0)return{results:[],totalCostUsd:0,capExceeded:!1};const a=W(t);if(!a.ok)return{results:[],totalCostUsd:0,capExceeded:!1};const n=a.client,o=j(t.costCapUsd),s=[];for(const i of e){if(!o.canCharge())break;try{const c=await n.suggestColorFix({foreground:i.foreground,background:i.background,fontSize:i.fontSize,fontWeight:i.fontWeight,targetLevel:i.targetLevel,paletteHints:r});o.recordCharge(c.costUsd),c.verdict==="suggested"&&c.candidates.length>0&&s.push({matchKey:i.matchKey,suggestions:c.candidates,reasoning:c.reasoning,costUsd:c.costUsd})}catch(c){Z.warn(`color-fix suggestion failed for ${i.matchKey}`,c)}}return{results:s,totalCostUsd:o.state.spentUsd,capExceeded:o.state.exceeded}}async function it(){const e=await chrome.storage.local.get("aiConfig");return X(e.aiConfig)}function ct(){return E("AI_COLOR_SUGGEST_REQUEST",async e=>{const t=await it();if(!t.enabled)return{type:"AI_COLOR_SUGGEST_RESPONSE",results:[],totalCostUsd:0,capExceeded:!1,unavailableReason:"AI augmentation is disabled in Settings → AI augmentation."};if(!t.apiKey)return{type:"AI_COLOR_SUGGEST_RESPONSE",results:[],totalCostUsd:0,capExceeded:!1,unavailableReason:"No AI API key configured. Add one in Settings → AI augmentation."};try{const{results:r,totalCostUsd:a,capExceeded:n}=await st(e.inputs,t,e.paletteHints);return{type:"AI_COLOR_SUGGEST_RESPONSE",results:r,totalCostUsd:a,capExceeded:n}}catch(r){return Z.warn("color-suggest handler failed",r),{type:"AI_COLOR_SUGGEST_RESPONSE",results:[],totalCostUsd:0,capExceeded:!1,unavailableReason:r instanceof Error?r.message:String(r)}}})}function H(e){if(!e)return null;const t=e.match(/rgba?\(\s*([0-9.]+)\s*,?\s*([0-9.]+)\s*,?\s*([0-9.]+)(?:\s*[,/]\s*([0-9.]+))?\s*\)/i);return t?{r:Math.round(parseFloat(t[1])),g:Math.round(parseFloat(t[2])),b:Math.round(parseFloat(t[3])),a:t[4]!==void 0?parseFloat(t[4]):1}:null}function G(e){const t=r=>{const a=r/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function lt(e,t){const r=G(e),a=G(t),n=Math.max(r,a),o=Math.min(r,a);return(n+.05)/(o+.05)}function ut(e,t){const r=Math.max(0,Math.min(1,e.a));return{r:Math.round(e.r*r+t.r*(1-r)),g:Math.round(e.g*r+t.g*(1-r)),b:Math.round(e.b*r+t.b*(1-r))}}function dt(e,t){var L;if(e!=="color-contrast"&&e!=="color-contrast-enhanced")return null;const r=t.styles;if(!r)return null;const a=((L=r.effectiveBackground)==null?void 0:L.color)??r.background,n=r.foreground;if(!n||!a)return null;const o=H(n),s=H(a);if(!o||!s||s.a<.999)return null;const i=o.a<.999?ut(o,s):{r:o.r,g:o.g,b:o.b},c=lt(i,s),l=r.fontSize??16,u=r.fontWeight??400,d=l>=24||l>=18.5&&u>=700,h=e==="color-contrast-enhanced"?d?4.5:7:d?3:4.5,g=c>=h?"pass":"fail",x=b=>`rgb(${b.r}, ${b.g}, ${b.b})`,re=`Deterministic WCAG contrast measurement (no AI guessing, no pixel sampling). Foreground ${x(i)}${o.a<.999?` (originally rgba with alpha=${o.a}, composited over background)`:""} against background ${x(s)} yields contrast ratio ${c.toFixed(2)}:1. Text is ${l}px at font-weight ${u}; ${d?"qualifies as large text (threshold 3:1 for AA)":"normal text (threshold 4.5:1 for AA)"}. ${g==="pass"?`Passes AA at ${h}:1.`:`Falls below the ${h}:1 threshold.`}`;return{verdict:g,ratio:c,threshold:h,reasoning:re}}async function ft(e,t,r){var i,c,l,u,d;const a=JSON.stringify({ruleId:e,selector:t,styles:{fg:((i=r.styles)==null?void 0:i.foreground)??null,bg:((c=r.styles)==null?void 0:c.background)??null,fs:((l=r.styles)==null?void 0:l.fontSize)??null,fw:((u=r.styles)==null?void 0:u.fontWeight)??null,ts:((d=r.styles)==null?void 0:d.textSample)??null},failureSummary:r.failureSummary??null}),n=new TextEncoder().encode(a),o=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(o)).map(p=>p.toString(16).padStart(2,"0")).join("")}const A=T("ai-incomplete-resolver");function B(e,t){if(!e)return t;const r=e.toLowerCase(),a=/verdict\s+corrected\s+to\s+pass|verdict:\s*pass\s+\(corrected\)/i,n=/verdict\s+corrected\s+to\s+fail|verdict:\s*fail\s+\(corrected\)/i,o=m(r,a),s=m(r,n);if(o>s&&o>=0)return"pass";if(s>o&&s>=0)return"fail";const i=/actually\s+passes|in\s+fact\s+passes|passes\s+AA/gi,c=/actually\s+fails|in\s+fact\s+fails|fails\s+AA/gi,l=m(r,i),u=m(r,c);return l<0&&u<0?t:l>u&&l/r.length>=.5?"pass":u>l&&u/r.length>=.5?"fail":t}function m(e,t){let r=-1;const a=t.flags.includes("g")?t.flags:t.flags+"g",n=new RegExp(t.source,a);let o;for(;(o=n.exec(e))!==null;)r=o.index,o.index===n.lastIndex&&n.lastIndex++;return r}async function gt(){const e=await chrome.storage.local.get("aiConfig");return X(e.aiConfig)}async function Et(e){if(!e.aiConfig.enabled||e.elements.length===0)return{resolutions:[],totalCostUsd:0};const t=W(e.aiConfig);if(!t.ok)return{resolutions:[],totalCostUsd:0};const r=t.client,a=j(e.aiConfig.costCapUsd),n=[],o=await oe(e.pageUrl),s=new Map;for(const i of o)s.set(`${i.ruleId}::${i.selector}`,i);for(const i of e.elements){if(!a.canCharge())break;const c=await ft(e.ruleId,i.selector,i),l=s.get(`${e.ruleId}::${i.selector}`),u=dt(e.ruleId,i);if(u){A.info(`Deterministic verdict for ${e.ruleId} on ${i.selector}: ${u.verdict} (${u.ratio.toFixed(2)}:1 vs ${u.threshold}:1) — math overrides cache + AI`),n.push({pageUrl:e.pageUrl,ruleId:e.ruleId,selector:i.selector,verdict:u.verdict,reasoning:u.reasoning,resolvedAt:new Date().toISOString(),costUsd:0,wcagCriterion:e.wcagCriterion,inputHash:c});continue}if(l&&l.inputHash===c&&l.verdict!=="uncertain"){A.info(`Reusing cached resolution for ${e.ruleId} on ${i.selector} (hash match, verdict=${l.verdict})`);const d=B(l.reasoning,l.verdict);n.push({...l,verdict:d,resolvedAt:new Date().toISOString(),costUsd:0,inputHash:c});continue}try{const d=await r.resolveAxeIncomplete({ruleId:e.ruleId,element:i,pageUrl:e.pageUrl,targetLevel:e.targetLevel});a.recordCharge(d.costUsd);const p=B(d.reasoning,d.verdict);n.push({pageUrl:e.pageUrl,ruleId:e.ruleId,selector:i.selector,verdict:p,reasoning:d.reasoning,resolvedAt:new Date().toISOString(),costUsd:d.costUsd,wcagCriterion:e.wcagCriterion,inputHash:c})}catch(d){A.warn(`resolveAxeIncomplete failed for ${i.selector}`,d)}}return n.length>0&&await se(n),{resolutions:n,totalCostUsd:a.state.spentUsd}}function pt(){return E("AI_RESOLVE_INCOMPLETE_REQUEST",async e=>{const t=await gt();if(!t.enabled)return{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:[],totalCostUsd:0,unavailableReason:"AI augmentation is disabled in Settings → AI augmentation."};if(!t.apiKey)return{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:[],totalCostUsd:0,unavailableReason:"No AI API key configured. Add one in Settings → AI augmentation."};try{const{resolutions:r,totalCostUsd:a}=await Et({ruleId:e.ruleId,pageUrl:e.pageUrl,wcagCriterion:e.wcagCriterion,elements:e.elements,targetLevel:e.targetLevel,aiConfig:t});return{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:r,totalCostUsd:a}}catch(r){return A.warn("ai-incomplete-resolver failed",r),{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:[],totalCostUsd:0,unavailableReason:r instanceof Error?r.message:"Unknown error during AI resolution."}}})}function ht(){return E("INTERACTIVE_AUDIT_REQUEST",async e=>{try{switch(e.criterionId){case"2.4.3":{const t=await fe({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl});return t.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:t.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t.error}}case"2.1.2":{const t=await de({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl});return t.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:t.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t.error}}case"2.4.7":{const t=await ue({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl});return t.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:t.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t.error}}case"1.4.11":{const t=await chrome.storage.local.get("sidePanel:lastAudit"),r=t==null?void 0:t["sidePanel:lastAudit"],a=(r==null?void 0:r.results)??[];if(a.length===0)return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:"No audit results available. Run an audit first; 1.4.11 needs the page screenshot."};const n=await le({componentId:e.componentId,pageUrl:e.pageUrl,results:a});return n.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:n.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:n.error}}case"1.3.2":{const t=await chrome.storage.local.get("sidePanel:lastAudit"),r=t==null?void 0:t["sidePanel:lastAudit"],a=(r==null?void 0:r.results)??[];if(a.length===0)return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:"No audit results available. Run an audit first, then the 1.3.2 walkthrough can judge its reading-order findings."};const n=await ce({componentId:e.componentId,pageUrl:e.pageUrl,results:a});return n.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:n.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:n.error}}case"2.5.3":{const t=await chrome.storage.local.get("sidePanel:lastAudit"),r=t==null?void 0:t["sidePanel:lastAudit"],a=await ie({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl,results:r==null?void 0:r.results});return a.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:a.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:a.error}}default:return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:`Interactive audit for criterion ${e.criterionId} not yet implemented.`}}}catch(t){return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}})}const Tt=T("ax-tree-snapshot"),St="1.3";function mt(e){var r,a,n;const t=[];for(const o of e.properties??[]){const s=(r=o.value)==null?void 0:r.value;s!==void 0&&(typeof s=="string"||typeof s=="number"||typeof s=="boolean"||s===null)&&t.push({name:o.name,value:s})}return{nodeId:e.nodeId,parentId:e.parentId,childIds:e.childIds??[],role:typeof((a=e.role)==null?void 0:a.value)=="string"?e.role.value:"unknown",name:typeof((n=e.name)==null?void 0:n.value)=="string"?e.name.value:"",ignored:!!e.ignored,properties:t,backendDomNodeId:e.backendDOMNodeId}}async function It(e){let t=!1;try{try{await chrome.debugger.attach({tabId:e},St),t=!0}catch(n){if(!(n instanceof Error?n.message:String(n)).includes("Another debugger"))throw Tt.warn("chrome.debugger.attach failed",n),n}await chrome.debugger.sendCommand({tabId:e},"Accessibility.enable");const r=await chrome.debugger.sendCommand({tabId:e},"Accessibility.getFullAXTree");return((r==null?void 0:r.nodes)??[]).map(mt)}finally{if(t)try{await chrome.debugger.detach({tabId:e})}catch{}}}const ee=T("perf-throttle"),Rt="1.3",wt={none:{label:"No throttling",network:null,cpuRate:1},"3g-slow":{label:"Slow 3G",network:{offline:!1,latency:400,downloadThroughput:500*1024/8,uploadThroughput:500*1024/8},cpuRate:6},"3g-fast":{label:"Fast 3G",network:{offline:!1,latency:150,downloadThroughput:1.5*1024*1024/8,uploadThroughput:750*1024/8},cpuRate:4},"4g":{label:"4G LTE",network:{offline:!1,latency:20,downloadThroughput:4*1024*1024/8,uploadThroughput:3*1024*1024/8},cpuRate:2},"cpu-2x":{label:"CPU 2× slowdown (no network throttle)",network:null,cpuRate:2},"cpu-4x":{label:"CPU 4× slowdown (no network throttle)",network:null,cpuRate:4}};async function At(e){try{return await chrome.debugger.attach({tabId:e},Rt),!0}catch(t){if((t instanceof Error?t.message:String(t)).includes("Another debugger"))return!1;throw t}}async function yt(e,t){const r=wt[t];await At(e),await chrome.debugger.sendCommand({tabId:e},"Network.enable"),r.network?await chrome.debugger.sendCommand({tabId:e},"Network.emulateNetworkConditions",r.network):await chrome.debugger.sendCommand({tabId:e},"Network.emulateNetworkConditions",{offline:!1,latency:0,downloadThroughput:-1,uploadThroughput:-1}),await chrome.debugger.sendCommand({tabId:e},"Emulation.setCPUThrottlingRate",{rate:r.cpuRate}),ee.info(`applied ${t} (label="${r.label}", cpu×${r.cpuRate})`)}async function _t(e){try{await chrome.debugger.sendCommand({tabId:e},"Network.emulateNetworkConditions",{offline:!1,latency:0,downloadThroughput:-1,uploadThroughput:-1}),await chrome.debugger.sendCommand({tabId:e},"Emulation.setCPUThrottlingRate",{rate:1})}catch(t){ee.debug("throttle reset commands failed (debugger may not be attached)",t)}}const f=T("service-worker");ke("service-worker");ge();var I,K;(K=(I=chrome.sidePanel)==null?void 0:I.setPanelBehavior)==null||K.call(I,{openPanelOnActionClick:!0}).catch(e=>f.warn("setPanelBehavior failed",e));Ee();pe();he();Te().catch(e=>f.warn("initial cloud pull failed",e));(async()=>(await Se(),await qe(),z(),me(),Ie(),Re()))();chrome.alarms.onAlarm.addListener(e=>{const t=we(e.name);t!==null&&Ae(t).catch(r=>f.warn(`scheduled audit ${t} threw at top level`,r))});Ye();ye();_e();ot();ct();Ce();pt();ht();self.addEventListener("unhandledrejection",e=>{const t=e.reason;xe(t instanceof Error?t:new Error(String(t)))});let y=!1;chrome.runtime.onConnect.addListener(e=>{if(e.name==="audit-keepalive"){f.debug("keepalive connected"),e.onDisconnect.addListener(async()=>{f.debug("keepalive disconnected"),await be()});return}if(e.name==="sidepanel-tracker"){y=!0,f.debug("chrome.sidePanel opened"),e.onDisconnect.addListener(async()=>{y=!1,f.debug("chrome.sidePanel closed — restoring in-page overlay"),await N()});return}});let U=!1;const S={isCanceled:()=>U};async function te(){const e=await _();if(e)try{await q(e,{type:"SIDEBAR_HIDE_REQUEST"})}catch(t){f.warn("sidebar hide failed",t)}}async function N(){const e=await _();if(e)try{await q(e,{type:"SIDEBAR_SHOW_REQUEST"})}catch(t){f.warn("sidebar show failed",t)}}E("START_AUDIT",async e=>{U=!1,await te();const t=await _();let r;const a={verifyFixesOnly:e.verifyFixesOnly};if(e.mode==="single-element"){if(!e.scope)throw new Error("START_AUDIT single-element requires scope");r=O(e.scope,S,e.frameId,e.matrixOverride,a)}else if(e.mode==="full-page")r=O("html",S,0,e.matrixOverride,a);else if(e.mode==="quick-scan"){const{QUICK_SCAN_MATRIX_SETTINGS:n}=await F(async()=>{const{QUICK_SCAN_MATRIX_SETTINGS:o}=await import("./ai-usage-log-BX3L6bKl.js").then(s=>s.I);return{QUICK_SCAN_MATRIX_SETTINGS:o}},__vite__mapDeps([0,1]));r=O(e.scope??"html",S,e.frameId??0,n,a)}else if(e.mode==="all-frames")r=Oe(S);else if(e.mode==="parallel-scan"){const{runParallelScan:n}=await F(async()=>{const{runParallelScan:o}=await import("./scheduled-audit-runner-DyKpb3zg.js").then(s=>s.aT);return{runParallelScan:o}},__vite__mapDeps([2,3,1,0]));r=n(S)}else r=ve(S);r.catch(n=>{f.error("audit failed",n);const o=n instanceof Error?n.message:String(n),s=/no audit target tab/i.test(o);Le({type:"AUDIT_FAILED_EVENT",error:{code:s?"RESTRICTED_URL":"UNKNOWN",message:s?"No audit target tab found. Open a regular http(s) page (not chrome:// or about:blank) and try again.":`Audit failed: ${o}`,recoverable:!0}})}).finally(()=>{t!=null&&Q(t).catch(n=>f.debug("post-audit debugger release failed (best-effort)",n)),y||N()})});E("CANCEL_AUDIT",async()=>{U=!0,f.info("cancel requested")});let k=!1;const Ct={isCanceled:()=>k};E("START_SITE_CRAWL",async e=>{k=!1,await te();const t=await _();Pe(e.startUrl,{maxPages:e.maxPages,includeRegex:e.includeRegex,excludeRegex:e.excludeRegex,verifyFixesOnly:e.verifyFixesOnly},Ct).catch(r=>f.error("site crawl failed",r)).finally(()=>{t!=null&&Q(t).catch(r=>f.debug("post-crawl debugger release failed (best-effort)",r)),y||N()})});E("CANCEL_SITE_CRAWL",async()=>{k=!0,f.info("site crawl cancel requested")});E("OPEN_SETTINGS",()=>{chrome.runtime.openOptionsPage()});E("PERF_THROTTLE_APPLY_REQUEST",async e=>{try{return await yt(e.tabId,e.profile),{type:"PERF_THROTTLE_APPLY_RESPONSE",ok:!0}}catch(t){return{type:"PERF_THROTTLE_APPLY_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}});E("PERF_THROTTLE_CLEAR_REQUEST",async e=>{try{return await _t(e.tabId),{type:"PERF_THROTTLE_CLEAR_RESPONSE",ok:!0}}catch(t){return{type:"PERF_THROTTLE_CLEAR_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}});E("AX_TREE_SNAPSHOT_REQUEST",async e=>{try{return{type:"AX_TREE_SNAPSHOT_RESPONSE",ok:!0,nodes:await It(e.tabId)}}catch(t){return f.warn("ax-tree snapshot failed",t),{type:"AX_TREE_SNAPSHOT_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}});f.info("service worker ready");
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ai-usage-log-BX3L6bKl.js","assets/crash-reporter-Bu2p8K-p.js","assets/scheduled-audit-runner-BB7YtjU4.js","assets/diff-DA41zYPc.js"])))=>i.map(i=>d[i]);
2
+ import{m as D,_ as F}from"./diff-DA41zYPc.js";import{ah as ae,ai as ne,aj as W,ak as j,g as oe,D as se,al as ie,am as ce,an as le,ao as ue,ap as de,aq as fe,ar as ge,as as Ee,at as pe,au as he,av as Te,aw as Se,ax as me,ay as Ie,ab as Re,az as we,aA as Ae,aB as ye,aC as _e,aD as Ce,aE as be,u as _,aF as O,aG as Oe,aH as ve,aI as Q,aJ as Pe}from"./scheduled-audit-runner-BB7YtjU4.js";import{v as R,T as $,w as X}from"./ai-usage-log-BX3L6bKl.js";import{c as T,o as E,f as Ue,g as Ne,i as ke,h as xe,d as q,e as Le}from"./crash-reporter-Bu2p8K-p.js";const P="tierConfig:cache",De=60*60*1e3,Fe=24*60*60*1e3,$e=7*24*60*60*1e3;async function Me(){return(await chrome.storage.local.get(P))[P]??null}async function Ve(e){await chrome.storage.local.set({[P]:e})}function He(e,t=Date.now()){const r=t-e.fetchedAt;return r<De?"fresh":r<Fe?"stale":r<$e?"grace":"expired"}function Ge(e,t){const r={...e},a=g=>{if(typeof g=="number")return g===-1?1/0:g},n=g=>typeof g=="boolean"?g:void 0,o=g=>{if(g==="all"||g==="configurable"||g==="default-only")return g},s=a(t.maxComponents);s!==void 0&&(r.maxComponents=s);const i=a(t.maxBaselines);i!==void 0&&(r.maxBaselines=i);const c=o(t.stateMatrix);c!==void 0&&(r.stateMatrix=c);const l=n(t.storybookAutoIterate);l!==void 0&&(r.storybookAutoIterate=l);const u=n(t.exportJson);u!==void 0&&(r.exportJson=u);const d=n(t.exportSarif);d!==void 0&&(r.exportSarif=d);const p=n(t.exportJunit);p!==void 0&&(r.exportJunit=p);const C=n(t.cloudSync);C!==void 0&&(r.cloudSync=C);const h=n(t.forensicAnchoring);return h!==void 0&&(r.forensicAnchoring=h),r}function Be(e,t){var a;if(e==="trial")return((a=t.trial)==null?void 0:a.features)??null;const r=t.plans.find(n=>n.code===e||n.code.startsWith(e+"-"));return(r==null?void 0:r.features)??null}const w=T("tier-config-client"),Ke="wcagcheckr",We=`https://api.wcagcheckr.com/v1/products/${Ke}/tier-config`,je=1e4,M="tier-config-refresh",Qe=60,Xe=["trial","free","solo","team"];function Y(e){const t={};for(const r of Xe){const a=Be(r,e);t[r]=a?Ge($[r],a):{...$[r]}}return t}async function qe(){const e=await Me();if(!e){R(null);return}if(He(e)==="expired"){w.warn("cached tier-config is expired (>7d); using hardcoded defaults"),R(null);return}R(Y(e.config))}async function z(){try{const e=await fetch(We,{signal:AbortSignal.timeout(je),headers:{accept:"application/json"}});if(!e.ok)throw new Error(`http ${e.status}`);const t=await e.json();await Ve({fetchedAt:Date.now(),config:t}),R(Y(t));const r=t.wcagTargetVersion;if(r==="2.1"||r==="2.2")try{await chrome.storage.local.set({wcagTargetVersion:r}),ae(r)}catch(a){w.warn("failed to persist wcagTargetVersion",a)}w.info("tier-config refreshed from server")}catch(e){w.warn("tier-config refresh failed; keeping prior cache",e)}}function Ye(){chrome.alarms.create(M,{periodInMinutes:Qe}),chrome.alarms.onAlarm.addListener(e=>{e.name===M&&z()})}const ze=T("support-messenger"),Je="https://api.wcagcheckr.com/v1/products/wcagcheckr/support",v="support:rate-window",Ze=5,et=10*60*1e3,tt=2,rt="wcagcheckr",V="storybook:lastDetected";async function at(e){if(!e)return;const t=await chrome.runtime.getPlatformInfo(),a=(await chrome.storage.local.get(V))[V];return{extensionVersion:chrome.runtime.getManifest().version,platform:t,storybookDetected:a!=null&&a.detected?a.version??"detected":"none",licenseTier:await ne(),logTail:Ue(Ne())}}async function nt(e=Date.now()){const r=((await chrome.storage.local.get(v))[v]??[]).filter(a=>e-a<et);return r.length>=Ze?!1:(r.push(e),await chrome.storage.local.set({[v]:r}),!0)}async function J(e,t=0){try{const r=await fetch(Je,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`http ${r.status}`);const a=await r.json();if(!a.success)throw new Error(a.error??"server returned success=false");return{ticketRef:a.ticketRef??""}}catch(r){if(t<tt){const a=(t+1)*1e3;return await new Promise(n=>setTimeout(n,a)),J(e,t+1)}throw r}}function ot(){return E("SUPPORT_MESSAGE_REQUEST",async e=>{if(!await nt())return{type:"SUPPORT_MESSAGE_RESPONSE",success:!1,error:D("NETWORK","Rate limit reached. Try again in 10 minutes.",!0)};try{const t=await at(e.includeContext);return{type:"SUPPORT_MESSAGE_RESPONSE",success:!0,ticketRef:(await J({productSlug:rt,subject:e.subject,body:e.body,replyEmail:e.replyEmail,context:t,extensionVersion:chrome.runtime.getManifest().version,timestamp:new Date().toISOString()})).ticketRef}}catch(t){ze.error("send failed",t);const r=t instanceof Error?t.message:String(t);return{type:"SUPPORT_MESSAGE_RESPONSE",success:!1,error:D("NETWORK",r,!0)}}})}const Z=T("ai-color-suggester");async function st(e,t,r=[]){if(!t.enabled||e.length===0)return{results:[],totalCostUsd:0,capExceeded:!1};const a=W(t);if(!a.ok)return{results:[],totalCostUsd:0,capExceeded:!1};const n=a.client,o=j(t.costCapUsd),s=[];for(const i of e){if(!o.canCharge())break;try{const c=await n.suggestColorFix({foreground:i.foreground,background:i.background,fontSize:i.fontSize,fontWeight:i.fontWeight,targetLevel:i.targetLevel,paletteHints:r});o.recordCharge(c.costUsd),c.verdict==="suggested"&&c.candidates.length>0&&s.push({matchKey:i.matchKey,suggestions:c.candidates,reasoning:c.reasoning,costUsd:c.costUsd})}catch(c){Z.warn(`color-fix suggestion failed for ${i.matchKey}`,c)}}return{results:s,totalCostUsd:o.state.spentUsd,capExceeded:o.state.exceeded}}async function it(){const e=await chrome.storage.local.get("aiConfig");return X(e.aiConfig)}function ct(){return E("AI_COLOR_SUGGEST_REQUEST",async e=>{const t=await it();if(!t.enabled)return{type:"AI_COLOR_SUGGEST_RESPONSE",results:[],totalCostUsd:0,capExceeded:!1,unavailableReason:"AI augmentation is disabled in Settings → AI augmentation."};if(!t.apiKey)return{type:"AI_COLOR_SUGGEST_RESPONSE",results:[],totalCostUsd:0,capExceeded:!1,unavailableReason:"No AI API key configured. Add one in Settings → AI augmentation."};try{const{results:r,totalCostUsd:a,capExceeded:n}=await st(e.inputs,t,e.paletteHints);return{type:"AI_COLOR_SUGGEST_RESPONSE",results:r,totalCostUsd:a,capExceeded:n}}catch(r){return Z.warn("color-suggest handler failed",r),{type:"AI_COLOR_SUGGEST_RESPONSE",results:[],totalCostUsd:0,capExceeded:!1,unavailableReason:r instanceof Error?r.message:String(r)}}})}function H(e){if(!e)return null;const t=e.match(/rgba?\(\s*([0-9.]+)\s*,?\s*([0-9.]+)\s*,?\s*([0-9.]+)(?:\s*[,/]\s*([0-9.]+))?\s*\)/i);return t?{r:Math.round(parseFloat(t[1])),g:Math.round(parseFloat(t[2])),b:Math.round(parseFloat(t[3])),a:t[4]!==void 0?parseFloat(t[4]):1}:null}function G(e){const t=r=>{const a=r/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function lt(e,t){const r=G(e),a=G(t),n=Math.max(r,a),o=Math.min(r,a);return(n+.05)/(o+.05)}function ut(e,t){const r=Math.max(0,Math.min(1,e.a));return{r:Math.round(e.r*r+t.r*(1-r)),g:Math.round(e.g*r+t.g*(1-r)),b:Math.round(e.b*r+t.b*(1-r))}}function dt(e,t){var L;if(e!=="color-contrast"&&e!=="color-contrast-enhanced")return null;const r=t.styles;if(!r)return null;const a=((L=r.effectiveBackground)==null?void 0:L.color)??r.background,n=r.foreground;if(!n||!a)return null;const o=H(n),s=H(a);if(!o||!s||s.a<.999)return null;const i=o.a<.999?ut(o,s):{r:o.r,g:o.g,b:o.b},c=lt(i,s),l=r.fontSize??16,u=r.fontWeight??400,d=l>=24||l>=18.5&&u>=700,h=e==="color-contrast-enhanced"?d?4.5:7:d?3:4.5,g=c>=h?"pass":"fail",x=b=>`rgb(${b.r}, ${b.g}, ${b.b})`,re=`Deterministic WCAG contrast measurement (no AI guessing, no pixel sampling). Foreground ${x(i)}${o.a<.999?` (originally rgba with alpha=${o.a}, composited over background)`:""} against background ${x(s)} yields contrast ratio ${c.toFixed(2)}:1. Text is ${l}px at font-weight ${u}; ${d?"qualifies as large text (threshold 3:1 for AA)":"normal text (threshold 4.5:1 for AA)"}. ${g==="pass"?`Passes AA at ${h}:1.`:`Falls below the ${h}:1 threshold.`}`;return{verdict:g,ratio:c,threshold:h,reasoning:re}}async function ft(e,t,r){var i,c,l,u,d;const a=JSON.stringify({ruleId:e,selector:t,styles:{fg:((i=r.styles)==null?void 0:i.foreground)??null,bg:((c=r.styles)==null?void 0:c.background)??null,fs:((l=r.styles)==null?void 0:l.fontSize)??null,fw:((u=r.styles)==null?void 0:u.fontWeight)??null,ts:((d=r.styles)==null?void 0:d.textSample)??null},failureSummary:r.failureSummary??null}),n=new TextEncoder().encode(a),o=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(o)).map(p=>p.toString(16).padStart(2,"0")).join("")}const A=T("ai-incomplete-resolver");function B(e,t){if(!e)return t;const r=e.toLowerCase(),a=/verdict\s+corrected\s+to\s+pass|verdict:\s*pass\s+\(corrected\)/i,n=/verdict\s+corrected\s+to\s+fail|verdict:\s*fail\s+\(corrected\)/i,o=m(r,a),s=m(r,n);if(o>s&&o>=0)return"pass";if(s>o&&s>=0)return"fail";const i=/actually\s+passes|in\s+fact\s+passes|passes\s+AA/gi,c=/actually\s+fails|in\s+fact\s+fails|fails\s+AA/gi,l=m(r,i),u=m(r,c);return l<0&&u<0?t:l>u&&l/r.length>=.5?"pass":u>l&&u/r.length>=.5?"fail":t}function m(e,t){let r=-1;const a=t.flags.includes("g")?t.flags:t.flags+"g",n=new RegExp(t.source,a);let o;for(;(o=n.exec(e))!==null;)r=o.index,o.index===n.lastIndex&&n.lastIndex++;return r}async function gt(){const e=await chrome.storage.local.get("aiConfig");return X(e.aiConfig)}async function Et(e){if(!e.aiConfig.enabled||e.elements.length===0)return{resolutions:[],totalCostUsd:0};const t=W(e.aiConfig);if(!t.ok)return{resolutions:[],totalCostUsd:0};const r=t.client,a=j(e.aiConfig.costCapUsd),n=[],o=await oe(e.pageUrl),s=new Map;for(const i of o)s.set(`${i.ruleId}::${i.selector}`,i);for(const i of e.elements){if(!a.canCharge())break;const c=await ft(e.ruleId,i.selector,i),l=s.get(`${e.ruleId}::${i.selector}`),u=dt(e.ruleId,i);if(u){A.info(`Deterministic verdict for ${e.ruleId} on ${i.selector}: ${u.verdict} (${u.ratio.toFixed(2)}:1 vs ${u.threshold}:1) — math overrides cache + AI`),n.push({pageUrl:e.pageUrl,ruleId:e.ruleId,selector:i.selector,verdict:u.verdict,reasoning:u.reasoning,resolvedAt:new Date().toISOString(),costUsd:0,wcagCriterion:e.wcagCriterion,inputHash:c});continue}if(l&&l.inputHash===c&&l.verdict!=="uncertain"){A.info(`Reusing cached resolution for ${e.ruleId} on ${i.selector} (hash match, verdict=${l.verdict})`);const d=B(l.reasoning,l.verdict);n.push({...l,verdict:d,resolvedAt:new Date().toISOString(),costUsd:0,inputHash:c});continue}try{const d=await r.resolveAxeIncomplete({ruleId:e.ruleId,element:i,pageUrl:e.pageUrl,targetLevel:e.targetLevel});a.recordCharge(d.costUsd);const p=B(d.reasoning,d.verdict);n.push({pageUrl:e.pageUrl,ruleId:e.ruleId,selector:i.selector,verdict:p,reasoning:d.reasoning,resolvedAt:new Date().toISOString(),costUsd:d.costUsd,wcagCriterion:e.wcagCriterion,inputHash:c})}catch(d){A.warn(`resolveAxeIncomplete failed for ${i.selector}`,d)}}return n.length>0&&await se(n),{resolutions:n,totalCostUsd:a.state.spentUsd}}function pt(){return E("AI_RESOLVE_INCOMPLETE_REQUEST",async e=>{const t=await gt();if(!t.enabled)return{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:[],totalCostUsd:0,unavailableReason:"AI augmentation is disabled in Settings → AI augmentation."};if(!t.apiKey)return{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:[],totalCostUsd:0,unavailableReason:"No AI API key configured. Add one in Settings → AI augmentation."};try{const{resolutions:r,totalCostUsd:a}=await Et({ruleId:e.ruleId,pageUrl:e.pageUrl,wcagCriterion:e.wcagCriterion,elements:e.elements,targetLevel:e.targetLevel,aiConfig:t});return{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:r,totalCostUsd:a}}catch(r){return A.warn("ai-incomplete-resolver failed",r),{type:"AI_RESOLVE_INCOMPLETE_RESPONSE",resolutions:[],totalCostUsd:0,unavailableReason:r instanceof Error?r.message:"Unknown error during AI resolution."}}})}function ht(){return E("INTERACTIVE_AUDIT_REQUEST",async e=>{try{switch(e.criterionId){case"2.4.3":{const t=await fe({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl});return t.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:t.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t.error}}case"2.1.2":{const t=await de({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl});return t.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:t.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t.error}}case"2.4.7":{const t=await ue({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl});return t.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:t.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t.error}}case"1.4.11":{const t=await chrome.storage.local.get("sidePanel:lastAudit"),r=t==null?void 0:t["sidePanel:lastAudit"],a=(r==null?void 0:r.results)??[];if(a.length===0)return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:"No audit results available. Run an audit first; 1.4.11 needs the page screenshot."};const n=await le({componentId:e.componentId,pageUrl:e.pageUrl,results:a});return n.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:n.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:n.error}}case"1.3.2":{const t=await chrome.storage.local.get("sidePanel:lastAudit"),r=t==null?void 0:t["sidePanel:lastAudit"],a=(r==null?void 0:r.results)??[];if(a.length===0)return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:"No audit results available. Run an audit first, then the 1.3.2 walkthrough can judge its reading-order findings."};const n=await ce({componentId:e.componentId,pageUrl:e.pageUrl,results:a});return n.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:n.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:n.error}}case"2.5.3":{const t=await chrome.storage.local.get("sidePanel:lastAudit"),r=t==null?void 0:t["sidePanel:lastAudit"],a=await ie({tabId:e.tabId,componentId:e.componentId,pageUrl:e.pageUrl,results:r==null?void 0:r.results});return a.ok?{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!0,result:a.result}:{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:a.error}}default:return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:`Interactive audit for criterion ${e.criterionId} not yet implemented.`}}}catch(t){return{type:"INTERACTIVE_AUDIT_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}})}const Tt=T("ax-tree-snapshot"),St="1.3";function mt(e){var r,a,n;const t=[];for(const o of e.properties??[]){const s=(r=o.value)==null?void 0:r.value;s!==void 0&&(typeof s=="string"||typeof s=="number"||typeof s=="boolean"||s===null)&&t.push({name:o.name,value:s})}return{nodeId:e.nodeId,parentId:e.parentId,childIds:e.childIds??[],role:typeof((a=e.role)==null?void 0:a.value)=="string"?e.role.value:"unknown",name:typeof((n=e.name)==null?void 0:n.value)=="string"?e.name.value:"",ignored:!!e.ignored,properties:t,backendDomNodeId:e.backendDOMNodeId}}async function It(e){let t=!1;try{try{await chrome.debugger.attach({tabId:e},St),t=!0}catch(n){if(!(n instanceof Error?n.message:String(n)).includes("Another debugger"))throw Tt.warn("chrome.debugger.attach failed",n),n}await chrome.debugger.sendCommand({tabId:e},"Accessibility.enable");const r=await chrome.debugger.sendCommand({tabId:e},"Accessibility.getFullAXTree");return((r==null?void 0:r.nodes)??[]).map(mt)}finally{if(t)try{await chrome.debugger.detach({tabId:e})}catch{}}}const ee=T("perf-throttle"),Rt="1.3",wt={none:{label:"No throttling",network:null,cpuRate:1},"3g-slow":{label:"Slow 3G",network:{offline:!1,latency:400,downloadThroughput:500*1024/8,uploadThroughput:500*1024/8},cpuRate:6},"3g-fast":{label:"Fast 3G",network:{offline:!1,latency:150,downloadThroughput:1.5*1024*1024/8,uploadThroughput:750*1024/8},cpuRate:4},"4g":{label:"4G LTE",network:{offline:!1,latency:20,downloadThroughput:4*1024*1024/8,uploadThroughput:3*1024*1024/8},cpuRate:2},"cpu-2x":{label:"CPU 2× slowdown (no network throttle)",network:null,cpuRate:2},"cpu-4x":{label:"CPU 4× slowdown (no network throttle)",network:null,cpuRate:4}};async function At(e){try{return await chrome.debugger.attach({tabId:e},Rt),!0}catch(t){if((t instanceof Error?t.message:String(t)).includes("Another debugger"))return!1;throw t}}async function yt(e,t){const r=wt[t];await At(e),await chrome.debugger.sendCommand({tabId:e},"Network.enable"),r.network?await chrome.debugger.sendCommand({tabId:e},"Network.emulateNetworkConditions",r.network):await chrome.debugger.sendCommand({tabId:e},"Network.emulateNetworkConditions",{offline:!1,latency:0,downloadThroughput:-1,uploadThroughput:-1}),await chrome.debugger.sendCommand({tabId:e},"Emulation.setCPUThrottlingRate",{rate:r.cpuRate}),ee.info(`applied ${t} (label="${r.label}", cpu×${r.cpuRate})`)}async function _t(e){try{await chrome.debugger.sendCommand({tabId:e},"Network.emulateNetworkConditions",{offline:!1,latency:0,downloadThroughput:-1,uploadThroughput:-1}),await chrome.debugger.sendCommand({tabId:e},"Emulation.setCPUThrottlingRate",{rate:1})}catch(t){ee.debug("throttle reset commands failed (debugger may not be attached)",t)}}const f=T("service-worker");ke("service-worker");ge();var I,K;(K=(I=chrome.sidePanel)==null?void 0:I.setPanelBehavior)==null||K.call(I,{openPanelOnActionClick:!0}).catch(e=>f.warn("setPanelBehavior failed",e));Ee();pe();he();Te().catch(e=>f.warn("initial cloud pull failed",e));(async()=>(await Se(),await qe(),z(),me(),Ie(),Re()))();chrome.alarms.onAlarm.addListener(e=>{const t=we(e.name);t!==null&&Ae(t).catch(r=>f.warn(`scheduled audit ${t} threw at top level`,r))});Ye();ye();_e();ot();ct();Ce();pt();ht();self.addEventListener("unhandledrejection",e=>{const t=e.reason;xe(t instanceof Error?t:new Error(String(t)))});let y=!1;chrome.runtime.onConnect.addListener(e=>{if(e.name==="audit-keepalive"){f.debug("keepalive connected"),e.onDisconnect.addListener(async()=>{f.debug("keepalive disconnected"),await be()});return}if(e.name==="sidepanel-tracker"){y=!0,f.debug("chrome.sidePanel opened"),e.onDisconnect.addListener(async()=>{y=!1,f.debug("chrome.sidePanel closed — restoring in-page overlay"),await N()});return}});let U=!1;const S={isCanceled:()=>U};async function te(){const e=await _();if(e)try{await q(e,{type:"SIDEBAR_HIDE_REQUEST"})}catch(t){f.warn("sidebar hide failed",t)}}async function N(){const e=await _();if(e)try{await q(e,{type:"SIDEBAR_SHOW_REQUEST"})}catch(t){f.warn("sidebar show failed",t)}}E("START_AUDIT",async e=>{U=!1,await te();const t=await _();let r;const a={verifyFixesOnly:e.verifyFixesOnly};if(e.mode==="single-element"){if(!e.scope)throw new Error("START_AUDIT single-element requires scope");r=O(e.scope,S,e.frameId,e.matrixOverride,a)}else if(e.mode==="full-page")r=O("html",S,0,e.matrixOverride,a);else if(e.mode==="quick-scan"){const{QUICK_SCAN_MATRIX_SETTINGS:n}=await F(async()=>{const{QUICK_SCAN_MATRIX_SETTINGS:o}=await import("./ai-usage-log-BX3L6bKl.js").then(s=>s.I);return{QUICK_SCAN_MATRIX_SETTINGS:o}},__vite__mapDeps([0,1]));r=O(e.scope??"html",S,e.frameId??0,n,a)}else if(e.mode==="all-frames")r=Oe(S);else if(e.mode==="parallel-scan"){const{runParallelScan:n}=await F(async()=>{const{runParallelScan:o}=await import("./scheduled-audit-runner-BB7YtjU4.js").then(s=>s.aT);return{runParallelScan:o}},__vite__mapDeps([2,3,1,0]));r=n(S)}else r=ve(S);r.catch(n=>{f.error("audit failed",n);const o=n instanceof Error?n.message:String(n),s=/no audit target tab/i.test(o);Le({type:"AUDIT_FAILED_EVENT",error:{code:s?"RESTRICTED_URL":"UNKNOWN",message:s?"No audit target tab found. Open a regular http(s) page (not chrome:// or about:blank) and try again.":`Audit failed: ${o}`,recoverable:!0}})}).finally(()=>{t!=null&&Q(t).catch(n=>f.debug("post-audit debugger release failed (best-effort)",n)),y||N()})});E("CANCEL_AUDIT",async()=>{U=!0,f.info("cancel requested")});let k=!1;const Ct={isCanceled:()=>k};E("START_SITE_CRAWL",async e=>{k=!1,await te();const t=await _();Pe(e.startUrl,{maxPages:e.maxPages,includeRegex:e.includeRegex,excludeRegex:e.excludeRegex,verifyFixesOnly:e.verifyFixesOnly},Ct).catch(r=>f.error("site crawl failed",r)).finally(()=>{t!=null&&Q(t).catch(r=>f.debug("post-crawl debugger release failed (best-effort)",r)),y||N()})});E("CANCEL_SITE_CRAWL",async()=>{k=!0,f.info("site crawl cancel requested")});E("OPEN_SETTINGS",()=>{chrome.runtime.openOptionsPage()});E("PERF_THROTTLE_APPLY_REQUEST",async e=>{try{return await yt(e.tabId,e.profile),{type:"PERF_THROTTLE_APPLY_RESPONSE",ok:!0}}catch(t){return{type:"PERF_THROTTLE_APPLY_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}});E("PERF_THROTTLE_CLEAR_REQUEST",async e=>{try{return await _t(e.tabId),{type:"PERF_THROTTLE_CLEAR_RESPONSE",ok:!0}}catch(t){return{type:"PERF_THROTTLE_CLEAR_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}});E("AX_TREE_SNAPSHOT_REQUEST",async e=>{try{return{type:"AX_TREE_SNAPSHOT_RESPONSE",ok:!0,nodes:await It(e.tabId)}}catch(t){return f.warn("ax-tree snapshot failed",t),{type:"AX_TREE_SNAPSHOT_RESPONSE",ok:!1,error:t instanceof Error?t.message:String(t)}}});f.info("service worker ready");
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-DNgytqhZ.js","assets/scheduled-audit-runner-DyKpb3zg.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Bu2p8K-p.js","assets/ai-usage-log-BX3L6bKl.js"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-B5Qt9EMX.js";import{j as e,r as p,c as we,R as je}from"./styles-Cn731SYD.js";import{u as w,c as Se,a as Ce,l as oe,s as Te,w as Re,r as Ie,b as Ae,d as Ne,p as Ee,e as Ue,E as ze,A as Fe}from"./ErrorBoundary-C-kswn4E.js";import{l as De,a as Pe,b as $e,c as J,d as We,g as ve,e as Le,f as Oe,W as He,r as Me,s as Be,h as Ve,i as he,j as ge,k as _e,m as Ge,n as Ke,o as qe,p as Ye}from"./scheduled-audit-runner-DyKpb3zg.js";import{s as D,r as Ze,i as Qe}from"./crash-reporter-Bu2p8K-p.js";import{B as X}from"./ai-usage-log-BX3L6bKl.js";import{_}from"./diff-DA41zYPc.js";import{copyAiFixerPrompt as Xe}from"./copy-ai-fixer-prompt-DQYkHOv3.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./design-system-audit-DpxJrxnb.js";function se({initialUrl:t,isRunning:a,onCrawl:r,onVerifyFixes:n,onAuditThisPage:s}){const[l,o]=p.useState(t),[i,c]=p.useState(25),[d,y]=p.useState(""),[j,m]=p.useState(""),[k,f]=p.useState(!1),[b,u]=p.useState(X),[g,S]=p.useState(X[0].id),[v,h]=p.useState(null);p.useEffect(()=>{t&&!l&&o(t)},[t]),p.useEffect(()=>{let C=!1;return Promise.all([D({type:"SETTINGS_GET",key:"matrixPresets"}),D({type:"SETTINGS_GET",key:"activePresetId"})]).then(([I,A])=>{if(C)return;const U=Array.isArray(I.data)?I.data:null;u(U&&U.length>0?U:X),typeof A.data=="string"&&S(A.data)}),()=>{C=!0}},[]);function x(C){const I=b.find(A=>A.id===C);I&&(S(C),D({type:"SETTINGS_SET",key:"activePresetId",value:C}),D({type:"SETTINGS_SET",key:"stateMatrix",value:I.matrix}))}function T(){h(null);for(const[C,I]of[["Include",d.trim()],["Exclude",j.trim()]])if(I)try{new RegExp(I)}catch(A){return h(`${C} regex invalid: ${A instanceof Error?A.message:String(A)}`),!1}return!0}function E(C){if(!T())return;const I={startUrl:l.trim(),maxPages:i,includeRegex:d.trim(),excludeRegex:j.trim()};C&&n?n(I):r(I)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-3)",textAlign:"left"},children:[e.jsx(M,{label:"Start URL",children:e.jsx("input",{type:"url",value:l,onChange:C=>o(C.target.value),placeholder:"https://yoursite.com",disabled:a,className:"v2-mono",style:B})}),e.jsx(M,{label:"Max pages",hint:"1–200. Each page runs the full pipeline you configured.",children:e.jsx("input",{type:"number",min:1,max:200,value:i,onChange:C=>c(Math.min(200,Math.max(1,parseInt(C.target.value,10)||25))),disabled:a,className:"v2-mono",style:{...B,maxWidth:100}})}),e.jsx(M,{label:"Audit depth",hint:"State matrix preset applied to every crawled page.",children:e.jsx("select",{value:g,onChange:C=>x(C.target.value),disabled:a,style:B,children:b.map(C=>e.jsx("option",{value:C.id,children:C.name},C.id))})}),e.jsx("button",{type:"button",onClick:()=>f(C=>!C),className:"v2-eyebrow",style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-ink-secondary)",textAlign:"left",alignSelf:"flex-start"},children:k?"− hide advanced filters":"+ show URL filters (include / exclude)"}),k&&e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Include only URLs matching",hint:"Optional regex. Empty = no filter.",children:e.jsx("input",{type:"text",value:d,onChange:C=>y(C.target.value),placeholder:"^https://example\\.com/products/",disabled:a,className:"v2-mono",style:B})}),e.jsx(M,{label:"Exclude URLs matching",hint:"Optional regex. Useful for /admin or /login while logged in.",children:e.jsx("input",{type:"text",value:j,onChange:C=>m(C.target.value),placeholder:"/admin|/dashboard|/login",disabled:a,className:"v2-mono",style:B})})]}),v&&e.jsx("p",{role:"alert",style:{color:"var(--v2-critical)",fontSize:12,margin:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",border:"1px solid var(--v2-critical)",borderRadius:4,background:"rgba(207, 44, 44, 0.06)"},children:v}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap",marginTop:"var(--v2-pad-2)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",disabled:a||!l.trim(),onClick:()=>E(!1),children:a?"Crawling…":"Crawl whole site"}),n&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",disabled:a||!l.trim(),onClick:()=>E(!0),title:"Skip walkthroughs that previously passed or were human-verified",children:"Verify fixes only"}),s&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",disabled:a,onClick:s,title:"Single-page audit on the active tab (no crawl)",children:"Just this page"})]})]})}function Je(){var c;const t=w(d=>d.siteCrawlProgress),a=w(d=>d.siteCrawlStatus),r=w(d=>d.progress),n=w(d=>d.aiProgress);function s(){D({type:"CANCEL_SITE_CRAWL"})}if(a!=="running")return null;const l=t?Math.min(100,Math.max(0,t.current/Math.max(1,t.total)*100)):0,o=r?Math.min(100,Math.max(0,r.current/Math.max(1,r.total)*100)):0,i=r!=null&&r.currentState?[r.currentState.pseudoState,r.currentState.theme&&r.currentState.theme!=="light"?r.currentState.theme:null,r.currentState.direction&&r.currentState.direction!=="ltr"?r.currentState.direction:null,(c=r.currentState.breakpoint)!=null&&c.id&&r.currentState.breakpoint.id!=="desktop"?r.currentState.breakpoint.id:null].filter(Boolean).join(" · "):"";return e.jsxs("div",{role:"status","aria-live":"polite",style:{background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:6,padding:"var(--v2-pad-4)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-3)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:"crawling…"}),e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:12,fontWeight:600,color:"var(--v2-ink-primary)",fontVariantNumeric:"tabular-nums"},children:t?`${t.current} / ${t.total}`:"…"})]}),e.jsx("div",{role:"progressbar","aria-valuenow":(t==null?void 0:t.current)??0,"aria-valuemin":0,"aria-valuemax":(t==null?void 0:t.total)??1,"aria-label":"Crawl progress",style:{height:8,background:"var(--v2-bg-elev-2)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,background:"var(--v2-action)",transition:"width 240ms ease"}})}),(t==null?void 0:t.url)&&e.jsxs("div",{children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:4},children:"current page"}),e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-secondary)",wordBreak:"break-all"},children:t.url})]}),(t==null?void 0:t.lastViolations)!==void 0&&t.lastViolations>0&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",fontVariantNumeric:"tabular-nums"},children:["last page: ",t.lastViolations," axe violation",t.lastViolations===1?"":"s"]}),r&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)",paddingTop:"var(--v2-pad-3)",borderTop:"1px solid var(--v2-border)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsx("span",{className:"v2-eyebrow",style:{color:"var(--v2-ink-tertiary)"},children:"this page · auditing"}),e.jsxs("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.current," / ",r.total]})]}),e.jsx("div",{role:"progressbar","aria-valuenow":r.current,"aria-valuemin":0,"aria-valuemax":r.total,"aria-label":"Current page audit progress",style:{height:4,background:"var(--v2-bg-elev-2)",borderRadius:2,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${o}%`,background:"var(--v2-ink-tertiary)",transition:"width 240ms ease"}})}),i&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)"},children:["state: ",i]}),n&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-needs-review)",fontVariantNumeric:"tabular-nums"},children:["AI: ",n.current," / ",n.total," · ",n.currentCheckLabel,n.candidatesTotal&&n.candidatesTotal>0?` (${n.candidatesDone??0}/${n.candidatesTotal})`:""]})]}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:s,children:"Cancel crawl"})})]})}function et(){const t=w(c=>c.status),a=w(c=>c.progress),r=w(c=>c.aiProgress);if(t!=="running")return null;const n=a?a.current>=a.total:!1,s=a?n?"Running deep analyzers…":`Auditing… ${a.current} / ${a.total}`:"Starting audit…",l=a?n?"reading order · tab order · typography · CSS vars · AI candidates":tt(a.currentState):"Loading axe + DOM analyzers",o=a?n?100:a.current/Math.max(1,a.total)*100:0;function i(){D({type:"CANCEL_AUDIT"})}return e.jsxs("div",{role:"status","aria-live":"polite",style:{background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:6,padding:"var(--v2-pad-4)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-4)"},children:[e.jsx(le,{label:s,detail:l,pct:o,valuenow:a?Math.min(a.current,a.total):0,valuemax:a?a.total:1,ariaLabel:a?n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${a.current} of ${a.total} states`:"Audit starting",fillColor:"var(--v2-action)"}),r&&e.jsx(le,{label:`AI augmentation… ${r.current} / ${r.total}`,detail:r.candidatesTotal&&r.candidatesTotal>0?`${r.currentCheckLabel} (${r.candidatesDone??0}/${r.candidatesTotal})`:r.currentCheckLabel,pct:r.current/Math.max(1,r.total)*100,valuenow:r.current,valuemax:r.total,ariaLabel:`AI augmentation: ${r.current} of ${r.total} checks. ${r.currentCheckLabel}`,fillColor:"var(--v2-needs-review)"}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:i,children:"Cancel audit"})})]})}function le({label:t,detail:a,pct:r,valuenow:n,valuemax:s,ariaLabel:l,fillColor:o}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:e.jsx("span",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:t})}),e.jsx("div",{role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":s,"aria-label":l,style:{height:6,background:"var(--v2-bg-elev-2)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,background:o,transition:"width 240ms ease"}})}),a&&e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-secondary)",wordBreak:"break-all"},children:a})]})}function tt(t){if(!t)return"";const a=[t.pseudoState];return t.theme&&t.theme!=="light"&&a.push(t.theme),t.direction&&t.direction!=="ltr"&&a.push(t.direction),a.join(" · ")}function M({label:t,hint:a,children:r}){return e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("span",{className:"v2-eyebrow",style:{color:"var(--v2-ink-secondary)"},children:t}),r,a&&e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:a})]})}const B={fontFamily:"var(--v2-body)",fontSize:12,padding:"8px 10px",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,outline:"none"};function Y(){const t=w(c=>c.siteCrawlReport),a=w(c=>c.results),r=w(c=>c.delta),n=w(c=>c.componentId),s=w(c=>c.status),l=w(c=>c.siteCrawlStatus),[o,i]=p.useState({report:null,resolvedFails:[]});return p.useEffect(()=>{var j;let c=!1;async function d(m){return m.length===0?[]:(await Promise.all(m.map(f=>ve(f)))).flat().map(Le).map(Oe).filter(f=>f.verdict==="fail")}if(l==="running"||s==="running"){i({report:null,resolvedFails:[]});return}if(t)return(async()=>{const m=t.pages.map(f=>f.url),k=await d(m);c||i({report:t,resolvedFails:k})})(),()=>{c=!0};if(a.length===0||!n){i({report:null,resolvedFails:[]});return}const y=(j=a[0])==null?void 0:j.pageUrl;if(!y){i({report:null,resolvedFails:[]});return}return(async()=>{try{const[m,k,f,b,u]=await Promise.all([De([n]),Pe([n]),$e(n),J([n]),d([y])]),g=new Map([[n,m]]),S=new Map([[n,k]]),v=new Map([[n,f]]),h=new Map([[n,b]]),x=new Date().toISOString(),T=We(y,[{url:y,results:a,delta:r,componentId:n,durationMs:0}],x,x,0,g,S,v,h);c||i({report:T,resolvedFails:u})}catch(m){console.warn("[v2] synthesize single-page report failed",m),c||i({report:null,resolvedFails:[]})}})(),()=>{c=!0}},[t,a,r,n,s,l]),o}const rt={"1.2.1":{howToCheck:"Confirm any audio-only or video-only media has a text alternative (transcript, captions, descriptive title). If the page has no audio or video at all, mark N/A with that note."},"1.2.2":{howToCheck:"For every prerecorded video with audio, verify captions are present and synchronized. Open each video, turn captions on, and spot-check 10–15 seconds. If the page has no video with audio, mark N/A."},"1.2.3":{howToCheck:"For every prerecorded video, confirm an audio description track OR a full text alternative is available. If no prerecorded video, mark N/A."},"1.2.4":{howToCheck:"For any live streaming media with audio, verify live captions are provided. If the page has no live media, mark N/A."},"1.2.5":{howToCheck:"For prerecorded video, confirm an audio description track is provided (separate from the main audio). If no prerecorded video, mark N/A."},"1.3.1":{howToCheck:"Inspect headings, lists, tables, and form labels. Programmatic structure should match visual structure: h1→h2→h3, real <ul>/<ol>, real <table> with <th>, every form field has a <label> or aria-label. Tabbing through the page should reveal the same structure a screen reader would announce."},"1.4.3":{howToCheck:"Open the inconclusive elements. Most commonly axe failed because the background is transparent, a gradient, or an image. Identify the EFFECTIVE background color a user sees and compute the contrast ratio against the foreground; needs ≥4.5:1 for normal text, ≥3:1 for large text (18pt+ or 14pt+ bold)."},"1.4.4":{howToCheck:"Zoom the page to 200% (Ctrl+Plus four times in most browsers). Verify all content remains visible and functional — no overlapping text, no clipped buttons, no horizontal scrollbar at 1280×1024 viewport."},"1.4.10":{howToCheck:"Resize the browser to 320 CSS px wide (or use devtools mobile emulation at 320×256). Confirm content reflows without two-dimensional scrolling — vertical scroll only, no horizontal scroll except for genuinely two-dimensional content (data tables, images, complex maps)."},"1.4.11":{howToCheck:"Verify every UI component's boundary (button borders, form field outlines, focus indicators) has ≥3:1 contrast against its adjacent color. Same for meaningful graphics (icons, infographic elements). Decorative graphics are exempt."},"1.4.12":{howToCheck:"Apply this CSS via devtools and confirm no content is clipped or hidden: line-height: 1.5; letter-spacing: 0.12em; word-spacing: 0.16em; paragraph spacing 2× font-size. If layout breaks, the page fails."},"2.1.1":{howToCheck:"Tab through every interactive element. Every button, link, form field, and custom control must be reachable AND operable via keyboard alone (Enter, Space, arrow keys as appropriate). Mouse-only affordances fail."},"2.1.2":{howToCheck:"Tab into every interactive component. Confirm Tab/Shift+Tab moves focus out. No element should trap focus (typical offenders: poorly-coded modals, embedded players)."},"2.4.1":{howToCheck:"Verify a skip-to-main-content link exists (typically first focusable element, visible on focus) OR landmark regions (<main>, <nav>) are present. Either lets keyboard users bypass repeated nav."},"2.4.3":{howToCheck:"Tab through the page in source order. Focus must move in a sequence that preserves meaning — usually left-to-right, top-to-bottom. Particularly check skip links and modals."},"2.4.4":{howToCheck:`Read each link's text WITH its surrounding context (parent paragraph, list item, table cell). The combined text must convey where the link goes. "Click here" alone is ambiguous; "Click here to read our pricing" passes when context is included.`},"2.4.5":{howToCheck:"Confirm at least two ways to find a given page exist: site search, sitemap, A-Z index, table of contents, or persistent navigation. Single-page sites and process-step pages (checkout) are exempt."},"2.4.6":{howToCheck:"Read each heading and form-field label in isolation. Each should describe the topic of its section or the purpose of its field WITHOUT requiring the surrounding content to make sense."},"2.4.7":{howToCheck:"Tab through every focusable element. The current focus must be VISUALLY distinct from neighbors — an outline, a box-shadow, a background change. The default browser outline counts; CSS that removes it without replacing fails."},"2.5.3":{howToCheck:"For every control with both a visible text label and an accessible name (aria-label, alt, etc.), verify the visible label appears (verbatim, or as a substring) in the accessible name. Otherwise voice-control users can't target it by saying its visible label."},"3.1.1":{howToCheck:'View source. Confirm <html lang="..."> is present with a valid language tag (e.g. "en", "en-US", "fr").'},"3.1.2":{howToCheck:"Find any passage of foreign-language text on the page (a quote, a borrowed phrase, an entire alternate-language section). Confirm it's wrapped with the appropriate lang attribute. If the entire page is in one language, mark N/A."},"3.2.1":{howToCheck:"Tab to each focusable element. Confirm receiving focus alone does NOT trigger a context change: no navigation, no modal opening, no form submission. Action only on explicit activation (click, Enter)."},"3.2.2":{howToCheck:"In each form, change one input value (type in a field, check a checkbox, change a select). Confirm this does NOT submit the form, navigate the page, or open a modal without first warning the user."},"3.2.3":{howToCheck:"Open at least three different pages on the site. Confirm the main navigation, footer navigation, and any breadcrumb appear in the SAME relative order on each. Reordering items between pages is a fail; adding or removing items based on auth state is acceptable."},"3.2.4":{howToCheck:"Identify a few common functional elements on the site (e.g., the search input, login button, cart button, social-share icons). Verify each appears with the SAME accessible name, label, and icon on every page where it appears. Inconsistent naming is the fail mode."},"3.3.1":{howToCheck:"Submit a form with invalid data. Confirm errors are identified in text (not just color), describe what went wrong, and ideally indicate which field. Browser-default validation messages count."},"3.3.2":{howToCheck:"Every form input should have a visible label (or visible placeholder + accessible name combination) AND an instruction when format matters (date format, password rules). Placeholder-only labels fail because they disappear on focus."},"3.3.3":{howToCheck:'Submit a form with invalid data. Confirm the error message describes HOW to fix the problem (e.g., "Email must contain @" not just "Invalid email"). Exempts cases where suggestion would compromise security (password rules).'},"3.3.4":{howToCheck:"For any form that submits a legal commitment, financial transaction, or modifies/deletes user data: confirm submissions are reversible, validated for errors before commit, OR show a confirmation step before final commit."},"4.1.3":{howToCheck:'Trigger any status update (form submitted, item added to cart, search completed, error appeared). Confirm screen-reader users receive the update via an aria-live region or role="status"/"alert" — without moving focus to the update.'}};function at(t){return rt[t]??null}const ce="aiConfig";function nt(t){return`https://www.w3.org/WAI/WCAG22/Understanding/${t}`}const it=new Map(He.map(t=>[t.id,t]));async function ot(t){const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];if(!(r!=null&&r.id))return{ok:!1,error:"No active tab."};const n=r.id,s=q(t.pageUrl),l=q(r.url??"");if(!(r.url===t.pageUrl)){try{await chrome.tabs.update(n,{url:t.pageUrl})}catch(y){return{ok:!1,error:y instanceof Error?y.message:"Failed to navigate tab."}}if(!await st(n,t.pageUrl,12e3))return{ok:!1,error:"Page did not finish loading in time."}}if(!t.selector)return{ok:!0,found:!1,matchCount:0};const i=[120,250,500,800,1200,800];let c="";for(let d=0;d<=i.length;d++)try{const y=await Ze(n,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:n,selector:t.selector,scrollIntoView:!0});return{ok:!0,found:y.found,matchCount:y.matchCount}}catch(y){const j=y instanceof Error?y.message:String(y);if(c=j,!(j.includes("Could not establish connection")||j.includes("Receiving end does not exist")))break;const k=i[d];if(k===void 0)break;await new Promise(f=>setTimeout(f,k))}return{ok:!1,error:s!==l?`Navigated to ${t.pageUrl} — but the in-page highlighter couldn't attach (${c}).`:c}}function q(t){try{return new URL(t).origin}catch{return""}}function st(t,a,r){return new Promise(n=>{let s=!1;const l=setTimeout(()=>{s||(s=!0,chrome.tabs.onUpdated.removeListener(o),n(!1))},r);function o(i,c,d){if(i!==t||c.status!=="complete")return;const y=q(d.url??""),j=q(a);j&&y&&y!==j||s||(s=!0,clearTimeout(l),chrome.tabs.onUpdated.removeListener(o),n(!0))}chrome.tabs.onUpdated.addListener(o)})}function de(t){try{const a=new URL(t),r=a.pathname+a.search+a.hash||"/";return r.length>60?r.slice(0,57)+"...":r}catch{return t}}function lt(t){return t.length>70?t.slice(0,67)+"...":t}function ct(t){try{const a=new Date(t),r=new Date,n=a.toDateString()===r.toDateString(),s=new Date(r);s.setDate(s.getDate()-1);const l=a.toDateString()===s.toDateString(),o=a.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n?`today, ${o}`:l?`yesterday, ${o}`:`${a.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${o}`}catch{return t}}function dt(){const{report:t}=Y(),a=w(u=>u.componentId),r=w(u=>u.siteCrawlReport),[n,s]=p.useState(!1),[l,o]=p.useState(new Set),[i,c]=p.useState(0),d=p.useRef(""),[y,j]=p.useState(!1),[m,k]=p.useState("claude-sonnet-4-6");p.useEffect(()=>{(async()=>{const g=(await chrome.storage.local.get(ce))[ce];d.current=(g==null?void 0:g.apiKey)??"",j(!!(g!=null&&g.apiKey)),g!=null&&g.model&&k(g.model)})()},[]);const f=vt(a,r,(t==null?void 0:t.pages.map(u=>u.url))??[]);if(p.useEffect(()=>{let u=!1;return(async()=>{if(!f){u||o(new Set);return}try{const g=await J([f]);if(u)return;o(new Set(g.map(S=>S.criterionId)))}catch{u||o(new Set)}})(),()=>{u=!0}},[f,i]),!t)return null;const b=t.blockingCriteria;return!b||b.length===0||t.siteGrade!=="A"&&t.siteGrade!=="B"?null:e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg-elev)"},children:[e.jsxs("button",{type:"button",onClick:()=>s(u=>!u),"aria-expanded":n,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-ink-primary)",fontSize:13,fontWeight:500,textAlign:"left",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--v2-pad-3)",width:"100%"},children:[e.jsx("span",{children:(()=>{const u=b.length,g=b.filter(v=>l.has(v.criterionId)).length,S=u-g;return g===0?`${u} criteri${u===1?"on":"a"} need${u===1?"s":""} your judgment`:S===0?`${u} criteri${u===1?"on":"a"} verified — re-crawl to lift the grade`:`${g} of ${u} verified · ${S} remaining`})()}),e.jsx("span",{"aria-hidden":"true",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:n?"▾":"▸"})]}),n&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:"Each criterion below has no affirmative evidence yet. Mark it Pass / N/A / Fail with a note about what you checked. Verdicts persist as forensic evidence and contribute to the audit's chain of custody."}),b.map(u=>e.jsx(ut,{criterionId:u.criterionId,title:u.title,state:u.state,evidence:u.evidence,targetComponentId:f,apiKeyRef:d,apiKeyPresent:y,model:m,onVerdictChange:()=>c(g=>g+1)},u.criterionId))]})]})}function ut({criterionId:t,title:a,state:r,evidence:n,targetComponentId:s,apiKeyRef:l,apiKeyPresent:o,model:i,onVerdictChange:c}){const[d,y]=p.useState(null),[j,m]=p.useState(""),[k,f]=p.useState(!1),[b,u]=p.useState(null),[g,S]=p.useState(null),[v,h]=p.useState(!0),[x,T]=p.useState(!1),[E,C]=p.useState(null),[I,A]=p.useState(null),[U,Q]=p.useState(null),$={untested:"No evidence — automation has no rule for this criterion",inconclusive:"Inconclusive — axe / AI ran but couldn't determine",failing:"Failing — at least one fail signal across the audit"};p.useEffect(()=>{let R=!1;return(async()=>{if(!s){R||h(!1);return}try{const P=(await J([s])).find(H=>H.criterionId===t);if(R)return;S(P?{verdict:P.verdict,note:P.note,verifiedAt:P.verifiedAt}:null)}catch{R||S(null)}finally{R||h(!1)}})(),()=>{R=!0}},[t,s]);async function be(){if(s){f(!0),u(null);try{await Me(s,t),S(null),c()}catch(R){u(R instanceof Error?R.message:String(R))}finally{f(!1)}}}const W=it.get(t),ae=W==null?void 0:W.shortDescription,ne=W==null?void 0:W.understandingSlug,ie=at(t);async function xe(){if(!l.current){A("Set an Anthropic API key in extension Options first.");return}T(!0),A(null);try{const z=`Explain WCAG ${t} (${a}) in the context of this audit. State: ${r==="untested"?"no automated evidence (no axe rule covers it)":r==="inconclusive"?"inconclusive — axe or AI ran but could not produce a definitive pass/fail":"failing — at least one fail signal across the audit"}. Cover: (1) what the criterion actually requires in plain language, (2) common failure modes a developer should look for, (3) how to manually verify it on this site, (4) when to mark N/A vs Pass vs Fail. Keep it tight — 5–8 sentences total.`,P=await Se({apiKey:l.current,model:i,messages:[{role:"user",content:z}],system:`You are wcagcheckr's WCAG explainer. The user is sitting in front of a forensic-grade audit tool and needs to record a manual verdict on a criterion the automation can't decide. Be precise. No marketing tone. When citing a verification step, name the exact device/browser/devtool action (e.g., "Resize Chrome devtools to 320 CSS px").`,maxTokens:600,maxCostUsd:.05});C(P.text),Q(P.costUsd)}catch(R){A(R instanceof Error?R.message:String(R))}finally{T(!1)}}async function ke(R){if(!s){u("No componentId available — re-run an audit first.");return}if(!j.trim()){u("Note is required — describe what you checked and why this verdict applies.");return}f(!0),u(null);const z=new Date().toISOString(),P=j.trim();try{await Be({componentId:s,criterionId:t,verdict:R,note:P,verifiedAt:z}),S({verdict:R,note:P,verifiedAt:z}),y(null),m(""),c()}catch(H){u(H instanceof Error?H.message:String(H))}finally{f(!1)}}if(g){const z={pass:{bg:"rgba(15, 143, 94, 0.08)",border:"var(--v2-verified)",ink:"var(--v2-verified)",label:"Pass"},na:{bg:"rgba(100, 116, 139, 0.10)",border:"var(--v2-border-strong)",ink:"var(--v2-ink-secondary)",label:"N/A"},fail:{bg:"rgba(207, 44, 44, 0.06)",border:"var(--v2-critical)",ink:"var(--v2-critical)",label:"Fail"}}[g.verdict];return e.jsxs("div",{role:"status",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:z.bg,border:`1px solid ${z.border}`,borderRadius:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)"},children:["WCAG ",t]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:a}),e.jsxs("span",{className:"v2-mono",style:{fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"2px 6px",borderRadius:3,color:"var(--v2-bg)",background:z.ink},children:["✓ ",z.label]})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:g.note}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:10,color:"var(--v2-ink-tertiary)"},children:["verified ",ct(g.verifiedAt)]}),e.jsx("button",{type:"button",onClick:be,disabled:k,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:k?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:k?"Un-marking…":"Un-mark this criterion"}),b&&e.jsx("span",{role:"alert",style:{fontSize:11,color:"var(--v2-critical)"},children:b})]})]})}return v?e.jsx("div",{"aria-hidden":"true",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4,minHeight:56}}):e.jsxs("div",{style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)"},children:["WCAG ",t]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:a})]}),ae&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:ae}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:$[r]}),ie&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,fontSize:10},children:"how to check"}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:ie.howToCheck})]}),n.length>0&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)"},children:[e.jsxs("p",{className:"v2-eyebrow",style:{margin:0,fontSize:10},children:["suspect locations · ",n.length]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:"4px 0 0",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:n.map((R,z)=>e.jsx(pt,{ev:R},`${R.pageUrl}::${R.selector??""}::${z}`))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap",alignItems:"center"},children:[ne&&e.jsx("a",{href:nt(ne),target:"_blank",rel:"noreferrer noopener",style:{fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:"Read W3C guidance ↗"}),o&&e.jsx("button",{type:"button",onClick:xe,disabled:x,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:x?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:x?"Explaining…":E?"Re-explain with AI":"Explain with AI ↗"})]}),(E||I)&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:4},children:[E&&e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.55,whiteSpace:"pre-wrap"},children:E}),I&&e.jsx("p",{role:"alert",style:{margin:0,fontSize:11,color:"var(--v2-critical)"},children:I}),U!==null&&e.jsxs("p",{className:"v2-mono",style:{margin:"4px 0 0",fontSize:10,color:"var(--v2-ink-tertiary)"},children:["$",U.toFixed(4)," · ",i]})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{y(d==="pass"?null:"pass"),u(null)},"aria-expanded":d==="pass",children:d==="pass"?"Cancel":"Mark Pass"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{y(d==="na"?null:"na"),u(null)},"aria-expanded":d==="na",children:d==="na"?"Cancel":"Mark N/A"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{y(d==="fail"?null:"fail"),u(null)},"aria-expanded":d==="fail",children:d==="fail"?"Cancel":"Mark Fail"})]}),d&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0},children:"verification note · required"}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:d==="na"?'Describe why this criterion does not apply to this audit (e.g., "no audio/video content on this page").':d==="pass"?'Describe what you checked to verify pass (e.g., "manually browsed page in keyboard-only mode, no focus traps").':'Describe the failure (e.g., "modal does not return focus to the trigger when closed").'}),e.jsx("textarea",{value:j,onChange:R=>m(R.target.value),rows:3,style:{width:"100%",fontFamily:"var(--v2-body)",fontSize:12,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,resize:"vertical",minHeight:56},placeholder:d==="na"?"e.g., No audio or video content present on this page; criterion is not applicable.":d==="pass"?"e.g., Manually verified — page resizes correctly at 200% zoom without horizontal scroll.":"e.g., Focus visible indicator missing on dark-mode buttons."}),b&&e.jsx("p",{role:"alert",style:{margin:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(207, 44, 44, 0.06)",border:"1px solid var(--v2-critical)",borderRadius:4,color:"var(--v2-critical)",fontSize:11},children:b}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>ke(d),disabled:k||!j.trim(),children:k?"Saving…":`Confirm ${d.toUpperCase()}`})})]})]})}function pt({ev:t}){const[a,r]=p.useState(!1),[n,s]=p.useState(null);async function l(){r(!0),s(null);try{const o=await ot({pageUrl:t.pageUrl,selector:t.selector});o.ok?t.selector?o.found?s({kind:"ok",text:`Element highlighted (${o.matchCount} match${o.matchCount===1?"":"es"}).`}):s({kind:"warn",text:"Page opened but the selector matched zero elements — DOM may have changed since the audit."}):s({kind:"ok",text:`Opened ${de(t.pageUrl)} — no element selector available; verify manually.`}):s({kind:"err",text:o.error})}finally{r(!1)}}return e.jsxs("li",{style:{padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4,display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsx("span",{className:"v2-mono",title:t.pageUrl,style:{fontSize:11,color:"var(--v2-ink-secondary)",overflowWrap:"anywhere"},children:de(t.pageUrl)}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:l,disabled:a,children:a?"Opening…":t.selector?"Show on page":"Open page"})]}),t.selector&&e.jsx("span",{className:"v2-mono",title:t.selector,style:{fontSize:11,color:"var(--v2-ink-tertiary)",overflowWrap:"anywhere"},children:lt(t.selector)}),t.notes&&e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:t.notes}),n&&e.jsx("span",{role:n.kind==="err"?"alert":"status",style:{fontSize:11,color:n.kind==="err"?"var(--v2-critical)":n.kind==="warn"?"var(--v2-needs-review)":"var(--v2-verified)"},children:n.text})]})}function vt(t,a,r){return t||(a!=null&&a.startUrl?a.startUrl:r[0]?r[0]:null)}function ht(){const{report:t,resolvedFails:a}=Y(),r=w(h=>h.siteCrawlReport),n=w(h=>h.siteCrawlStatus),s=w(h=>h.siteCrawlError),l=w(h=>h.status),o=n==="running",c=o||l==="running"&&!o,d=!!t&&!r,[y,j]=p.useState(null);p.useEffect(()=>{let h=!1;return chrome.tabs.query({active:!0,currentWindow:!0}).then(x=>{var T;h||j(((T=x[0])==null?void 0:T.url)??null)}),()=>{h=!0}},[]);const[m,k]=p.useState(!1);function f(h,x=!1){h.startUrl&&(w.getState().setSiteCrawlStatus("running"),w.getState().setSiteCrawlReport(null),w.getState().setSiteCrawlError(null),oe({type:"START_SITE_CRAWL",startUrl:h.startUrl,maxPages:h.maxPages,...h.includeRegex?{includeRegex:h.includeRegex}:{},...h.excludeRegex?{excludeRegex:h.excludeRegex}:{},...x?{verifyFixesOnly:!0}:{}}))}function b(){oe({type:"START_AUDIT",mode:"full-page"}),w.getState().startNewScan()}if(c)return e.jsx("section",{"aria-label":"Audit in progress",style:{padding:"var(--v2-pad-5) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)"},children:o?e.jsx(Je,{}):e.jsx(et,{})});if(!t)return e.jsxs("section",{"aria-label":"No audit yet",style:{padding:"var(--v2-pad-6) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",maxWidth:640,margin:"0 auto"},children:[e.jsx("p",{className:"v2-eyebrow",style:{marginBottom:"var(--v2-pad-2)"},children:"new audit"}),e.jsx("h1",{className:"v2-display",style:{fontSize:28,fontWeight:500,letterSpacing:"-0.02em",color:"var(--v2-ink-primary)",margin:0,marginBottom:"var(--v2-pad-2)"},children:"Configure your crawl."}),s&&e.jsxs("div",{role:"alert",style:{marginBottom:"var(--v2-pad-4)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-critical)",borderRadius:4,background:"rgba(207, 44, 44, 0.06)",color:"var(--v2-critical)",fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:600,marginRight:6},children:"Last crawl failed:"}),s]}),e.jsx("p",{style:{color:"var(--v2-ink-secondary)",margin:0,marginBottom:"var(--v2-pad-5)",maxWidth:520},children:"The crawler follows internal links from the start URL, same-origin only. Each page runs your full audit pipeline (axe + DOM analyzers + AI walkthroughs). Findings appear below as a single unified list."}),e.jsx(se,{initialUrl:y??"",isRunning:c,onCrawl:h=>f(h,!1),onAuditThisPage:b})]});const u=a.length,g=(t.totalWalkthroughFindings??0)+t.totalUniqueViolations+u,S=(t.walkthroughAcknowledgements??[]).length,v=t.totalNeedsReview;return e.jsxs("section",{"aria-label":"Audit summary",style:{padding:"var(--v2-pad-6) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"var(--v2-pad-6)"},children:[e.jsx(mt,{grade:t.siteGrade}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:"var(--v2-pad-3)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0},children:d?"page grade · single-page audit":`site grade · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"}`}),e.jsx("h1",{className:"v2-display",style:{fontSize:22,fontWeight:500,letterSpacing:"-0.01em",color:"var(--v2-ink-primary)",margin:0,lineHeight:1.25},children:(()=>{var T;const h=g+v,x=((T=t.blockingCriteria)==null?void 0:T.length)??0;return h===0&&x===0?"All clear — nothing open.":h===0&&x>0?`Visible findings clear — ${x} criteri${x===1?"on":"a"} still need${x===1?"s":""} your judgment.`:`${h} finding${h===1?"":"s"} to address.`})()}),e.jsx(ft,{openCount:g,reviewCount:v,verifiedCount:S,axeCount:t.totalUniqueViolations,walkthroughCount:t.totalWalkthroughFindings??0,autoCount:u}),y&&!gt(y,t.startUrl)&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",wordBreak:"break-all"},children:["Active tab: ",y]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap"},children:[d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:b,title:"Re-audit the current page",children:"Re-audit this page"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>k(h=>!h),"aria-expanded":m,title:"Open crawl setup to audit the whole site instead",children:m?"Hide crawl options":"Crawl whole site"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:()=>f({startUrl:t.startUrl,maxPages:25,includeRegex:"",excludeRegex:""},!1),title:`Re-crawl ${t.startUrl} (same options)`,children:"Re-crawl"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:b,title:"Single-page audit of the active tab (no crawl)",children:"Just this page"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>f({startUrl:t.startUrl,maxPages:25,includeRegex:"",excludeRegex:""},!0),title:"Skip walkthroughs that previously passed or were human-verified",children:"Verify fixes only"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>k(h=>!h),"aria-expanded":m,children:m?"Hide options":"Adjust options"})]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{Ce(),w.getState().setSiteCrawlReport(null),w.getState().setSiteCrawlError(null),Ve(null).catch(()=>{})},title:"Wipe these results so you can start fresh",style:{marginLeft:"auto"},children:"Clear results"})]})]})]}),e.jsx(dt,{}),m&&e.jsx("div",{style:{marginTop:"var(--v2-pad-5)",paddingTop:"var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)",maxWidth:640},children:e.jsx(se,{initialUrl:t.startUrl,isRunning:c,onCrawl:h=>f(h,!1),onVerifyFixes:h=>f(h,!0),onAuditThisPage:b})})]})}function gt(t,a){try{return new URL(t).origin===new URL(a).origin}catch{return!1}}function mt({grade:t}){const a={A:"var(--v2-grade-a)",B:"var(--v2-grade-b)",C:"var(--v2-grade-c)",D:"var(--v2-grade-d)",F:"var(--v2-grade-f)"};return e.jsx("div",{"aria-label":`Grade ${t}`,role:"img",style:{display:"flex",alignItems:"center",justifyContent:"center",minWidth:140},children:e.jsx("span",{className:"v2-display",style:{fontSize:132,lineHeight:1,fontWeight:500,color:a[t],letterSpacing:"-0.04em",fontVariationSettings:'"opsz" 144'},children:t})})}function ft({openCount:t,reviewCount:a,verifiedCount:r,axeCount:n,walkthroughCount:s,autoCount:l}){return e.jsxs("dl",{style:{display:"flex",gap:"var(--v2-pad-4)",flexWrap:"wrap",margin:0,color:"var(--v2-ink-secondary)",fontSize:12},children:[e.jsx(L,{term:"open",value:t,tone:t>0?"attention":"neutral"}),e.jsx(L,{term:"review",value:a,tone:a>0?"review":"neutral"}),e.jsx(L,{term:"verified",value:r,tone:r>0?"positive":"neutral"}),e.jsx("span",{style:{color:"var(--v2-ink-faint)"},children:"·"}),e.jsx(L,{term:"axe",value:n,tone:"neutral"}),e.jsx(L,{term:"walkthrough",value:s,tone:"neutral"}),l>0&&e.jsx(L,{term:"auto-contrast",value:l,tone:"neutral"})]})}function L({term:t,value:a,tone:r}){const n={attention:"var(--v2-critical)",review:"var(--v2-needs-review)",positive:"var(--v2-verified)",neutral:"var(--v2-ink-secondary)"};return e.jsxs("div",{style:{display:"inline-flex",alignItems:"baseline",gap:6},children:[e.jsx("dt",{className:"v2-eyebrow",style:{display:"inline",margin:0,color:"var(--v2-ink-tertiary)"},children:t}),e.jsx("dd",{className:"v2-mono",style:{margin:0,fontWeight:600,fontSize:13,color:n[r],fontVariantNumeric:"tabular-nums"},children:a})]})}const yt=new Set(["2.4.3","2.1.2","2.4.7","1.3.2","1.4.11","2.5.3"]);function ue(t){return yt.has(t)}async function pe(t){var n,s;const a=w.getState();if(a.componentId&&((n=a.results[0])==null?void 0:n.pageUrl)===t)return a.componentId;const r=await he();return((s=r==null?void 0:r.find(l=>l.url===t))==null?void 0:s.componentId)??null}async function bt(t,a){var l;const r=w.getState(),n=[];if(r.componentId&&r.results.length>0){const o=(l=r.results[0])==null?void 0:l.pageUrl,i=a.find(c=>c.url===o);if(i){for(const c of r.results)for(const d of c.violations)d.ruleId===t&&d.target.selector===i.selector&&n.push({componentId:r.componentId,matchKey:d.matchKey});if(n.length>0)return n}}const s=await he()??[];for(const o of a){const i=s.find(c=>c.url===o.url);if(i)for(const c of i.results)for(const d of c.violations)d.ruleId===t&&d.target.selector===o.selector&&n.push({componentId:i.componentId,matchKey:d.matchKey})}return n}function xt({row:t}){return e.jsxs("details",{style:{background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:6,overflow:"hidden"},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"var(--v2-pad-3) var(--v2-pad-4)",listStyle:"none",display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-3)"},children:[e.jsx(kt,{row:t}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(wt,{row:t}),e.jsx(jt,{row:t})]}),e.jsx(St,{})]}),e.jsx("div",{style:{padding:"0 var(--v2-pad-4) var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)"},children:e.jsx(Ct,{row:t})})]})}function kt({row:t}){if(t.kind==="walkthrough-ack")return e.jsx("span",{className:"v2-chip v2-chip-verified","aria-label":"Status: human verified",children:"verified"});if(t.kind==="needs-review")return e.jsx("span",{className:"v2-chip v2-chip-review","aria-label":"Status: needs human review",children:"review"});if(t.kind==="auto-contrast")return e.jsx("span",{className:"v2-chip v2-chip-serious","aria-label":"Severity: serious, auto-resolved by pixel sampler",title:"Empirical pixel-contrast measurement, not an axe-confirmed violation. Human verification recommended.",children:"auto · serious"});if(t.kind==="walkthrough-fail")return e.jsx("span",{className:t.verdict==="fail"?"v2-chip v2-chip-serious":"v2-chip v2-chip-moderate","aria-label":`Severity: ${t.verdict}`,children:t.verdict});const a={critical:"v2-chip-critical",serious:"v2-chip-serious",moderate:"v2-chip-moderate",minor:"v2-chip-minor"};return e.jsx("span",{className:`v2-chip ${a[t.impact]}`,"aria-label":`Severity: ${t.impact}`,children:t.impact})}function wt({row:t}){const a=t.kind==="walkthrough-fail"||t.kind==="walkthrough-ack"||t.kind==="needs-review"||t.kind==="axe"||t.kind==="auto-contrast"?t.criterion:null,r=t.kind==="walkthrough-fail"?`AI walkthrough ${t.verdict} on this criterion.`:t.kind==="walkthrough-ack"?"Human-verified by an auditor.":t.kind==="needs-review"?t.description:t.kind==="auto-contrast"?"Empirical contrast measurement fell below threshold.":t.description;return e.jsxs("p",{style:{margin:0,marginBottom:4,color:"var(--v2-ink-primary)",fontSize:13,fontWeight:500,lineHeight:1.4},children:[a&&e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)",marginRight:8},children:["WCAG ",a]}),r]})}function jt({row:t}){const a=t.kind==="axe"||t.kind==="needs-review"?t.pages.length:1,r=t.kind==="axe"||t.kind==="needs-review"||t.kind==="auto-contrast"?t.selector:null,n=t.kind==="walkthrough-fail"||t.kind==="walkthrough-ack"||t.kind==="auto-contrast"?t.pageUrl:null;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[r&&e.jsx("code",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",background:"var(--v2-bg-elev-2)",padding:"2px 6px",borderRadius:2,wordBreak:"break-all"},children:r}),n&&e.jsx("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-tertiary)",wordBreak:"break-all"},children:n}),a>1&&e.jsxs("span",{className:"v2-eyebrow",style:{marginLeft:"auto"},children:["on ",a," pages"]})]})}function St(){return e.jsx("span",{"aria-hidden":"true",style:{color:"var(--v2-ink-tertiary)",fontFamily:"var(--v2-mono)",fontSize:12,marginLeft:8,marginTop:2},children:"⏵"})}function Ct({row:t}){return t.kind==="walkthrough-fail"?e.jsx(Rt,{row:t}):t.kind==="walkthrough-ack"?e.jsx(It,{row:t}):t.kind==="needs-review"?e.jsx(At,{row:t}):t.kind==="auto-contrast"?e.jsx(Tt,{row:t}):e.jsx(Nt,{row:t})}function Tt({row:t}){const[a,r]=p.useState(!1),[n,s]=p.useState(!1),[l,o]=p.useState(""),[i,c]=p.useState(!1),[d,y]=p.useState(!1),[j,m]=p.useState(null),k=ge(t.ruleId);async function f(){if(c(!0),m(null),!l.trim()){m("Note is required — explain why the empirical contrast measurement is wrong, or why this element is acceptable in context."),c(!1);return}try{const u=(await ve(t.pageUrl)).find(S=>S.ruleId===t.ruleId&&S.selector===t.selector),g={pageUrl:t.pageUrl,ruleId:t.ruleId,selector:t.selector,verdict:"pass",reasoning:`Human override: ${l.trim()}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-BR7yhaX2.js","assets/scheduled-audit-runner-BB7YtjU4.js","assets/diff-DA41zYPc.js","assets/crash-reporter-Bu2p8K-p.js","assets/ai-usage-log-BX3L6bKl.js"])))=>i.map(i=>d[i]);
2
+ import"./modulepreload-polyfill-B5Qt9EMX.js";import{j as e,r as p,c as we,R as je}from"./styles-Cn731SYD.js";import{u as w,c as Se,a as Ce,l as oe,s as Te,w as Re,r as Ie,b as Ae,d as Ne,p as Ee,e as Ue,E as ze,A as Fe}from"./ErrorBoundary-D1JAy1Pn.js";import{l as De,a as Pe,b as $e,c as J,d as We,g as ve,e as Le,f as Oe,W as He,r as Me,s as Be,h as Ve,i as he,j as ge,k as _e,m as Ge,n as Ke,o as qe,p as Ye}from"./scheduled-audit-runner-BB7YtjU4.js";import{s as D,r as Ze,i as Qe}from"./crash-reporter-Bu2p8K-p.js";import{B as X}from"./ai-usage-log-BX3L6bKl.js";import{_}from"./diff-DA41zYPc.js";import{copyAiFixerPrompt as Xe}from"./copy-ai-fixer-prompt-Br53Kw8o.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./design-system-audit-DpxJrxnb.js";function se({initialUrl:t,isRunning:a,onCrawl:r,onVerifyFixes:n,onAuditThisPage:s}){const[l,o]=p.useState(t),[i,c]=p.useState(25),[d,y]=p.useState(""),[j,m]=p.useState(""),[k,f]=p.useState(!1),[b,u]=p.useState(X),[g,S]=p.useState(X[0].id),[v,h]=p.useState(null);p.useEffect(()=>{t&&!l&&o(t)},[t]),p.useEffect(()=>{let C=!1;return Promise.all([D({type:"SETTINGS_GET",key:"matrixPresets"}),D({type:"SETTINGS_GET",key:"activePresetId"})]).then(([I,A])=>{if(C)return;const U=Array.isArray(I.data)?I.data:null;u(U&&U.length>0?U:X),typeof A.data=="string"&&S(A.data)}),()=>{C=!0}},[]);function x(C){const I=b.find(A=>A.id===C);I&&(S(C),D({type:"SETTINGS_SET",key:"activePresetId",value:C}),D({type:"SETTINGS_SET",key:"stateMatrix",value:I.matrix}))}function T(){h(null);for(const[C,I]of[["Include",d.trim()],["Exclude",j.trim()]])if(I)try{new RegExp(I)}catch(A){return h(`${C} regex invalid: ${A instanceof Error?A.message:String(A)}`),!1}return!0}function E(C){if(!T())return;const I={startUrl:l.trim(),maxPages:i,includeRegex:d.trim(),excludeRegex:j.trim()};C&&n?n(I):r(I)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-3)",textAlign:"left"},children:[e.jsx(M,{label:"Start URL",children:e.jsx("input",{type:"url",value:l,onChange:C=>o(C.target.value),placeholder:"https://yoursite.com",disabled:a,className:"v2-mono",style:B})}),e.jsx(M,{label:"Max pages",hint:"1–200. Each page runs the full pipeline you configured.",children:e.jsx("input",{type:"number",min:1,max:200,value:i,onChange:C=>c(Math.min(200,Math.max(1,parseInt(C.target.value,10)||25))),disabled:a,className:"v2-mono",style:{...B,maxWidth:100}})}),e.jsx(M,{label:"Audit depth",hint:"State matrix preset applied to every crawled page.",children:e.jsx("select",{value:g,onChange:C=>x(C.target.value),disabled:a,style:B,children:b.map(C=>e.jsx("option",{value:C.id,children:C.name},C.id))})}),e.jsx("button",{type:"button",onClick:()=>f(C=>!C),className:"v2-eyebrow",style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-ink-secondary)",textAlign:"left",alignSelf:"flex-start"},children:k?"− hide advanced filters":"+ show URL filters (include / exclude)"}),k&&e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Include only URLs matching",hint:"Optional regex. Empty = no filter.",children:e.jsx("input",{type:"text",value:d,onChange:C=>y(C.target.value),placeholder:"^https://example\\.com/products/",disabled:a,className:"v2-mono",style:B})}),e.jsx(M,{label:"Exclude URLs matching",hint:"Optional regex. Useful for /admin or /login while logged in.",children:e.jsx("input",{type:"text",value:j,onChange:C=>m(C.target.value),placeholder:"/admin|/dashboard|/login",disabled:a,className:"v2-mono",style:B})})]}),v&&e.jsx("p",{role:"alert",style:{color:"var(--v2-critical)",fontSize:12,margin:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",border:"1px solid var(--v2-critical)",borderRadius:4,background:"rgba(207, 44, 44, 0.06)"},children:v}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap",marginTop:"var(--v2-pad-2)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",disabled:a||!l.trim(),onClick:()=>E(!1),children:a?"Crawling…":"Crawl whole site"}),n&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",disabled:a||!l.trim(),onClick:()=>E(!0),title:"Skip walkthroughs that previously passed or were human-verified",children:"Verify fixes only"}),s&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",disabled:a,onClick:s,title:"Single-page audit on the active tab (no crawl)",children:"Just this page"})]})]})}function Je(){var c;const t=w(d=>d.siteCrawlProgress),a=w(d=>d.siteCrawlStatus),r=w(d=>d.progress),n=w(d=>d.aiProgress);function s(){D({type:"CANCEL_SITE_CRAWL"})}if(a!=="running")return null;const l=t?Math.min(100,Math.max(0,t.current/Math.max(1,t.total)*100)):0,o=r?Math.min(100,Math.max(0,r.current/Math.max(1,r.total)*100)):0,i=r!=null&&r.currentState?[r.currentState.pseudoState,r.currentState.theme&&r.currentState.theme!=="light"?r.currentState.theme:null,r.currentState.direction&&r.currentState.direction!=="ltr"?r.currentState.direction:null,(c=r.currentState.breakpoint)!=null&&c.id&&r.currentState.breakpoint.id!=="desktop"?r.currentState.breakpoint.id:null].filter(Boolean).join(" · "):"";return e.jsxs("div",{role:"status","aria-live":"polite",style:{background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:6,padding:"var(--v2-pad-4)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-3)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:"crawling…"}),e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:12,fontWeight:600,color:"var(--v2-ink-primary)",fontVariantNumeric:"tabular-nums"},children:t?`${t.current} / ${t.total}`:"…"})]}),e.jsx("div",{role:"progressbar","aria-valuenow":(t==null?void 0:t.current)??0,"aria-valuemin":0,"aria-valuemax":(t==null?void 0:t.total)??1,"aria-label":"Crawl progress",style:{height:8,background:"var(--v2-bg-elev-2)",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,background:"var(--v2-action)",transition:"width 240ms ease"}})}),(t==null?void 0:t.url)&&e.jsxs("div",{children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:4},children:"current page"}),e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-secondary)",wordBreak:"break-all"},children:t.url})]}),(t==null?void 0:t.lastViolations)!==void 0&&t.lastViolations>0&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",fontVariantNumeric:"tabular-nums"},children:["last page: ",t.lastViolations," axe violation",t.lastViolations===1?"":"s"]}),r&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)",paddingTop:"var(--v2-pad-3)",borderTop:"1px solid var(--v2-border)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsx("span",{className:"v2-eyebrow",style:{color:"var(--v2-ink-tertiary)"},children:"this page · auditing"}),e.jsxs("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.current," / ",r.total]})]}),e.jsx("div",{role:"progressbar","aria-valuenow":r.current,"aria-valuemin":0,"aria-valuemax":r.total,"aria-label":"Current page audit progress",style:{height:4,background:"var(--v2-bg-elev-2)",borderRadius:2,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${o}%`,background:"var(--v2-ink-tertiary)",transition:"width 240ms ease"}})}),i&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)"},children:["state: ",i]}),n&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-needs-review)",fontVariantNumeric:"tabular-nums"},children:["AI: ",n.current," / ",n.total," · ",n.currentCheckLabel,n.candidatesTotal&&n.candidatesTotal>0?` (${n.candidatesDone??0}/${n.candidatesTotal})`:""]})]}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:s,children:"Cancel crawl"})})]})}function et(){const t=w(c=>c.status),a=w(c=>c.progress),r=w(c=>c.aiProgress);if(t!=="running")return null;const n=a?a.current>=a.total:!1,s=a?n?"Running deep analyzers…":`Auditing… ${a.current} / ${a.total}`:"Starting audit…",l=a?n?"reading order · tab order · typography · CSS vars · AI candidates":tt(a.currentState):"Loading axe + DOM analyzers",o=a?n?100:a.current/Math.max(1,a.total)*100:0;function i(){D({type:"CANCEL_AUDIT"})}return e.jsxs("div",{role:"status","aria-live":"polite",style:{background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:6,padding:"var(--v2-pad-4)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-4)"},children:[e.jsx(le,{label:s,detail:l,pct:o,valuenow:a?Math.min(a.current,a.total):0,valuemax:a?a.total:1,ariaLabel:a?n?"Running deep analyzers: reading order, tab order, typography, custom properties, AI candidates.":`Audit progress: ${a.current} of ${a.total} states`:"Audit starting",fillColor:"var(--v2-action)"}),r&&e.jsx(le,{label:`AI augmentation… ${r.current} / ${r.total}`,detail:r.candidatesTotal&&r.candidatesTotal>0?`${r.currentCheckLabel} (${r.candidatesDone??0}/${r.candidatesTotal})`:r.currentCheckLabel,pct:r.current/Math.max(1,r.total)*100,valuenow:r.current,valuemax:r.total,ariaLabel:`AI augmentation: ${r.current} of ${r.total} checks. ${r.currentCheckLabel}`,fillColor:"var(--v2-needs-review)"}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:i,children:"Cancel audit"})})]})}function le({label:t,detail:a,pct:r,valuenow:n,valuemax:s,ariaLabel:l,fillColor:o}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:e.jsx("span",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:t})}),e.jsx("div",{role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":s,"aria-label":l,style:{height:6,background:"var(--v2-bg-elev-2)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,background:o,transition:"width 240ms ease"}})}),a&&e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-secondary)",wordBreak:"break-all"},children:a})]})}function tt(t){if(!t)return"";const a=[t.pseudoState];return t.theme&&t.theme!=="light"&&a.push(t.theme),t.direction&&t.direction!=="ltr"&&a.push(t.direction),a.join(" · ")}function M({label:t,hint:a,children:r}){return e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("span",{className:"v2-eyebrow",style:{color:"var(--v2-ink-secondary)"},children:t}),r,a&&e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:a})]})}const B={fontFamily:"var(--v2-body)",fontSize:12,padding:"8px 10px",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,outline:"none"};function Y(){const t=w(c=>c.siteCrawlReport),a=w(c=>c.results),r=w(c=>c.delta),n=w(c=>c.componentId),s=w(c=>c.status),l=w(c=>c.siteCrawlStatus),[o,i]=p.useState({report:null,resolvedFails:[]});return p.useEffect(()=>{var j;let c=!1;async function d(m){return m.length===0?[]:(await Promise.all(m.map(f=>ve(f)))).flat().map(Le).map(Oe).filter(f=>f.verdict==="fail")}if(l==="running"||s==="running"){i({report:null,resolvedFails:[]});return}if(t)return(async()=>{const m=t.pages.map(f=>f.url),k=await d(m);c||i({report:t,resolvedFails:k})})(),()=>{c=!0};if(a.length===0||!n){i({report:null,resolvedFails:[]});return}const y=(j=a[0])==null?void 0:j.pageUrl;if(!y){i({report:null,resolvedFails:[]});return}return(async()=>{try{const[m,k,f,b,u]=await Promise.all([De([n]),Pe([n]),$e(n),J([n]),d([y])]),g=new Map([[n,m]]),S=new Map([[n,k]]),v=new Map([[n,f]]),h=new Map([[n,b]]),x=new Date().toISOString(),T=We(y,[{url:y,results:a,delta:r,componentId:n,durationMs:0}],x,x,0,g,S,v,h);c||i({report:T,resolvedFails:u})}catch(m){console.warn("[v2] synthesize single-page report failed",m),c||i({report:null,resolvedFails:[]})}})(),()=>{c=!0}},[t,a,r,n,s,l]),o}const rt={"1.2.1":{howToCheck:"Confirm any audio-only or video-only media has a text alternative (transcript, captions, descriptive title). If the page has no audio or video at all, mark N/A with that note."},"1.2.2":{howToCheck:"For every prerecorded video with audio, verify captions are present and synchronized. Open each video, turn captions on, and spot-check 10–15 seconds. If the page has no video with audio, mark N/A."},"1.2.3":{howToCheck:"For every prerecorded video, confirm an audio description track OR a full text alternative is available. If no prerecorded video, mark N/A."},"1.2.4":{howToCheck:"For any live streaming media with audio, verify live captions are provided. If the page has no live media, mark N/A."},"1.2.5":{howToCheck:"For prerecorded video, confirm an audio description track is provided (separate from the main audio). If no prerecorded video, mark N/A."},"1.3.1":{howToCheck:"Inspect headings, lists, tables, and form labels. Programmatic structure should match visual structure: h1→h2→h3, real <ul>/<ol>, real <table> with <th>, every form field has a <label> or aria-label. Tabbing through the page should reveal the same structure a screen reader would announce."},"1.4.3":{howToCheck:"Open the inconclusive elements. Most commonly axe failed because the background is transparent, a gradient, or an image. Identify the EFFECTIVE background color a user sees and compute the contrast ratio against the foreground; needs ≥4.5:1 for normal text, ≥3:1 for large text (18pt+ or 14pt+ bold)."},"1.4.4":{howToCheck:"Zoom the page to 200% (Ctrl+Plus four times in most browsers). Verify all content remains visible and functional — no overlapping text, no clipped buttons, no horizontal scrollbar at 1280×1024 viewport."},"1.4.10":{howToCheck:"Resize the browser to 320 CSS px wide (or use devtools mobile emulation at 320×256). Confirm content reflows without two-dimensional scrolling — vertical scroll only, no horizontal scroll except for genuinely two-dimensional content (data tables, images, complex maps)."},"1.4.11":{howToCheck:"Verify every UI component's boundary (button borders, form field outlines, focus indicators) has ≥3:1 contrast against its adjacent color. Same for meaningful graphics (icons, infographic elements). Decorative graphics are exempt."},"1.4.12":{howToCheck:"Apply this CSS via devtools and confirm no content is clipped or hidden: line-height: 1.5; letter-spacing: 0.12em; word-spacing: 0.16em; paragraph spacing 2× font-size. If layout breaks, the page fails."},"2.1.1":{howToCheck:"Tab through every interactive element. Every button, link, form field, and custom control must be reachable AND operable via keyboard alone (Enter, Space, arrow keys as appropriate). Mouse-only affordances fail."},"2.1.2":{howToCheck:"Tab into every interactive component. Confirm Tab/Shift+Tab moves focus out. No element should trap focus (typical offenders: poorly-coded modals, embedded players)."},"2.4.1":{howToCheck:"Verify a skip-to-main-content link exists (typically first focusable element, visible on focus) OR landmark regions (<main>, <nav>) are present. Either lets keyboard users bypass repeated nav."},"2.4.3":{howToCheck:"Tab through the page in source order. Focus must move in a sequence that preserves meaning — usually left-to-right, top-to-bottom. Particularly check skip links and modals."},"2.4.4":{howToCheck:`Read each link's text WITH its surrounding context (parent paragraph, list item, table cell). The combined text must convey where the link goes. "Click here" alone is ambiguous; "Click here to read our pricing" passes when context is included.`},"2.4.5":{howToCheck:"Confirm at least two ways to find a given page exist: site search, sitemap, A-Z index, table of contents, or persistent navigation. Single-page sites and process-step pages (checkout) are exempt."},"2.4.6":{howToCheck:"Read each heading and form-field label in isolation. Each should describe the topic of its section or the purpose of its field WITHOUT requiring the surrounding content to make sense."},"2.4.7":{howToCheck:"Tab through every focusable element. The current focus must be VISUALLY distinct from neighbors — an outline, a box-shadow, a background change. The default browser outline counts; CSS that removes it without replacing fails."},"2.5.3":{howToCheck:"For every control with both a visible text label and an accessible name (aria-label, alt, etc.), verify the visible label appears (verbatim, or as a substring) in the accessible name. Otherwise voice-control users can't target it by saying its visible label."},"3.1.1":{howToCheck:'View source. Confirm <html lang="..."> is present with a valid language tag (e.g. "en", "en-US", "fr").'},"3.1.2":{howToCheck:"Find any passage of foreign-language text on the page (a quote, a borrowed phrase, an entire alternate-language section). Confirm it's wrapped with the appropriate lang attribute. If the entire page is in one language, mark N/A."},"3.2.1":{howToCheck:"Tab to each focusable element. Confirm receiving focus alone does NOT trigger a context change: no navigation, no modal opening, no form submission. Action only on explicit activation (click, Enter)."},"3.2.2":{howToCheck:"In each form, change one input value (type in a field, check a checkbox, change a select). Confirm this does NOT submit the form, navigate the page, or open a modal without first warning the user."},"3.2.3":{howToCheck:"Open at least three different pages on the site. Confirm the main navigation, footer navigation, and any breadcrumb appear in the SAME relative order on each. Reordering items between pages is a fail; adding or removing items based on auth state is acceptable."},"3.2.4":{howToCheck:"Identify a few common functional elements on the site (e.g., the search input, login button, cart button, social-share icons). Verify each appears with the SAME accessible name, label, and icon on every page where it appears. Inconsistent naming is the fail mode."},"3.3.1":{howToCheck:"Submit a form with invalid data. Confirm errors are identified in text (not just color), describe what went wrong, and ideally indicate which field. Browser-default validation messages count."},"3.3.2":{howToCheck:"Every form input should have a visible label (or visible placeholder + accessible name combination) AND an instruction when format matters (date format, password rules). Placeholder-only labels fail because they disappear on focus."},"3.3.3":{howToCheck:'Submit a form with invalid data. Confirm the error message describes HOW to fix the problem (e.g., "Email must contain @" not just "Invalid email"). Exempts cases where suggestion would compromise security (password rules).'},"3.3.4":{howToCheck:"For any form that submits a legal commitment, financial transaction, or modifies/deletes user data: confirm submissions are reversible, validated for errors before commit, OR show a confirmation step before final commit."},"4.1.3":{howToCheck:'Trigger any status update (form submitted, item added to cart, search completed, error appeared). Confirm screen-reader users receive the update via an aria-live region or role="status"/"alert" — without moving focus to the update.'}};function at(t){return rt[t]??null}const ce="aiConfig";function nt(t){return`https://www.w3.org/WAI/WCAG22/Understanding/${t}`}const it=new Map(He.map(t=>[t.id,t]));async function ot(t){const r=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0];if(!(r!=null&&r.id))return{ok:!1,error:"No active tab."};const n=r.id,s=q(t.pageUrl),l=q(r.url??"");if(!(r.url===t.pageUrl)){try{await chrome.tabs.update(n,{url:t.pageUrl})}catch(y){return{ok:!1,error:y instanceof Error?y.message:"Failed to navigate tab."}}if(!await st(n,t.pageUrl,12e3))return{ok:!1,error:"Page did not finish loading in time."}}if(!t.selector)return{ok:!0,found:!1,matchCount:0};const i=[120,250,500,800,1200,800];let c="";for(let d=0;d<=i.length;d++)try{const y=await Ze(n,{type:"HIGHLIGHT_SHOW_REQUEST",tabId:n,selector:t.selector,scrollIntoView:!0});return{ok:!0,found:y.found,matchCount:y.matchCount}}catch(y){const j=y instanceof Error?y.message:String(y);if(c=j,!(j.includes("Could not establish connection")||j.includes("Receiving end does not exist")))break;const k=i[d];if(k===void 0)break;await new Promise(f=>setTimeout(f,k))}return{ok:!1,error:s!==l?`Navigated to ${t.pageUrl} — but the in-page highlighter couldn't attach (${c}).`:c}}function q(t){try{return new URL(t).origin}catch{return""}}function st(t,a,r){return new Promise(n=>{let s=!1;const l=setTimeout(()=>{s||(s=!0,chrome.tabs.onUpdated.removeListener(o),n(!1))},r);function o(i,c,d){if(i!==t||c.status!=="complete")return;const y=q(d.url??""),j=q(a);j&&y&&y!==j||s||(s=!0,clearTimeout(l),chrome.tabs.onUpdated.removeListener(o),n(!0))}chrome.tabs.onUpdated.addListener(o)})}function de(t){try{const a=new URL(t),r=a.pathname+a.search+a.hash||"/";return r.length>60?r.slice(0,57)+"...":r}catch{return t}}function lt(t){return t.length>70?t.slice(0,67)+"...":t}function ct(t){try{const a=new Date(t),r=new Date,n=a.toDateString()===r.toDateString(),s=new Date(r);s.setDate(s.getDate()-1);const l=a.toDateString()===s.toDateString(),o=a.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n?`today, ${o}`:l?`yesterday, ${o}`:`${a.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${o}`}catch{return t}}function dt(){const{report:t}=Y(),a=w(u=>u.componentId),r=w(u=>u.siteCrawlReport),[n,s]=p.useState(!1),[l,o]=p.useState(new Set),[i,c]=p.useState(0),d=p.useRef(""),[y,j]=p.useState(!1),[m,k]=p.useState("claude-sonnet-4-6");p.useEffect(()=>{(async()=>{const g=(await chrome.storage.local.get(ce))[ce];d.current=(g==null?void 0:g.apiKey)??"",j(!!(g!=null&&g.apiKey)),g!=null&&g.model&&k(g.model)})()},[]);const f=vt(a,r,(t==null?void 0:t.pages.map(u=>u.url))??[]);if(p.useEffect(()=>{let u=!1;return(async()=>{if(!f){u||o(new Set);return}try{const g=await J([f]);if(u)return;o(new Set(g.map(S=>S.criterionId)))}catch{u||o(new Set)}})(),()=>{u=!0}},[f,i]),!t)return null;const b=t.blockingCriteria;return!b||b.length===0||t.siteGrade!=="A"&&t.siteGrade!=="B"?null:e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg-elev)"},children:[e.jsxs("button",{type:"button",onClick:()=>s(u=>!u),"aria-expanded":n,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-ink-primary)",fontSize:13,fontWeight:500,textAlign:"left",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--v2-pad-3)",width:"100%"},children:[e.jsx("span",{children:(()=>{const u=b.length,g=b.filter(v=>l.has(v.criterionId)).length,S=u-g;return g===0?`${u} criteri${u===1?"on":"a"} need${u===1?"s":""} your judgment`:S===0?`${u} criteri${u===1?"on":"a"} verified — re-crawl to lift the grade`:`${g} of ${u} verified · ${S} remaining`})()}),e.jsx("span",{"aria-hidden":"true",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:n?"▾":"▸"})]}),n&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:"Each criterion below has no affirmative evidence yet. Mark it Pass / N/A / Fail with a note about what you checked. Verdicts persist as forensic evidence and contribute to the audit's chain of custody."}),b.map(u=>e.jsx(ut,{criterionId:u.criterionId,title:u.title,state:u.state,evidence:u.evidence,targetComponentId:f,apiKeyRef:d,apiKeyPresent:y,model:m,onVerdictChange:()=>c(g=>g+1)},u.criterionId))]})]})}function ut({criterionId:t,title:a,state:r,evidence:n,targetComponentId:s,apiKeyRef:l,apiKeyPresent:o,model:i,onVerdictChange:c}){const[d,y]=p.useState(null),[j,m]=p.useState(""),[k,f]=p.useState(!1),[b,u]=p.useState(null),[g,S]=p.useState(null),[v,h]=p.useState(!0),[x,T]=p.useState(!1),[E,C]=p.useState(null),[I,A]=p.useState(null),[U,Q]=p.useState(null),$={untested:"No evidence — automation has no rule for this criterion",inconclusive:"Inconclusive — axe / AI ran but couldn't determine",failing:"Failing — at least one fail signal across the audit"};p.useEffect(()=>{let R=!1;return(async()=>{if(!s){R||h(!1);return}try{const P=(await J([s])).find(H=>H.criterionId===t);if(R)return;S(P?{verdict:P.verdict,note:P.note,verifiedAt:P.verifiedAt}:null)}catch{R||S(null)}finally{R||h(!1)}})(),()=>{R=!0}},[t,s]);async function be(){if(s){f(!0),u(null);try{await Me(s,t),S(null),c()}catch(R){u(R instanceof Error?R.message:String(R))}finally{f(!1)}}}const W=it.get(t),ae=W==null?void 0:W.shortDescription,ne=W==null?void 0:W.understandingSlug,ie=at(t);async function xe(){if(!l.current){A("Set an Anthropic API key in extension Options first.");return}T(!0),A(null);try{const z=`Explain WCAG ${t} (${a}) in the context of this audit. State: ${r==="untested"?"no automated evidence (no axe rule covers it)":r==="inconclusive"?"inconclusive — axe or AI ran but could not produce a definitive pass/fail":"failing — at least one fail signal across the audit"}. Cover: (1) what the criterion actually requires in plain language, (2) common failure modes a developer should look for, (3) how to manually verify it on this site, (4) when to mark N/A vs Pass vs Fail. Keep it tight — 5–8 sentences total.`,P=await Se({apiKey:l.current,model:i,messages:[{role:"user",content:z}],system:`You are wcagcheckr's WCAG explainer. The user is sitting in front of a forensic-grade audit tool and needs to record a manual verdict on a criterion the automation can't decide. Be precise. No marketing tone. When citing a verification step, name the exact device/browser/devtool action (e.g., "Resize Chrome devtools to 320 CSS px").`,maxTokens:600,maxCostUsd:.05});C(P.text),Q(P.costUsd)}catch(R){A(R instanceof Error?R.message:String(R))}finally{T(!1)}}async function ke(R){if(!s){u("No componentId available — re-run an audit first.");return}if(!j.trim()){u("Note is required — describe what you checked and why this verdict applies.");return}f(!0),u(null);const z=new Date().toISOString(),P=j.trim();try{await Be({componentId:s,criterionId:t,verdict:R,note:P,verifiedAt:z}),S({verdict:R,note:P,verifiedAt:z}),y(null),m(""),c()}catch(H){u(H instanceof Error?H.message:String(H))}finally{f(!1)}}if(g){const z={pass:{bg:"rgba(15, 143, 94, 0.08)",border:"var(--v2-verified)",ink:"var(--v2-verified)",label:"Pass"},na:{bg:"rgba(100, 116, 139, 0.10)",border:"var(--v2-border-strong)",ink:"var(--v2-ink-secondary)",label:"N/A"},fail:{bg:"rgba(207, 44, 44, 0.06)",border:"var(--v2-critical)",ink:"var(--v2-critical)",label:"Fail"}}[g.verdict];return e.jsxs("div",{role:"status",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:z.bg,border:`1px solid ${z.border}`,borderRadius:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)"},children:["WCAG ",t]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:a}),e.jsxs("span",{className:"v2-mono",style:{fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"2px 6px",borderRadius:3,color:"var(--v2-bg)",background:z.ink},children:["✓ ",z.label]})]}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:g.note}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:10,color:"var(--v2-ink-tertiary)"},children:["verified ",ct(g.verifiedAt)]}),e.jsx("button",{type:"button",onClick:be,disabled:k,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:k?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:k?"Un-marking…":"Un-mark this criterion"}),b&&e.jsx("span",{role:"alert",style:{fontSize:11,color:"var(--v2-critical)"},children:b})]})]})}return v?e.jsx("div",{"aria-hidden":"true",style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4,minHeight:56}}):e.jsxs("div",{style:{padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)"},children:["WCAG ",t]}),e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:a})]}),ae&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:ae}),e.jsx("p",{style:{margin:"6px 0 0",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:$[r]}),ie&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,fontSize:10},children:"how to check"}),e.jsx("p",{style:{margin:"2px 0 0",fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.5},children:ie.howToCheck})]}),n.length>0&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)"},children:[e.jsxs("p",{className:"v2-eyebrow",style:{margin:0,fontSize:10},children:["suspect locations · ",n.length]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:"4px 0 0",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:n.map((R,z)=>e.jsx(pt,{ev:R},`${R.pageUrl}::${R.selector??""}::${z}`))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap",alignItems:"center"},children:[ne&&e.jsx("a",{href:nt(ne),target:"_blank",rel:"noreferrer noopener",style:{fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:"Read W3C guidance ↗"}),o&&e.jsx("button",{type:"button",onClick:xe,disabled:x,style:{appearance:"none",background:"none",border:"none",padding:0,cursor:x?"wait":"pointer",fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textUnderlineOffset:2},children:x?"Explaining…":E?"Re-explain with AI":"Explain with AI ↗"})]}),(E||I)&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:4},children:[E&&e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-primary)",lineHeight:1.55,whiteSpace:"pre-wrap"},children:E}),I&&e.jsx("p",{role:"alert",style:{margin:0,fontSize:11,color:"var(--v2-critical)"},children:I}),U!==null&&e.jsxs("p",{className:"v2-mono",style:{margin:"4px 0 0",fontSize:10,color:"var(--v2-ink-tertiary)"},children:["$",U.toFixed(4)," · ",i]})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-3)",flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{y(d==="pass"?null:"pass"),u(null)},"aria-expanded":d==="pass",children:d==="pass"?"Cancel":"Mark Pass"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{y(d==="na"?null:"na"),u(null)},"aria-expanded":d==="na",children:d==="na"?"Cancel":"Mark N/A"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{y(d==="fail"?null:"fail"),u(null)},"aria-expanded":d==="fail",children:d==="fail"?"Cancel":"Mark Fail"})]}),d&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0},children:"verification note · required"}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:d==="na"?'Describe why this criterion does not apply to this audit (e.g., "no audio/video content on this page").':d==="pass"?'Describe what you checked to verify pass (e.g., "manually browsed page in keyboard-only mode, no focus traps").':'Describe the failure (e.g., "modal does not return focus to the trigger when closed").'}),e.jsx("textarea",{value:j,onChange:R=>m(R.target.value),rows:3,style:{width:"100%",fontFamily:"var(--v2-body)",fontSize:12,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,resize:"vertical",minHeight:56},placeholder:d==="na"?"e.g., No audio or video content present on this page; criterion is not applicable.":d==="pass"?"e.g., Manually verified — page resizes correctly at 200% zoom without horizontal scroll.":"e.g., Focus visible indicator missing on dark-mode buttons."}),b&&e.jsx("p",{role:"alert",style:{margin:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(207, 44, 44, 0.06)",border:"1px solid var(--v2-critical)",borderRadius:4,color:"var(--v2-critical)",fontSize:11},children:b}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>ke(d),disabled:k||!j.trim(),children:k?"Saving…":`Confirm ${d.toUpperCase()}`})})]})]})}function pt({ev:t}){const[a,r]=p.useState(!1),[n,s]=p.useState(null);async function l(){r(!0),s(null);try{const o=await ot({pageUrl:t.pageUrl,selector:t.selector});o.ok?t.selector?o.found?s({kind:"ok",text:`Element highlighted (${o.matchCount} match${o.matchCount===1?"":"es"}).`}):s({kind:"warn",text:"Page opened but the selector matched zero elements — DOM may have changed since the audit."}):s({kind:"ok",text:`Opened ${de(t.pageUrl)} — no element selector available; verify manually.`}):s({kind:"err",text:o.error})}finally{r(!1)}}return e.jsxs("li",{style:{padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:4,display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsx("span",{className:"v2-mono",title:t.pageUrl,style:{fontSize:11,color:"var(--v2-ink-secondary)",overflowWrap:"anywhere"},children:de(t.pageUrl)}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:l,disabled:a,children:a?"Opening…":t.selector?"Show on page":"Open page"})]}),t.selector&&e.jsx("span",{className:"v2-mono",title:t.selector,style:{fontSize:11,color:"var(--v2-ink-tertiary)",overflowWrap:"anywhere"},children:lt(t.selector)}),t.notes&&e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:t.notes}),n&&e.jsx("span",{role:n.kind==="err"?"alert":"status",style:{fontSize:11,color:n.kind==="err"?"var(--v2-critical)":n.kind==="warn"?"var(--v2-needs-review)":"var(--v2-verified)"},children:n.text})]})}function vt(t,a,r){return t||(a!=null&&a.startUrl?a.startUrl:r[0]?r[0]:null)}function ht(){const{report:t,resolvedFails:a}=Y(),r=w(h=>h.siteCrawlReport),n=w(h=>h.siteCrawlStatus),s=w(h=>h.siteCrawlError),l=w(h=>h.status),o=n==="running",c=o||l==="running"&&!o,d=!!t&&!r,[y,j]=p.useState(null);p.useEffect(()=>{let h=!1;return chrome.tabs.query({active:!0,currentWindow:!0}).then(x=>{var T;h||j(((T=x[0])==null?void 0:T.url)??null)}),()=>{h=!0}},[]);const[m,k]=p.useState(!1);function f(h,x=!1){h.startUrl&&(w.getState().setSiteCrawlStatus("running"),w.getState().setSiteCrawlReport(null),w.getState().setSiteCrawlError(null),oe({type:"START_SITE_CRAWL",startUrl:h.startUrl,maxPages:h.maxPages,...h.includeRegex?{includeRegex:h.includeRegex}:{},...h.excludeRegex?{excludeRegex:h.excludeRegex}:{},...x?{verifyFixesOnly:!0}:{}}))}function b(){oe({type:"START_AUDIT",mode:"full-page"}),w.getState().startNewScan()}if(c)return e.jsx("section",{"aria-label":"Audit in progress",style:{padding:"var(--v2-pad-5) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)"},children:o?e.jsx(Je,{}):e.jsx(et,{})});if(!t)return e.jsxs("section",{"aria-label":"No audit yet",style:{padding:"var(--v2-pad-6) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",maxWidth:640,margin:"0 auto"},children:[e.jsx("p",{className:"v2-eyebrow",style:{marginBottom:"var(--v2-pad-2)"},children:"new audit"}),e.jsx("h1",{className:"v2-display",style:{fontSize:28,fontWeight:500,letterSpacing:"-0.02em",color:"var(--v2-ink-primary)",margin:0,marginBottom:"var(--v2-pad-2)"},children:"Configure your crawl."}),s&&e.jsxs("div",{role:"alert",style:{marginBottom:"var(--v2-pad-4)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-critical)",borderRadius:4,background:"rgba(207, 44, 44, 0.06)",color:"var(--v2-critical)",fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:600,marginRight:6},children:"Last crawl failed:"}),s]}),e.jsx("p",{style:{color:"var(--v2-ink-secondary)",margin:0,marginBottom:"var(--v2-pad-5)",maxWidth:520},children:"The crawler follows internal links from the start URL, same-origin only. Each page runs your full audit pipeline (axe + DOM analyzers + AI walkthroughs). Findings appear below as a single unified list."}),e.jsx(se,{initialUrl:y??"",isRunning:c,onCrawl:h=>f(h,!1),onAuditThisPage:b})]});const u=a.length,g=(t.totalWalkthroughFindings??0)+t.totalUniqueViolations+u,S=(t.walkthroughAcknowledgements??[]).length,v=t.totalNeedsReview;return e.jsxs("section",{"aria-label":"Audit summary",style:{padding:"var(--v2-pad-6) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"var(--v2-pad-6)"},children:[e.jsx(mt,{grade:t.siteGrade}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",gap:"var(--v2-pad-3)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0},children:d?"page grade · single-page audit":`site grade · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"}`}),e.jsx("h1",{className:"v2-display",style:{fontSize:22,fontWeight:500,letterSpacing:"-0.01em",color:"var(--v2-ink-primary)",margin:0,lineHeight:1.25},children:(()=>{var T;const h=g+v,x=((T=t.blockingCriteria)==null?void 0:T.length)??0;return h===0&&x===0?"All clear — nothing open.":h===0&&x>0?`Visible findings clear — ${x} criteri${x===1?"on":"a"} still need${x===1?"s":""} your judgment.`:`${h} finding${h===1?"":"s"} to address.`})()}),e.jsx(ft,{openCount:g,reviewCount:v,verifiedCount:S,axeCount:t.totalUniqueViolations,walkthroughCount:t.totalWalkthroughFindings??0,autoCount:u}),y&&!gt(y,t.startUrl)&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",wordBreak:"break-all"},children:["Active tab: ",y]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-2)",flexWrap:"wrap"},children:[d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:b,title:"Re-audit the current page",children:"Re-audit this page"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>k(h=>!h),"aria-expanded":m,title:"Open crawl setup to audit the whole site instead",children:m?"Hide crawl options":"Crawl whole site"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:()=>f({startUrl:t.startUrl,maxPages:25,includeRegex:"",excludeRegex:""},!1),title:`Re-crawl ${t.startUrl} (same options)`,children:"Re-crawl"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:b,title:"Single-page audit of the active tab (no crawl)",children:"Just this page"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>f({startUrl:t.startUrl,maxPages:25,includeRegex:"",excludeRegex:""},!0),title:"Skip walkthroughs that previously passed or were human-verified",children:"Verify fixes only"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>k(h=>!h),"aria-expanded":m,children:m?"Hide options":"Adjust options"})]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{Ce(),w.getState().setSiteCrawlReport(null),w.getState().setSiteCrawlError(null),Ve(null).catch(()=>{})},title:"Wipe these results so you can start fresh",style:{marginLeft:"auto"},children:"Clear results"})]})]})]}),e.jsx(dt,{}),m&&e.jsx("div",{style:{marginTop:"var(--v2-pad-5)",paddingTop:"var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)",maxWidth:640},children:e.jsx(se,{initialUrl:t.startUrl,isRunning:c,onCrawl:h=>f(h,!1),onVerifyFixes:h=>f(h,!0),onAuditThisPage:b})})]})}function gt(t,a){try{return new URL(t).origin===new URL(a).origin}catch{return!1}}function mt({grade:t}){const a={A:"var(--v2-grade-a)",B:"var(--v2-grade-b)",C:"var(--v2-grade-c)",D:"var(--v2-grade-d)",F:"var(--v2-grade-f)"};return e.jsx("div",{"aria-label":`Grade ${t}`,role:"img",style:{display:"flex",alignItems:"center",justifyContent:"center",minWidth:140},children:e.jsx("span",{className:"v2-display",style:{fontSize:132,lineHeight:1,fontWeight:500,color:a[t],letterSpacing:"-0.04em",fontVariationSettings:'"opsz" 144'},children:t})})}function ft({openCount:t,reviewCount:a,verifiedCount:r,axeCount:n,walkthroughCount:s,autoCount:l}){return e.jsxs("dl",{style:{display:"flex",gap:"var(--v2-pad-4)",flexWrap:"wrap",margin:0,color:"var(--v2-ink-secondary)",fontSize:12},children:[e.jsx(L,{term:"open",value:t,tone:t>0?"attention":"neutral"}),e.jsx(L,{term:"review",value:a,tone:a>0?"review":"neutral"}),e.jsx(L,{term:"verified",value:r,tone:r>0?"positive":"neutral"}),e.jsx("span",{style:{color:"var(--v2-ink-faint)"},children:"·"}),e.jsx(L,{term:"axe",value:n,tone:"neutral"}),e.jsx(L,{term:"walkthrough",value:s,tone:"neutral"}),l>0&&e.jsx(L,{term:"auto-contrast",value:l,tone:"neutral"})]})}function L({term:t,value:a,tone:r}){const n={attention:"var(--v2-critical)",review:"var(--v2-needs-review)",positive:"var(--v2-verified)",neutral:"var(--v2-ink-secondary)"};return e.jsxs("div",{style:{display:"inline-flex",alignItems:"baseline",gap:6},children:[e.jsx("dt",{className:"v2-eyebrow",style:{display:"inline",margin:0,color:"var(--v2-ink-tertiary)"},children:t}),e.jsx("dd",{className:"v2-mono",style:{margin:0,fontWeight:600,fontSize:13,color:n[r],fontVariantNumeric:"tabular-nums"},children:a})]})}const yt=new Set(["2.4.3","2.1.2","2.4.7","1.3.2","1.4.11","2.5.3"]);function ue(t){return yt.has(t)}async function pe(t){var n,s;const a=w.getState();if(a.componentId&&((n=a.results[0])==null?void 0:n.pageUrl)===t)return a.componentId;const r=await he();return((s=r==null?void 0:r.find(l=>l.url===t))==null?void 0:s.componentId)??null}async function bt(t,a){var l;const r=w.getState(),n=[];if(r.componentId&&r.results.length>0){const o=(l=r.results[0])==null?void 0:l.pageUrl,i=a.find(c=>c.url===o);if(i){for(const c of r.results)for(const d of c.violations)d.ruleId===t&&d.target.selector===i.selector&&n.push({componentId:r.componentId,matchKey:d.matchKey});if(n.length>0)return n}}const s=await he()??[];for(const o of a){const i=s.find(c=>c.url===o.url);if(i)for(const c of i.results)for(const d of c.violations)d.ruleId===t&&d.target.selector===o.selector&&n.push({componentId:i.componentId,matchKey:d.matchKey})}return n}function xt({row:t}){return e.jsxs("details",{style:{background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:6,overflow:"hidden"},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"var(--v2-pad-3) var(--v2-pad-4)",listStyle:"none",display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-3)"},children:[e.jsx(kt,{row:t}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(wt,{row:t}),e.jsx(jt,{row:t})]}),e.jsx(St,{})]}),e.jsx("div",{style:{padding:"0 var(--v2-pad-4) var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)"},children:e.jsx(Ct,{row:t})})]})}function kt({row:t}){if(t.kind==="walkthrough-ack")return e.jsx("span",{className:"v2-chip v2-chip-verified","aria-label":"Status: human verified",children:"verified"});if(t.kind==="needs-review")return e.jsx("span",{className:"v2-chip v2-chip-review","aria-label":"Status: needs human review",children:"review"});if(t.kind==="auto-contrast")return e.jsx("span",{className:"v2-chip v2-chip-serious","aria-label":"Severity: serious, auto-resolved by pixel sampler",title:"Empirical pixel-contrast measurement, not an axe-confirmed violation. Human verification recommended.",children:"auto · serious"});if(t.kind==="walkthrough-fail")return e.jsx("span",{className:t.verdict==="fail"?"v2-chip v2-chip-serious":"v2-chip v2-chip-moderate","aria-label":`Severity: ${t.verdict}`,children:t.verdict});const a={critical:"v2-chip-critical",serious:"v2-chip-serious",moderate:"v2-chip-moderate",minor:"v2-chip-minor"};return e.jsx("span",{className:`v2-chip ${a[t.impact]}`,"aria-label":`Severity: ${t.impact}`,children:t.impact})}function wt({row:t}){const a=t.kind==="walkthrough-fail"||t.kind==="walkthrough-ack"||t.kind==="needs-review"||t.kind==="axe"||t.kind==="auto-contrast"?t.criterion:null,r=t.kind==="walkthrough-fail"?`AI walkthrough ${t.verdict} on this criterion.`:t.kind==="walkthrough-ack"?"Human-verified by an auditor.":t.kind==="needs-review"?t.description:t.kind==="auto-contrast"?"Empirical contrast measurement fell below threshold.":t.description;return e.jsxs("p",{style:{margin:0,marginBottom:4,color:"var(--v2-ink-primary)",fontSize:13,fontWeight:500,lineHeight:1.4},children:[a&&e.jsxs("span",{className:"v2-mono",style:{fontSize:11,fontWeight:600,color:"var(--v2-ink-tertiary)",marginRight:8},children:["WCAG ",a]}),r]})}function jt({row:t}){const a=t.kind==="axe"||t.kind==="needs-review"?t.pages.length:1,r=t.kind==="axe"||t.kind==="needs-review"||t.kind==="auto-contrast"?t.selector:null,n=t.kind==="walkthrough-fail"||t.kind==="walkthrough-ack"||t.kind==="auto-contrast"?t.pageUrl:null;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[r&&e.jsx("code",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",background:"var(--v2-bg-elev-2)",padding:"2px 6px",borderRadius:2,wordBreak:"break-all"},children:r}),n&&e.jsx("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-tertiary)",wordBreak:"break-all"},children:n}),a>1&&e.jsxs("span",{className:"v2-eyebrow",style:{marginLeft:"auto"},children:["on ",a," pages"]})]})}function St(){return e.jsx("span",{"aria-hidden":"true",style:{color:"var(--v2-ink-tertiary)",fontFamily:"var(--v2-mono)",fontSize:12,marginLeft:8,marginTop:2},children:"⏵"})}function Ct({row:t}){return t.kind==="walkthrough-fail"?e.jsx(Rt,{row:t}):t.kind==="walkthrough-ack"?e.jsx(It,{row:t}):t.kind==="needs-review"?e.jsx(At,{row:t}):t.kind==="auto-contrast"?e.jsx(Tt,{row:t}):e.jsx(Nt,{row:t})}function Tt({row:t}){const[a,r]=p.useState(!1),[n,s]=p.useState(!1),[l,o]=p.useState(""),[i,c]=p.useState(!1),[d,y]=p.useState(!1),[j,m]=p.useState(null),k=ge(t.ruleId);async function f(){if(c(!0),m(null),!l.trim()){m("Note is required — explain why the empirical contrast measurement is wrong, or why this element is acceptable in context."),c(!1);return}try{const u=(await ve(t.pageUrl)).find(S=>S.ruleId===t.ruleId&&S.selector===t.selector),g={pageUrl:t.pageUrl,ruleId:t.ruleId,selector:t.selector,verdict:"pass",reasoning:`Human override: ${l.trim()}
3
3
 
4
- (Original empirical reasoning: ${t.reasoning})`,resolvedAt:new Date().toISOString(),costUsd:0,wcagCriterion:t.criterion,inputHash:u==null?void 0:u.inputHash};await Ge(g),y(!0),r(!1)}catch(b){m(b instanceof Error?b.message:String(b))}finally{c(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(V,{label:"Empirical measurement",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap"},children:t.reasoning})}),e.jsx("p",{style:{margin:0,marginBottom:"var(--v2-pad-3)",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5,fontStyle:"italic"},children:"This finding came from a pixel-level screenshot diff of text against the rendered background, not from axe-core. Treat as a strong hint for human review, not a confirmed violation — gradients, translucent overlays, and animated backdrops can fool the sampler."}),d?e.jsx(te,{}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[k&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>s(b=>!b),"aria-expanded":n,children:n?"Hide fix recipe":"Show fix recipe"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>r(b=>!b),"aria-expanded":a,children:a?"Cancel":"Mark verified manually"})]}),n&&k&&e.jsx(fe,{summary:k.summary,snippet:k.snippet}),a&&e.jsx(ee,{note:l,setNote:o,busy:i,err:j,onConfirm:f,hint:"Why the empirical measurement is wrong, or why this is acceptable. Overrides the resolution to pass.",placeholder:"e.g., Text sits over a video poster image; static screenshot misreads the rendered background. Production poster passes 7:1."}),j&&!a&&e.jsx(Z,{message:j})]})]})}function Rt({row:t}){const[a,r]=p.useState(!1),[n,s]=p.useState(""),[l,o]=p.useState(!1),[i,c]=p.useState(!1),[d,y]=p.useState(!1),[j,m]=p.useState(null),[k,f]=p.useState(null),b=ue(t.criterion);async function u(){if(o(!0),f(null),!n.trim()){f("Note is required — explain how you manually verified this."),o(!1);return}try{const S=await pe(t.pageUrl);if(!S){f("Could not find this page in the audit data. Re-run the audit and try again.");return}await _e({componentId:S,criterionId:t.criterion,pageUrl:t.pageUrl,note:n.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:t.verdict}),c(!0),r(!1)}catch(S){f(S instanceof Error?S.message:String(S))}finally{o(!1)}}async function g(){var S;y(!0),m(null),f(null);try{const h=(S=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:S.id;if(!h){f("Open the audited page in your active tab to re-run.");return}const x=await pe(t.pageUrl);if(!x){f("Could not find this page in the audit data.");return}if(!ue(t.criterion)){f(`Re-run is only available for interactive criteria. ${t.criterion} is not supported.`);return}const E=await D({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterion,tabId:h,componentId:x,pageUrl:t.pageUrl});if(!E.ok){f(E.error??"Re-run failed.");return}m(`Re-run verdict: ${E.verdict??"unknown"}. Re-audit the page to refresh this list.`)}catch(v){f(v instanceof Error?v.message:String(v))}finally{y(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(V,{label:"AI reasoning",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6},children:t.reasoning})}),i?e.jsx(te,{}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[b&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:g,disabled:d,children:d?"Re-running…":"Re-run walkthrough"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>r(S=>!S),"aria-expanded":a,children:a?"Cancel":"Mark verified manually"})]}),j&&e.jsx("p",{role:"status",style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(15, 143, 94, 0.08)",border:"1px solid var(--v2-verified)",borderRadius:4,color:"var(--v2-verified)",fontSize:11,lineHeight:1.5},children:j}),a&&e.jsx(ee,{note:n,setNote:s,busy:l,err:k,onConfirm:u,hint:"Explain what you checked. This goes into the forensic record.",placeholder:"e.g., Verified — focus indicator visible on every interactive control under :focus-visible; tested with keyboard nav."}),k&&!a&&e.jsx(Z,{message:k})]})]})}function It({row:t}){return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(V,{label:"What the human verified",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6},children:t.reasoning})}),e.jsxs("p",{style:{color:"var(--v2-ink-tertiary)",fontSize:11,margin:0,marginTop:"var(--v2-pad-2)"},children:["Original AI verdict: ",e.jsx("strong",{children:t.verdict}),". Now treated as pass for conformance."]})]})}function At({row:t}){return e.jsx(me,{row:t,kind:"needs-review"})}function Nt({row:t}){return e.jsx(me,{row:t,kind:"axe"})}function me({row:t,kind:a}){const[r,n]=p.useState(!1),[s,l]=p.useState(""),[o,i]=p.useState(!1),[c,d]=p.useState(!1),[y,j]=p.useState(!1),[m,k]=p.useState(null),f=ge(t.ruleId);async function b(){if(i(!0),k(null),!s.trim()){k(a==="needs-review"?"Note is required — explain your review judgment.":"Note is required — explain why this isn't actually an issue in your context."),i(!1);return}try{const u=await bt(t.ruleId,t.pages);if(u.length===0){k("Could not find this finding in the persisted audit data. Re-run the audit and try again.");return}for(const g of u)await Ke({componentId:g.componentId,matchKey:g.matchKey,ruleId:t.ruleId,note:s.trim()});d(!0),n(!1)}catch(u){k(u instanceof Error?u.message:String(u))}finally{i(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[a==="needs-review"&&t.failureSummary&&e.jsx(V,{label:"AI assessment",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap"},children:t.failureSummary})}),e.jsx(V,{label:"Affected",children:e.jsxs("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:4},children:[t.pages.slice(0,8).map(u=>e.jsx("li",{children:e.jsx("a",{href:u.url,target:"_blank",rel:"noopener noreferrer",className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textDecorationColor:"var(--v2-ink-faint)",textUnderlineOffset:2},children:u.url})},u.url)),t.pages.length>8&&e.jsxs("li",{className:"v2-eyebrow",children:["+ ",t.pages.length-8," more"]})]})}),c?e.jsx(te,{}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[a==="axe"&&f&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>j(u=>!u),"aria-expanded":y,children:y?"Hide fix recipe":"Show fix recipe"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>n(u=>!u),"aria-expanded":r,children:r?"Cancel":"Mark verified manually"})]}),y&&f&&e.jsx(fe,{summary:f.summary,snippet:f.snippet}),r&&e.jsx(ee,{note:s,setNote:l,busy:o,err:m,onConfirm:b,hint:a==="needs-review"?"Your review judgment. Goes into the forensic record.":"Why this isn't actually an issue in your context. Goes into the forensic record.",placeholder:a==="needs-review"?"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.":'e.g., This element is decorative; aria-hidden + role="presentation" applied via design system.',confirmLabel:`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),m&&!r&&e.jsx(Z,{message:m})]})]})}function ee({note:t,setNote:a,busy:r,err:n,onConfirm:s,hint:l,placeholder:o,confirmLabel:i="Confirm acknowledgement"}){return e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border-strong)",borderRadius:4,background:"var(--v2-bg)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:6},children:"verification note · required"}),e.jsx("p",{style:{margin:0,marginBottom:"var(--v2-pad-2)",fontSize:11,color:"var(--v2-ink-tertiary)"},children:l}),e.jsx("textarea",{value:t,onChange:c=>a(c.target.value),placeholder:o,rows:3,style:{width:"100%",fontFamily:"var(--v2-body)",fontSize:12,lineHeight:1.5,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,resize:"vertical",minHeight:70},autoFocus:!0}),n&&e.jsx(Z,{message:n}),e.jsx("div",{style:{marginTop:"var(--v2-pad-2)"},children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:s,disabled:r||!t.trim(),children:r?"Saving…":i})})]})}function fe({summary:t,snippet:a}){return e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-verified)",borderRadius:4,background:"rgba(15, 143, 94, 0.06)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:6,color:"var(--v2-verified)"},children:"how to fix"}),e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6},children:t}),a&&e.jsx("pre",{className:"v2-mono",style:{marginTop:"var(--v2-pad-2)",marginBottom:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:3,fontSize:11,color:"var(--v2-ink-primary)",overflowX:"auto",whiteSpace:"pre"},children:e.jsx("code",{children:a})})]})}function te(){return e.jsxs("div",{role:"status",style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(15, 143, 94, 0.08)",border:"1px solid var(--v2-verified)",borderRadius:4,color:"var(--v2-verified)",fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:600},children:"✓ Acknowledged."})," ","The ack is saved. Re-audit or re-crawl to see this finding drop out of the list."]})}function Z({message:t}){return e.jsx("p",{role:"alert",style:{marginTop:"var(--v2-pad-2)",marginBottom:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",border:"1px solid var(--v2-critical)",background:"rgba(207, 44, 44, 0.06)",borderRadius:4,color:"var(--v2-critical)",fontSize:11,lineHeight:1.4},children:t})}function V({label:t,children:a}){return e.jsxs("div",{style:{marginBottom:"var(--v2-pad-3)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:6},children:t}),a]})}function re({children:t}){return e.jsx("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap",marginTop:"var(--v2-pad-2)"},children:t})}function Et(){const{report:t,resolvedFails:a}=Y(),[r,n]=p.useState("open"),s=p.useMemo(()=>t?Ft(t.pages,t.findingGroups??[],a):[],[t,a]),l=p.useMemo(()=>r==="all"?s:s.filter(i=>r==="verified"?i.kind==="walkthrough-ack":r==="review"?i.kind==="needs-review":r==="open"?i.kind==="axe"||i.kind==="walkthrough-fail"||i.kind==="auto-contrast":!0),[s,r]);if(!t)return null;const o={all:s.length,open:s.filter(i=>i.kind==="axe"||i.kind==="walkthrough-fail"||i.kind==="auto-contrast").length,review:s.filter(i=>i.kind==="needs-review").length,verified:s.filter(i=>i.kind==="walkthrough-ack").length};return e.jsxs("section",{"aria-labelledby":"findings-heading",style:{padding:"var(--v2-pad-5) var(--v2-pad-5) var(--v2-pad-7)"},children:[e.jsxs("header",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)",marginBottom:"var(--v2-pad-4)",flexWrap:"wrap"},children:[e.jsx("h2",{id:"findings-heading",className:"v2-display",style:{fontSize:20,fontWeight:500,letterSpacing:"-0.01em",color:"var(--v2-ink-primary)",margin:0},children:"Findings"}),e.jsx(Ut,{filter:r,setFilter:n,counts:o})]}),l.length===0?e.jsx(zt,{filter:r}):e.jsx("ul",{"aria-label":`${r} findings, ${l.length} items`,style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:l.map((i,c)=>e.jsx("li",{style:{animation:`v2-row-in 240ms ease ${Math.min(c,12)*30}ms both`},children:e.jsx(xt,{row:i})},i.key))})]})}function Ut({filter:t,setFilter:a,counts:r}){const n=[{id:"open",label:"Open"},{id:"review",label:"Review"},{id:"verified",label:"Verified"},{id:"all",label:"All"}];return e.jsx("div",{role:"tablist","aria-label":"Filter findings",style:{display:"inline-flex",gap:4,background:"var(--v2-bg-elev)",padding:3,borderRadius:6,border:"1px solid var(--v2-border)"},children:n.map(s=>{const l=t===s.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>a(s.id),style:{fontFamily:"var(--v2-body)",fontSize:11,padding:"5px 10px",borderRadius:4,border:"none",cursor:"pointer",background:l?"var(--v2-bg-elev-2)":"transparent",color:l?"var(--v2-ink-primary)":"var(--v2-ink-secondary)",fontWeight:l?600:500,transition:"background 120ms ease, color 120ms ease",display:"inline-flex",alignItems:"baseline",gap:5},children:[s.label,e.jsx("span",{className:"v2-mono",style:{fontSize:10,color:"var(--v2-ink-tertiary)",fontVariantNumeric:"tabular-nums"},children:r[s.id]})]},s.id)})})}function zt({filter:t}){const r={open:{headline:"Nothing open.",sub:"No axe violations or AI walkthrough failures across the audited pages. Switch to All to see everything, or to Verified for a record of acknowledged items."},review:{headline:"No items awaiting review.",sub:"AI walkthroughs returned definitive verdicts (or human verifications) for every criterion that needed judgment."},verified:{headline:"No human verifications recorded.",sub:"When you mark a walkthrough finding as manually verified, it appears here with your note + timestamp."},all:{headline:"Nothing to show.",sub:"No audit data yet — run a scan to begin."}}[t];return e.jsxs("div",{role:"status","aria-live":"polite",style:{padding:"var(--v2-pad-6) var(--v2-pad-4)",textAlign:"center",border:"1px dashed var(--v2-border)",borderRadius:6},children:[e.jsx("p",{className:"v2-display",style:{fontSize:18,fontWeight:500,color:"var(--v2-ink-primary)",margin:0,marginBottom:"var(--v2-pad-2)"},children:r.headline}),e.jsx("p",{style:{color:"var(--v2-ink-secondary)",margin:0,maxWidth:440,marginInline:"auto"},children:r.sub})]})}function Ft(t,a,r=[]){const n=[];for(const o of a)o.needsReview?n.push({kind:"needs-review",key:`nr::${o.ruleId}::${o.representativeSelector}`,criterion:o.wcagCriterion,ruleId:o.ruleId,description:o.axeDescription,selector:o.representativeSelector,failureSummary:o.failureSummary,pages:o.pages,group:o}):n.push({kind:"axe",key:`axe::${o.ruleId}::${o.representativeSelector}`,criterion:o.wcagCriterion,ruleId:o.ruleId,impact:o.impact,description:o.axeDescription,selector:o.representativeSelector,pages:o.pages,isShared:o.isShared});const s=new Set;for(const o of t){for(const i of o.walkthroughFindings??[]){const c=`wt-fail::${i.criterionId}::${i.pageUrl}`;s.has(c)||(s.add(c),n.push({kind:"walkthrough-fail",key:c,criterion:i.criterionId,verdict:i.verdict,impact:i.impact,reasoning:i.reasoning,pageUrl:i.pageUrl}))}for(const i of o.walkthroughAcknowledgements??[]){const c=`wt-ack::${i.criterionId}::${i.pageUrl}`;s.has(c)||(s.add(c),n.push({kind:"walkthrough-ack",key:c,criterion:i.criterionId,verdict:i.verdict,reasoning:i.reasoning,pageUrl:i.pageUrl}))}}for(const o of r)n.push({kind:"auto-contrast",key:`auto::${o.ruleId}::${o.selector}::${o.pageUrl}`,criterion:o.wcagCriterion??"1.4.3",ruleId:o.ruleId,impact:"serious",selector:o.selector,pageUrl:o.pageUrl,reasoning:o.reasoning});const l={critical:0,serious:1,moderate:2,minor:3,"needs-review":4,ack:5};return n.sort((o,i)=>{const c=o.kind==="walkthrough-ack"?l.ack:o.kind==="needs-review"?l["needs-review"]:l[o.impact],d=i.kind==="walkthrough-ack"?l.ack:i.kind==="needs-review"?l["needs-review"]:l[i.impact];return(c??99)-(d??99)}),n}function Dt({open:t,onClose:a}){const{report:r}=Y(),n=w(v=>v.siteCrawlReport),s=w(v=>v.results),l=w(v=>v.componentId),o=w(v=>v.delta),i=!!n,c=i||s.length>0,[d,y]=p.useState({}),j=p.useRef(null);p.useEffect(()=>{var h;if(!t)return;const v=x=>{x.key==="Escape"&&a()};return document.addEventListener("keydown",v),(h=j.current)==null||h.focus(),()=>document.removeEventListener("keydown",v)},[t,a]);function m(v,h){y(x=>({...x,[v]:h}))}async function k(){m("ai-prompt",{state:"busy"});try{if(i){const v=await D({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[],...r?{siteCrawlReport:r}:{}});if(!(v!=null&&v.content))throw new Error("Empty response");await navigator.clipboard.writeText(v.content),await G(v.content,"ai-fixer-prompt.md","text/markdown"),m("ai-prompt",{state:"done",message:"Copied to clipboard + opened in a new tab."})}else{if(!s.length)throw new Error("No audit results yet");await Xe({results:s,componentId:l??null,delta:o}),m("ai-prompt",{state:"done",message:"Copied to clipboard + opened in a new tab."})}}catch(v){m("ai-prompt",{state:"error",message:v instanceof Error?v.message:String(v)})}}async function f(){m("html",{state:"busy"});try{if(i&&r){const{renderSiteReportHtml:v}=await _(async()=>{const{renderSiteReportHtml:x}=await import("./site-report-renderer-DNgytqhZ.js");return{renderSiteReportHtml:x}},__vite__mapDeps([0,1,2,3,4])),h=v(r);await G(h,"site-report.html","text/html"),m("html",{state:"done",message:"Opened in a new tab — Save as PDF or use Cmd/Ctrl+S."})}else{if(!s.length)throw new Error("No audit results yet");const{toHtmlPrint:v}=await _(async()=>{const{toHtmlPrint:x}=await import("./scheduled-audit-runner-DyKpb3zg.js").then(T=>T.aU);return{toHtmlPrint:x}},__vite__mapDeps([1,2,3,4])),h=v(s,o??void 0);await G(h,"page-report.html","text/html"),m("html",{state:"done",message:"Opened in a new tab — Save as PDF or use Cmd/Ctrl+S."})}}catch(v){m("html",{state:"error",message:v instanceof Error?v.message:String(v)})}}async function b(v,h,x){m(v,{state:"busy"});try{const T=await D({type:"EXPORT_REQUEST",format:v,results:i?[]:s,...o&&!i?{delta:o}:{},...i?{siteCrawlSource:!0}:{}});if(!(T!=null&&T.content))throw new Error("Empty response");await G(T.content,x,"text/html"),m(v,{state:"done",message:`${h} opened in a new tab.`})}catch(T){m(v,{state:"error",message:T instanceof Error?T.message:String(T)})}}async function u(){m("zip",{state:"busy"});try{const{createZip:v}=await _(async()=>{const{createZip:U}=await import("./zip-encoder-CtULHXx_.js");return{createZip:U}},[]),{renderSiteReportHtml:h}=await _(async()=>{const{renderSiteReportHtml:U}=await import("./site-report-renderer-DNgytqhZ.js");return{renderSiteReportHtml:U}},__vite__mapDeps([0,1,2,3,4])),x=[];if(i&&r)try{x.push({name:"site-report.html",content:h(r)})}catch{}const T=i?[{format:"ai-prompt-site-crawl",filename:"ai-fixer-prompt.md"},{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}]:[{format:"ai-prompt",filename:"ai-fixer-prompt.md"},{format:"html-print",filename:"page-report.html"}];for(const{format:U,filename:Q}of T)try{const $=await D({type:"EXPORT_REQUEST",format:U,results:i?[]:s,...o&&!i?{delta:o}:{},...i?{siteCrawlSource:!0}:{}});$!=null&&$.content&&x.push({name:Q,content:$.content})}catch{}if(x.length===0)throw new Error("All exports failed");const E=v(x),C=new Blob([E],{type:"application/zip"}),I=URL.createObjectURL(C),A=document.createElement("a");A.href=I,A.download=i?"wcagcheckr-site-bundle.zip":"wcagcheckr-page-bundle.zip",A.click(),setTimeout(()=>URL.revokeObjectURL(I),6e4),m("zip",{state:"done",message:`Downloaded ${x.length} file${x.length===1?"":"s"}.`})}catch(v){m("zip",{state:"error",message:v instanceof Error?v.message:String(v)})}}function g(v){w.getState().setView(v),chrome.storage.local.set({v2UiEnabled:!1}),a()}function S(){D({type:"OPEN_SETTINGS"})}return t?e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Tools and exports",style:{position:"fixed",inset:0,zIndex:50,display:"flex"},children:[e.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(26, 20, 16, 0.35)",backdropFilter:"blur(2px)"},"aria-hidden":"true"}),e.jsxs("div",{style:{position:"relative",marginLeft:"auto",width:"min(100%, 440px)",height:"100%",background:"var(--v2-bg)",borderLeft:"1px solid var(--v2-border-strong)",boxShadow:"-12px 0 28px rgba(26, 20, 16, 0.18)",overflowY:"auto",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{position:"sticky",top:0,background:"var(--v2-bg)",borderBottom:"1px solid var(--v2-border)",padding:"var(--v2-pad-4) var(--v2-pad-5)",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:1},children:[e.jsx("h2",{className:"v2-display",style:{margin:0,fontSize:18,fontWeight:500,color:"var(--v2-ink-primary)"},children:"Tools"}),e.jsx("button",{ref:j,type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:a,"aria-label":"Close tools drawer",children:"Close"})]}),e.jsxs("div",{style:{padding:"var(--v2-pad-5)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-5)"},children:[!c&&e.jsx("p",{style:{margin:0,padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:4,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.5},children:"Most tools need an audit to act on. Run an audit first, then come back here."}),c&&e.jsxs(e.Fragment,{children:[e.jsx(O,{title:"AI fixer",children:e.jsx(F,{status:d["ai-prompt"],label:i?"Copy site-wide AI fix prompt":"Copy AI fix prompt",description:i?"Multi-page markdown for ChatGPT/Claude/Copilot. Site-wide summary, consistency findings, per-page violations + fix recipes.":"Markdown for ChatGPT/Claude/Copilot. Every violation with fix recipes, AI-resolved fails, acknowledged context.",onClick:k})}),e.jsxs(O,{title:"Reports",children:[e.jsx(F,{status:d.html,label:i?"Site report (HTML)":"Page report (HTML)",description:i?"Full crawl summary with per-page grades, top violations, consistency findings. Print-ready.":"Print-friendly single-page report.",onClick:f}),e.jsx(F,{status:d["executive-report"],label:"Executive report",description:"Hero grade + framing, top risks, next steps. For non-technical readers.",onClick:()=>b("executive-report","Executive report","executive-report.html")}),i&&e.jsx(F,{status:d["ticket-bundle"],label:"Ticket bundle",description:"Markdown formatted for paste into Linear / Jira / GitHub Issues — one ticket per finding, sorted by severity.",onClick:()=>b("ticket-bundle","Ticket bundle","ticket-bundle.md")})]}),e.jsxs(O,{title:"Compliance & legal",children:[e.jsx(F,{status:d["defense-bundle"],label:"Defense bundle",description:"Anchored chain-of-custody evidence package. Use in pre-litigation.",onClick:()=>b("defense-bundle","Defense bundle","defense-bundle.html")}),e.jsx(F,{status:d["deposition-packet"],label:"Deposition packet",description:"Full evidence bundle — anchor, receipts, fingerprints, signing cert.",onClick:()=>b("deposition-packet","Deposition packet","deposition-packet.html")}),e.jsx(F,{status:d.vpat,label:"VPAT",description:"Voluntary Product Accessibility Template. Procurement-ready.",onClick:()=>b("vpat","VPAT","vpat.html")}),e.jsx(F,{status:d["conformance-crosswalk"],label:"Conformance crosswalk",description:"WCAG ↔ Section 508 ↔ EN 301 549 mapping.",onClick:()=>b("conformance-crosswalk","Conformance crosswalk","conformance-crosswalk.html")}),e.jsx(F,{status:d["methodology-doc"],label:"Methodology PDF",description:"Auditor-explainable methodology — what was tested, how, with what tools.",onClick:()=>b("methodology-doc","Methodology doc","methodology-doc.html")}),e.jsx(F,{status:d["evidence-bundle"],label:"Evidence bundle",description:"Lighter than defense bundle — audit records + summary.",onClick:()=>b("evidence-bundle","Evidence bundle","evidence-bundle.html")})]}),e.jsx(O,{title:"Bulk",children:e.jsx(F,{status:d.zip,label:i?"Download all as ZIP":"Download both as ZIP",description:i?"Every format above bundled in one ZIP. Runs each export in sequence — ~30s for an 8-page crawl.":"AI fix prompt + page report in one ZIP.",onClick:u})})]}),e.jsxs(O,{title:"Specialized views (classic UI)",children:[e.jsx("p",{style:{margin:0,marginBottom:"var(--v2-pad-2)",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:`These surfaces aren't ported to v2 yet — clicking opens them in the classic UI. Return to v2 anytime via the "Try v2 UI" button in the classic Header.`}),e.jsx(N,{label:"State matrix",description:"Per-state findings grid (hover · focus · dark · RTL · etc.)",onClick:()=>g("matrix")}),e.jsx(N,{label:"Per-area compliance",description:"9 sub-grade areas with drill-in: Color & contrast, Keyboard, etc.",onClick:()=>g("report")}),e.jsx(N,{label:"Baseline delta",description:"New vs. persistent vs. fixed vs. acknowledged since the last baseline.",onClick:()=>g("delta")}),e.jsx(N,{label:"Forensic log",description:"Anchored audit history with chain-of-custody.",onClick:()=>g("forensic")}),e.jsx(N,{label:"Risk dashboard",description:"Lawsuit / conformance risk tiers with prioritized actions.",onClick:()=>g("risk")}),e.jsx(N,{label:"WCAG 3 mapping",description:"Outcome-level grouping per WCAG 3 snapshot.",onClick:()=>g("wcag3")}),e.jsx(N,{label:"WCAG-EM verdicts",description:"Formal per-criterion verdict map.",onClick:()=>g("compliance")}),e.jsx(N,{label:"Schedules",description:"Recurring audit management with email alerts.",onClick:()=>g("schedules")}),e.jsx(N,{label:"Copilot chat",description:"Anthropic-powered Q&A over your audit context.",onClick:()=>g("copilot")}),e.jsx(N,{label:"Accessibility tree",description:"Inspect the live aria tree as assistive tech sees it.",onClick:()=>g("ax-tree")}),e.jsx(N,{label:"Design tokens",description:"CSS-token / design-system audit.",onClick:()=>g("tokens")}),e.jsx(N,{label:"Guided audit",description:"13 manual IGT workflows (keyboard, screen reader, etc.).",onClick:()=>g("guided")}),e.jsx(N,{label:"Per-component scorecard",description:"Custom rules, baselines, per-component drill-in.",onClick:()=>g("scorecard")}),e.jsx(N,{label:"User journey flows",description:"Multi-step audit recordings.",onClick:()=>g("flows")}),e.jsx(N,{label:"Activity / IGT runs",description:"Manual workflow run history.",onClick:()=>g("activity")})]}),e.jsx(O,{title:"Settings",children:e.jsx(F,{status:void 0,label:"Open settings",description:"Matrix preset, AI config, axe rule overrides, breakpoints, auto-export.",onClick:S})})]})]})]}):null}async function G(t,a,r){const n=new Blob([t],{type:r}),s=URL.createObjectURL(n);try{await chrome.tabs.create({url:s})}catch{const l=document.createElement("a");l.href=s,l.download=a,l.click()}setTimeout(()=>URL.revokeObjectURL(s),6e4)}function O({title:t,children:a}){return e.jsxs("div",{children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:"var(--v2-pad-2)",color:"var(--v2-ink-tertiary)"},children:t}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:a})]})}function F({label:t,description:a,status:r,onClick:n}){const s=(r==null?void 0:r.state)==="busy",l=(r==null?void 0:r.state)==="done",o=(r==null?void 0:r.state)==="error";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:t}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:n,disabled:s,children:s?"Working…":l?"Run again":"Run"})]}),a&&e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:a}),l&&(r==null?void 0:r.message)&&e.jsxs("p",{role:"status",style:{margin:0,marginTop:4,fontSize:11,color:"var(--v2-verified)"},children:["✓ ",r.message]}),o&&(r==null?void 0:r.message)&&e.jsx("p",{role:"alert",style:{margin:0,marginTop:4,fontSize:11,color:"var(--v2-critical)"},children:r.message})]})}function N({label:t,description:a,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,style:{appearance:"none",cursor:"pointer",display:"flex",flexDirection:"column",gap:4,padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg)",textAlign:"left",font:"inherit",color:"var(--v2-ink-primary)",width:"100%"},children:[e.jsxs("span",{style:{fontSize:13,fontWeight:500},children:[t," →"]}),e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:a})]})}function Pt(){var l,o;const t=w(i=>i.siteCrawlReport),a=w(i=>i.results),[r,n]=p.useState(!1),s=(t==null?void 0:t.startUrl)??((l=a[0])==null?void 0:l.pageUrl)??((o=a[0])==null?void 0:o.scope)??null;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{role:"banner",style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-4)",padding:"var(--v2-pad-3) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",background:"var(--v2-bg)",minHeight:44},children:[e.jsx("a",{href:"#main-content",className:"v2-skip-link",style:{position:"absolute",left:-9999},onFocus:i=>{i.currentTarget.style.left="var(--v2-pad-4)",i.currentTarget.style.top="var(--v2-pad-4)"},onBlur:i=>{i.currentTarget.style.left="-9999px"},children:"Skip to main content"}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-2)"},children:[e.jsx("span",{className:"v2-display",style:{fontSize:18,fontWeight:600,letterSpacing:"-0.01em",color:"var(--v2-ink-primary)"},children:"wcagcheckr"}),e.jsx("span",{className:"v2-eyebrow",children:"v2"})]}),s&&e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-2)",marginLeft:"var(--v2-pad-4)",minWidth:0,flex:1},children:[e.jsx("span",{className:"v2-eyebrow",children:"scope"}),e.jsx("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},title:s,children:s})]}),e.jsxs("nav",{"aria-label":"Application",style:{display:"flex",gap:"var(--v2-pad-1)",marginLeft:"auto"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{chrome.storage.local.set({v2UiEnabled:!1})},"aria-label":"Switch back to the classic UI",title:"Switch back to the classic v1 UI",children:"Use v1"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>n(!0),"aria-label":"Open tools and exports drawer","aria-expanded":r,title:"Exports, baselines, schedules, forensic log, settings, more",children:"Tools"})]})]}),e.jsx(Dt,{open:r,onClose:()=>n(!1)})]})}function $t(){return p.useEffect(()=>{const t=Te(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),n=Re();Ie({forceRefresh:!0}).catch(()=>{}),Ae().catch(()=>{}),Ne().catch(()=>{}),Ee().catch(()=>{}),Ue().catch(()=>{}),qe().then(l=>{w.getState().setAcknowledgedKeys(new Set(l.map(o=>o.matchKey)))}).catch(()=>{});let s=!1;return Ye().then(l=>{s||l&&w.setState({siteCrawlReport:l})}).catch(()=>{}),()=>{s=!0,n();try{t.disconnect()}catch{}try{r==null||r.disconnect()}catch{}}},[]),e.jsxs("div",{className:"v2-root",children:[e.jsx(Pt,{}),e.jsxs("main",{id:"main-content","aria-label":"wcagcheckr findings",children:[e.jsx(ht,{}),e.jsx(Et,{})]})]})}Qe("side-panel");const K="v2UiEnabled";function Wt(){const[t,a]=p.useState(null);return p.useEffect(()=>{let r=!1;chrome.storage.local.get(K).then(s=>{r||a(!!s[K])}).catch(()=>a(!1));const n=(s,l)=>{var o;l==="local"&&K in s&&a(!!((o=s[K])!=null&&o.newValue))};return chrome.storage.onChanged.addListener(n),()=>{r=!0,chrome.storage.onChanged.removeListener(n)}},[]),t===null?null:t?e.jsx($t,{}):e.jsx(Fe,{})}const ye=document.getElementById("root");if(!ye)throw new Error("side-panel: #root not found");we(ye).render(e.jsx(je.StrictMode,{children:e.jsx(ze,{children:e.jsx(Wt,{})})}));
4
+ (Original empirical reasoning: ${t.reasoning})`,resolvedAt:new Date().toISOString(),costUsd:0,wcagCriterion:t.criterion,inputHash:u==null?void 0:u.inputHash};await Ge(g),y(!0),r(!1)}catch(b){m(b instanceof Error?b.message:String(b))}finally{c(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(V,{label:"Empirical measurement",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap"},children:t.reasoning})}),e.jsx("p",{style:{margin:0,marginBottom:"var(--v2-pad-3)",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5,fontStyle:"italic"},children:"This finding came from a pixel-level screenshot diff of text against the rendered background, not from axe-core. Treat as a strong hint for human review, not a confirmed violation — gradients, translucent overlays, and animated backdrops can fool the sampler."}),d?e.jsx(te,{}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[k&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>s(b=>!b),"aria-expanded":n,children:n?"Hide fix recipe":"Show fix recipe"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>r(b=>!b),"aria-expanded":a,children:a?"Cancel":"Mark verified manually"})]}),n&&k&&e.jsx(fe,{summary:k.summary,snippet:k.snippet}),a&&e.jsx(ee,{note:l,setNote:o,busy:i,err:j,onConfirm:f,hint:"Why the empirical measurement is wrong, or why this is acceptable. Overrides the resolution to pass.",placeholder:"e.g., Text sits over a video poster image; static screenshot misreads the rendered background. Production poster passes 7:1."}),j&&!a&&e.jsx(Z,{message:j})]})]})}function Rt({row:t}){const[a,r]=p.useState(!1),[n,s]=p.useState(""),[l,o]=p.useState(!1),[i,c]=p.useState(!1),[d,y]=p.useState(!1),[j,m]=p.useState(null),[k,f]=p.useState(null),b=ue(t.criterion);async function u(){if(o(!0),f(null),!n.trim()){f("Note is required — explain how you manually verified this."),o(!1);return}try{const S=await pe(t.pageUrl);if(!S){f("Could not find this page in the audit data. Re-run the audit and try again.");return}await _e({componentId:S,criterionId:t.criterion,pageUrl:t.pageUrl,note:n.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:t.verdict}),c(!0),r(!1)}catch(S){f(S instanceof Error?S.message:String(S))}finally{o(!1)}}async function g(){var S;y(!0),m(null),f(null);try{const h=(S=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:S.id;if(!h){f("Open the audited page in your active tab to re-run.");return}const x=await pe(t.pageUrl);if(!x){f("Could not find this page in the audit data.");return}if(!ue(t.criterion)){f(`Re-run is only available for interactive criteria. ${t.criterion} is not supported.`);return}const E=await D({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterion,tabId:h,componentId:x,pageUrl:t.pageUrl});if(!E.ok){f(E.error??"Re-run failed.");return}m(`Re-run verdict: ${E.verdict??"unknown"}. Re-audit the page to refresh this list.`)}catch(v){f(v instanceof Error?v.message:String(v))}finally{y(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(V,{label:"AI reasoning",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6},children:t.reasoning})}),i?e.jsx(te,{}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[b&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:g,disabled:d,children:d?"Re-running…":"Re-run walkthrough"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>r(S=>!S),"aria-expanded":a,children:a?"Cancel":"Mark verified manually"})]}),j&&e.jsx("p",{role:"status",style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(15, 143, 94, 0.08)",border:"1px solid var(--v2-verified)",borderRadius:4,color:"var(--v2-verified)",fontSize:11,lineHeight:1.5},children:j}),a&&e.jsx(ee,{note:n,setNote:s,busy:l,err:k,onConfirm:u,hint:"Explain what you checked. This goes into the forensic record.",placeholder:"e.g., Verified — focus indicator visible on every interactive control under :focus-visible; tested with keyboard nav."}),k&&!a&&e.jsx(Z,{message:k})]})]})}function It({row:t}){return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(V,{label:"What the human verified",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6},children:t.reasoning})}),e.jsxs("p",{style:{color:"var(--v2-ink-tertiary)",fontSize:11,margin:0,marginTop:"var(--v2-pad-2)"},children:["Original AI verdict: ",e.jsx("strong",{children:t.verdict}),". Now treated as pass for conformance."]})]})}function At({row:t}){return e.jsx(me,{row:t,kind:"needs-review"})}function Nt({row:t}){return e.jsx(me,{row:t,kind:"axe"})}function me({row:t,kind:a}){const[r,n]=p.useState(!1),[s,l]=p.useState(""),[o,i]=p.useState(!1),[c,d]=p.useState(!1),[y,j]=p.useState(!1),[m,k]=p.useState(null),f=ge(t.ruleId);async function b(){if(i(!0),k(null),!s.trim()){k(a==="needs-review"?"Note is required — explain your review judgment.":"Note is required — explain why this isn't actually an issue in your context."),i(!1);return}try{const u=await bt(t.ruleId,t.pages);if(u.length===0){k("Could not find this finding in the persisted audit data. Re-run the audit and try again.");return}for(const g of u)await Ke({componentId:g.componentId,matchKey:g.matchKey,ruleId:t.ruleId,note:s.trim()});d(!0),n(!1)}catch(u){k(u instanceof Error?u.message:String(u))}finally{i(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[a==="needs-review"&&t.failureSummary&&e.jsx(V,{label:"AI assessment",children:e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap"},children:t.failureSummary})}),e.jsx(V,{label:"Affected",children:e.jsxs("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:4},children:[t.pages.slice(0,8).map(u=>e.jsx("li",{children:e.jsx("a",{href:u.url,target:"_blank",rel:"noopener noreferrer",className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",textDecoration:"underline",textDecorationColor:"var(--v2-ink-faint)",textUnderlineOffset:2},children:u.url})},u.url)),t.pages.length>8&&e.jsxs("li",{className:"v2-eyebrow",children:["+ ",t.pages.length-8," more"]})]})}),c?e.jsx(te,{}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[a==="axe"&&f&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>j(u=>!u),"aria-expanded":y,children:y?"Hide fix recipe":"Show fix recipe"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>n(u=>!u),"aria-expanded":r,children:r?"Cancel":"Mark verified manually"})]}),y&&f&&e.jsx(fe,{summary:f.summary,snippet:f.snippet}),r&&e.jsx(ee,{note:s,setNote:l,busy:o,err:m,onConfirm:b,hint:a==="needs-review"?"Your review judgment. Goes into the forensic record.":"Why this isn't actually an issue in your context. Goes into the forensic record.",placeholder:a==="needs-review"?"e.g., Verified — image is a portrait of the named founder; alt text correctly identifies subject and role.":'e.g., This element is decorative; aria-hidden + role="presentation" applied via design system.',confirmLabel:`Confirm — acknowledge on ${t.pages.length} page${t.pages.length===1?"":"s"}`}),m&&!r&&e.jsx(Z,{message:m})]})]})}function ee({note:t,setNote:a,busy:r,err:n,onConfirm:s,hint:l,placeholder:o,confirmLabel:i="Confirm acknowledgement"}){return e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border-strong)",borderRadius:4,background:"var(--v2-bg)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:6},children:"verification note · required"}),e.jsx("p",{style:{margin:0,marginBottom:"var(--v2-pad-2)",fontSize:11,color:"var(--v2-ink-tertiary)"},children:l}),e.jsx("textarea",{value:t,onChange:c=>a(c.target.value),placeholder:o,rows:3,style:{width:"100%",fontFamily:"var(--v2-body)",fontSize:12,lineHeight:1.5,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",color:"var(--v2-ink-primary)",border:"1px solid var(--v2-border-strong)",borderRadius:4,resize:"vertical",minHeight:70},autoFocus:!0}),n&&e.jsx(Z,{message:n}),e.jsx("div",{style:{marginTop:"var(--v2-pad-2)"},children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:s,disabled:r||!t.trim(),children:r?"Saving…":i})})]})}function fe({summary:t,snippet:a}){return e.jsxs("div",{style:{marginTop:"var(--v2-pad-3)",padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-verified)",borderRadius:4,background:"rgba(15, 143, 94, 0.06)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:6,color:"var(--v2-verified)"},children:"how to fix"}),e.jsx("p",{style:{margin:0,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.6},children:t}),a&&e.jsx("pre",{className:"v2-mono",style:{marginTop:"var(--v2-pad-2)",marginBottom:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"var(--v2-bg)",border:"1px solid var(--v2-border)",borderRadius:3,fontSize:11,color:"var(--v2-ink-primary)",overflowX:"auto",whiteSpace:"pre"},children:e.jsx("code",{children:a})})]})}function te(){return e.jsxs("div",{role:"status",style:{marginTop:"var(--v2-pad-2)",padding:"var(--v2-pad-2) var(--v2-pad-3)",background:"rgba(15, 143, 94, 0.08)",border:"1px solid var(--v2-verified)",borderRadius:4,color:"var(--v2-verified)",fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{fontWeight:600},children:"✓ Acknowledged."})," ","The ack is saved. Re-audit or re-crawl to see this finding drop out of the list."]})}function Z({message:t}){return e.jsx("p",{role:"alert",style:{marginTop:"var(--v2-pad-2)",marginBottom:0,padding:"var(--v2-pad-2) var(--v2-pad-3)",border:"1px solid var(--v2-critical)",background:"rgba(207, 44, 44, 0.06)",borderRadius:4,color:"var(--v2-critical)",fontSize:11,lineHeight:1.4},children:t})}function V({label:t,children:a}){return e.jsxs("div",{style:{marginBottom:"var(--v2-pad-3)"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:6},children:t}),a]})}function re({children:t}){return e.jsx("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap",marginTop:"var(--v2-pad-2)"},children:t})}function Et(){const{report:t,resolvedFails:a}=Y(),[r,n]=p.useState("open"),s=p.useMemo(()=>t?Ft(t.pages,t.findingGroups??[],a):[],[t,a]),l=p.useMemo(()=>r==="all"?s:s.filter(i=>r==="verified"?i.kind==="walkthrough-ack":r==="review"?i.kind==="needs-review":r==="open"?i.kind==="axe"||i.kind==="walkthrough-fail"||i.kind==="auto-contrast":!0),[s,r]);if(!t)return null;const o={all:s.length,open:s.filter(i=>i.kind==="axe"||i.kind==="walkthrough-fail"||i.kind==="auto-contrast").length,review:s.filter(i=>i.kind==="needs-review").length,verified:s.filter(i=>i.kind==="walkthrough-ack").length};return e.jsxs("section",{"aria-labelledby":"findings-heading",style:{padding:"var(--v2-pad-5) var(--v2-pad-5) var(--v2-pad-7)"},children:[e.jsxs("header",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--v2-pad-3)",marginBottom:"var(--v2-pad-4)",flexWrap:"wrap"},children:[e.jsx("h2",{id:"findings-heading",className:"v2-display",style:{fontSize:20,fontWeight:500,letterSpacing:"-0.01em",color:"var(--v2-ink-primary)",margin:0},children:"Findings"}),e.jsx(Ut,{filter:r,setFilter:n,counts:o})]}),l.length===0?e.jsx(zt,{filter:r}):e.jsx("ul",{"aria-label":`${r} findings, ${l.length} items`,style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:l.map((i,c)=>e.jsx("li",{style:{animation:`v2-row-in 240ms ease ${Math.min(c,12)*30}ms both`},children:e.jsx(xt,{row:i})},i.key))})]})}function Ut({filter:t,setFilter:a,counts:r}){const n=[{id:"open",label:"Open"},{id:"review",label:"Review"},{id:"verified",label:"Verified"},{id:"all",label:"All"}];return e.jsx("div",{role:"tablist","aria-label":"Filter findings",style:{display:"inline-flex",gap:4,background:"var(--v2-bg-elev)",padding:3,borderRadius:6,border:"1px solid var(--v2-border)"},children:n.map(s=>{const l=t===s.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>a(s.id),style:{fontFamily:"var(--v2-body)",fontSize:11,padding:"5px 10px",borderRadius:4,border:"none",cursor:"pointer",background:l?"var(--v2-bg-elev-2)":"transparent",color:l?"var(--v2-ink-primary)":"var(--v2-ink-secondary)",fontWeight:l?600:500,transition:"background 120ms ease, color 120ms ease",display:"inline-flex",alignItems:"baseline",gap:5},children:[s.label,e.jsx("span",{className:"v2-mono",style:{fontSize:10,color:"var(--v2-ink-tertiary)",fontVariantNumeric:"tabular-nums"},children:r[s.id]})]},s.id)})})}function zt({filter:t}){const r={open:{headline:"Nothing open.",sub:"No axe violations or AI walkthrough failures across the audited pages. Switch to All to see everything, or to Verified for a record of acknowledged items."},review:{headline:"No items awaiting review.",sub:"AI walkthroughs returned definitive verdicts (or human verifications) for every criterion that needed judgment."},verified:{headline:"No human verifications recorded.",sub:"When you mark a walkthrough finding as manually verified, it appears here with your note + timestamp."},all:{headline:"Nothing to show.",sub:"No audit data yet — run a scan to begin."}}[t];return e.jsxs("div",{role:"status","aria-live":"polite",style:{padding:"var(--v2-pad-6) var(--v2-pad-4)",textAlign:"center",border:"1px dashed var(--v2-border)",borderRadius:6},children:[e.jsx("p",{className:"v2-display",style:{fontSize:18,fontWeight:500,color:"var(--v2-ink-primary)",margin:0,marginBottom:"var(--v2-pad-2)"},children:r.headline}),e.jsx("p",{style:{color:"var(--v2-ink-secondary)",margin:0,maxWidth:440,marginInline:"auto"},children:r.sub})]})}function Ft(t,a,r=[]){const n=[];for(const o of a)o.needsReview?n.push({kind:"needs-review",key:`nr::${o.ruleId}::${o.representativeSelector}`,criterion:o.wcagCriterion,ruleId:o.ruleId,description:o.axeDescription,selector:o.representativeSelector,failureSummary:o.failureSummary,pages:o.pages,group:o}):n.push({kind:"axe",key:`axe::${o.ruleId}::${o.representativeSelector}`,criterion:o.wcagCriterion,ruleId:o.ruleId,impact:o.impact,description:o.axeDescription,selector:o.representativeSelector,pages:o.pages,isShared:o.isShared});const s=new Set;for(const o of t){for(const i of o.walkthroughFindings??[]){const c=`wt-fail::${i.criterionId}::${i.pageUrl}`;s.has(c)||(s.add(c),n.push({kind:"walkthrough-fail",key:c,criterion:i.criterionId,verdict:i.verdict,impact:i.impact,reasoning:i.reasoning,pageUrl:i.pageUrl}))}for(const i of o.walkthroughAcknowledgements??[]){const c=`wt-ack::${i.criterionId}::${i.pageUrl}`;s.has(c)||(s.add(c),n.push({kind:"walkthrough-ack",key:c,criterion:i.criterionId,verdict:i.verdict,reasoning:i.reasoning,pageUrl:i.pageUrl}))}}for(const o of r)n.push({kind:"auto-contrast",key:`auto::${o.ruleId}::${o.selector}::${o.pageUrl}`,criterion:o.wcagCriterion??"1.4.3",ruleId:o.ruleId,impact:"serious",selector:o.selector,pageUrl:o.pageUrl,reasoning:o.reasoning});const l={critical:0,serious:1,moderate:2,minor:3,"needs-review":4,ack:5};return n.sort((o,i)=>{const c=o.kind==="walkthrough-ack"?l.ack:o.kind==="needs-review"?l["needs-review"]:l[o.impact],d=i.kind==="walkthrough-ack"?l.ack:i.kind==="needs-review"?l["needs-review"]:l[i.impact];return(c??99)-(d??99)}),n}function Dt({open:t,onClose:a}){const{report:r}=Y(),n=w(v=>v.siteCrawlReport),s=w(v=>v.results),l=w(v=>v.componentId),o=w(v=>v.delta),i=!!n,c=i||s.length>0,[d,y]=p.useState({}),j=p.useRef(null);p.useEffect(()=>{var h;if(!t)return;const v=x=>{x.key==="Escape"&&a()};return document.addEventListener("keydown",v),(h=j.current)==null||h.focus(),()=>document.removeEventListener("keydown",v)},[t,a]);function m(v,h){y(x=>({...x,[v]:h}))}async function k(){m("ai-prompt",{state:"busy"});try{if(i){const v=await D({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[],...r?{siteCrawlReport:r}:{}});if(!(v!=null&&v.content))throw new Error("Empty response");await navigator.clipboard.writeText(v.content),await G(v.content,"ai-fixer-prompt.md","text/markdown"),m("ai-prompt",{state:"done",message:"Copied to clipboard + opened in a new tab."})}else{if(!s.length)throw new Error("No audit results yet");await Xe({results:s,componentId:l??null,delta:o}),m("ai-prompt",{state:"done",message:"Copied to clipboard + opened in a new tab."})}}catch(v){m("ai-prompt",{state:"error",message:v instanceof Error?v.message:String(v)})}}async function f(){m("html",{state:"busy"});try{if(i&&r){const{renderSiteReportHtml:v}=await _(async()=>{const{renderSiteReportHtml:x}=await import("./site-report-renderer-BR7yhaX2.js");return{renderSiteReportHtml:x}},__vite__mapDeps([0,1,2,3,4])),h=v(r);await G(h,"site-report.html","text/html"),m("html",{state:"done",message:"Opened in a new tab — Save as PDF or use Cmd/Ctrl+S."})}else{if(!s.length)throw new Error("No audit results yet");const{toHtmlPrint:v}=await _(async()=>{const{toHtmlPrint:x}=await import("./scheduled-audit-runner-BB7YtjU4.js").then(T=>T.aU);return{toHtmlPrint:x}},__vite__mapDeps([1,2,3,4])),h=v(s,o??void 0);await G(h,"page-report.html","text/html"),m("html",{state:"done",message:"Opened in a new tab — Save as PDF or use Cmd/Ctrl+S."})}}catch(v){m("html",{state:"error",message:v instanceof Error?v.message:String(v)})}}async function b(v,h,x){m(v,{state:"busy"});try{const T=await D({type:"EXPORT_REQUEST",format:v,results:i?[]:s,...o&&!i?{delta:o}:{},...i?{siteCrawlSource:!0}:{}});if(!(T!=null&&T.content))throw new Error("Empty response");await G(T.content,x,"text/html"),m(v,{state:"done",message:`${h} opened in a new tab.`})}catch(T){m(v,{state:"error",message:T instanceof Error?T.message:String(T)})}}async function u(){m("zip",{state:"busy"});try{const{createZip:v}=await _(async()=>{const{createZip:U}=await import("./zip-encoder-CtULHXx_.js");return{createZip:U}},[]),{renderSiteReportHtml:h}=await _(async()=>{const{renderSiteReportHtml:U}=await import("./site-report-renderer-BR7yhaX2.js");return{renderSiteReportHtml:U}},__vite__mapDeps([0,1,2,3,4])),x=[];if(i&&r)try{x.push({name:"site-report.html",content:h(r)})}catch{}const T=i?[{format:"ai-prompt-site-crawl",filename:"ai-fixer-prompt.md"},{format:"defense-bundle",filename:"defense-bundle.html"},{format:"deposition-packet",filename:"deposition-packet.html"},{format:"evidence-bundle",filename:"evidence-bundle.html"},{format:"vpat",filename:"vpat.html"},{format:"conformance-crosswalk",filename:"conformance-crosswalk.html"},{format:"methodology-doc",filename:"methodology-doc.html"},{format:"executive-report",filename:"executive-report.html"}]:[{format:"ai-prompt",filename:"ai-fixer-prompt.md"},{format:"html-print",filename:"page-report.html"}];for(const{format:U,filename:Q}of T)try{const $=await D({type:"EXPORT_REQUEST",format:U,results:i?[]:s,...o&&!i?{delta:o}:{},...i?{siteCrawlSource:!0}:{}});$!=null&&$.content&&x.push({name:Q,content:$.content})}catch{}if(x.length===0)throw new Error("All exports failed");const E=v(x),C=new Blob([E],{type:"application/zip"}),I=URL.createObjectURL(C),A=document.createElement("a");A.href=I,A.download=i?"wcagcheckr-site-bundle.zip":"wcagcheckr-page-bundle.zip",A.click(),setTimeout(()=>URL.revokeObjectURL(I),6e4),m("zip",{state:"done",message:`Downloaded ${x.length} file${x.length===1?"":"s"}.`})}catch(v){m("zip",{state:"error",message:v instanceof Error?v.message:String(v)})}}function g(v){w.getState().setView(v),chrome.storage.local.set({v2UiEnabled:!1}),a()}function S(){D({type:"OPEN_SETTINGS"})}return t?e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Tools and exports",style:{position:"fixed",inset:0,zIndex:50,display:"flex"},children:[e.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(26, 20, 16, 0.35)",backdropFilter:"blur(2px)"},"aria-hidden":"true"}),e.jsxs("div",{style:{position:"relative",marginLeft:"auto",width:"min(100%, 440px)",height:"100%",background:"var(--v2-bg)",borderLeft:"1px solid var(--v2-border-strong)",boxShadow:"-12px 0 28px rgba(26, 20, 16, 0.18)",overflowY:"auto",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{position:"sticky",top:0,background:"var(--v2-bg)",borderBottom:"1px solid var(--v2-border)",padding:"var(--v2-pad-4) var(--v2-pad-5)",display:"flex",alignItems:"center",justifyContent:"space-between",zIndex:1},children:[e.jsx("h2",{className:"v2-display",style:{margin:0,fontSize:18,fontWeight:500,color:"var(--v2-ink-primary)"},children:"Tools"}),e.jsx("button",{ref:j,type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:a,"aria-label":"Close tools drawer",children:"Close"})]}),e.jsxs("div",{style:{padding:"var(--v2-pad-5)",display:"flex",flexDirection:"column",gap:"var(--v2-pad-5)"},children:[!c&&e.jsx("p",{style:{margin:0,padding:"var(--v2-pad-3) var(--v2-pad-4)",background:"var(--v2-bg-elev)",border:"1px solid var(--v2-border)",borderRadius:4,color:"var(--v2-ink-secondary)",fontSize:12,lineHeight:1.5},children:"Most tools need an audit to act on. Run an audit first, then come back here."}),c&&e.jsxs(e.Fragment,{children:[e.jsx(O,{title:"AI fixer",children:e.jsx(F,{status:d["ai-prompt"],label:i?"Copy site-wide AI fix prompt":"Copy AI fix prompt",description:i?"Multi-page markdown for ChatGPT/Claude/Copilot. Site-wide summary, consistency findings, per-page violations + fix recipes.":"Markdown for ChatGPT/Claude/Copilot. Every violation with fix recipes, AI-resolved fails, acknowledged context.",onClick:k})}),e.jsxs(O,{title:"Reports",children:[e.jsx(F,{status:d.html,label:i?"Site report (HTML)":"Page report (HTML)",description:i?"Full crawl summary with per-page grades, top violations, consistency findings. Print-ready.":"Print-friendly single-page report.",onClick:f}),e.jsx(F,{status:d["executive-report"],label:"Executive report",description:"Hero grade + framing, top risks, next steps. For non-technical readers.",onClick:()=>b("executive-report","Executive report","executive-report.html")}),i&&e.jsx(F,{status:d["ticket-bundle"],label:"Ticket bundle",description:"Markdown formatted for paste into Linear / Jira / GitHub Issues — one ticket per finding, sorted by severity.",onClick:()=>b("ticket-bundle","Ticket bundle","ticket-bundle.md")})]}),e.jsxs(O,{title:"Compliance & legal",children:[e.jsx(F,{status:d["defense-bundle"],label:"Defense bundle",description:"Anchored chain-of-custody evidence package. Use in pre-litigation.",onClick:()=>b("defense-bundle","Defense bundle","defense-bundle.html")}),e.jsx(F,{status:d["deposition-packet"],label:"Deposition packet",description:"Full evidence bundle — anchor, receipts, fingerprints, signing cert.",onClick:()=>b("deposition-packet","Deposition packet","deposition-packet.html")}),e.jsx(F,{status:d.vpat,label:"VPAT",description:"Voluntary Product Accessibility Template. Procurement-ready.",onClick:()=>b("vpat","VPAT","vpat.html")}),e.jsx(F,{status:d["conformance-crosswalk"],label:"Conformance crosswalk",description:"WCAG ↔ Section 508 ↔ EN 301 549 mapping.",onClick:()=>b("conformance-crosswalk","Conformance crosswalk","conformance-crosswalk.html")}),e.jsx(F,{status:d["methodology-doc"],label:"Methodology PDF",description:"Auditor-explainable methodology — what was tested, how, with what tools.",onClick:()=>b("methodology-doc","Methodology doc","methodology-doc.html")}),e.jsx(F,{status:d["evidence-bundle"],label:"Evidence bundle",description:"Lighter than defense bundle — audit records + summary.",onClick:()=>b("evidence-bundle","Evidence bundle","evidence-bundle.html")})]}),e.jsx(O,{title:"Bulk",children:e.jsx(F,{status:d.zip,label:i?"Download all as ZIP":"Download both as ZIP",description:i?"Every format above bundled in one ZIP. Runs each export in sequence — ~30s for an 8-page crawl.":"AI fix prompt + page report in one ZIP.",onClick:u})})]}),e.jsxs(O,{title:"Specialized views (classic UI)",children:[e.jsx("p",{style:{margin:0,marginBottom:"var(--v2-pad-2)",fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:`These surfaces aren't ported to v2 yet — clicking opens them in the classic UI. Return to v2 anytime via the "Try v2 UI" button in the classic Header.`}),e.jsx(N,{label:"State matrix",description:"Per-state findings grid (hover · focus · dark · RTL · etc.)",onClick:()=>g("matrix")}),e.jsx(N,{label:"Per-area compliance",description:"9 sub-grade areas with drill-in: Color & contrast, Keyboard, etc.",onClick:()=>g("report")}),e.jsx(N,{label:"Baseline delta",description:"New vs. persistent vs. fixed vs. acknowledged since the last baseline.",onClick:()=>g("delta")}),e.jsx(N,{label:"Forensic log",description:"Anchored audit history with chain-of-custody.",onClick:()=>g("forensic")}),e.jsx(N,{label:"Risk dashboard",description:"Lawsuit / conformance risk tiers with prioritized actions.",onClick:()=>g("risk")}),e.jsx(N,{label:"WCAG 3 mapping",description:"Outcome-level grouping per WCAG 3 snapshot.",onClick:()=>g("wcag3")}),e.jsx(N,{label:"WCAG-EM verdicts",description:"Formal per-criterion verdict map.",onClick:()=>g("compliance")}),e.jsx(N,{label:"Schedules",description:"Recurring audit management with email alerts.",onClick:()=>g("schedules")}),e.jsx(N,{label:"Copilot chat",description:"Anthropic-powered Q&A over your audit context.",onClick:()=>g("copilot")}),e.jsx(N,{label:"Accessibility tree",description:"Inspect the live aria tree as assistive tech sees it.",onClick:()=>g("ax-tree")}),e.jsx(N,{label:"Design tokens",description:"CSS-token / design-system audit.",onClick:()=>g("tokens")}),e.jsx(N,{label:"Guided audit",description:"13 manual IGT workflows (keyboard, screen reader, etc.).",onClick:()=>g("guided")}),e.jsx(N,{label:"Per-component scorecard",description:"Custom rules, baselines, per-component drill-in.",onClick:()=>g("scorecard")}),e.jsx(N,{label:"User journey flows",description:"Multi-step audit recordings.",onClick:()=>g("flows")}),e.jsx(N,{label:"Activity / IGT runs",description:"Manual workflow run history.",onClick:()=>g("activity")})]}),e.jsx(O,{title:"Settings",children:e.jsx(F,{status:void 0,label:"Open settings",description:"Matrix preset, AI config, axe rule overrides, breakpoints, auto-export.",onClick:S})})]})]})]}):null}async function G(t,a,r){const n=new Blob([t],{type:r}),s=URL.createObjectURL(n);try{await chrome.tabs.create({url:s})}catch{const l=document.createElement("a");l.href=s,l.download=a,l.click()}setTimeout(()=>URL.revokeObjectURL(s),6e4)}function O({title:t,children:a}){return e.jsxs("div",{children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,marginBottom:"var(--v2-pad-2)",color:"var(--v2-ink-tertiary)"},children:t}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)"},children:a})]})}function F({label:t,description:a,status:r,onClick:n}){const s=(r==null?void 0:r.state)==="busy",l=(r==null?void 0:r.state)==="done",o=(r==null?void 0:r.state)==="error";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:t}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:n,disabled:s,children:s?"Working…":l?"Run again":"Run"})]}),a&&e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:a}),l&&(r==null?void 0:r.message)&&e.jsxs("p",{role:"status",style:{margin:0,marginTop:4,fontSize:11,color:"var(--v2-verified)"},children:["✓ ",r.message]}),o&&(r==null?void 0:r.message)&&e.jsx("p",{role:"alert",style:{margin:0,marginTop:4,fontSize:11,color:"var(--v2-critical)"},children:r.message})]})}function N({label:t,description:a,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,style:{appearance:"none",cursor:"pointer",display:"flex",flexDirection:"column",gap:4,padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-border)",borderRadius:4,background:"var(--v2-bg)",textAlign:"left",font:"inherit",color:"var(--v2-ink-primary)",width:"100%"},children:[e.jsxs("span",{style:{fontSize:13,fontWeight:500},children:[t," →"]}),e.jsx("span",{style:{fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:a})]})}function Pt(){var l,o;const t=w(i=>i.siteCrawlReport),a=w(i=>i.results),[r,n]=p.useState(!1),s=(t==null?void 0:t.startUrl)??((l=a[0])==null?void 0:l.pageUrl)??((o=a[0])==null?void 0:o.scope)??null;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{role:"banner",style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-4)",padding:"var(--v2-pad-3) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",background:"var(--v2-bg)",minHeight:44},children:[e.jsx("a",{href:"#main-content",className:"v2-skip-link",style:{position:"absolute",left:-9999},onFocus:i=>{i.currentTarget.style.left="var(--v2-pad-4)",i.currentTarget.style.top="var(--v2-pad-4)"},onBlur:i=>{i.currentTarget.style.left="-9999px"},children:"Skip to main content"}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-2)"},children:[e.jsx("span",{className:"v2-display",style:{fontSize:18,fontWeight:600,letterSpacing:"-0.01em",color:"var(--v2-ink-primary)"},children:"wcagcheckr"}),e.jsx("span",{className:"v2-eyebrow",children:"v2"})]}),s&&e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--v2-pad-2)",marginLeft:"var(--v2-pad-4)",minWidth:0,flex:1},children:[e.jsx("span",{className:"v2-eyebrow",children:"scope"}),e.jsx("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},title:s,children:s})]}),e.jsxs("nav",{"aria-label":"Application",style:{display:"flex",gap:"var(--v2-pad-1)",marginLeft:"auto"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>{chrome.storage.local.set({v2UiEnabled:!1})},"aria-label":"Switch back to the classic UI",title:"Switch back to the classic v1 UI",children:"Use v1"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>n(!0),"aria-label":"Open tools and exports drawer","aria-expanded":r,title:"Exports, baselines, schedules, forensic log, settings, more",children:"Tools"})]})]}),e.jsx(Dt,{open:r,onClose:()=>n(!1)})]})}function $t(){return p.useEffect(()=>{const t=Te(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),n=Re();Ie({forceRefresh:!0}).catch(()=>{}),Ae().catch(()=>{}),Ne().catch(()=>{}),Ee().catch(()=>{}),Ue().catch(()=>{}),qe().then(l=>{w.getState().setAcknowledgedKeys(new Set(l.map(o=>o.matchKey)))}).catch(()=>{});let s=!1;return Ye().then(l=>{s||l&&w.setState({siteCrawlReport:l})}).catch(()=>{}),()=>{s=!0,n();try{t.disconnect()}catch{}try{r==null||r.disconnect()}catch{}}},[]),e.jsxs("div",{className:"v2-root",children:[e.jsx(Pt,{}),e.jsxs("main",{id:"main-content","aria-label":"wcagcheckr findings",children:[e.jsx(ht,{}),e.jsx(Et,{})]})]})}Qe("side-panel");const K="v2UiEnabled";function Wt(){const[t,a]=p.useState(null);return p.useEffect(()=>{let r=!1;chrome.storage.local.get(K).then(s=>{r||a(!!s[K])}).catch(()=>a(!1));const n=(s,l)=>{var o;l==="local"&&K in s&&a(!!((o=s[K])!=null&&o.newValue))};return chrome.storage.onChanged.addListener(n),()=>{r=!0,chrome.storage.onChanged.removeListener(n)}},[]),t===null?null:t?e.jsx($t,{}):e.jsx(Fe,{})}const ye=document.getElementById("root");if(!ye)throw new Error("side-panel: #root not found");we(ye).render(e.jsx(je.StrictMode,{children:e.jsx(ze,{children:e.jsx(Wt,{})})}));
@@ -1,4 +1,4 @@
1
- import{aK as v,aL as k}from"./scheduled-audit-runner-DyKpb3zg.js";import"./diff-DA41zYPc.js";import"./crash-reporter-Bu2p8K-p.js";import"./ai-usage-log-BX3L6bKl.js";const f={A:"#16a34a",B:"#65a30d",C:"#ca8a04",D:"#dc2626",F:"#7f1d1d"},z={low:"#16a34a",moderate:"#ca8a04",high:"#dc2626",critical:"#7f1d1d"},d={critical:"#7f1d1d",serious:"#dc2626",moderate:"#ca8a04",minor:"#65a30d"};function o(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function h(e){if(e<1e3)return`${e}ms`;const n=Math.round(e/100)/10;if(n<60)return`${n}s`;const a=Math.floor(n/60),s=Math.round(n-a*60);return`${a}m ${s}s`}function R(e){return`<span style="display:inline-block;background:${f[e]};color:#fff;font-weight:700;padding:2px 10px;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;">${e}</span>`}function m(e){return`<span style="display:inline-block;background:${z[e]};color:#fff;font-weight:600;padding:2px 10px;border-radius:12px;font-size:11px;text-transform:uppercase;letter-spacing:0.05em;">${e}</span>`}function A(e){return`<span style="display:inline-block;background:${d[e]};color:#fff;font-weight:600;padding:1px 8px;border-radius:10px;font-size:11px;">${e}</span>`}function M(e){return`
1
+ import{aK as v,aL as k}from"./scheduled-audit-runner-BB7YtjU4.js";import"./diff-DA41zYPc.js";import"./crash-reporter-Bu2p8K-p.js";import"./ai-usage-log-BX3L6bKl.js";const f={A:"#16a34a",B:"#65a30d",C:"#ca8a04",D:"#dc2626",F:"#7f1d1d"},z={low:"#16a34a",moderate:"#ca8a04",high:"#dc2626",critical:"#7f1d1d"},d={critical:"#7f1d1d",serious:"#dc2626",moderate:"#ca8a04",minor:"#65a30d"};function o(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function h(e){if(e<1e3)return`${e}ms`;const n=Math.round(e/100)/10;if(n<60)return`${n}s`;const a=Math.floor(n/60),s=Math.round(n-a*60);return`${a}m ${s}s`}function R(e){return`<span style="display:inline-block;background:${f[e]};color:#fff;font-weight:700;padding:2px 10px;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;">${e}</span>`}function m(e){return`<span style="display:inline-block;background:${z[e]};color:#fff;font-weight:600;padding:2px 10px;border-radius:12px;font-size:11px;text-transform:uppercase;letter-spacing:0.05em;">${e}</span>`}function A(e){return`<span style="display:inline-block;background:${d[e]};color:#fff;font-weight:600;padding:1px 8px;border-radius:10px;font-size:11px;">${e}</span>`}function M(e){return`
2
2
  <section style="background:#0f172a;color:#fff;padding:32px 40px;border-radius:8px;margin-bottom:24px;">
3
3
  <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:24px;flex-wrap:wrap;">
4
4
  <div>