@wcag-checkr/ci 1.0.11 → 1.0.12

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,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ErrorBoundary-CGD9kz0E.js","assets/styles-DlQee1FU.js","assets/_commonjsHelpers-Cpj98o6Y.js","assets/crash-reporter-DAZnNefT.js","assets/ai-usage-log-C9Opn0x0.js","assets/styles-wT2ZFAYL.css","assets/scheduled-audit-runner-EQBltZPz.js","assets/preload-helper-D7HrI6pR.js","assets/diff-CECbooHD.js","assets/design-system-audit-DpxJrxnb.js"])))=>i.map(i=>d[i]);
2
- import{_ as l}from"./preload-helper-D7HrI6pR.js";import{r as v}from"./crash-reporter-DAZnNefT.js";async function C(e){var f,w,y,g;if(e.results.length===0)return;let d;if(e.componentId){const o=await chrome.storage.local.get("igtRuns"),a=((o==null?void 0:o.igtRuns)??{})[e.componentId]??{};d=Object.values(a)}let p,u;const i=((f=e.results[0])==null?void 0:f.pageUrl)??((w=e.results[0])==null?void 0:w.scope)??"";if(i){const{getDismissalsForUrl:o}=await l(async()=>{const{getDismissalsForUrl:t}=await import("./ErrorBoundary-CGD9kz0E.js").then(n=>n.o);return{getDismissalsForUrl:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),r=await o(i);p=Object.keys(r);const{getResolutionsForPage:a}=await l(async()=>{const{getResolutionsForPage:t}=await import("./scheduled-audit-runner-EQBltZPz.js").then(n=>n.b5);return{getResolutionsForPage:t}},__vite__mapDeps([6,7,3,8,4])),c=await a(i),x=new Set;for(const t of e.results)for(const n of((y=t.axeRulesEvaluated)==null?void 0:y.incomplete)??[])for(const _ of n.elements??[])x.add(`${n.ruleId}::${_.selector}`);u=c.filter(t=>x.has(`${t.ruleId}::${t.selector}`))}let m;if(e.componentId){const{loadAcknowledgedKeysForComponent:o}=await l(async()=>{const{loadAcknowledgedKeysForComponent:a}=await import("./scheduled-audit-runner-EQBltZPz.js").then(c=>c.b4);return{loadAcknowledgedKeysForComponent:a}},__vite__mapDeps([6,7,3,8,4])),r=await o(e.componentId);m=r.size>0?Array.from(r):void 0}const b=await v({type:"EXPORT_REQUEST",format:"ai-prompt",results:e.results,delta:e.delta??void 0,manualRuns:d,siteCrawlReport:e.siteCrawlReport??void 0,dismissedKeys:p,incompleteResolutions:u,acknowledgedKeys:m});try{await navigator.clipboard.writeText(b.content)}catch{}const h=`<!doctype html><html><head><meta charset="utf-8"><title>AI fix prompt</title>
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ErrorBoundary-D-5bMIZq.js","assets/styles-uesms5w-.js","assets/_commonjsHelpers-Cpj98o6Y.js","assets/crash-reporter-DAZnNefT.js","assets/ai-usage-log-C9Opn0x0.js","assets/styles-8UI6xBiw.css","assets/scheduled-audit-runner-EQBltZPz.js","assets/preload-helper-D7HrI6pR.js","assets/diff-CECbooHD.js","assets/design-system-audit-DpxJrxnb.js"])))=>i.map(i=>d[i]);
2
+ import{_ as l}from"./preload-helper-D7HrI6pR.js";import{r as v}from"./crash-reporter-DAZnNefT.js";async function C(e){var f,w,y,g;if(e.results.length===0)return;let d;if(e.componentId){const o=await chrome.storage.local.get("igtRuns"),a=((o==null?void 0:o.igtRuns)??{})[e.componentId]??{};d=Object.values(a)}let p,u;const i=((f=e.results[0])==null?void 0:f.pageUrl)??((w=e.results[0])==null?void 0:w.scope)??"";if(i){const{getDismissalsForUrl:o}=await l(async()=>{const{getDismissalsForUrl:t}=await import("./ErrorBoundary-D-5bMIZq.js").then(n=>n.o);return{getDismissalsForUrl:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),r=await o(i);p=Object.keys(r);const{getResolutionsForPage:a}=await l(async()=>{const{getResolutionsForPage:t}=await import("./scheduled-audit-runner-EQBltZPz.js").then(n=>n.b5);return{getResolutionsForPage:t}},__vite__mapDeps([6,7,3,8,4])),c=await a(i),x=new Set;for(const t of e.results)for(const n of((y=t.axeRulesEvaluated)==null?void 0:y.incomplete)??[])for(const _ of n.elements??[])x.add(`${n.ruleId}::${_.selector}`);u=c.filter(t=>x.has(`${t.ruleId}::${t.selector}`))}let m;if(e.componentId){const{loadAcknowledgedKeysForComponent:o}=await l(async()=>{const{loadAcknowledgedKeysForComponent:a}=await import("./scheduled-audit-runner-EQBltZPz.js").then(c=>c.b4);return{loadAcknowledgedKeysForComponent:a}},__vite__mapDeps([6,7,3,8,4])),r=await o(e.componentId);m=r.size>0?Array.from(r):void 0}const b=await v({type:"EXPORT_REQUEST",format:"ai-prompt",results:e.results,delta:e.delta??void 0,manualRuns:d,siteCrawlReport:e.siteCrawlReport??void 0,dismissedKeys:p,incompleteResolutions:u,acknowledgedKeys:m});try{await navigator.clipboard.writeText(b.content)}catch{}const h=`<!doctype html><html><head><meta charset="utf-8"><title>AI fix prompt</title>
3
3
  <style>body{font:14px/1.5 ui-monospace,Menlo,monospace;max-width:920px;margin:24px auto;padding:0 16px;color:#0f172a;}
4
4
  .banner{background:#ecfdf5;border:1px solid #6ee7b7;padding:12px 14px;border-radius:6px;margin-bottom:16px;font-family:system-ui;}
5
5
  pre{white-space:pre-wrap;word-break:break-word;background:#f8fafc;border:1px solid #e2e8f0;padding:14px;border-radius:6px;font-size:13px;}
@@ -1 +1 @@
1
- import"./modulepreload-polyfill-B5Qt9EMX.js";import{c as s,j as e,R as n}from"./styles-DlQee1FU.js";import{E as i,u as a,n as l}from"./ErrorBoundary-CGD9kz0E.js";import{i as p,e as m}from"./crash-reporter-DAZnNefT.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./ai-usage-log-C9Opn0x0.js";import"./scheduled-audit-runner-EQBltZPz.js";import"./preload-helper-D7HrI6pR.js";import"./diff-CECbooHD.js";import"./design-system-audit-DpxJrxnb.js";p("devtools-panel");function c(){const t=a(r=>r.tier);return m(t,"devtoolsPanel")?e.jsx(l,{}):e.jsxs("div",{style:{padding:24,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif'},children:[e.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"#1f2923"},children:"DevTools panel isn’t available on your current plan"}),e.jsx("p",{style:{marginTop:8,fontSize:13,color:"#64748b"},children:"The wcagcheckr DevTools panel is part of a higher-tier plan. The extension’s side panel is still available — open it from the extensions menu."})]})}const o=document.getElementById("root");if(!o)throw new Error("devtools panel: #root not found");s(o).render(e.jsx(n.StrictMode,{children:e.jsx(i,{children:e.jsx(c,{})})}));
1
+ import"./modulepreload-polyfill-B5Qt9EMX.js";import{c as s,j as e,R as n}from"./styles-uesms5w-.js";import{E as i,u as a,n as l}from"./ErrorBoundary-D-5bMIZq.js";import{i as p,e as m}from"./crash-reporter-DAZnNefT.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./ai-usage-log-C9Opn0x0.js";import"./scheduled-audit-runner-EQBltZPz.js";import"./preload-helper-D7HrI6pR.js";import"./diff-CECbooHD.js";import"./design-system-audit-DpxJrxnb.js";p("devtools-panel");function c(){const t=a(r=>r.tier);return m(t,"devtoolsPanel")?e.jsx(l,{}):e.jsxs("div",{style:{padding:24,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif'},children:[e.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"#1f2923"},children:"DevTools panel isn’t available on your current plan"}),e.jsx("p",{style:{marginTop:8,fontSize:13,color:"#64748b"},children:"The wcagcheckr DevTools panel is part of a higher-tier plan. The extension’s side panel is still available — open it from the extensions menu."})]})}const o=document.getElementById("root");if(!o)throw new Error("devtools panel: #root not found");s(o).render(e.jsx(n.StrictMode,{children:e.jsx(i,{children:e.jsx(c,{})})}));
@@ -1,4 +1,4 @@
1
- import"./modulepreload-polyfill-B5Qt9EMX.js";import{a as q,R as D,u as z,j as e,b as X,r as l,d as be,P as U,e as L,f as ge,g as Ge,h as Be,i as ye,k as _,y as Ke,C as Ve,A as He,c as Ye}from"./styles-DlQee1FU.js";import{c as ve,r as T,o as Je,T as ze,a as We,s as C,O as Z,b as qe,l as Qe,g as Xe,d as Ze}from"./crash-reporter-DAZnNefT.js";import{w as et,r as tt}from"./tier-config-client-CGmK5CXV.js";import{D as st,A as K,g as at,a as nt,s as ee,c as rt,b as V,l as ot,d as lt,e as te}from"./ai-usage-log-C9Opn0x0.js";import{l as it,s as se,v as ct}from"./custom-rules-CAe0nbES.js";import"./_commonjsHelpers-Cpj98o6Y.js";function dt(t){const s=t+"CollectionProvider",[a,n]=q(s),[o,d]=a(s,{collectionRef:{current:null},itemMap:new Map}),c=N=>{const{scope:p,children:x}=N,f=D.useRef(null),y=D.useRef(new Map).current;return e.jsx(o,{scope:p,itemMap:y,collectionRef:f,children:x})};c.displayName=s;const r=t+"CollectionSlot",u=X(r),m=D.forwardRef((N,p)=>{const{scope:x,children:f}=N,y=d(r,x),k=z(p,y.collectionRef);return e.jsx(u,{ref:k,children:f})});m.displayName=r;const i=t+"CollectionItemSlot",h="data-radix-collection-item",b=X(i),g=D.forwardRef((N,p)=>{const{scope:x,children:f,...y}=N,k=D.useRef(null),F=z(p,k),R=d(i,x);return D.useEffect(()=>(R.itemMap.set(k,{ref:k,...y}),()=>void R.itemMap.delete(k))),e.jsx(b,{[h]:"",ref:F,children:f})});g.displayName=i;function j(N){const p=d(t+"CollectionConsumer",N);return D.useCallback(()=>{const f=p.collectionRef.current;if(!f)return[];const y=Array.from(f.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((R,E)=>y.indexOf(R.ref.current)-y.indexOf(E.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:c,Slot:m,ItemSlot:g},j,n]}var ut=l.createContext(void 0);function je(t){const s=l.useContext(ut);return t||s||"ltr"}var H="rovingFocusGroup.onEntryFocus",xt={bubbles:!1,cancelable:!0},O="RovingFocusGroup",[W,Ne,mt]=dt(O),[ht,ke]=q(O,[mt]),[pt,ft]=ht(O),Se=l.forwardRef((t,s)=>e.jsx(W.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(W.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(bt,{...t,ref:s})})}));Se.displayName=O;var bt=l.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:o=!1,dir:d,currentTabStopId:c,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:u,onEntryFocus:m,preventScrollOnEntryFocus:i=!1,...h}=t,b=l.useRef(null),g=z(s,b),j=je(d),[N,p]=ge({prop:c,defaultProp:r??null,onChange:u,caller:O}),[x,f]=l.useState(!1),y=Ge(m),k=Ne(a),F=l.useRef(!1),[R,E]=l.useState(0);return l.useEffect(()=>{const w=b.current;if(w)return w.addEventListener(H,y),()=>w.removeEventListener(H,y)},[y]),e.jsx(pt,{scope:a,orientation:n,dir:j,loop:o,currentTabStopId:N,onItemFocus:l.useCallback(w=>p(w),[p]),onItemShiftTab:l.useCallback(()=>f(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(w=>w+1),[]),onFocusableItemRemove:l.useCallback(()=>E(w=>w-1),[]),children:e.jsx(U.div,{tabIndex:x||R===0?-1:0,"data-orientation":n,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:L(t.onMouseDown,()=>{F.current=!0}),onFocus:L(t.onFocus,w=>{const v=!F.current;if(w.target===w.currentTarget&&v&&!x){const S=new CustomEvent(H,xt);if(w.currentTarget.dispatchEvent(S),!S.defaultPrevented){const A=k().filter(P=>P.focusable),I=A.find(P=>P.active),Oe=A.find(P=>P.id===N),$e=[I,Oe,...A].filter(Boolean).map(P=>P.ref.current);Ce($e,i)}}F.current=!1}),onBlur:L(t.onBlur,()=>f(!1))})})}),we="RovingFocusGroupItem",Te=l.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:o=!1,tabStopId:d,children:c,...r}=t,u=be(),m=d||u,i=ft(we,a),h=i.currentTabStopId===m,b=Ne(a),{onFocusableItemAdd:g,onFocusableItemRemove:j,currentTabStopId:N}=i;return l.useEffect(()=>{if(n)return g(),()=>j()},[n,g,j]),e.jsx(W.ItemSlot,{scope:a,id:m,focusable:n,active:o,children:e.jsx(U.span,{tabIndex:h?0:-1,"data-orientation":i.orientation,...r,ref:s,onMouseDown:L(t.onMouseDown,p=>{n?i.onItemFocus(m):p.preventDefault()}),onFocus:L(t.onFocus,()=>i.onItemFocus(m)),onKeyDown:L(t.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){i.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const x=vt(p,i.orientation,i.dir);if(x!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let y=b().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const k=y.indexOf(p.currentTarget);y=i.loop?jt(y,k+1):y.slice(k+1)}setTimeout(()=>Ce(y))}}),children:typeof c=="function"?c({isCurrentTabStop:h,hasTabStop:N!=null}):c})})});Te.displayName=we;var gt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function vt(t,s,a){const n=yt(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return gt[n]}function Ce(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function jt(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var Nt=Se,kt=Te,B="Tabs",[St]=q(B,[ke]),Ee=ke(),[wt,Q]=St(B),Ae=l.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:o,defaultValue:d,orientation:c="horizontal",dir:r,activationMode:u="automatic",...m}=t,i=je(r),[h,b]=ge({prop:n,onChange:o,defaultProp:d??"",caller:B});return e.jsx(wt,{scope:a,baseId:be(),value:h,onValueChange:b,orientation:c,dir:i,activationMode:u,children:e.jsx(U.div,{dir:i,"data-orientation":c,...m,ref:s})})});Ae.displayName=B;var Ie="TabsList",Re=l.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...o}=t,d=Q(Ie,a),c=Ee(a);return e.jsx(Nt,{asChild:!0,...c,orientation:d.orientation,dir:d.dir,loop:n,children:e.jsx(U.div,{role:"tablist","aria-orientation":d.orientation,...o,ref:s})})});Re.displayName=Ie;var _e="TabsTrigger",Le=l.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:o=!1,...d}=t,c=Q(_e,a),r=Ee(a),u=Pe(c.baseId,n),m=Ue(c.baseId,n),i=n===c.value;return e.jsx(kt,{asChild:!0,...r,focusable:!o,active:i,children:e.jsx(U.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":m,"data-state":i?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...d,ref:s,onMouseDown:L(t.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?c.onValueChange(n):h.preventDefault()}),onKeyDown:L(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&c.onValueChange(n)}),onFocus:L(t.onFocus,()=>{const h=c.activationMode!=="manual";!i&&!o&&h&&c.onValueChange(n)})})})});Le.displayName=_e;var Fe="TabsContent",De=l.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:o,children:d,...c}=t,r=Q(Fe,a),u=Pe(r.baseId,n),m=Ue(r.baseId,n),i=n===r.value,h=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(b)},[]),e.jsx(Be,{present:o||i,children:({present:b})=>e.jsx(U.div,{"data-state":i?"active":"inactive","data-orientation":r.orientation,role:"tabpanel","aria-labelledby":u,hidden:!b,id:m,tabIndex:0,...c,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:b&&d})})});De.displayName=Fe;function Pe(t,s){return`${t}-trigger-${s}`}function Ue(t,s){return`${t}-content-${s}`}var Tt=Ae,Ct=Re,Et=Le,$=De;const At=["default","hover","focus","focus-visible","active","disabled"],It=["light","dark","forced-colors-active","forced-colors-none"],Rt=["ltr","rtl"];function _t({value:t,onChange:s}){function a(o,d){return o.includes(d)?o.filter(c=>c!==d):[...o,d]}function n(){const o=t.ariaVariations.length===0?1:t.ariaVariations.length;return t.pseudoStates.length*o*t.themes.length*t.directions.length*t.breakpoints.length}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[e.jsx(G,{label:"Pseudo-states",all:At,selected:t.pseudoStates,onToggle:o=>s({...t,pseudoStates:a(t.pseudoStates,o)})}),e.jsx(G,{label:"Themes",all:It,selected:t.themes,onToggle:o=>s({...t,themes:a(t.themes,o)})}),e.jsx(G,{label:"Directions",all:Rt,selected:t.directions,onToggle:o=>s({...t,directions:a(t.directions,o)})}),e.jsx(G,{label:"Breakpoints",all:t.breakpointPresets.map(o=>o.id),selected:t.breakpoints,onToggle:o=>s({...t,breakpoints:a(t.breakpoints,o)})}),e.jsxs("p",{className:"text-xs text-slate-500 pt-2 border-t border-slate-100",children:[e.jsx("strong",{children:n()})," audits per component"]})]})}function G({label:t,all:s,selected:a,onToggle:n}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium mb-1.5",children:t}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(o=>{const d=a.includes(o);return e.jsx("button",{type:"button",onClick:()=>n(o),className:d?"text-xs px-2 py-1 rounded bg-brand-500 text-white":"text-xs px-2 py-1 rounded bg-slate-100 text-slate-700 hover:bg-slate-200",children:o},o)})})]})}function Lt({value:t,onChange:s}){const[a,n]=l.useState(""),[o,d]=l.useState("");function c(m){m.preventDefault();const i=a.trim(),h=o.trim();!i||!h||(s({...t,[i]:h}),n(""),d(""))}function r(m){const i={...t};delete i[m],s(i)}const u=Object.entries(t);return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[u.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no aliases"}):e.jsx("ul",{className:"space-y-1",children:u.map(([m,i])=>e.jsxs("li",{className:"text-xs flex items-center justify-between gap-2 border border-slate-100 rounded p-1.5",children:[e.jsxs("span",{className:"font-mono truncate",title:`${m} → ${i}`,children:[m," ",e.jsx("span",{className:"text-slate-500",children:"→"})," ",i]}),e.jsx("button",{onClick:()=>r(m),className:"text-slate-500 hover:text-red-600 shrink-0","aria-label":`Remove alias ${m}`,children:"×"})]},m))}),e.jsxs("form",{onSubmit:c,className:"grid grid-cols-[1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"From"}),e.jsx("input",{type:"text",value:a,onChange:m=>n(m.target.value),placeholder:"https://example.com::testid:btn-a",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"Treat as"}),e.jsx("input",{type:"text",value:o,onChange:m=>d(m.target.value),placeholder:"https://example.com::testid:btn-canonical",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsx("button",{type:"submit",className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",disabled:!a.trim()||!o.trim(),children:"Add"})]})]})}const ae=ve("billing-portal-client"),Ft="https://api.wcagcheckr.com",Dt="wcagcheckr",Pt=15e3;async function Ut(t){const s=`${Ft}/v1/products/${Dt}/billing-portal`;try{const a=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(Pt)}),n=await a.json().catch(()=>null);return a.ok?n!=null&&n.url?{ok:!0,url:n.url}:{ok:!1,error:"malformed response — no url",status:a.status}:(ae.warn(`billing portal HTTP ${a.status}`,n),{ok:!1,status:a.status,error:(n==null?void 0:n.hint)??(n==null?void 0:n.error)??`HTTP ${a.status}`})}catch(a){return ae.warn("billing portal request failed",a),{ok:!1,error:a instanceof Error?a.message:String(a)}}}const ne=ve("subscription-resume-client"),Mt="https://api.wcagcheckr.com",Ot="wcagcheckr",$t=1e4;async function Gt(t){try{const s=await fetch(`${Mt}/v1/products/${Ot}/subscription/resume`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout($t)}),a=await s.json().catch(()=>null);return s.ok?{ok:!0,alreadyActive:(a==null?void 0:a.alreadyActive)===!0}:(ne.warn(`resume http ${s.status}`,a),{ok:!1,status:s.status,error:(a==null?void 0:a.hint)??(a==null?void 0:a.error)??`HTTP ${s.status}`})}catch(s){return ne.warn("resume request failed",s),{ok:!1,error:s instanceof Error?s.message:String(s)}}}const Bt={free:"Free",solo:"Solo",team:"Team"},Kt={free:"Free",solo:"Solo (monthly)","solo-yearly":"Solo (yearly)","solo-single-month":"Solo (single month — non-recurring)",team:"Team (5 seats, monthly)","team-yearly":"Team (5 seats, yearly)","team-15":"Team (15 seats, monthly)","team-15-yearly":"Team (15 seats, yearly)"},Vt=new Set(["solo-single-month"]);function Ht(t){if(!t)return null;const s=new Date(t).getTime()-Date.now();return Number.isFinite(s)?Math.ceil(s/(24*60*60*1e3)):null}function M(t){return t?Kt[t]??t:"—"}function re(t){if(!t)return"no expiry on file";try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}function Yt({tier:t,onTierChange:s}){const[a,n]=l.useState(null),[o,d]=l.useState(null),[c,r]=l.useState(!1),[u,m]=l.useState(""),[i,h]=l.useState(!1),[b,g]=l.useState(null),[j,N]=l.useState(!1),[p,x]=l.useState(!1),f=ye(),y=l.useCallback(async v=>{const A=(await chrome.storage.local.get("licenseToken")).licenseToken??null;if(n(A),!A){d(null);return}try{const I=await T({type:"LICENSE_VALIDATE_REQUEST",token:A,forceRefresh:(v==null?void 0:v.forceRefresh)===!0});d(I)}catch{d(null)}},[]);l.useEffect(()=>(y({forceRefresh:!0}),Je("LICENSE_CHANGED_EVENT",()=>{y()})),[y]);async function k(){if(u.trim()){h(!0),g(null);try{const v=await T({type:"LICENSE_SET_REQUEST",token:u.trim()}),S=await T({type:"LICENSE_VALIDATE_REQUEST",token:u.trim()});if(S.valid&&S.plan){const A=Wt(S.plan);s(A);let I=`Activated as ${M(S.plan)}.`;v.seatClaim.ok?v.seatClaim.overCapacity&&(I=`Activated as ${M(S.plan)}. Note: this license is currently OVER its seat cap (${v.seatClaim.seatsUsed} of ${v.seatClaim.seatsTotal} seats). Release one or upgrade.`):v.seatClaim.reason==="cap-reached"?I=`Activated as ${M(S.plan)}, BUT this license is at its seat capacity (${v.seatClaim.seatsUsed} of ${v.seatClaim.seatsTotal} seats used). Release a seat from another device, or upgrade to a higher-seat plan. This device's seat won't be active until you do.`:v.seatClaim.reason==="network"&&(I=`Activated as ${M(S.plan)}. (Seat-tracking ping failed — retrying in the background.)`),g(I),v.seatClaim.ok&&!v.seatClaim.overCapacity?_.polite(I):_.assertive(I),m(""),r(!1),await y()}else{const A="Token did not validate. Check the value and try again.";g(A),_.assertive(A)}}catch(v){const S=v instanceof Error?v.message:String(v);g(S),_.assertive(S)}finally{h(!1)}}}async function F(){if(a)try{await navigator.clipboard.writeText(a),N(!0),setTimeout(()=>N(!1),2e3)}catch{}}async function R(){if(window.confirm(`Remove the active license token from this extension?
1
+ import"./modulepreload-polyfill-B5Qt9EMX.js";import{a as q,R as D,u as z,j as e,b as X,r as l,d as be,P as U,e as L,f as ge,g as Ge,h as Be,i as ye,k as _,y as Ke,C as Ve,A as He,c as Ye}from"./styles-uesms5w-.js";import{c as ve,r as T,o as Je,T as ze,a as We,s as C,O as Z,b as qe,l as Qe,g as Xe,d as Ze}from"./crash-reporter-DAZnNefT.js";import{w as et,r as tt}from"./tier-config-client-CGmK5CXV.js";import{D as st,A as K,g as at,a as nt,s as ee,c as rt,b as V,l as ot,d as lt,e as te}from"./ai-usage-log-C9Opn0x0.js";import{l as it,s as se,v as ct}from"./custom-rules-CAe0nbES.js";import"./_commonjsHelpers-Cpj98o6Y.js";function dt(t){const s=t+"CollectionProvider",[a,n]=q(s),[o,d]=a(s,{collectionRef:{current:null},itemMap:new Map}),c=N=>{const{scope:p,children:x}=N,f=D.useRef(null),y=D.useRef(new Map).current;return e.jsx(o,{scope:p,itemMap:y,collectionRef:f,children:x})};c.displayName=s;const r=t+"CollectionSlot",u=X(r),m=D.forwardRef((N,p)=>{const{scope:x,children:f}=N,y=d(r,x),k=z(p,y.collectionRef);return e.jsx(u,{ref:k,children:f})});m.displayName=r;const i=t+"CollectionItemSlot",h="data-radix-collection-item",b=X(i),g=D.forwardRef((N,p)=>{const{scope:x,children:f,...y}=N,k=D.useRef(null),F=z(p,k),R=d(i,x);return D.useEffect(()=>(R.itemMap.set(k,{ref:k,...y}),()=>void R.itemMap.delete(k))),e.jsx(b,{[h]:"",ref:F,children:f})});g.displayName=i;function j(N){const p=d(t+"CollectionConsumer",N);return D.useCallback(()=>{const f=p.collectionRef.current;if(!f)return[];const y=Array.from(f.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((R,E)=>y.indexOf(R.ref.current)-y.indexOf(E.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:c,Slot:m,ItemSlot:g},j,n]}var ut=l.createContext(void 0);function je(t){const s=l.useContext(ut);return t||s||"ltr"}var H="rovingFocusGroup.onEntryFocus",xt={bubbles:!1,cancelable:!0},O="RovingFocusGroup",[W,Ne,mt]=dt(O),[ht,ke]=q(O,[mt]),[pt,ft]=ht(O),Se=l.forwardRef((t,s)=>e.jsx(W.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(W.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(bt,{...t,ref:s})})}));Se.displayName=O;var bt=l.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:o=!1,dir:d,currentTabStopId:c,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:u,onEntryFocus:m,preventScrollOnEntryFocus:i=!1,...h}=t,b=l.useRef(null),g=z(s,b),j=je(d),[N,p]=ge({prop:c,defaultProp:r??null,onChange:u,caller:O}),[x,f]=l.useState(!1),y=Ge(m),k=Ne(a),F=l.useRef(!1),[R,E]=l.useState(0);return l.useEffect(()=>{const w=b.current;if(w)return w.addEventListener(H,y),()=>w.removeEventListener(H,y)},[y]),e.jsx(pt,{scope:a,orientation:n,dir:j,loop:o,currentTabStopId:N,onItemFocus:l.useCallback(w=>p(w),[p]),onItemShiftTab:l.useCallback(()=>f(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(w=>w+1),[]),onFocusableItemRemove:l.useCallback(()=>E(w=>w-1),[]),children:e.jsx(U.div,{tabIndex:x||R===0?-1:0,"data-orientation":n,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:L(t.onMouseDown,()=>{F.current=!0}),onFocus:L(t.onFocus,w=>{const v=!F.current;if(w.target===w.currentTarget&&v&&!x){const S=new CustomEvent(H,xt);if(w.currentTarget.dispatchEvent(S),!S.defaultPrevented){const A=k().filter(P=>P.focusable),I=A.find(P=>P.active),Oe=A.find(P=>P.id===N),$e=[I,Oe,...A].filter(Boolean).map(P=>P.ref.current);Ce($e,i)}}F.current=!1}),onBlur:L(t.onBlur,()=>f(!1))})})}),we="RovingFocusGroupItem",Te=l.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:o=!1,tabStopId:d,children:c,...r}=t,u=be(),m=d||u,i=ft(we,a),h=i.currentTabStopId===m,b=Ne(a),{onFocusableItemAdd:g,onFocusableItemRemove:j,currentTabStopId:N}=i;return l.useEffect(()=>{if(n)return g(),()=>j()},[n,g,j]),e.jsx(W.ItemSlot,{scope:a,id:m,focusable:n,active:o,children:e.jsx(U.span,{tabIndex:h?0:-1,"data-orientation":i.orientation,...r,ref:s,onMouseDown:L(t.onMouseDown,p=>{n?i.onItemFocus(m):p.preventDefault()}),onFocus:L(t.onFocus,()=>i.onItemFocus(m)),onKeyDown:L(t.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){i.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const x=vt(p,i.orientation,i.dir);if(x!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let y=b().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const k=y.indexOf(p.currentTarget);y=i.loop?jt(y,k+1):y.slice(k+1)}setTimeout(()=>Ce(y))}}),children:typeof c=="function"?c({isCurrentTabStop:h,hasTabStop:N!=null}):c})})});Te.displayName=we;var gt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function vt(t,s,a){const n=yt(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return gt[n]}function Ce(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function jt(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var Nt=Se,kt=Te,B="Tabs",[St]=q(B,[ke]),Ee=ke(),[wt,Q]=St(B),Ae=l.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:o,defaultValue:d,orientation:c="horizontal",dir:r,activationMode:u="automatic",...m}=t,i=je(r),[h,b]=ge({prop:n,onChange:o,defaultProp:d??"",caller:B});return e.jsx(wt,{scope:a,baseId:be(),value:h,onValueChange:b,orientation:c,dir:i,activationMode:u,children:e.jsx(U.div,{dir:i,"data-orientation":c,...m,ref:s})})});Ae.displayName=B;var Ie="TabsList",Re=l.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...o}=t,d=Q(Ie,a),c=Ee(a);return e.jsx(Nt,{asChild:!0,...c,orientation:d.orientation,dir:d.dir,loop:n,children:e.jsx(U.div,{role:"tablist","aria-orientation":d.orientation,...o,ref:s})})});Re.displayName=Ie;var _e="TabsTrigger",Le=l.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:o=!1,...d}=t,c=Q(_e,a),r=Ee(a),u=Pe(c.baseId,n),m=Ue(c.baseId,n),i=n===c.value;return e.jsx(kt,{asChild:!0,...r,focusable:!o,active:i,children:e.jsx(U.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":m,"data-state":i?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...d,ref:s,onMouseDown:L(t.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?c.onValueChange(n):h.preventDefault()}),onKeyDown:L(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&c.onValueChange(n)}),onFocus:L(t.onFocus,()=>{const h=c.activationMode!=="manual";!i&&!o&&h&&c.onValueChange(n)})})})});Le.displayName=_e;var Fe="TabsContent",De=l.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:o,children:d,...c}=t,r=Q(Fe,a),u=Pe(r.baseId,n),m=Ue(r.baseId,n),i=n===r.value,h=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(b)},[]),e.jsx(Be,{present:o||i,children:({present:b})=>e.jsx(U.div,{"data-state":i?"active":"inactive","data-orientation":r.orientation,role:"tabpanel","aria-labelledby":u,hidden:!b,id:m,tabIndex:0,...c,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:b&&d})})});De.displayName=Fe;function Pe(t,s){return`${t}-trigger-${s}`}function Ue(t,s){return`${t}-content-${s}`}var Tt=Ae,Ct=Re,Et=Le,$=De;const At=["default","hover","focus","focus-visible","active","disabled"],It=["light","dark","forced-colors-active","forced-colors-none"],Rt=["ltr","rtl"];function _t({value:t,onChange:s}){function a(o,d){return o.includes(d)?o.filter(c=>c!==d):[...o,d]}function n(){const o=t.ariaVariations.length===0?1:t.ariaVariations.length;return t.pseudoStates.length*o*t.themes.length*t.directions.length*t.breakpoints.length}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[e.jsx(G,{label:"Pseudo-states",all:At,selected:t.pseudoStates,onToggle:o=>s({...t,pseudoStates:a(t.pseudoStates,o)})}),e.jsx(G,{label:"Themes",all:It,selected:t.themes,onToggle:o=>s({...t,themes:a(t.themes,o)})}),e.jsx(G,{label:"Directions",all:Rt,selected:t.directions,onToggle:o=>s({...t,directions:a(t.directions,o)})}),e.jsx(G,{label:"Breakpoints",all:t.breakpointPresets.map(o=>o.id),selected:t.breakpoints,onToggle:o=>s({...t,breakpoints:a(t.breakpoints,o)})}),e.jsxs("p",{className:"text-xs text-slate-500 pt-2 border-t border-slate-100",children:[e.jsx("strong",{children:n()})," audits per component"]})]})}function G({label:t,all:s,selected:a,onToggle:n}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium mb-1.5",children:t}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(o=>{const d=a.includes(o);return e.jsx("button",{type:"button",onClick:()=>n(o),className:d?"text-xs px-2 py-1 rounded bg-brand-500 text-white":"text-xs px-2 py-1 rounded bg-slate-100 text-slate-700 hover:bg-slate-200",children:o},o)})})]})}function Lt({value:t,onChange:s}){const[a,n]=l.useState(""),[o,d]=l.useState("");function c(m){m.preventDefault();const i=a.trim(),h=o.trim();!i||!h||(s({...t,[i]:h}),n(""),d(""))}function r(m){const i={...t};delete i[m],s(i)}const u=Object.entries(t);return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[u.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no aliases"}):e.jsx("ul",{className:"space-y-1",children:u.map(([m,i])=>e.jsxs("li",{className:"text-xs flex items-center justify-between gap-2 border border-slate-100 rounded p-1.5",children:[e.jsxs("span",{className:"font-mono truncate",title:`${m} → ${i}`,children:[m," ",e.jsx("span",{className:"text-slate-500",children:"→"})," ",i]}),e.jsx("button",{onClick:()=>r(m),className:"text-slate-500 hover:text-red-600 shrink-0","aria-label":`Remove alias ${m}`,children:"×"})]},m))}),e.jsxs("form",{onSubmit:c,className:"grid grid-cols-[1fr_1fr_auto] gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"From"}),e.jsx("input",{type:"text",value:a,onChange:m=>n(m.target.value),placeholder:"https://example.com::testid:btn-a",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-slate-500 mb-1",children:"Treat as"}),e.jsx("input",{type:"text",value:o,onChange:m=>d(m.target.value),placeholder:"https://example.com::testid:btn-canonical",className:"w-full text-xs border border-slate-300 rounded px-2 py-1 font-mono"})]}),e.jsx("button",{type:"submit",className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",disabled:!a.trim()||!o.trim(),children:"Add"})]})]})}const ae=ve("billing-portal-client"),Ft="https://api.wcagcheckr.com",Dt="wcagcheckr",Pt=15e3;async function Ut(t){const s=`${Ft}/v1/products/${Dt}/billing-portal`;try{const a=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(Pt)}),n=await a.json().catch(()=>null);return a.ok?n!=null&&n.url?{ok:!0,url:n.url}:{ok:!1,error:"malformed response — no url",status:a.status}:(ae.warn(`billing portal HTTP ${a.status}`,n),{ok:!1,status:a.status,error:(n==null?void 0:n.hint)??(n==null?void 0:n.error)??`HTTP ${a.status}`})}catch(a){return ae.warn("billing portal request failed",a),{ok:!1,error:a instanceof Error?a.message:String(a)}}}const ne=ve("subscription-resume-client"),Mt="https://api.wcagcheckr.com",Ot="wcagcheckr",$t=1e4;async function Gt(t){try{const s=await fetch(`${Mt}/v1/products/${Ot}/subscription/resume`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout($t)}),a=await s.json().catch(()=>null);return s.ok?{ok:!0,alreadyActive:(a==null?void 0:a.alreadyActive)===!0}:(ne.warn(`resume http ${s.status}`,a),{ok:!1,status:s.status,error:(a==null?void 0:a.hint)??(a==null?void 0:a.error)??`HTTP ${s.status}`})}catch(s){return ne.warn("resume request failed",s),{ok:!1,error:s instanceof Error?s.message:String(s)}}}const Bt={free:"Free",solo:"Solo",team:"Team"},Kt={free:"Free",solo:"Solo (monthly)","solo-yearly":"Solo (yearly)","solo-single-month":"Solo (single month — non-recurring)",team:"Team (5 seats, monthly)","team-yearly":"Team (5 seats, yearly)","team-15":"Team (15 seats, monthly)","team-15-yearly":"Team (15 seats, yearly)"},Vt=new Set(["solo-single-month"]);function Ht(t){if(!t)return null;const s=new Date(t).getTime()-Date.now();return Number.isFinite(s)?Math.ceil(s/(24*60*60*1e3)):null}function M(t){return t?Kt[t]??t:"—"}function re(t){if(!t)return"no expiry on file";try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}function Yt({tier:t,onTierChange:s}){const[a,n]=l.useState(null),[o,d]=l.useState(null),[c,r]=l.useState(!1),[u,m]=l.useState(""),[i,h]=l.useState(!1),[b,g]=l.useState(null),[j,N]=l.useState(!1),[p,x]=l.useState(!1),f=ye(),y=l.useCallback(async v=>{const A=(await chrome.storage.local.get("licenseToken")).licenseToken??null;if(n(A),!A){d(null);return}try{const I=await T({type:"LICENSE_VALIDATE_REQUEST",token:A,forceRefresh:(v==null?void 0:v.forceRefresh)===!0});d(I)}catch{d(null)}},[]);l.useEffect(()=>(y({forceRefresh:!0}),Je("LICENSE_CHANGED_EVENT",()=>{y()})),[y]);async function k(){if(u.trim()){h(!0),g(null);try{const v=await T({type:"LICENSE_SET_REQUEST",token:u.trim()}),S=await T({type:"LICENSE_VALIDATE_REQUEST",token:u.trim()});if(S.valid&&S.plan){const A=Wt(S.plan);s(A);let I=`Activated as ${M(S.plan)}.`;v.seatClaim.ok?v.seatClaim.overCapacity&&(I=`Activated as ${M(S.plan)}. Note: this license is currently OVER its seat cap (${v.seatClaim.seatsUsed} of ${v.seatClaim.seatsTotal} seats). Release one or upgrade.`):v.seatClaim.reason==="cap-reached"?I=`Activated as ${M(S.plan)}, BUT this license is at its seat capacity (${v.seatClaim.seatsUsed} of ${v.seatClaim.seatsTotal} seats used). Release a seat from another device, or upgrade to a higher-seat plan. This device's seat won't be active until you do.`:v.seatClaim.reason==="network"&&(I=`Activated as ${M(S.plan)}. (Seat-tracking ping failed — retrying in the background.)`),g(I),v.seatClaim.ok&&!v.seatClaim.overCapacity?_.polite(I):_.assertive(I),m(""),r(!1),await y()}else{const A="Token did not validate. Check the value and try again.";g(A),_.assertive(A)}}catch(v){const S=v instanceof Error?v.message:String(v);g(S),_.assertive(S)}finally{h(!1)}}}async function F(){if(a)try{await navigator.clipboard.writeText(a),N(!0),setTimeout(()=>N(!1),2e3)}catch{}}async function R(){if(window.confirm(`Remove the active license token from this extension?
2
2
 
3
3
  Your subscription stays active server-side — you can paste the same token back in any time. The extension will fall back to trial / free until then.`)){a&&await We(a),await chrome.storage.local.remove("licenseToken"),n(null),d(null);try{const S=await T({type:"TIER_GET"});s(S.tier)}catch{s("free")}_.polite("License token removed.")}}const E=ze[t],w=a!==null&&(o==null?void 0:o.valid)===!0;return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Current tier"}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-slate-100 text-slate-700",children:Bt[t]})]}),e.jsxs("ul",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("li",{children:["Components:"," ",Number.isFinite(E.maxComponents)?E.maxComponents:"unlimited"]}),e.jsxs("li",{children:["Baselines:"," ",Number.isFinite(E.maxBaselines)?E.maxBaselines:"unlimited"]}),e.jsxs("li",{children:["State matrix: ",E.stateMatrix]}),e.jsxs("li",{children:["Storybook auto-iterate: ",E.storybookAutoIterate?"yes":"no"]}),e.jsxs("li",{children:["JSON export: ",E.exportJson?"yes":"no"]}),e.jsxs("li",{children:["SARIF / JUnit export: ",E.exportSarif?"yes":"no"]})]}),w&&o?e.jsx(Jt,{token:a,info:o,copied:j,onCopy:F,onRemove:R,onUseDifferent:()=>r(!0),onManageSubscription:async()=>{const v=await Ut({licenseToken:a});v.ok?window.open(v.url,"_blank","noopener,noreferrer"):(g(`Couldn't open billing portal: ${v.error}`),_.assertive("Could not open billing portal."))},onResumeSubscription:async()=>{const v=await Gt({licenseToken:a});if(v.ok){const S=v.alreadyActive?"Subscription was already active — no change needed.":"Subscription resumed. Cancellation has been reversed.";g(S),_.polite(S),await y({forceRefresh:!0})}else g(`Couldn't resume subscription: ${v.error}`),_.assertive("Could not resume subscription.")},onRenew:()=>x(!0),message:b}):a?e.jsx(zt,{token:a,onRemove:R,onUseDifferent:()=>r(!0)}):e.jsx(oe,{token:u,onTokenChange:m,submitting:i,message:b,onSubmit:k}),w&&c&&e.jsx(oe,{token:u,onTokenChange:m,submitting:i,message:b,onSubmit:k,replacing:!0,onCancel:()=>{r(!1),m(""),g(null)}}),!w&&t==="free"&&e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Solo"}),": $",f.solo.monthlyUsd,"/mo (recurring) ·"," ","$",f.solo.yearlyUsd,"/yr (save"," ",Ke(f.solo.monthlyUsd,f.solo.yearlyUsd),"%) ·"," ","$",f.solo.singleMonthUsd," single month (no recurring) · single user."]}),e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Team"}),": $",f.team.fiveSeatMonthlyUsd,"/mo for 5 seats ·"," ","$",f.team.fifteenSeatMonthlyUsd,"/mo for 15 seats."]}),e.jsx("button",{type:"button",onClick:()=>x(!0),className:"inline-block text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Upgrade →"})]}),e.jsx(Ve,{open:p,onClose:()=>x(!1)})]})}function Jt({token:t,info:s,copied:a,onCopy:n,onRemove:o,onUseDifferent:d,onManageSubscription:c,onResumeSubscription:r,onRenew:u,message:m}){const i=s.features,h=typeof(i==null?void 0:i.seatsUsed)=="number"?i.seatsUsed:null,b=typeof(i==null?void 0:i.seatsTotal)=="number"?i.seatsTotal:null,g=b!==null,j=h!==null&&b!==null&&h>b,N=h!==null&&b!==null&&h===b,p=s.plan?Vt.has(s.plan):!1,x=Ht(s.expiresAt),f=p&&x!==null&&x<=7,y=ye();return e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-700",children:"Active license"}),e.jsx("span",{className:s.cancelAtPeriodEnd?"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-100 text-amber-900":"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-800",children:s.cancelAtPeriodEnd?"cancellation scheduled":s.status??"unknown"})]}),s.pastDueSince&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded p-2 text-[11px] text-rose-900",children:[e.jsx("strong",{children:"Payment failed."})," Stripe couldn't charge your card. Access continues during the grace period (usually up to 7 days while Stripe retries), then this license will cancel automatically."," ",e.jsx("button",{type:"button",onClick:c,className:"font-medium underline-offset-2 hover:underline",children:"Update your card via the Stripe portal →"})]}),s.cancelAtPeriodEnd&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded p-2 text-[11px] text-amber-900 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Cancellation scheduled."})," Your subscription was cancelled via Stripe. Access continues until ",e.jsx("strong",{children:re(s.expiresAt)}),", then this license stops working."]}),e.jsx("button",{type:"button",onClick:r,className:"text-[11px] font-medium underline-offset-2 hover:underline",children:"Resume subscription →"})]}),j&&e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded p-2 text-[11px] text-rose-900",children:[e.jsx("strong",{children:"Over seat capacity."})," This license has"," ",e.jsx("strong",{children:h})," seats in use but the plan only includes"," ",e.jsx("strong",{children:b}),". New devices will be rejected. Release a seat from another device, or upgrade to a higher-seat plan via Manage subscription below."]}),N&&!j&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded p-2 text-[11px] text-amber-900",children:[e.jsx("strong",{children:"At seat capacity."})," All ",e.jsx("strong",{children:b})," seats are in use. The next new device that tries to activate this license will be rejected until a seat is released."]}),e.jsxs("dl",{className:"text-xs text-slate-600 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1",children:[e.jsx("dt",{className:"text-slate-500",children:"Plan"}),e.jsx("dd",{children:M(s.plan)}),e.jsx("dt",{className:"text-slate-500",children:"Email"}),e.jsx("dd",{className:"truncate",children:s.email??"—"}),e.jsx("dt",{className:"text-slate-500",children:p?"Expires":"Renews / ends"}),e.jsxs("dd",{children:[re(s.expiresAt),x!==null&&x>=0&&x<=14?e.jsx("span",{className:f?"ml-2 text-[10px] text-amber-900 bg-amber-100 rounded px-1.5 py-0.5":"ml-2 text-[10px] text-slate-500",children:x===0?"today":x===1?"1 day left":`${x} days left`}):null]}),g?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Seats"}),e.jsx("dd",{children:h!==null?`${h} of ${b} used`:`${b} total`})]}):null]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-500 mb-1",children:"Token"}),e.jsxs("div",{className:"flex items-stretch gap-1",children:[e.jsx("code",{className:"flex-1 font-mono text-[11px] bg-slate-100 border border-slate-200 rounded px-2 py-1.5 select-all break-all",children:t}),e.jsx("button",{type:"button",onClick:n,className:"text-[11px] px-2 py-1.5 border border-slate-300 rounded bg-white hover:bg-slate-50 shrink-0",children:a?"Copied ✓":"Copy"})]})]}),e.jsx("div",{className:"pt-1 flex flex-wrap gap-2",children:p?e.jsx("button",{type:"button",onClick:u,className:f?"text-xs px-3 py-1.5 bg-amber-500 text-white rounded hover:bg-amber-600":"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",title:"Buy another month — extends your existing license, no new token to copy",children:f?`Renew now — $${y.solo.singleMonthUsd} →`:`Buy another month — $${y.solo.singleMonthUsd} →`}):e.jsx("button",{type:"button",onClick:c,className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600",title:"Open Stripe's billing portal — change plan or seat count, update card, view invoices, cancel",children:"Manage subscription →"})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:d,className:"text-[11px] text-brand-600 hover:underline",children:"Use a different token"}),e.jsx("span",{className:"text-slate-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:o,className:"text-[11px] text-rose-700 hover:underline",children:"Remove license from this extension"})]}),m&&e.jsx("p",{className:"text-xs text-slate-600 pt-1",children:m})]})}function zt({token:t,onRemove:s,onUseDifferent:a}){return e.jsxs("div",{className:"border-t border-rose-100 pt-3 space-y-2 bg-rose-50/40 -mx-3 px-3 pb-2 rounded-b",children:[e.jsxs("p",{className:"text-xs text-rose-800",children:[e.jsx("strong",{children:"License token rejected by the server."})," The token may have been revoked, the subscription canceled, or the network is down. Verify your subscription and try a different token — or remove this one and continue on the trial / free tier."]}),e.jsx("p",{className:"text-[11px] text-rose-700 font-mono break-all",children:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:a,className:"text-[11px] text-brand-600 hover:underline",children:"Use a different token"}),e.jsx("span",{className:"text-slate-300","aria-hidden":"true",children:"·"}),e.jsx("button",{type:"button",onClick:s,className:"text-[11px] text-rose-700 hover:underline",children:"Remove and continue without a license"})]})]})}function oe({token:t,onTokenChange:s,submitting:a,message:n,onSubmit:o,replacing:d,onCancel:c}){return e.jsxs("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[e.jsx("label",{htmlFor:"opt-license-token",className:"block text-xs font-medium",children:d?"Replace with a different token":"Activate license token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"opt-license-token",type:"text",value:t,onChange:r=>s(r.target.value),placeholder:"00000000-0000-0000-0000-000000000000",className:"flex-1 text-xs border border-slate-300 rounded px-2 py-1 font-mono"}),e.jsx("button",{onClick:o,disabled:a||!t.trim(),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:a?"Validating…":d?"Replace":"Activate"}),d&&c&&e.jsx("button",{type:"button",onClick:c,className:"text-xs px-3 py-1 border border-slate-300 rounded text-slate-700 hover:bg-slate-50",children:"Cancel"})]}),n&&e.jsx("p",{className:"text-xs text-slate-600",children:n})]})}function Wt(t){return t==="solo"||t==="solo-yearly"||t==="solo-single-month"?"solo":t==="team"||t==="team-15"||t==="team-yearly"||t==="team-15-yearly"?"team":"free"}const qt=new Set(st.map(t=>t.id));function Qt({presets:t,onChange:s}){const[a,n]=l.useState({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1});function o(r){r.preventDefault();const u=a.id.trim();!u||t.some(m=>m.id===u)||(s([...t,{...a,id:u,label:a.label.trim()||`${u} (${a.width}×${a.height})`}]),n({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1}))}function d(r){s(t.filter(u=>u.id!==r))}function c(r,u){s(t.map(m=>m.id===r?{...m,...u}:m))}return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[t.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no breakpoints"}):e.jsx("ul",{className:"space-y-1.5",children:t.map(r=>{const u=qt.has(r.id);return e.jsxs("li",{className:"grid grid-cols-[1fr_70px_70px_auto_auto] gap-2 items-center text-xs",children:[e.jsxs("span",{className:"font-medium truncate",title:r.id,children:[r.label,u&&e.jsx("span",{className:"text-slate-500 font-normal ml-1",children:"(default)"})]}),e.jsx("input",{type:"number",value:r.width,onChange:m=>c(r.id,{width:Number(m.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Width for ${r.label}`,min:1}),e.jsx("input",{type:"number",value:r.height,onChange:m=>c(r.id,{height:Number(m.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Height for ${r.label}`,min:1}),e.jsxs("label",{className:"flex items-center gap-1 text-slate-600",children:[e.jsx("input",{type:"checkbox",checked:r.mobile,onChange:m=>c(r.id,{mobile:m.target.checked})}),"mobile"]}),u?e.jsx("span",{className:"w-4","aria-hidden":"true"}):e.jsx("button",{onClick:()=>d(r.id),className:"text-slate-500 hover:text-red-600","aria-label":`Remove ${r.label}`,children:"×"})]},r.id)})}),e.jsxs("form",{onSubmit:o,className:"grid grid-cols-[1fr_1fr_70px_70px_auto] gap-2 items-end pt-3 border-t border-slate-100",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-id",className:"block text-xs text-slate-500 mb-1",children:"ID"}),e.jsx("input",{id:"bp-draft-id",type:"text",value:a.id,onChange:r=>n({...a,id:r.target.value}),placeholder:"laptop",className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-label",className:"block text-xs text-slate-500 mb-1",children:"Label"}),e.jsx("input",{id:"bp-draft-label",type:"text",value:a.label,onChange:r=>n({...a,label:r.target.value}),placeholder:"Laptop (1440×900)",className:"w-full text-xs border border-slate-300 rounded px-2 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-width",className:"block text-xs text-slate-500 mb-1",children:"W"}),e.jsx("input",{id:"bp-draft-width",type:"number",value:a.width,onChange:r=>n({...a,width:Number(r.target.value)||0}),min:1,className:"w-full text-xs border border-slate-300 rounded px-1.5 py-1"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"bp-draft-height",className:"block text-xs text-slate-500 mb-1",children:"H"}),e.jsx("input",{id:"bp-draft-height",type:"number",value:a.height,onChange:r=>n({...a,height:Number(r.target.value)||0}),min:1,className:"w-full text-xs border border-slate-300 rounded px-1.5 py-1"})]}),e.jsx("button",{type:"submit",disabled:!a.id.trim()||t.some(r=>r.id===a.id.trim()),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:"Add"})]})]})}function Xt({stateMatrix:t,componentIdAliases:s,onImport:a}){const n=l.useRef(null),[o,d]=l.useState(null);function c(){const u={schemaVersion:1,exportedAt:new Date().toISOString(),stateMatrix:t,componentIdAliases:s},m=new Blob([JSON.stringify(u,null,2)],{type:"application/json"}),i=URL.createObjectURL(m),h=document.createElement("a");h.href=i,h.download=`wcag-auditor-settings-${new Date().toISOString().slice(0,10)}.json`,h.click(),URL.revokeObjectURL(i),d("Exported.")}async function r(u){var m,i;d(null);try{const h=await u.text(),b=JSON.parse(h);if(b.schemaVersion!==1)throw new Error(`Unsupported schemaVersion: ${b.schemaVersion}`);if(!((m=b.stateMatrix)!=null&&m.pseudoStates)||!((i=b.stateMatrix)!=null&&i.breakpointPresets))throw new Error("stateMatrix is malformed");await C({type:"SETTINGS_SET",key:"stateMatrix",value:b.stateMatrix}),await C({type:"SETTINGS_SET",key:"componentIdAliases",value:b.componentIdAliases??{}}),a({stateMatrix:b.stateMatrix,componentIdAliases:b.componentIdAliases??{}}),d("Imported.")}catch(h){d(`Import failed: ${h instanceof Error?h.message:String(h)}`)}}return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Export settings"}),e.jsx("button",{onClick:()=>{var u;return(u=n.current)==null?void 0:u.click()},className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Import settings…"}),e.jsx("input",{ref:n,type:"file",accept:"application/json,.json",className:"hidden",onChange:u=>{var i;const m=(i=u.target.files)==null?void 0:i[0];m&&r(m),u.target.value=""}})]}),o&&e.jsx("p",{className:"text-xs text-slate-600",children:o})]})}function Zt(){const[t,s]=l.useState(null);l.useEffect(()=>{chrome.storage.local.get(Z).then(n=>s(n[Z]===!0))},[]);async function a(){const n=!t;s(n),await qe(n)}return t===null?e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"}):e.jsx("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a,className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Send anonymized crash reports"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"When the extension hits an unexpected error, send the error message + redacted stack trace + extension version. URLs, emails, and license tokens are stripped before sending. No audit data, page content, or browsing history is included."})]})]})})}function es(){const[t,s]=l.useState(null);l.useEffect(()=>{chrome.storage.local.get(K).then(n=>s(n[K]===!0))},[]);async function a(){const n=!t;s(n),await chrome.storage.local.set({[K]:n})}return t===null?e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"}):e.jsx("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:a,className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Skip the download confirmation"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"By default, generating a defense or evidence bundle pops up a small confirmation asking whether to download or preview. Enable this to skip the prompt and have the file land directly in your Downloads folder. Keep it off if you'd rather decide each time (recommended for non-technical users — surprise downloads can be alarming)."})]})]})})}const ts={"deposition-packet":{name:"Deposition packet",description:"Court-grade HTML with VPS-anchored RFC 3161 timestamp. Use for active litigation / regulatory submission."},"defense-bundle":{name:"Defense bundle",description:"Locally anchored attorney-ready HTML. The everyday remediation-trail artifact — exec summary, findings, screenshots, VPAT, methodology. Recommended baseline."},"html-print":{name:"Printable HTML",description:"Simple print-ready HTML for sharing with stakeholders. No anchoring, no legal framing — just the findings."},"ai-prompt":{name:"AI fix prompt (markdown)",description:"Markdown prompt for Claude / Cursor / Copilot Chat. Includes fix recipes per violation + acknowledged-findings context. Use for dev handoff after each audit."}};function ss(){const[t,s]=l.useState(null);if(l.useEffect(()=>{let o=!1;return(async()=>{const d=await at();o||s(d)})(),()=>{o=!0}},[]),!t)return e.jsx("p",{className:"text-xs text-slate-500",children:"Loading…"});async function a(){const o={...t,enabled:!t.enabled};s(o),await ee(o)}async function n(o){const d=t.formats.includes(o);let c;d?(c=t.formats.filter(u=>u!==o),c.length===0&&t.enabled&&(c=t.formats)):c=[...t.formats,o];const r={...t,formats:c};s(r),await ee(r)}return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:()=>void a(),className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:"Auto-export every audit"}),e.jsxs("span",{className:"block text-slate-500 mt-0.5",children:["Each completed audit silently downloads the formats checked below. Same setting applies to both manual and scheduled audits. Scheduled audits land in ",e.jsx("span",{className:"font-mono",children:"Downloads/wcagcheckr/{domain}/"}),"; scheduled audits only fire while Chrome is running."]})]})]}),t.enabled&&e.jsxs("fieldset",{className:"pl-6 space-y-2",children:[e.jsx("legend",{className:"text-xs font-medium text-slate-700",children:"Formats to export"}),nt.map(o=>{const d=t.formats.includes(o),c=ts[o];return e.jsxs("label",{className:"flex items-start gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:()=>void n(o),className:"mt-0.5"}),e.jsxs("span",{className:"leading-snug",children:[e.jsx("span",{className:"font-medium",children:c.name}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:c.description})]})]},o)})]})]})}function as(){const[t,s]=l.useState(null),[a,n]=l.useState(!1);async function o(){const c=await chrome.storage.local.get(null),r=Object.keys(c).filter(u=>u.startsWith("auditCache:"));s(r.length)}l.useEffect(()=>{o()},[]);async function d(){n(!0);try{await rt(),await o()}finally{n(!1)}}return e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Audit cache"}),e.jsx("span",{className:"block text-slate-500 mt-0.5",children:"Repeat audits of the same component skip the state-matrix iteration when the DOM is unchanged from the last audit (10-50× faster). The fingerprint is DOM-only — if you change ONLY CSS, the cache won't notice and will return stale results. Clear it here when that happens."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:d,disabled:a||(t??0)===0,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 disabled:opacity-50 disabled:cursor-not-allowed border border-slate-300 rounded",children:a?"Clearing…":"Clear audit cache"}),e.jsx("span",{className:"text-xs text-slate-500",children:t===null?"Loading…":t===0?"Cache is empty.":`${t} cached audit${t===1?"":"s"}.`})]})]})}const le="licenseToken";function ie(t){const s=Date.now()-new Date(t).getTime(),a=Math.floor(s/6e4);if(a<1)return"just now";if(a<60)return`${a} min ago`;const n=Math.floor(a/60);if(n<24)return`${n}h ago`;const o=Math.floor(n/24);return o<30?`${o}d ago`:new Date(t).toLocaleDateString()}function ns(t){return t.slice(0,8)+"…"}function rs(t){return t?/Edg\//.test(t)?"Edge":/Chrome\//.test(t)?"Chrome":/Firefox\//.test(t)?"Firefox":/Safari\//.test(t)?"Safari":t.slice(0,30):"unknown"}function os(){const[t,s]=l.useState(null),[a,n]=l.useState(null),[o,d]=l.useState(null),[c,r]=l.useState(0),[u,m]=l.useState(null),[i,h]=l.useState(!1),[b,g]=l.useState(null),j=l.useCallback(async()=>{h(!0),g(null);try{const x=(await chrome.storage.local.get(le))[le]??null;if(s(x),!x){n(null);return}const f=await Qe(x);if(!f){g("Could not load seats — check network or license validity.");return}n(f.seats),d(f.seatsTotal),r(f.seatsUsed),m(await Xe())}finally{h(!1)}},[]);l.useEffect(()=>{j()},[j]);async function N(p){if(!t)return;const f=p===u?"Revoke THIS device? You will have to re-claim a seat on the next audit (if a seat is available).":"Revoke this seat? The device will be denied audits until it re-claims a seat (subject to the seat cap).";if(window.confirm(f)){h(!0);try{if(!await Ze(t,p)){g("Revoke failed — try again or check network.");return}await j()}finally{h(!1)}}}return t?o===null?e.jsx("div",{className:"text-xs text-slate-500",children:"This license has no seat cap (Solo / single-month / free / trial). Upgrade to a Team plan to see and manage seats here."}):e.jsxs("div",{className:"border border-slate-200 rounded p-3 bg-white space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Team seats"}),e.jsxs("span",{className:"text-slate-500 ml-2",children:[c," of ",o," used",c>o&&e.jsx("span",{className:"ml-2 text-amber-700",children:"(over capacity — release to bring under limit)"})]})]}),e.jsx("button",{onClick:j,disabled:i,className:"text-xs px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:i?"Loading…":"Refresh"})]}),b&&e.jsx("p",{className:"text-xs text-red-700",children:b}),a&&a.length>0?e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-slate-500",children:[e.jsx("th",{className:"font-normal py-1",children:"Device"}),e.jsx("th",{className:"font-normal py-1",children:"Browser"}),e.jsx("th",{className:"font-normal py-1",children:"Claimed"}),e.jsx("th",{className:"font-normal py-1",children:"Last active"}),e.jsx("th",{className:"font-normal py-1"})]})}),e.jsx("tbody",{children:a.map(p=>e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsxs("td",{className:"py-1",children:[e.jsx("code",{className:"text-[10px] text-slate-600",children:ns(p.deviceId)}),p.deviceId===u&&e.jsx("span",{className:"ml-1 text-[10px] text-brand-700",children:"(this device)"})]}),e.jsx("td",{className:"py-1 text-slate-700",children:rs(p.userAgent)}),e.jsx("td",{className:"py-1 text-slate-500",children:ie(p.claimedAt)}),e.jsx("td",{className:"py-1 text-slate-500",children:ie(p.lastSeenAt)}),e.jsx("td",{className:"py-1 text-right",children:e.jsx("button",{onClick:()=>N(p.deviceId),disabled:i,className:"text-[11px] px-2 py-0.5 border border-slate-300 rounded hover:bg-red-50 hover:text-red-800 hover:border-red-300 disabled:opacity-50",children:"Revoke"})})]},p.deviceId))})]}):e.jsx("p",{className:"text-xs text-slate-500",children:"No seats claimed yet."})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Activate a Team license to manage seats here."})}const ls=[{id:"use-our-button",description:"Use the design-system Button, not raw <button>.",impact:"moderate",selector:"button:not([data-component='Button']):not([data-component^='ds-'])",check:{type:"fail-on-match",message:"Replace raw <button> with the design-system Button component."},enabled:!0},{id:"no-inline-styles",description:"Inline style attribute escapes the design tokens.",impact:"minor",selector:"[style]",check:{type:"fail-on-match",message:"Move this style into a design-token-aware CSS class."},enabled:!0},{id:"cta-needs-testid",description:"Every call-to-action button must have data-testid for E2E.",impact:"serious",selector:'button.cta, [data-component="Button"][data-variant="primary"]',check:{type:"attribute-required",attribute:"data-testid",message:"Add a data-testid attribute so QA can target this element."},enabled:!1}];function is(){const[t,s]=l.useState(""),[a,n]=l.useState([]),[o,d]=l.useState(!1),[c,r]=l.useState(null);l.useEffect(()=>{it().then(i=>{s(i.length>0?JSON.stringify(i,null,2):""),d(!0)})},[]);function u(){if(t.trim().length===0){se([]),n([]),r(Date.now());return}let i;try{i=JSON.parse(t)}catch(g){n([`Invalid JSON: ${g instanceof Error?g.message:String(g)}`]);return}const{valid:h,errors:b}=ct(i);if(b.length>0){n(b);return}n([]),se(h),r(Date.now()),s(JSON.stringify(h,null,2))}function m(){s(JSON.stringify(ls,null,2)),n([])}return o?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Custom rules check your design-system contracts during every audit. Three check types supported:"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"fail-on-match"})," (every element matching the selector is a violation),"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"attribute-required"})," ","(the named attribute must be present), and"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"attribute-equals"})," ","(attribute must equal a specific value). Output appears in audit results alongside built-in WCAG rules."]}),e.jsx("textarea",{value:t,onChange:i=>s(i.target.value),rows:14,spellCheck:!1,placeholder:"[]",className:"w-full text-xs font-mono border border-slate-300 rounded p-2 resize-y"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:u,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Save"}),e.jsx("button",{onClick:m,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50",children:"Load example rules"}),c&&a.length===0&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(c).toLocaleTimeString(),"."]})]}),a.length>0&&e.jsx("div",{className:"border border-red-200 bg-red-50 rounded p-2 text-xs text-red-800 space-y-1",children:a.map((i,h)=>e.jsx("div",{children:i},h))})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ce="disabledRules";function cs(){const[t,s]=l.useState(""),[a,n]=l.useState(!1),[o,d]=l.useState(null);l.useEffect(()=>{T({type:"SETTINGS_GET",key:ce}).then(r=>{const u=Array.isArray(r.data)?r.data:[];s(u.join(`
4
4
  `)),n(!0)})},[]);function c(r){const u=r.split(`
@@ -1,4 +1,4 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/site-report-renderer-C3U9cFY3.js","assets/scheduled-audit-runner-EQBltZPz.js","assets/preload-helper-D7HrI6pR.js","assets/crash-reporter-DAZnNefT.js","assets/diff-CECbooHD.js","assets/ai-usage-log-C9Opn0x0.js"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-B5Qt9EMX.js";import{r as c,j as e,C as we,c as Ee,R as Ae}from"./styles-DlQee1FU.js";import{u as m,a as oe,c as Ie,C as Ne,M as Ue,l as ne,b as ze,d as Pe,e as De,i as Le,P as _e,f as We,s as Ge,w as Fe,r as Me,g as Oe,h as $e,j as He,p as Be,k as Ve,A as qe,m as Ke,E as Ye,n as Qe}from"./ErrorBoundary-CGD9kz0E.js";import{s as S,r as Ze,i as Xe}from"./crash-reporter-DAZnNefT.js";import{B as ie,t as Je,u as et}from"./ai-usage-log-C9Opn0x0.js";import{c as tt,C as rt,a as at,d as nt,l as je,g as Se,s as it,b as st,e as ot,f as lt,h as ue,i as ct,j as dt}from"./scheduled-audit-runner-EQBltZPz.js";import{_ as re}from"./preload-helper-D7HrI6pR.js";import{copyAiFixerPrompt as ut}from"./copy-ai-fixer-prompt-DYAVFhB3.js";import{w as pe,h as ve,r as ge}from"./tier-config-client-CGmK5CXV.js";import{w as he,r as me}from"./rubric-config-client-CEBmuFV7.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./diff-CECbooHD.js";import"./design-system-audit-DpxJrxnb.js";function fe({initialUrl:t,isRunning:a,onCrawl:r,onVerifyFixes:o,onAuditThisPage:s,reviewEnabled:l,onToggleReview:n}){const[i,v]=c.useState(t),[x,w]=c.useState(25),[g,y]=c.useState(""),[b,j]=c.useState(""),[k,h]=c.useState(!1),[E,P]=c.useState(ie),[f,F]=c.useState(ie[0].id),[$,U]=c.useState(null),[W,R]=c.useState(!0);c.useEffect(()=>{t&&!i&&v(t)},[t]),c.useEffect(()=>{let u=!1;return Promise.all([S({type:"SETTINGS_GET",key:"matrixPresets"}),S({type:"SETTINGS_GET",key:"activePresetId"})]).then(([T,L])=>{if(u)return;const d=Array.isArray(T.data)?T.data:null;P(d&&d.length>0?d:ie),typeof L.data=="string"&&F(L.data)}),()=>{u=!0}},[]),c.useEffect(()=>{let u=!1;return S({type:"SETTINGS_GET",key:"crawlRememberSettings"}).then(async T=>{if(u)return;const d=T.data!==!1;if(R(d),!d)return;const[C,B,M]=await Promise.all([S({type:"SETTINGS_GET",key:"crawlMaxPages"}),S({type:"SETTINGS_GET",key:"crawlIncludeRegex"}),S({type:"SETTINGS_GET",key:"crawlExcludeRegex"})]);if(u)return;const O=C.data;typeof O=="number"&&O>=1&&w(Math.min(200,O));const Z=B.data,X=M.data;typeof Z=="string"&&Z&&y(Z),typeof X=="string"&&X&&j(X),(typeof Z=="string"&&Z||typeof X=="string"&&X)&&h(!0)}),()=>{u=!0}},[]);function Q(u){w(u),W&&S({type:"SETTINGS_SET",key:"crawlMaxPages",value:u})}function p(u){y(u),W&&S({type:"SETTINGS_SET",key:"crawlIncludeRegex",value:u})}function z(u){j(u),W&&S({type:"SETTINGS_SET",key:"crawlExcludeRegex",value:u})}function A(u){R(u),S({type:"SETTINGS_SET",key:"crawlRememberSettings",value:u}),u&&(S({type:"SETTINGS_SET",key:"crawlMaxPages",value:x}),S({type:"SETTINGS_SET",key:"crawlIncludeRegex",value:g.trim()}),S({type:"SETTINGS_SET",key:"crawlExcludeRegex",value:b.trim()}))}function I(u){const T=E.find(L=>L.id===u);T&&(F(u),S({type:"SETTINGS_SET",key:"activePresetId",value:u}),S({type:"SETTINGS_SET",key:"stateMatrix",value:T.matrix}))}function H(){U(null);for(const[u,T]of[["Include",g.trim()],["Exclude",b.trim()]])if(T)try{new RegExp(T)}catch(L){return U(`${u} regex invalid: ${L instanceof Error?L.message:String(L)}`),!1}return!0}function D(){const u=i.trim();if(!u)return null;let T;try{T=new URL(u)}catch{return"Start URL must be a full URL starting with http:// or https://."}return T.protocol!=="http:"&&T.protocol!=="https:"?`Start URL must use http:// or https:// — ${T.protocol} can't be crawled.`:null}const N=D(),q=!!i.trim()&&!N;function V(u){if(!H()||!q)return;const T={startUrl:i.trim(),maxPages:x,includeRegex:g.trim(),excludeRegex:b.trim()};u&&o?o(T):r(T)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-3)",textAlign:"left"},children:[e.jsxs(J,{label:"Start URL",children:[e.jsx("input",{type:"url",value:i,onChange:u=>v(u.target.value),placeholder:"https://yoursite.com",disabled:a,"aria-invalid":!!N,className:"v2-mono",style:ee}),N&&e.jsx("p",{role:"alert",style:{margin:"4px 0 0",fontSize:11,color:"var(--v2-critical)",lineHeight:1.4},children:N})]}),e.jsx(J,{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:x,onChange:u=>Q(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),disabled:a,className:"v2-mono",style:{...ee,maxWidth:100}})}),e.jsx(J,{label:"Audit depth",hint:"State matrix preset applied to every crawled page.",children:e.jsx("select",{value:f,onChange:u=>I(u.target.value),disabled:a,style:ee,children:E.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))})}),e.jsx("button",{type:"button",onClick:()=>h(u=>!u),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(J,{label:"Include only URLs matching",hint:"Optional regex. Empty = no filter.",children:e.jsx("input",{type:"text",value:g,onChange:u=>p(u.target.value),placeholder:"^https://example\\.com/products/",disabled:a,className:"v2-mono",style:ee})}),e.jsx(J,{label:"Exclude URLs matching",hint:"Optional regex. Useful for /admin or /login while logged in.",children:e.jsx("input",{type:"text",value:b,onChange:u=>z(u.target.value),placeholder:"/admin|/dashboard|/login",disabled:a,className:"v2-mono",style:ee})})]}),$&&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:$}),e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-2)",fontSize:12,lineHeight:1.4,color:"var(--v2-ink-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:W,disabled:a,onChange:u=>A(u.target.checked),style:{marginTop:2}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:"Remember these settings."})," ","Keep max pages + the include/exclude filters for next time (the audit-depth preset is always remembered)."]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-2)",fontSize:12,lineHeight:1.4,color:"var(--v2-ink-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l,disabled:a,onChange:u=>n(u.target.checked),style:{marginTop:2}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:"Review pages before auditing."})," ","List every page that would be crawled, then remove any you don't want before the audit runs."]})]}),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||!q,onClick:()=>V(!1),children:a?"Crawling…":l?"Find pages to audit":"Crawl whole site"}),o&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",disabled:a||!q,onClick:()=>V(!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 pt(){var w;const t=m(g=>g.siteCrawlProgress),a=m(g=>g.siteCrawlStatus),r=m(g=>g.progress),o=m(g=>g.aiProgress),[s,l]=c.useState(!1);function n(){l(!0),S({type:"CANCEL_SITE_CRAWL"})}if(a!=="running")return null;const i=t?Math.min(100,Math.max(0,t.current/Math.max(1,t.total)*100)):0,v=r?Math.min(100,Math.max(0,r.current/Math.max(1,r.total)*100)):0,x=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,(w=r.currentState.breakpoint)!=null&&w.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:`${i}%`,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:`${v}%`,background:"var(--v2-ink-tertiary)",transition:"width 240ms ease"}})}),x&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)"},children:["state: ",x]}),o&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-needs-review)",fontVariantNumeric:"tabular-nums"},children:["AI: ",o.current," / ",o.total," · ",o.currentCheckLabel,o.candidatesTotal&&o.candidatesTotal>0?` (${o.candidatesDone??0}/${o.candidatesTotal})`:""]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:n,disabled:s,children:s?"Cancelling…":"Cancel crawl"}),s&&e.jsx("span",{"aria-live":"polite",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:"Wrapping up current page audit — final cancel can take up to a few seconds."})]})]})}function vt(){const t=m(s=>s.crawlDiscoveryStatus),a=m(s=>s.crawlDiscoveryFound),r=m(s=>s.crawlDiscoveryLastUrl);function o(){S({type:"CANCEL_CRAWL_DISCOVERY"}),m.getState().resetCrawlDiscovery()}return t!=="discovering"?null: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.jsx("p",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:"finding pages…"}),e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:12,fontWeight:600,color:"var(--v2-ink-primary)",fontVariantNumeric:"tabular-nums"},children:[a," page",a===1?"":"s"," found"]}),r&&e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-secondary)",wordBreak:"break-all"},children:r}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:"Loading each page to read its links — no audit yet. You'll prune the list before anything is audited."}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:o,children:"Cancel"})})]})}function gt({onAudit:t}){const a=m(n=>n.crawlDiscoveryStatus),r=m(n=>n.crawlDiscoveryUrls),[o,s]=c.useState(new Set);c.useEffect(()=>{a==="reviewing"&&s(new Set(r))},[a,r]);function l(){S({type:"CANCEL_CRAWL_DISCOVERY"}),m.getState().resetCrawlDiscovery()}return a!=="reviewing"?null:e.jsxs("div",{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)",textAlign:"left"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:"review pages to audit"}),e.jsxs("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.4},children:["Found ",e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:r.length})," page",r.length===1?"":"s",". Uncheck any you don't want, then audit the rest. ",e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:o.size})," selected."]}),r.length===0?e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-tertiary)"},children:"No pages discovered from this URL. Check the start URL + filters and try again."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",onClick:()=>s(new Set(r)),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-action)",fontSize:11},children:"select all"}),e.jsx("button",{type:"button",onClick:()=>s(new Set),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-action)",fontSize:11},children:"select none"})]}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,maxHeight:300,overflowY:"auto",border:"1px solid var(--v2-border)",borderRadius:4},children:r.map(n=>e.jsx("li",{style:{borderBottom:"1px solid var(--v2-border)"},children:e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-2)",padding:"6px 10px",fontSize:11,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:o.has(n),onChange:i=>s(v=>{const x=new Set(v);return i.target.checked?x.add(n):x.delete(n),x}),style:{marginTop:2}}),e.jsx("span",{className:"v2-mono",style:{wordBreak:"break-all",color:"var(--v2-ink-secondary)"},children:n})]})},n))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsxs("button",{type:"button",className:"v2-btn v2-btn-primary",disabled:o.size===0,onClick:()=>t(r.filter(n=>o.has(n))),children:["Audit ",o.size," page",o.size===1?"":"s"]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:l,children:"Cancel"})]})]})}function ht(){const t=m(w=>w.status),a=m(w=>w.progress),r=m(w=>w.aiProgress),[o,s]=c.useState(!1);if(t!=="running")return null;const l=a?a.current>=a.total:!1,n=a?l?"Running deep analyzers…":`Auditing… ${a.current} / ${a.total}`:"Starting audit…",i=a?l?"reading order · tab order · typography · CSS vars · AI candidates":mt(a.currentState):"Loading axe + DOM analyzers",v=a?l?100:a.current/Math.max(1,a.total)*100:0;function x(){s(!0),S({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(xe,{label:n,detail:i,pct:v,valuenow:a?Math.min(a.current,a.total):0,valuemax:a?a.total:1,ariaLabel:a?l?"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(xe,{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.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:x,disabled:o,children:o?"Cancelling…":"Cancel audit"}),o&&e.jsx("span",{"aria-live":"polite",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:"Wrapping up — final cancel can take up to a few seconds."})]})]})}function xe({label:t,detail:a,pct:r,valuenow:o,valuemax:s,ariaLabel:l,fillColor:n}){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":o,"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:n,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 mt(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 J({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 ee={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 ft({sealed:t}){const[a,r]=c.useState(!1),o=JSON.stringify({claim:t.claim,hash:t.hash,receipt:t.receipt},null,2),s=new Date(t.claim.auditedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),l=()=>{navigator.clipboard.writeText(o).then(()=>{r(!0),setTimeout(()=>r(!1),2500)})};return e.jsxs("div",{role:"group","aria-label":"Wall of Fame badge",style:{marginTop:"var(--v2-pad-5)",padding:"var(--v2-pad-4)",border:"1px solid var(--v2-verified, #15803d)",borderRadius:6,background:"var(--v2-verified-bg, rgba(21,128,61,0.06))",maxWidth:640},children:[e.jsx("p",{style:{margin:0,fontWeight:600,fontSize:13,color:"var(--v2-ink-primary)"},children:"🏆 You earned a Wall of Fame badge"}),e.jsxs("p",{style:{margin:"var(--v2-pad-2) 0 0",fontSize:12,color:"var(--v2-ink-secondary)"},children:["WCAG ",t.claim.wcagLevel," · grade ",t.claim.grade," · ",t.claim.pageCount," page",t.claim.pageCount===1?"":"s"," · audited ",s]}),e.jsxs("p",{style:{margin:"var(--v2-pad-2) 0 0",fontSize:11,lineHeight:1.5,color:"var(--v2-ink-tertiary)"},children:["Submit this signed attestation at ",e.jsx("strong",{children:"accessibilitywatch.org"})," to claim a public, dated, verifiable badge for ",e.jsx("strong",{children:t.claim.domain}),". They verify the signature and confirm you control the domain before it goes live."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:l,children:a?"Copied ✓":"Copy attestation"}),e.jsx("span",{role:"status","aria-live":"polite",style:{fontSize:11,color:"var(--v2-verified, #15803d)"},children:a?"Attestation copied to clipboard.":""})]})]})}function xt(t){const[a,r]=c.useState(null);return c.useEffect(()=>{if(!t){r(null);return}let o=!1;const s=()=>Ze({type:"SITE_CLAIM_GET_REQUEST",domain:t}).then(n=>{o||r(n.claim)}).catch(()=>{o||r(null)});s();const l=n=>{typeof n=="object"&&n!==null&&n.type==="SITE_CLAIM_SEALED_EVENT"&&n.domain===t&&s()};return chrome.runtime.onMessage.addListener(l),()=>{o=!0,chrome.runtime.onMessage.removeListener(l)}},[t]),a}function ye({open:t,gaps:a,onRunFull:r,onQuickCheck:o,onCancel:s}){return t?e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Audit settings are below WCAG 2.1 AA conformance",style:{position:"fixed",inset:0,background:"rgba(2,6,23,0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:s,children:e.jsxs("div",{onClick:l=>l.stopPropagation(),style:{background:"#0f172a",border:"1px solid #334155",borderRadius:10,maxWidth:460,width:"100%",padding:20,color:"#e2e8f0"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:16},children:"Your settings aren’t a Full 2.1 AA audit"}),e.jsxs("p",{style:{margin:"0 0 10px",fontSize:13,color:"#cbd5e1",lineHeight:1.5},children:["A grade only means WCAG 2.1 AA if the audit exercised the states and checks the AA criteria live in. With your current settings, this run is a ",e.jsx("strong",{children:"quick check"}),", not a conformance result."]}),e.jsx("ul",{style:{margin:"0 0 14px",paddingLeft:18,fontSize:12,color:"#fca5a5",lineHeight:1.6},children:a.map((l,n)=>e.jsx("li",{children:l},n))}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("button",{onClick:r,style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"10px 12px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Run the Full 2.1 AA audit (applies the preset, then crawls)"}),e.jsx("button",{onClick:o,style:{background:"#1e293b",color:"#cbd5e1",border:"1px solid #334155",borderRadius:6,padding:"10px 12px",fontSize:13,cursor:"pointer"},children:"Quick check with current settings — not a conformance result"}),e.jsx("button",{onClick:s,style:{background:"none",color:"#64748b",border:"none",fontSize:12,padding:"4px",cursor:"pointer"},children:"Cancel"})]}),e.jsx("p",{style:{margin:"12px 0 0",fontSize:11,color:"#64748b",lineHeight:1.5},children:"Either way, the grade and every export are stamped with the exact settings used — a quick check can’t be mistaken for a conformance result. (Owner mode isn’t affected; it only flags demand-letter bait.)"})]})}):null}function yt(){const[t,a]=c.useState([]),[r,o]=c.useState(!1),s=c.useRef(null),l=c.useRef(!1),n=c.useCallback(async()=>{try{const g=await chrome.storage.local.get(["stateMatrix","runsPerState","aiConfig"]),y=g.aiConfig??{},b=tt({stateMatrix:g.stateMatrix,runsPerState:typeof g.runsPerState=="number"?g.runsPerState:1,aiEnabled:!!y.enabled&&!!y.apiKey});return a(b),b}catch{return a([]),[]}},[]);c.useEffect(()=>{n()},[n]);const i=c.useCallback(async g=>{if((await n()).length===0||l.current){g();return}s.current=g,o(!0)},[n]),v=c.useCallback(async()=>{try{const b=(await chrome.storage.local.get("aiConfig")).aiConfig??{};await chrome.storage.local.set({stateMatrix:at,runsPerState:rt,aiConfig:{...b,enabled:!0}})}catch{}l.current=!0,o(!1);const g=s.current;s.current=null,g==null||g()},[]),x=c.useCallback(()=>{l.current=!0,o(!1);const g=s.current;s.current=null,g==null||g()},[]),w=c.useCallback(()=>{o(!1),s.current=null},[]);return{gaps:t,gateOpen:r,requestCrawl:i,runFull:v,quickCheck:x,cancel:w}}function bt(){const{report:t,resolvedFails:a}=oe(),r=m(d=>d.siteCrawlReport),o=m(d=>d.siteCrawlStatus),s=m(d=>d.siteCrawlError),l=m(d=>d.status),n=o==="running",v=n||l==="running"&&!n,x=!!t&&!r,w=!x&&(t==null?void 0:t.siteGrade)==="A"&&t.startUrl?nt(t.startUrl):null,g=xt(w),[y,b]=c.useState(null);c.useEffect(()=>{let d=!1;return chrome.tabs.query({active:!0,currentWindow:!0}).then(C=>{var M;if(d)return;const B=((M=C[0])==null?void 0:M.url)??null;b(B&&/^https?:\/\//i.test(B)?B:null)}),()=>{d=!0}},[]);const[j,k]=c.useState(!1),h=m(d=>d.crawlDiscoveryStatus),[E,P]=c.useState(!0),f=yt(),[F,$]=c.useState("");c.useEffect(()=>{S({type:"SETTINGS_GET",key:"crawlReviewEnabled"}).then(d=>{const C=d.data;typeof C=="boolean"&&P(C)})},[]);function U(d){P(d),S({type:"SETTINGS_SET",key:"crawlReviewEnabled",value:d})}function W(d,C=!1){if(d.startUrl){if(C){R(d,!0);return}f.requestCrawl(()=>R(d,!1))}}function R(d,C=!1){if(E&&!C){$(d.startUrl),m.getState().setSiteCrawlError(null),m.getState().setCrawlDiscoveryStatus("discovering"),ze({type:"START_CRAWL_DISCOVERY",startUrl:d.startUrl,maxPages:d.maxPages,...d.includeRegex?{includeRegex:d.includeRegex}:{},...d.excludeRegex?{excludeRegex:d.excludeRegex}:{}});return}m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),ne({type:"START_SITE_CRAWL",startUrl:d.startUrl,maxPages:d.maxPages,...d.includeRegex?{includeRegex:d.includeRegex}:{},...d.excludeRegex?{excludeRegex:d.excludeRegex}:{},...C?{verifyFixesOnly:!0}:{}})}function Q(d){d.length!==0&&(m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),m.getState().resetCrawlDiscovery(),ne({type:"START_SITE_CRAWL",startUrl:F,urls:d}))}function p(){ne({type:"START_AUDIT",mode:"full-page"}),m.getState().startNewScan()}const[z,A]=c.useState(!1),[I,H]=c.useState(null),[D,N]=c.useState(null);async function q(){A(!0),H(null),N(null);const d=(t==null?void 0:t.siteGrade)??"A";try{const C=await S({type:"REGRADE_SITE_CRAWL"});if((C==null?void 0:C.ok)===!0)setTimeout(()=>{var O;const M=((O=m.getState().siteCrawlReport)==null?void 0:O.siteGrade)??d;N({prevGrade:d,nextGrade:M,at:Date.now()})},0);else{const M=(C==null?void 0:C.reason)??"Regrade failed.";H(M)}}catch(C){H(C instanceof Error?C.message:String(C))}finally{A(!1)}}if(c.useEffect(()=>{if(!D)return;const d=setTimeout(()=>N(null),6e3);return()=>clearTimeout(d)},[D]),v)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:n?e.jsx(pt,{}):e.jsx(ht,{})});if(h==="discovering"||h==="reviewing")return e.jsx("section",{"aria-label":"Choose pages to audit",style:{padding:"var(--v2-pad-5) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",maxWidth:640,margin:"0 auto"},children:h==="discovering"?e.jsx(vt,{}):e.jsx(gt,{onAudit:Q})});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(fe,{initialUrl:y??"",isRunning:v,onCrawl:d=>W(d,!1),onAuditThisPage:p,reviewEnabled:E,onToggleReview:U}),e.jsx(ye,{open:f.gateOpen,gaps:f.gaps,onRunFull:f.runFull,onQuickCheck:f.quickCheck,onCancel:f.cancel})]});const V=a.length,u=(t.totalWalkthroughFindings??0)+t.totalUniqueViolations+V,T=(t.walkthroughAcknowledgements??[]).length,L=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(wt,{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:x?"page grade · single-page audit":`site grade · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"}`}),e.jsxs("p",{style:{margin:0,fontSize:11,lineHeight:1.4,color:"var(--v2-ink-tertiary)"},children:["Your ",e.jsx("strong",{children:"combined grade"})," — severity (your most serious finding) and breadth (how many of the 9 areas have issues) together, with a legal floor so a serious issue can't be averaged away. The Dev view shows the same letter."]}),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 B,M;if(((B=t.spotCheckGate)==null?void 0:B.status)==="pending"){const O=t.spotCheckGate;return`On track for A — answer ${O.unanswered.length} more content-meaning spot-check${O.unanswered.length===1?"":"s"} below to finalize your grade (${O.answered}/${O.total} done).`}const d=u+L,C=((M=t.blockingCriteria)==null?void 0:M.length)??0;return d===0&&C===0?"All clear — nothing open.":d===0&&C>0?`Visible findings clear — ${C} criteri${C===1?"on":"a"} still need${C===1?"s":""} your judgment.`:`${d} finding${d===1?"":"s"} to address.`})()}),e.jsx(jt,{openCount:u,reviewCount:L,verifiedCount:T,axeCount:t.totalUniqueViolations,walkthroughCount:t.totalWalkthroughFindings??0,autoCount:V}),y&&!kt(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:[x?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:p,title:"Re-audit the current page",children:"Re-audit this page"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>k(d=>!d),"aria-expanded":j,title:"Open crawl setup to audit the whole site instead",children:j?"Hide crawl options":"Crawl whole site"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:q,disabled:z,title:"Re-aggregate this audit against your latest verdicts + acks. No re-crawl. Use this after marking criteria in the Coverage gaps panel.",children:z?"Regrading…":"Regrade"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>W({startUrl:t.startUrl,maxPages:25,includeRegex:"",excludeRegex:""},!1),title:`Re-crawl ${t.startUrl} (same options) — full audit re-run, use when page code changed`,children:"Re-crawl"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:p,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:()=>W({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(d=>!d),"aria-expanded":j,children:j?"Hide options":"Adjust options"})]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>void Ie(),title:"Wipe these results so you can start fresh",style:{marginLeft:"auto"},children:"Clear results"})]}),I&&e.jsx("p",{role:"alert",style:{margin:"var(--v2-pad-2) 0 0",fontSize:11,color:"var(--v2-critical)"},children:I}),D&&!I&&e.jsx("p",{role:"status",style:{margin:"var(--v2-pad-2) 0 0",fontSize:11,color:"var(--v2-verified)"},children:D.prevGrade===D.nextGrade?`Regraded — grade unchanged at ${D.nextGrade}. Any verdict changes you made were already in this report.`:`Regraded — grade ${D.prevGrade} → ${D.nextGrade}.`})]})]}),(g==null?void 0:g.receipt)&&e.jsx(ft,{sealed:g}),e.jsx(Ne,{}),e.jsx(Ue,{}),j&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-5)",paddingTop:"var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)",maxWidth:640},children:[e.jsx(fe,{initialUrl:t.startUrl,isRunning:v,onCrawl:d=>W(d,!1),onVerifyFixes:d=>W(d,!0),onAuditThisPage:p,reviewEnabled:E,onToggleReview:U}),e.jsx(ye,{open:f.gateOpen,gaps:f.gaps,onRunFull:f.runFull,onQuickCheck:f.quickCheck,onCancel:f.cancel})]})]})}function kt(t,a){try{return new URL(t).origin===new URL(a).origin}catch{return!1}}function wt({grade:t}){if(t==="pending")return e.jsx("div",{"aria-label":"Grade pending — spot-checks outstanding",role:"img",style:{display:"flex",alignItems:"center",justifyContent:"center",minWidth:140},children:e.jsx("span",{className:"v2-display",style:{fontSize:40,lineHeight:1.05,fontWeight:600,color:"var(--v2-ink-secondary, #94a3b8)",letterSpacing:"-0.02em",textAlign:"center"},children:"Pending"})});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 jt({openCount:t,reviewCount:a,verifiedCount:r,axeCount:o,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(K,{term:"open",value:t,tone:t>0?"attention":"neutral"}),e.jsx(K,{term:"review",value:a,tone:a>0?"review":"neutral"}),e.jsx(K,{term:"verified",value:r,tone:r>0?"positive":"neutral"}),e.jsx("span",{style:{color:"var(--v2-ink-faint)"},children:"·"}),e.jsx(K,{term:"axe",value:o,tone:"neutral"}),e.jsx(K,{term:"walkthrough",value:s,tone:"neutral"}),l>0&&e.jsx(K,{term:"auto-contrast",value:l,tone:"neutral"})]})}function K({term:t,value:a,tone:r}){const o={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:o[r],fontVariantNumeric:"tabular-nums"},children:a})]})}const St=new Set(["2.4.3","2.1.2","2.4.7","1.3.2","1.4.11","2.5.3"]);function be(t){return St.has(t)}async function ke(t){var o,s;const a=m.getState();if(a.componentId&&((o=a.results[0])==null?void 0:o.pageUrl)===t)return a.componentId;const r=await je();return((s=r==null?void 0:r.find(l=>l.url===t))==null?void 0:s.componentId)??null}async function Ct(t,a){var l;const r=m.getState(),o=[];if(r.componentId&&r.results.length>0){const n=(l=r.results[0])==null?void 0:l.pageUrl,i=a.find(v=>v.url===n);if(i){for(const v of r.results)for(const x of v.violations)x.ruleId===t&&x.target.selector===i.selector&&o.push({componentId:r.componentId,matchKey:x.matchKey});if(o.length>0)return o}}const s=await je()??[];for(const n of a){const i=s.find(v=>v.url===n.url);if(i)for(const v of i.results)for(const x of v.violations)x.ruleId===t&&x.target.selector===n.selector&&o.push({componentId:i.componentId,matchKey:x.matchKey})}return o}function Rt({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(Tt,{row:t}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(Et,{row:t}),e.jsx(At,{row:t})]}),e.jsx(It,{})]}),e.jsx("div",{style:{padding:"0 var(--v2-pad-4) var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)"},children:e.jsx(Nt,{row:t})})]})}function Tt({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 Et({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"?t.verdict==="uncertain"?"AI could not decide this criterion — needs your manual verification.":"AI walkthrough fail 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 At({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,o=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}),o&&e.jsx("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-tertiary)",wordBreak:"break-all"},children:o}),a>1&&e.jsxs("span",{className:"v2-eyebrow",style:{marginLeft:"auto"},children:["on ",a," pages"]})]})}function It(){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 Nt({row:t}){return t.kind==="walkthrough-fail"?e.jsx(zt,{row:t}):t.kind==="walkthrough-ack"?e.jsx(Pt,{row:t}):t.kind==="needs-review"?e.jsx(Dt,{row:t}):t.kind==="auto-contrast"?e.jsx(Ut,{row:t}):e.jsx(Lt,{row:t})}function Ut({row:t}){const[a,r]=c.useState(!1),[o,s]=c.useState(!1),[l,n]=c.useState(""),[i,v]=c.useState(!1),[x,w]=c.useState(!1),[g,y]=c.useState(null),b=Se(t.ruleId);async function j(){if(v(!0),y(null),!l.trim()){y("Note is required — explain why the empirical contrast measurement is wrong, or why this element is acceptable in context."),v(!1);return}try{const h=(await st(t.pageUrl)).find(P=>P.ruleId===t.ruleId&&P.selector===t.selector),E={pageUrl:t.pageUrl,ruleId:t.ruleId,selector:t.selector,verdict:"pass",reasoning:`Human override: ${l.trim()}
2
+ import"./modulepreload-polyfill-B5Qt9EMX.js";import{r as c,j as e,C as we,c as Ee,R as Ae}from"./styles-uesms5w-.js";import{u as m,a as oe,c as Ie,C as Ne,M as Ue,l as ne,b as ze,d as Pe,e as De,i as Le,P as _e,f as We,s as Ge,w as Fe,r as Me,g as Oe,h as $e,j as He,p as Be,k as Ve,A as qe,m as Ke,E as Ye,n as Qe}from"./ErrorBoundary-D-5bMIZq.js";import{s as S,r as Ze,i as Xe}from"./crash-reporter-DAZnNefT.js";import{B as ie,t as Je,u as et}from"./ai-usage-log-C9Opn0x0.js";import{c as tt,C as rt,a as at,d as nt,l as je,g as Se,s as it,b as st,e as ot,f as lt,h as ue,i as ct,j as dt}from"./scheduled-audit-runner-EQBltZPz.js";import{_ as re}from"./preload-helper-D7HrI6pR.js";import{copyAiFixerPrompt as ut}from"./copy-ai-fixer-prompt-tOtbF2rw.js";import{w as pe,h as ve,r as ge}from"./tier-config-client-CGmK5CXV.js";import{w as he,r as me}from"./rubric-config-client-CEBmuFV7.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./diff-CECbooHD.js";import"./design-system-audit-DpxJrxnb.js";function fe({initialUrl:t,isRunning:a,onCrawl:r,onVerifyFixes:o,onAuditThisPage:s,reviewEnabled:l,onToggleReview:n}){const[i,v]=c.useState(t),[x,w]=c.useState(25),[g,y]=c.useState(""),[b,j]=c.useState(""),[k,h]=c.useState(!1),[E,P]=c.useState(ie),[f,F]=c.useState(ie[0].id),[$,U]=c.useState(null),[W,R]=c.useState(!0);c.useEffect(()=>{t&&!i&&v(t)},[t]),c.useEffect(()=>{let u=!1;return Promise.all([S({type:"SETTINGS_GET",key:"matrixPresets"}),S({type:"SETTINGS_GET",key:"activePresetId"})]).then(([T,L])=>{if(u)return;const d=Array.isArray(T.data)?T.data:null;P(d&&d.length>0?d:ie),typeof L.data=="string"&&F(L.data)}),()=>{u=!0}},[]),c.useEffect(()=>{let u=!1;return S({type:"SETTINGS_GET",key:"crawlRememberSettings"}).then(async T=>{if(u)return;const d=T.data!==!1;if(R(d),!d)return;const[C,B,M]=await Promise.all([S({type:"SETTINGS_GET",key:"crawlMaxPages"}),S({type:"SETTINGS_GET",key:"crawlIncludeRegex"}),S({type:"SETTINGS_GET",key:"crawlExcludeRegex"})]);if(u)return;const O=C.data;typeof O=="number"&&O>=1&&w(Math.min(200,O));const Z=B.data,X=M.data;typeof Z=="string"&&Z&&y(Z),typeof X=="string"&&X&&j(X),(typeof Z=="string"&&Z||typeof X=="string"&&X)&&h(!0)}),()=>{u=!0}},[]);function Q(u){w(u),W&&S({type:"SETTINGS_SET",key:"crawlMaxPages",value:u})}function p(u){y(u),W&&S({type:"SETTINGS_SET",key:"crawlIncludeRegex",value:u})}function z(u){j(u),W&&S({type:"SETTINGS_SET",key:"crawlExcludeRegex",value:u})}function A(u){R(u),S({type:"SETTINGS_SET",key:"crawlRememberSettings",value:u}),u&&(S({type:"SETTINGS_SET",key:"crawlMaxPages",value:x}),S({type:"SETTINGS_SET",key:"crawlIncludeRegex",value:g.trim()}),S({type:"SETTINGS_SET",key:"crawlExcludeRegex",value:b.trim()}))}function I(u){const T=E.find(L=>L.id===u);T&&(F(u),S({type:"SETTINGS_SET",key:"activePresetId",value:u}),S({type:"SETTINGS_SET",key:"stateMatrix",value:T.matrix}))}function H(){U(null);for(const[u,T]of[["Include",g.trim()],["Exclude",b.trim()]])if(T)try{new RegExp(T)}catch(L){return U(`${u} regex invalid: ${L instanceof Error?L.message:String(L)}`),!1}return!0}function D(){const u=i.trim();if(!u)return null;let T;try{T=new URL(u)}catch{return"Start URL must be a full URL starting with http:// or https://."}return T.protocol!=="http:"&&T.protocol!=="https:"?`Start URL must use http:// or https:// — ${T.protocol} can't be crawled.`:null}const N=D(),q=!!i.trim()&&!N;function V(u){if(!H()||!q)return;const T={startUrl:i.trim(),maxPages:x,includeRegex:g.trim(),excludeRegex:b.trim()};u&&o?o(T):r(T)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-3)",textAlign:"left"},children:[e.jsxs(J,{label:"Start URL",children:[e.jsx("input",{type:"url",value:i,onChange:u=>v(u.target.value),placeholder:"https://yoursite.com",disabled:a,"aria-invalid":!!N,className:"v2-mono",style:ee}),N&&e.jsx("p",{role:"alert",style:{margin:"4px 0 0",fontSize:11,color:"var(--v2-critical)",lineHeight:1.4},children:N})]}),e.jsx(J,{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:x,onChange:u=>Q(Math.min(200,Math.max(1,parseInt(u.target.value,10)||25))),disabled:a,className:"v2-mono",style:{...ee,maxWidth:100}})}),e.jsx(J,{label:"Audit depth",hint:"State matrix preset applied to every crawled page.",children:e.jsx("select",{value:f,onChange:u=>I(u.target.value),disabled:a,style:ee,children:E.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))})}),e.jsx("button",{type:"button",onClick:()=>h(u=>!u),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(J,{label:"Include only URLs matching",hint:"Optional regex. Empty = no filter.",children:e.jsx("input",{type:"text",value:g,onChange:u=>p(u.target.value),placeholder:"^https://example\\.com/products/",disabled:a,className:"v2-mono",style:ee})}),e.jsx(J,{label:"Exclude URLs matching",hint:"Optional regex. Useful for /admin or /login while logged in.",children:e.jsx("input",{type:"text",value:b,onChange:u=>z(u.target.value),placeholder:"/admin|/dashboard|/login",disabled:a,className:"v2-mono",style:ee})})]}),$&&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:$}),e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-2)",fontSize:12,lineHeight:1.4,color:"var(--v2-ink-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:W,disabled:a,onChange:u=>A(u.target.checked),style:{marginTop:2}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:"Remember these settings."})," ","Keep max pages + the include/exclude filters for next time (the audit-depth preset is always remembered)."]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-2)",fontSize:12,lineHeight:1.4,color:"var(--v2-ink-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l,disabled:a,onChange:u=>n(u.target.checked),style:{marginTop:2}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:"Review pages before auditing."})," ","List every page that would be crawled, then remove any you don't want before the audit runs."]})]}),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||!q,onClick:()=>V(!1),children:a?"Crawling…":l?"Find pages to audit":"Crawl whole site"}),o&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",disabled:a||!q,onClick:()=>V(!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 pt(){var w;const t=m(g=>g.siteCrawlProgress),a=m(g=>g.siteCrawlStatus),r=m(g=>g.progress),o=m(g=>g.aiProgress),[s,l]=c.useState(!1);function n(){l(!0),S({type:"CANCEL_SITE_CRAWL"})}if(a!=="running")return null;const i=t?Math.min(100,Math.max(0,t.current/Math.max(1,t.total)*100)):0,v=r?Math.min(100,Math.max(0,r.current/Math.max(1,r.total)*100)):0,x=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,(w=r.currentState.breakpoint)!=null&&w.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:`${i}%`,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:`${v}%`,background:"var(--v2-ink-tertiary)",transition:"width 240ms ease"}})}),x&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)"},children:["state: ",x]}),o&&e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-needs-review)",fontVariantNumeric:"tabular-nums"},children:["AI: ",o.current," / ",o.total," · ",o.currentCheckLabel,o.candidatesTotal&&o.candidatesTotal>0?` (${o.candidatesDone??0}/${o.candidatesTotal})`:""]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:n,disabled:s,children:s?"Cancelling…":"Cancel crawl"}),s&&e.jsx("span",{"aria-live":"polite",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:"Wrapping up current page audit — final cancel can take up to a few seconds."})]})]})}function vt(){const t=m(s=>s.crawlDiscoveryStatus),a=m(s=>s.crawlDiscoveryFound),r=m(s=>s.crawlDiscoveryLastUrl);function o(){S({type:"CANCEL_CRAWL_DISCOVERY"}),m.getState().resetCrawlDiscovery()}return t!=="discovering"?null: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.jsx("p",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:"finding pages…"}),e.jsxs("p",{className:"v2-mono",style:{margin:0,fontSize:12,fontWeight:600,color:"var(--v2-ink-primary)",fontVariantNumeric:"tabular-nums"},children:[a," page",a===1?"":"s"," found"]}),r&&e.jsx("p",{className:"v2-mono",style:{margin:0,fontSize:11,color:"var(--v2-ink-secondary)",wordBreak:"break-all"},children:r}),e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.4},children:"Loading each page to read its links — no audit yet. You'll prune the list before anything is audited."}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:o,children:"Cancel"})})]})}function gt({onAudit:t}){const a=m(n=>n.crawlDiscoveryStatus),r=m(n=>n.crawlDiscoveryUrls),[o,s]=c.useState(new Set);c.useEffect(()=>{a==="reviewing"&&s(new Set(r))},[a,r]);function l(){S({type:"CANCEL_CRAWL_DISCOVERY"}),m.getState().resetCrawlDiscovery()}return a!=="reviewing"?null:e.jsxs("div",{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)",textAlign:"left"},children:[e.jsx("p",{className:"v2-eyebrow",style:{margin:0,color:"var(--v2-action)"},children:"review pages to audit"}),e.jsxs("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-secondary)",lineHeight:1.4},children:["Found ",e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:r.length})," page",r.length===1?"":"s",". Uncheck any you don't want, then audit the rest. ",e.jsx("strong",{style:{color:"var(--v2-ink-primary)"},children:o.size})," selected."]}),r.length===0?e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--v2-ink-tertiary)"},children:"No pages discovered from this URL. Check the start URL + filters and try again."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",onClick:()=>s(new Set(r)),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-action)",fontSize:11},children:"select all"}),e.jsx("button",{type:"button",onClick:()=>s(new Set),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--v2-action)",fontSize:11},children:"select none"})]}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,maxHeight:300,overflowY:"auto",border:"1px solid var(--v2-border)",borderRadius:4},children:r.map(n=>e.jsx("li",{style:{borderBottom:"1px solid var(--v2-border)"},children:e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--v2-pad-2)",padding:"6px 10px",fontSize:11,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:o.has(n),onChange:i=>s(v=>{const x=new Set(v);return i.target.checked?x.add(n):x.delete(n),x}),style:{marginTop:2}}),e.jsx("span",{className:"v2-mono",style:{wordBreak:"break-all",color:"var(--v2-ink-secondary)"},children:n})]})},n))})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap"},children:[e.jsxs("button",{type:"button",className:"v2-btn v2-btn-primary",disabled:o.size===0,onClick:()=>t(r.filter(n=>o.has(n))),children:["Audit ",o.size," page",o.size===1?"":"s"]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:l,children:"Cancel"})]})]})}function ht(){const t=m(w=>w.status),a=m(w=>w.progress),r=m(w=>w.aiProgress),[o,s]=c.useState(!1);if(t!=="running")return null;const l=a?a.current>=a.total:!1,n=a?l?"Running deep analyzers…":`Auditing… ${a.current} / ${a.total}`:"Starting audit…",i=a?l?"reading order · tab order · typography · CSS vars · AI candidates":mt(a.currentState):"Loading axe + DOM analyzers",v=a?l?100:a.current/Math.max(1,a.total)*100:0;function x(){s(!0),S({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(xe,{label:n,detail:i,pct:v,valuenow:a?Math.min(a.current,a.total):0,valuemax:a?a.total:1,ariaLabel:a?l?"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(xe,{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.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:x,disabled:o,children:o?"Cancelling…":"Cancel audit"}),o&&e.jsx("span",{"aria-live":"polite",style:{fontSize:11,color:"var(--v2-ink-tertiary)"},children:"Wrapping up — final cancel can take up to a few seconds."})]})]})}function xe({label:t,detail:a,pct:r,valuenow:o,valuemax:s,ariaLabel:l,fillColor:n}){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":o,"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:n,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 mt(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 J({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 ee={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 ft({sealed:t}){const[a,r]=c.useState(!1),o=JSON.stringify({claim:t.claim,hash:t.hash,receipt:t.receipt},null,2),s=new Date(t.claim.auditedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),l=()=>{navigator.clipboard.writeText(o).then(()=>{r(!0),setTimeout(()=>r(!1),2500)})};return e.jsxs("div",{role:"group","aria-label":"Wall of Fame badge",style:{marginTop:"var(--v2-pad-5)",padding:"var(--v2-pad-4)",border:"1px solid var(--v2-verified, #15803d)",borderRadius:6,background:"var(--v2-verified-bg, rgba(21,128,61,0.06))",maxWidth:640},children:[e.jsx("p",{style:{margin:0,fontWeight:600,fontSize:13,color:"var(--v2-ink-primary)"},children:"🏆 You earned a Wall of Fame badge"}),e.jsxs("p",{style:{margin:"var(--v2-pad-2) 0 0",fontSize:12,color:"var(--v2-ink-secondary)"},children:["WCAG ",t.claim.wcagLevel," · grade ",t.claim.grade," · ",t.claim.pageCount," page",t.claim.pageCount===1?"":"s"," · audited ",s]}),e.jsxs("p",{style:{margin:"var(--v2-pad-2) 0 0",fontSize:11,lineHeight:1.5,color:"var(--v2-ink-tertiary)"},children:["Submit this signed attestation at ",e.jsx("strong",{children:"accessibilitywatch.org"})," to claim a public, dated, verifiable badge for ",e.jsx("strong",{children:t.claim.domain}),". They verify the signature and confirm you control the domain before it goes live."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-2)",marginTop:"var(--v2-pad-3)"},children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:l,children:a?"Copied ✓":"Copy attestation"}),e.jsx("span",{role:"status","aria-live":"polite",style:{fontSize:11,color:"var(--v2-verified, #15803d)"},children:a?"Attestation copied to clipboard.":""})]})]})}function xt(t){const[a,r]=c.useState(null);return c.useEffect(()=>{if(!t){r(null);return}let o=!1;const s=()=>Ze({type:"SITE_CLAIM_GET_REQUEST",domain:t}).then(n=>{o||r(n.claim)}).catch(()=>{o||r(null)});s();const l=n=>{typeof n=="object"&&n!==null&&n.type==="SITE_CLAIM_SEALED_EVENT"&&n.domain===t&&s()};return chrome.runtime.onMessage.addListener(l),()=>{o=!0,chrome.runtime.onMessage.removeListener(l)}},[t]),a}function ye({open:t,gaps:a,onRunFull:r,onQuickCheck:o,onCancel:s}){return t?e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Audit settings are below WCAG 2.1 AA conformance",style:{position:"fixed",inset:0,background:"rgba(2,6,23,0.7)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:s,children:e.jsxs("div",{onClick:l=>l.stopPropagation(),style:{background:"#0f172a",border:"1px solid #334155",borderRadius:10,maxWidth:460,width:"100%",padding:20,color:"#e2e8f0"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:16},children:"Your settings aren’t a Full 2.1 AA audit"}),e.jsxs("p",{style:{margin:"0 0 10px",fontSize:13,color:"#cbd5e1",lineHeight:1.5},children:["A grade only means WCAG 2.1 AA if the audit exercised the states and checks the AA criteria live in. With your current settings, this run is a ",e.jsx("strong",{children:"quick check"}),", not a conformance result."]}),e.jsx("ul",{style:{margin:"0 0 14px",paddingLeft:18,fontSize:12,color:"#fca5a5",lineHeight:1.6},children:a.map((l,n)=>e.jsx("li",{children:l},n))}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("button",{onClick:r,style:{background:"#2563eb",color:"#fff",border:"none",borderRadius:6,padding:"10px 12px",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Run the Full 2.1 AA audit (applies the preset, then crawls)"}),e.jsx("button",{onClick:o,style:{background:"#1e293b",color:"#cbd5e1",border:"1px solid #334155",borderRadius:6,padding:"10px 12px",fontSize:13,cursor:"pointer"},children:"Quick check with current settings — not a conformance result"}),e.jsx("button",{onClick:s,style:{background:"none",color:"#64748b",border:"none",fontSize:12,padding:"4px",cursor:"pointer"},children:"Cancel"})]}),e.jsx("p",{style:{margin:"12px 0 0",fontSize:11,color:"#64748b",lineHeight:1.5},children:"Either way, the grade and every export are stamped with the exact settings used — a quick check can’t be mistaken for a conformance result. (Owner mode isn’t affected; it only flags demand-letter bait.)"})]})}):null}function yt(){const[t,a]=c.useState([]),[r,o]=c.useState(!1),s=c.useRef(null),l=c.useRef(!1),n=c.useCallback(async()=>{try{const g=await chrome.storage.local.get(["stateMatrix","runsPerState","aiConfig"]),y=g.aiConfig??{},b=tt({stateMatrix:g.stateMatrix,runsPerState:typeof g.runsPerState=="number"?g.runsPerState:1,aiEnabled:!!y.enabled&&!!y.apiKey});return a(b),b}catch{return a([]),[]}},[]);c.useEffect(()=>{n()},[n]);const i=c.useCallback(async g=>{if((await n()).length===0||l.current){g();return}s.current=g,o(!0)},[n]),v=c.useCallback(async()=>{try{const b=(await chrome.storage.local.get("aiConfig")).aiConfig??{};await chrome.storage.local.set({stateMatrix:at,runsPerState:rt,aiConfig:{...b,enabled:!0}})}catch{}l.current=!0,o(!1);const g=s.current;s.current=null,g==null||g()},[]),x=c.useCallback(()=>{l.current=!0,o(!1);const g=s.current;s.current=null,g==null||g()},[]),w=c.useCallback(()=>{o(!1),s.current=null},[]);return{gaps:t,gateOpen:r,requestCrawl:i,runFull:v,quickCheck:x,cancel:w}}function bt(){const{report:t,resolvedFails:a}=oe(),r=m(d=>d.siteCrawlReport),o=m(d=>d.siteCrawlStatus),s=m(d=>d.siteCrawlError),l=m(d=>d.status),n=o==="running",v=n||l==="running"&&!n,x=!!t&&!r,w=!x&&(t==null?void 0:t.siteGrade)==="A"&&t.startUrl?nt(t.startUrl):null,g=xt(w),[y,b]=c.useState(null);c.useEffect(()=>{let d=!1;return chrome.tabs.query({active:!0,currentWindow:!0}).then(C=>{var M;if(d)return;const B=((M=C[0])==null?void 0:M.url)??null;b(B&&/^https?:\/\//i.test(B)?B:null)}),()=>{d=!0}},[]);const[j,k]=c.useState(!1),h=m(d=>d.crawlDiscoveryStatus),[E,P]=c.useState(!0),f=yt(),[F,$]=c.useState("");c.useEffect(()=>{S({type:"SETTINGS_GET",key:"crawlReviewEnabled"}).then(d=>{const C=d.data;typeof C=="boolean"&&P(C)})},[]);function U(d){P(d),S({type:"SETTINGS_SET",key:"crawlReviewEnabled",value:d})}function W(d,C=!1){if(d.startUrl){if(C){R(d,!0);return}f.requestCrawl(()=>R(d,!1))}}function R(d,C=!1){if(E&&!C){$(d.startUrl),m.getState().setSiteCrawlError(null),m.getState().setCrawlDiscoveryStatus("discovering"),ze({type:"START_CRAWL_DISCOVERY",startUrl:d.startUrl,maxPages:d.maxPages,...d.includeRegex?{includeRegex:d.includeRegex}:{},...d.excludeRegex?{excludeRegex:d.excludeRegex}:{}});return}m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),ne({type:"START_SITE_CRAWL",startUrl:d.startUrl,maxPages:d.maxPages,...d.includeRegex?{includeRegex:d.includeRegex}:{},...d.excludeRegex?{excludeRegex:d.excludeRegex}:{},...C?{verifyFixesOnly:!0}:{}})}function Q(d){d.length!==0&&(m.getState().setSiteCrawlStatus("running"),m.getState().setSiteCrawlReport(null),m.getState().setSiteCrawlError(null),m.getState().resetCrawlDiscovery(),ne({type:"START_SITE_CRAWL",startUrl:F,urls:d}))}function p(){ne({type:"START_AUDIT",mode:"full-page"}),m.getState().startNewScan()}const[z,A]=c.useState(!1),[I,H]=c.useState(null),[D,N]=c.useState(null);async function q(){A(!0),H(null),N(null);const d=(t==null?void 0:t.siteGrade)??"A";try{const C=await S({type:"REGRADE_SITE_CRAWL"});if((C==null?void 0:C.ok)===!0)setTimeout(()=>{var O;const M=((O=m.getState().siteCrawlReport)==null?void 0:O.siteGrade)??d;N({prevGrade:d,nextGrade:M,at:Date.now()})},0);else{const M=(C==null?void 0:C.reason)??"Regrade failed.";H(M)}}catch(C){H(C instanceof Error?C.message:String(C))}finally{A(!1)}}if(c.useEffect(()=>{if(!D)return;const d=setTimeout(()=>N(null),6e3);return()=>clearTimeout(d)},[D]),v)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:n?e.jsx(pt,{}):e.jsx(ht,{})});if(h==="discovering"||h==="reviewing")return e.jsx("section",{"aria-label":"Choose pages to audit",style:{padding:"var(--v2-pad-5) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",maxWidth:640,margin:"0 auto"},children:h==="discovering"?e.jsx(vt,{}):e.jsx(gt,{onAudit:Q})});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(fe,{initialUrl:y??"",isRunning:v,onCrawl:d=>W(d,!1),onAuditThisPage:p,reviewEnabled:E,onToggleReview:U}),e.jsx(ye,{open:f.gateOpen,gaps:f.gaps,onRunFull:f.runFull,onQuickCheck:f.quickCheck,onCancel:f.cancel})]});const V=a.length,u=(t.totalWalkthroughFindings??0)+t.totalUniqueViolations+V,T=(t.walkthroughAcknowledgements??[]).length,L=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(wt,{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:x?"page grade · single-page audit":`site grade · ${t.pagesAudited} page${t.pagesAudited===1?"":"s"}`}),e.jsxs("p",{style:{margin:0,fontSize:11,lineHeight:1.4,color:"var(--v2-ink-tertiary)"},children:["Your ",e.jsx("strong",{children:"combined grade"})," — severity (your most serious finding) and breadth (how many of the 9 areas have issues) together, with a legal floor so a serious issue can't be averaged away. The Dev view shows the same letter."]}),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 B,M;if(((B=t.spotCheckGate)==null?void 0:B.status)==="pending"){const O=t.spotCheckGate;return`On track for A — answer ${O.unanswered.length} more content-meaning spot-check${O.unanswered.length===1?"":"s"} below to finalize your grade (${O.answered}/${O.total} done).`}const d=u+L,C=((M=t.blockingCriteria)==null?void 0:M.length)??0;return d===0&&C===0?"All clear — nothing open.":d===0&&C>0?`Visible findings clear — ${C} criteri${C===1?"on":"a"} still need${C===1?"s":""} your judgment.`:`${d} finding${d===1?"":"s"} to address.`})()}),e.jsx(jt,{openCount:u,reviewCount:L,verifiedCount:T,axeCount:t.totalUniqueViolations,walkthroughCount:t.totalWalkthroughFindings??0,autoCount:V}),y&&!kt(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:[x?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:p,title:"Re-audit the current page",children:"Re-audit this page"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>k(d=>!d),"aria-expanded":j,title:"Open crawl setup to audit the whole site instead",children:j?"Hide crawl options":"Crawl whole site"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary",onClick:q,disabled:z,title:"Re-aggregate this audit against your latest verdicts + acks. No re-crawl. Use this after marking criteria in the Coverage gaps panel.",children:z?"Regrading…":"Regrade"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:()=>W({startUrl:t.startUrl,maxPages:25,includeRegex:"",excludeRegex:""},!1),title:`Re-crawl ${t.startUrl} (same options) — full audit re-run, use when page code changed`,children:"Re-crawl"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost",onClick:p,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:()=>W({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(d=>!d),"aria-expanded":j,children:j?"Hide options":"Adjust options"})]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>void Ie(),title:"Wipe these results so you can start fresh",style:{marginLeft:"auto"},children:"Clear results"})]}),I&&e.jsx("p",{role:"alert",style:{margin:"var(--v2-pad-2) 0 0",fontSize:11,color:"var(--v2-critical)"},children:I}),D&&!I&&e.jsx("p",{role:"status",style:{margin:"var(--v2-pad-2) 0 0",fontSize:11,color:"var(--v2-verified)"},children:D.prevGrade===D.nextGrade?`Regraded — grade unchanged at ${D.nextGrade}. Any verdict changes you made were already in this report.`:`Regraded — grade ${D.prevGrade} → ${D.nextGrade}.`})]})]}),(g==null?void 0:g.receipt)&&e.jsx(ft,{sealed:g}),e.jsx(Ne,{}),e.jsx(Ue,{}),j&&e.jsxs("div",{style:{marginTop:"var(--v2-pad-5)",paddingTop:"var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)",maxWidth:640},children:[e.jsx(fe,{initialUrl:t.startUrl,isRunning:v,onCrawl:d=>W(d,!1),onVerifyFixes:d=>W(d,!0),onAuditThisPage:p,reviewEnabled:E,onToggleReview:U}),e.jsx(ye,{open:f.gateOpen,gaps:f.gaps,onRunFull:f.runFull,onQuickCheck:f.quickCheck,onCancel:f.cancel})]})]})}function kt(t,a){try{return new URL(t).origin===new URL(a).origin}catch{return!1}}function wt({grade:t}){if(t==="pending")return e.jsx("div",{"aria-label":"Grade pending — spot-checks outstanding",role:"img",style:{display:"flex",alignItems:"center",justifyContent:"center",minWidth:140},children:e.jsx("span",{className:"v2-display",style:{fontSize:40,lineHeight:1.05,fontWeight:600,color:"var(--v2-ink-secondary, #94a3b8)",letterSpacing:"-0.02em",textAlign:"center"},children:"Pending"})});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 jt({openCount:t,reviewCount:a,verifiedCount:r,axeCount:o,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(K,{term:"open",value:t,tone:t>0?"attention":"neutral"}),e.jsx(K,{term:"review",value:a,tone:a>0?"review":"neutral"}),e.jsx(K,{term:"verified",value:r,tone:r>0?"positive":"neutral"}),e.jsx("span",{style:{color:"var(--v2-ink-faint)"},children:"·"}),e.jsx(K,{term:"axe",value:o,tone:"neutral"}),e.jsx(K,{term:"walkthrough",value:s,tone:"neutral"}),l>0&&e.jsx(K,{term:"auto-contrast",value:l,tone:"neutral"})]})}function K({term:t,value:a,tone:r}){const o={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:o[r],fontVariantNumeric:"tabular-nums"},children:a})]})}const St=new Set(["2.4.3","2.1.2","2.4.7","1.3.2","1.4.11","2.5.3"]);function be(t){return St.has(t)}async function ke(t){var o,s;const a=m.getState();if(a.componentId&&((o=a.results[0])==null?void 0:o.pageUrl)===t)return a.componentId;const r=await je();return((s=r==null?void 0:r.find(l=>l.url===t))==null?void 0:s.componentId)??null}async function Ct(t,a){var l;const r=m.getState(),o=[];if(r.componentId&&r.results.length>0){const n=(l=r.results[0])==null?void 0:l.pageUrl,i=a.find(v=>v.url===n);if(i){for(const v of r.results)for(const x of v.violations)x.ruleId===t&&x.target.selector===i.selector&&o.push({componentId:r.componentId,matchKey:x.matchKey});if(o.length>0)return o}}const s=await je()??[];for(const n of a){const i=s.find(v=>v.url===n.url);if(i)for(const v of i.results)for(const x of v.violations)x.ruleId===t&&x.target.selector===n.selector&&o.push({componentId:i.componentId,matchKey:x.matchKey})}return o}function Rt({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(Tt,{row:t}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(Et,{row:t}),e.jsx(At,{row:t})]}),e.jsx(It,{})]}),e.jsx("div",{style:{padding:"0 var(--v2-pad-4) var(--v2-pad-4)",borderTop:"1px solid var(--v2-border)"},children:e.jsx(Nt,{row:t})})]})}function Tt({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 Et({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"?t.verdict==="uncertain"?"AI could not decide this criterion — needs your manual verification.":"AI walkthrough fail 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 At({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,o=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}),o&&e.jsx("span",{className:"v2-mono",style:{fontSize:11,color:"var(--v2-ink-tertiary)",wordBreak:"break-all"},children:o}),a>1&&e.jsxs("span",{className:"v2-eyebrow",style:{marginLeft:"auto"},children:["on ",a," pages"]})]})}function It(){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 Nt({row:t}){return t.kind==="walkthrough-fail"?e.jsx(zt,{row:t}):t.kind==="walkthrough-ack"?e.jsx(Pt,{row:t}):t.kind==="needs-review"?e.jsx(Dt,{row:t}):t.kind==="auto-contrast"?e.jsx(Ut,{row:t}):e.jsx(Lt,{row:t})}function Ut({row:t}){const[a,r]=c.useState(!1),[o,s]=c.useState(!1),[l,n]=c.useState(""),[i,v]=c.useState(!1),[x,w]=c.useState(!1),[g,y]=c.useState(null),b=Se(t.ruleId);async function j(){if(v(!0),y(null),!l.trim()){y("Note is required — explain why the empirical contrast measurement is wrong, or why this element is acceptable in context."),v(!1);return}try{const h=(await st(t.pageUrl)).find(P=>P.ruleId===t.ruleId&&P.selector===t.selector),E={pageUrl:t.pageUrl,ruleId:t.ruleId,selector:t.selector,verdict:"pass",reasoning:`Human override: ${l.trim()}
3
3
 
4
4
  (Original empirical reasoning: ${t.reasoning})`,resolvedAt:new Date().toISOString(),costUsd:0,wcagCriterion:t.criterion,inputHash:h==null?void 0:h.inputHash};await ot(E),w(!0),r(!1)}catch(k){y(k instanceof Error?k.message:String(k))}finally{v(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(te,{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."}),x?e.jsx(ce,{}):e.jsxs(e.Fragment,{children:[e.jsxs(de,{children:[b&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>s(k=>!k),"aria-expanded":o,children:o?"Hide fix recipe":"Show fix recipe"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>r(k=>!k),"aria-expanded":a,children:a?"Cancel":"Mark verified manually"})]}),o&&b&&e.jsx(Re,{summary:b.summary,snippet:b.snippet}),a&&e.jsx(le,{note:l,setNote:n,busy:i,err:g,onConfirm:j,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."}),g&&!a&&e.jsx(ae,{message:g})]})]})}function zt({row:t}){const[a,r]=c.useState(!1),[o,s]=c.useState(""),[l,n]=c.useState(!1),[i,v]=c.useState(!1),[x,w]=c.useState(!1),[g,y]=c.useState(null),[b,j]=c.useState(null),k=be(t.criterion),h=Pe();async function E(){if(n(!0),j(null),!o.trim()){j("Note is required — explain how you manually verified this."),n(!1);return}try{const f=await ke(t.pageUrl);if(!f){j("Could not find this page in the audit data. Re-run the audit and try again.");return}await it({componentId:f,criterionId:t.criterion,pageUrl:t.pageUrl,note:o.trim(),acknowledgedAt:new Date().toISOString(),verdictAtAck:t.verdict}),v(!0),r(!1)}catch(f){j(f instanceof Error?f.message:String(f))}finally{n(!1)}}async function P(){var f;w(!0),y(null),j(null);try{const $=(f=(await chrome.tabs.query({active:!0,currentWindow:!0}))[0])==null?void 0:f.id;if(!$){j("Open the audited page in your active tab to re-run.");return}const U=await ke(t.pageUrl);if(!U){j("Could not find this page in the audit data.");return}if(!be(t.criterion)){j(`Re-run is only available for interactive criteria. ${t.criterion} is not supported.`);return}const R=await S({type:"INTERACTIVE_AUDIT_REQUEST",criterionId:t.criterion,tabId:$,componentId:U,pageUrl:t.pageUrl});if(!R.ok){j(R.error??"Re-run failed.");return}y(`Re-run verdict: ${R.verdict??"unknown"}. Re-audit the page to refresh this list.`)}catch(F){j(F instanceof Error?F.message:String(F))}finally{w(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(te,{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(ce,{}):e.jsxs(e.Fragment,{children:[e.jsxs(de,{children:[k&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:P,disabled:x||!h,title:h?void 0:"AI walkthroughs need an Anthropic API key. Add one in Settings → AI.",children:x?"Re-running…":"Re-run walkthrough"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>r(f=>!f),"aria-expanded":a,children:a?"Cancel":"Mark verified manually"})]}),g&&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:g}),a&&e.jsx(le,{note:o,setNote:s,busy:l,err:b,onConfirm:E,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."}),b&&!a&&e.jsx(ae,{message:b})]})]})}function Pt({row:t}){return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[e.jsx(te,{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 Dt({row:t}){return e.jsx(Ce,{row:t,kind:"needs-review"})}function Lt({row:t}){return e.jsx(Ce,{row:t,kind:"axe"})}function Ce({row:t,kind:a}){const[r,o]=c.useState(!1),[s,l]=c.useState(""),[n,i]=c.useState(!1),[v,x]=c.useState(!1),[w,g]=c.useState(!1),[y,b]=c.useState(null),j=Se(t.ruleId);async function k(){if(i(!0),b(null),!s.trim()){b(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 h=await Ct(t.ruleId,t.pages);if(h.length===0){b("Could not find this finding in the persisted audit data. Re-run the audit and try again.");return}for(const E of h)await lt({componentId:E.componentId,matchKey:E.matchKey,ruleId:t.ruleId,note:s.trim()});x(!0),o(!1)}catch(h){b(h instanceof Error?h.message:String(h))}finally{i(!1)}}return e.jsxs("div",{style:{paddingTop:"var(--v2-pad-3)"},children:[a==="needs-review"&&t.failureSummary&&e.jsx(te,{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(te,{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(h=>e.jsx("li",{children:e.jsx("a",{href:h.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:h.url})},h.url)),t.pages.length>8&&e.jsxs("li",{className:"v2-eyebrow",children:["+ ",t.pages.length-8," more"]})]})}),v?e.jsx(ce,{}):e.jsxs(e.Fragment,{children:[e.jsxs(de,{children:[a==="axe"&&j&&e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>g(h=>!h),"aria-expanded":w,children:w?"Hide fix recipe":"Show fix recipe"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>o(h=>!h),"aria-expanded":r,children:r?"Cancel":"Mark verified manually"})]}),w&&j&&e.jsx(Re,{summary:j.summary,snippet:j.snippet}),r&&e.jsx(le,{note:s,setNote:l,busy:n,err:y,onConfirm:k,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"}`}),y&&!r&&e.jsx(ae,{message:y})]})]})}function le({note:t,setNote:a,busy:r,err:o,onConfirm:s,hint:l,placeholder:n,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:v=>a(v.target.value),placeholder:n,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}),o&&e.jsx(ae,{message:o}),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 Re({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 ce(){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 ae({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 te({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 de({children:t}){return e.jsx("div",{style:{display:"flex",gap:"var(--v2-pad-2)",flexWrap:"wrap",marginTop:"var(--v2-pad-2)"},children:t})}function _t(){const{report:t,resolvedFails:a}=oe(),[r,o]=c.useState("open"),s=c.useMemo(()=>t?Ft(t.pages,t.findingGroups??[],a):[],[t,a]),l=c.useMemo(()=>r==="all"?s:s.filter(i=>r==="verified"?i.kind==="walkthrough-ack":r==="review"?i.kind==="needs-review"||i.kind==="walkthrough-fail"&&i.verdict==="uncertain":r==="open"?i.kind==="axe"||i.kind==="walkthrough-fail"&&i.verdict==="fail"||i.kind==="auto-contrast":!0),[s,r]);if(!t)return null;const n={all:s.length,open:s.filter(i=>i.kind==="axe"||i.kind==="walkthrough-fail"&&i.verdict==="fail"||i.kind==="auto-contrast").length,review:s.filter(i=>i.kind==="needs-review"||i.kind==="walkthrough-fail"&&i.verdict==="uncertain").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(Wt,{filter:r,setFilter:o,counts:n})]}),l.length===0?e.jsx(Gt,{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,v)=>e.jsx("li",{style:{animation:`v2-row-in 240ms ease ${Math.min(v,12)*30}ms both`},children:e.jsx(Rt,{row:i})},i.key))})]})}function Wt({filter:t,setFilter:a,counts:r}){const o=[{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:o.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 Gt({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 o=[];for(const n of a)n.needsReview?o.push({kind:"needs-review",key:`nr::${n.ruleId}::${n.representativeSelector}`,criterion:n.wcagCriterion,ruleId:n.ruleId,description:n.axeDescription,selector:n.representativeSelector,failureSummary:n.failureSummary,pages:n.pages,group:n}):o.push({kind:"axe",key:`axe::${n.ruleId}::${n.representativeSelector}`,criterion:n.wcagCriterion,ruleId:n.ruleId,impact:n.impact,description:n.axeDescription,selector:n.representativeSelector,pages:n.pages,isShared:n.isShared});const s=new Set;for(const n of t){for(const i of n.walkthroughFindings??[]){const v=`wt-fail::${i.criterionId}::${i.pageUrl}`;s.has(v)||(s.add(v),o.push({kind:"walkthrough-fail",key:v,criterion:i.criterionId,verdict:i.verdict,impact:i.impact,reasoning:i.reasoning,pageUrl:i.pageUrl}))}for(const i of n.walkthroughAcknowledgements??[]){const v=`wt-ack::${i.criterionId}::${i.pageUrl}`;s.has(v)||(s.add(v),o.push({kind:"walkthrough-ack",key:v,criterion:i.criterionId,verdict:i.verdict,reasoning:i.reasoning,pageUrl:i.pageUrl}))}}for(const n of r)o.push({kind:"auto-contrast",key:`auto::${n.ruleId}::${n.selector}::${n.pageUrl}`,criterion:n.wcagCriterion??"1.4.3",ruleId:n.ruleId,impact:"serious",selector:n.selector,pageUrl:n.pageUrl,reasoning:n.reasoning});const l={critical:0,serious:1,moderate:2,minor:3,"needs-review":4,ack:5};return o.sort((n,i)=>{const v=n.kind==="walkthrough-ack"?l.ack:n.kind==="needs-review"?l["needs-review"]:l[n.impact],x=i.kind==="walkthrough-ack"?l.ack:i.kind==="needs-review"?l["needs-review"]:l[i.impact];return(v??99)-(x??99)}),o}function Mt({open:t,onClose:a}){const{report:r}=oe(),o=m(p=>p.siteCrawlReport),s=m(p=>p.results),l=m(p=>p.componentId),n=m(p=>p.delta),i=!!o,v=i||s.length>0,x=m(p=>p.tier),w=p=>!Le(x,p),[g,y]=c.useState(!1),b=()=>y(!0),j=i?"ai-prompt-site-crawl":"ai-prompt",k=De({storeComponentId:l,storeCrawlReport:o,pageUrls:(r==null?void 0:r.pages.map(p=>p.url))??[]}),[h,E]=c.useState({}),P=c.useRef(null);c.useEffect(()=>{var z;if(!t)return;const p=A=>{A.key==="Escape"&&a()};return document.addEventListener("keydown",p),(z=P.current)==null||z.focus(),()=>document.removeEventListener("keydown",p)},[t,a]);function f(p,z){E(A=>({...A,[p]:z}))}async function F(){f("ai-prompt",{state:"busy"});try{if(i){const p=await S({type:"EXPORT_REQUEST",format:"ai-prompt-site-crawl",results:[],...r?{siteCrawlReport:r}:{}});if(!(p!=null&&p.content))throw new Error("Empty response");await navigator.clipboard.writeText(p.content),Je(p.content,"ai-fixer-prompt.md","text/markdown"),f("ai-prompt",{state:"done",message:"Copied to clipboard + saved ai-fixer-prompt.md to Downloads."})}else{if(!s.length)throw new Error("No audit results yet");await ut({results:s,componentId:l??null,delta:n}),f("ai-prompt",{state:"done",message:"Copied to clipboard + opened in a new tab."})}}catch(p){f("ai-prompt",{state:"error",message:p instanceof Error?p.message:String(p)})}}async function $(){f("html",{state:"busy"});try{if(i&&r){const{renderSiteReportHtml:p}=await re(async()=>{const{renderSiteReportHtml:I}=await import("./site-report-renderer-C3U9cFY3.js");return{renderSiteReportHtml:I}},__vite__mapDeps([0,1,2,3,4,5])),z=await ue([r.startUrl]).catch(()=>[]),A=p(r,void 0,z);await se(A,"site-report.html","text/html"),f("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:p}=await re(async()=>{const{toHtmlPrint:A}=await import("./scheduled-audit-runner-EQBltZPz.js").then(I=>I.b8);return{toHtmlPrint:A}},__vite__mapDeps([1,2,3,4,5])),z=p(s,n??void 0);await se(z,"page-report.html","text/html"),f("html",{state:"done",message:"Opened in a new tab — Save as PDF or use Cmd/Ctrl+S."})}}catch(p){f("html",{state:"error",message:p instanceof Error?p.message:String(p)})}}async function U(p,z,A){f(p,{state:"busy"});try{const I=await S({type:"EXPORT_REQUEST",format:p,results:i?[]:s,...n&&!i?{delta:n}:{},...i?{siteCrawlSource:!0}:{},...k?{auditTargetId:k}:{}});if(!(I!=null&&I.content))throw new Error("Empty response");await se(I.content,A,"text/html"),f(p,{state:"done",message:`${z} opened in a new tab.`})}catch(I){f(p,{state:"error",message:I instanceof Error?I.message:String(I)})}}async function W(){const{createZip:p}=await re(async()=>{const{createZip:N}=await import("./zip-encoder-CtULHXx_.js");return{createZip:N}},[]),{renderSiteReportHtml:z}=await re(async()=>{const{renderSiteReportHtml:N}=await import("./site-report-renderer-C3U9cFY3.js");return{renderSiteReportHtml:N}},__vite__mapDeps([0,1,2,3,4,5])),A=[],I=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"}],H=I.length+(i&&r?1:0);let D=0;f("zip",{state:"busy",progress:{current:0,total:H,label:"Starting…"}});try{if(i&&r){D++,f("zip",{state:"busy",progress:{current:D,total:H,label:"site-report.html (client-side)"}});try{const T=await ue([r.startUrl]).catch(()=>[]);A.push({name:"site-report.html",content:z(r,void 0,T)})}catch{}}for(const{format:T,filename:L}of I){D++,f("zip",{state:"busy",progress:{current:D,total:H,label:L}});try{const d=await S({type:"EXPORT_REQUEST",format:T,results:i?[]:s,...n&&!i?{delta:n}:{},...i?{siteCrawlSource:!0}:{},...k?{auditTargetId:k}:{}});d!=null&&d.content&&A.push({name:L,content:d.content})}catch{}}if(A.length===0)throw new Error("All exports failed");const N=p(A),q=new Blob([N],{type:"application/zip"}),V=URL.createObjectURL(q),u=document.createElement("a");u.href=V,u.download=i?"wcagcheckr-site-bundle.zip":"wcagcheckr-page-bundle.zip",u.click(),setTimeout(()=>URL.revokeObjectURL(V),6e4),f("zip",{state:"done",message:`Downloaded ${A.length} file${A.length===1?"":"s"}.`})}catch(N){f("zip",{state:"error",message:N instanceof Error?N.message:String(N)})}}function R(p){m.getState().setView(p),m.getState().setUserMode("dev"),S({type:"SETTINGS_SET",key:"userMode",value:"dev"}),a()}function Q(){S({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:P,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:[!v&&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."}),v&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{title:"AI fixer",children:e.jsx(G,{status:h["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:F,locked:w(j),onUpgrade:b})}),e.jsxs(Y,{title:"Reports",children:[e.jsx(G,{status:h.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:$}),e.jsx(G,{status:h["executive-report"],label:"Executive report",description:"Hero grade + framing, top risks, next steps. For non-technical readers.",onClick:()=>U("executive-report","Executive report","executive-report.html"),locked:w("executive-report"),onUpgrade:b}),i&&e.jsx(G,{status:h["ticket-bundle"],label:"Ticket bundle",description:"Markdown formatted for paste into Linear / Jira / GitHub Issues — one ticket per finding, sorted by severity.",onClick:()=>U("ticket-bundle","Ticket bundle","ticket-bundle.md")})]}),e.jsxs(Y,{title:"Compliance & legal",children:[e.jsx(G,{status:h["defense-bundle"],label:"Defense bundle",description:"Anchored chain-of-custody evidence package. Use in pre-litigation.",onClick:()=>U("defense-bundle","Defense bundle","defense-bundle.html"),locked:w("defense-bundle"),onUpgrade:b}),e.jsx(G,{status:h["deposition-packet"],label:"Deposition packet",description:"Full evidence bundle — anchor, receipts, fingerprints, signing cert.",onClick:()=>U("deposition-packet","Deposition packet","deposition-packet.html"),locked:w("deposition-packet"),onUpgrade:b}),e.jsx(G,{status:h.vpat,label:"VPAT",description:"Voluntary Product Accessibility Template. Procurement-ready.",onClick:()=>U("vpat","VPAT","vpat.html"),locked:w("vpat"),onUpgrade:b}),e.jsx(G,{status:h["conformance-crosswalk"],label:"Conformance crosswalk",description:"WCAG ↔ Section 508 ↔ EN 301 549 mapping.",onClick:()=>U("conformance-crosswalk","Conformance crosswalk","conformance-crosswalk.html"),locked:w("conformance-crosswalk"),onUpgrade:b}),e.jsx(G,{status:h["methodology-doc"],label:"Methodology PDF",description:"Auditor-explainable methodology — what was tested, how, with what tools.",onClick:()=>U("methodology-doc","Methodology doc","methodology-doc.html"),locked:w("methodology-doc"),onUpgrade:b}),e.jsx(G,{status:h["evidence-bundle"],label:"Evidence bundle",description:"Lighter than defense bundle — audit records + summary.",onClick:()=>U("evidence-bundle","Evidence bundle","evidence-bundle.html"),locked:w("evidence-bundle"),onUpgrade:b})]}),e.jsx(Y,{title:"Bulk",children:e.jsx(G,{status:h.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:W,locked:w(i?"defense-bundle":"ai-prompt"),onUpgrade:b})})]}),e.jsxs(Y,{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(_,{label:"State matrix",description:"Per-state findings grid (hover · focus · dark · RTL · etc.)",onClick:()=>R("matrix")}),e.jsx(_,{label:"Per-area compliance",description:"9 sub-grade areas with drill-in: Color & contrast, Keyboard, etc.",onClick:()=>R("report")}),e.jsx(_,{label:"Baseline delta",description:"New vs. persistent vs. fixed vs. acknowledged since the last baseline.",onClick:()=>R("delta")}),e.jsx(_,{label:"Forensic log",description:"Anchored audit history with chain-of-custody.",onClick:()=>R("forensic")}),e.jsx(_,{label:"Risk dashboard",description:"Lawsuit / conformance risk tiers with prioritized actions.",onClick:()=>R("risk")}),e.jsx(_,{label:"WCAG 3 mapping",description:"Outcome-level grouping per WCAG 3 snapshot.",onClick:()=>R("wcag3")}),e.jsx(_,{label:"WCAG-EM verdicts",description:"Formal per-criterion verdict map.",onClick:()=>R("compliance")}),e.jsx(_,{label:"Schedules",description:"Recurring audit management with email alerts.",onClick:()=>R("schedules")}),e.jsx(_,{label:"Copilot chat",description:"Anthropic-powered Q&A over your audit context.",onClick:()=>R("copilot")}),e.jsx(_,{label:"Accessibility tree",description:"Inspect the live aria tree as assistive tech sees it.",onClick:()=>R("ax-tree")}),e.jsx(_,{label:"Design tokens",description:"CSS-token / design-system audit.",onClick:()=>R("tokens")}),e.jsx(_,{label:"Guided audit",description:"13 manual IGT workflows (keyboard, screen reader, etc.).",onClick:()=>R("guided")}),e.jsx(_,{label:"Per-component scorecard",description:"Custom rules, baselines, per-component drill-in.",onClick:()=>R("scorecard")}),e.jsx(_,{label:"User journey flows",description:"Multi-step audit recordings.",onClick:()=>R("flows")}),e.jsx(_,{label:"Activity / IGT runs",description:"Manual workflow run history.",onClick:()=>R("activity")})]}),e.jsx(Y,{title:"Settings",children:e.jsx(G,{status:void 0,label:"Open settings",description:"Matrix preset, AI config, axe rule overrides, breakpoints, auto-export.",onClick:Q})})]})]}),e.jsx(we,{open:g,onClose:()=>y(!1)})]}):null}async function se(t,a,r){const{body:o,type:s}=et(t,r),l=new Blob([o],{type:s}),n=URL.createObjectURL(l);try{await chrome.tabs.create({url:n})}catch{const i=document.createElement("a");i.href=n,i.download=a,i.click()}setTimeout(()=>URL.revokeObjectURL(n),6e4)}function Y({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 G({label:t,description:a,status:r,onClick:o,locked:s=!1,onUpgrade:l}){const n=(r==null?void 0:r.state)==="busy",i=(r==null?void 0:r.state)==="done",v=(r==null?void 0:r.state)==="error";return s?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"var(--v2-pad-3) var(--v2-pad-4)",border:"1px solid var(--v2-warning, #f59e0b)",borderRadius:4,background:"var(--v2-warning-bg, rgba(245,158,11,0.08))"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--v2-pad-3)"},children:[e.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"var(--v2-ink-primary)"},children:["🔒 ",t]}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-sm",onClick:l,children:"Upgrade"})]}),e.jsxs("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:[e.jsx("strong",{children:"Upgrade to unlock"}),a?` · ${a}`:""]})]}):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:o,disabled:n,children:n?"Working…":i?"Run again":"Run"})]}),a&&e.jsx("p",{style:{margin:0,fontSize:11,color:"var(--v2-ink-tertiary)",lineHeight:1.5},children:a}),n&&(r==null?void 0:r.progress)&&e.jsxs("p",{role:"status","aria-live":"polite",style:{margin:0,marginTop:4,fontSize:11,color:"var(--v2-ink-secondary)"},children:[r.progress.current,"/",r.progress.total," — ",r.progress.label??""]}),i&&(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]}),v&&(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 _({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 Ot(){var l,n;const t=m(i=>i.siteCrawlReport),a=m(i=>i.results),[r,o]=c.useState(!1),s=(t==null?void 0:t.startUrl)??((l=a[0])==null?void 0:l.pageUrl)??((n=a[0])==null?void 0:n.scope)??null;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{role:"banner",style:{display:"flex",flexDirection:"column",gap:"var(--v2-pad-2)",padding:"var(--v2-pad-3) var(--v2-pad-5)",borderBottom:"1px solid var(--v2-border)",background:"var(--v2-bg)"},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:"center",gap:"var(--v2-pad-3)",minWidth:0,minHeight:28},children:[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)",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.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(_e,{})})]}),e.jsxs("nav",{"aria-label":"Application",style:{display:"flex",alignItems:"center",gap:"var(--v2-pad-2)",justifyContent:"flex-end"},children:[e.jsx(We,{}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-primary v2-btn-sm",onClick:()=>o(!0),"aria-label":"Open tools and exports drawer","aria-expanded":r,title:"Exports, baselines, schedules, forensic log, settings, more",children:"Tools"}),e.jsx("button",{type:"button",className:"v2-btn v2-btn-ghost v2-btn-sm",onClick:()=>void S({type:"OPEN_SETTINGS"}),"aria-label":"Open settings",title:"Settings",children:"⚙"})]})]}),e.jsx(Mt,{open:r,onClose:()=>o(!1)})]})}function $t(){return c.useEffect(()=>{const t=Ge(),r=new URLSearchParams(window.location.search).get("context")==="overlay"?null:chrome.runtime.connect({name:"sidepanel-tracker"}),o=Fe();Me({forceRefresh:!0}).catch(()=>{}),Oe().catch(()=>{}),$e().catch(()=>{}),He().catch(()=>{}),Be().catch(()=>{}),Ve().catch(()=>{}),ct().then(l=>{m.getState().setAcknowledgedKeys(new Set(l.map(n=>n.matchKey)))}).catch(()=>{});let s=!1;return dt().then(l=>{s||l&&m.setState(n=>n.siteCrawlStatus==="running"?{siteCrawlReport:l}:{siteCrawlReport:l,siteCrawlStatus:"complete"})}).catch(()=>{}),()=>{s=!0,o();try{t.disconnect()}catch{}try{r==null||r.disconnect()}catch{}}},[]),e.jsxs("div",{className:"v2-root",children:[e.jsx(Ot,{}),e.jsx(qe,{}),e.jsx(Ke,{}),e.jsxs("main",{id:"main-content","aria-label":"wcagcheckr findings",children:[e.jsx(bt,{}),e.jsx(_t,{})]})]})}function Ht({persona:t,children:a}){const r=t==="power"?"Power user":"Dev",[o,s]=c.useState(!1),l=c.useRef(null);c.useEffect(()=>{const i=l.current;i&&(i.inert=!0)},[]);function n(){chrome.storage.local.set({userMode:"owner",v2UiEnabled:!1}),S({type:"SETTINGS_SET",key:"userMode",value:"owner"})}return e.jsxs("div",{className:"relative h-screen overflow-hidden",children:[e.jsx("div",{ref:l,"aria-hidden":"true",className:"h-full overflow-hidden blur-[2px] opacity-50 pointer-events-none select-none",children:a}),e.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"locked-persona-title",className:"max-w-sm w-full bg-white border border-slate-200 rounded-xl shadow-xl p-5 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl","aria-hidden":"true",children:"🔒"}),e.jsxs("h2",{id:"locked-persona-title",className:"text-base font-semibold text-slate-900",children:[r," mode is a paid feature"]})]}),e.jsxs("p",{className:"text-xs text-slate-600 leading-snug",children:[r," mode unlocks the full WCAG findings, fix recipes, and exports for every page — that needs a license. On the free plan, ",e.jsx("strong",{children:"Owner mode"})," ","(the lawsuit-target screener) is yours to use, no license required."]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:()=>s(!0),className:"w-full text-sm px-4 py-2 bg-brand-500 text-white rounded hover:bg-brand-600 font-medium",children:"Upgrade to unlock →"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void S({type:"OPEN_SETTINGS"}),className:"text-xs text-slate-600 hover:text-slate-900 underline-offset-2 hover:underline",children:"I have a license token"}),e.jsx("button",{type:"button",onClick:n,className:"text-xs font-medium text-brand-700 hover:underline",children:"← Back to Owner mode"})]})]})]})}),e.jsx(we,{open:o,onClose:()=>s(!1)})]})}function Bt(){return e.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center min-h-screen gap-4 px-6 py-10 text-center",children:[e.jsx("div",{className:"text-3xl","aria-hidden":"true",children:"📡"}),e.jsx("h1",{className:"text-base font-semibold text-slate-800",children:"Internet connection required"}),e.jsx("p",{className:"max-w-xs text-sm leading-relaxed text-slate-600",children:"wcagcheckr needs to reach its license server to run. Connect to the internet and reload."}),e.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"rounded bg-slate-800 px-4 py-1.5 text-sm font-medium text-white hover:bg-slate-700",children:"Reload"})]})}Xe("side-panel");function Vt(){const[t,a]=c.useState(null),[r,o]=c.useState(!1),[,s]=c.useState(0),[l,n]=c.useState(null),[i,v]=c.useState(!1),[x,w]=c.useState(!1);if(c.useEffect(()=>{let y=!1;(async()=>{if(await Promise.all([pe(),he()]),!y){if(o(!0),await ve()){y||n(!0),Promise.all([ge(),me()]).then(()=>{y||s(k=>k+1)}).catch(()=>{});return}await Promise.all([ge(),me()]).catch(()=>{}),!y&&(s(k=>k+1),n(await ve()))}})(),chrome.storage.local.get("licenseToken").then(k=>{y||w(!!k.licenseToken)}).catch(()=>{}).finally(()=>{y||v(!0)});function b(k){const h=k.userMode,E=!!k.v2UiEnabled;let P;h==="owner"||h==="power"||h==="dev"?P=h:P=E?"power":"owner",y||a(P)}chrome.storage.local.get(["userMode","v2UiEnabled"]).then(b).catch(()=>a("owner"));const j=(k,h)=>{h==="local"&&("tierConfig:cache"in k&&pe().then(()=>{y||s(E=>E+1)}),"rubricConfigCache"in k&&he().then(()=>{y||s(E=>E+1)}),"licenseToken"in k&&chrome.storage.local.get("licenseToken").then(E=>{y||w(!!E.licenseToken)}),!(!("userMode"in k)&&!("v2UiEnabled"in k))&&chrome.storage.local.get(["userMode","v2UiEnabled"]).then(b))};return chrome.storage.onChanged.addListener(j),()=>{y=!0,chrome.storage.onChanged.removeListener(j)}},[]),t===null||!r||!i||l===null)return null;if(!l)return e.jsx(Bt,{});const g=t==="power"?e.jsx($t,{}):e.jsx(Qe,{});return(t==="power"||t==="dev")&&!x?e.jsx(Ht,{persona:t,children:g}):g}const Te=document.getElementById("root");if(!Te)throw new Error("side-panel: #root not found");Ee(Te).render(e.jsx(Ae.StrictMode,{children:e.jsx(Ye,{children:e.jsx(Vt,{})})}));