@wcag-checkr/ci 1.0.0-rc.27 → 1.0.0-rc.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{options-Cehm725W.js → options-BG2i5vFf.js} +5 -5
- package/dist/assets/{service-worker.ts-CO86CV_p.js → service-worker.ts-CHQZuZgM.js} +46 -46
- package/dist/manifest.json +4 -3
- package/dist/options/options.html +1 -1
- package/dist/service-worker-loader.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import"./modulepreload-polyfill-B5Qt9EMX.js";import{a as z,R as D,u as W,j as e,b as X,r as i,d as he,P,e as L,f as pe,g as Ue,h as Oe,i as R,C as $e,A as K,k as Ge,c as Be}from"./styles-C4Kq0zOO.js";import{c as be,r as w,o as Ke,s as C,O as Z,a as Ve}from"./crash-reporter-Dc5lvxvY.js";import{T as Je,P as _,r as He,D as Ye,l as We,g as qe,a as ze,b as ee}from"./state-PELIq3oj.js";import{c as Qe,D as V,l as Xe,a as Ze}from"./ai-usage-log-Dj9Ub_DT.js";import{l as et,s as te,v as tt}from"./custom-rules-CAe0nbES.js";import"./_commonjsHelpers-Cpj98o6Y.js";function st(t){const s=t+"CollectionProvider",[a,n]=z(s),[o,x]=a(s,{collectionRef:{current:null},itemMap:new Map}),d=j=>{const{scope:p,children:c}=j,f=D.useRef(null),N=D.useRef(new Map).current;return e.jsx(o,{scope:p,itemMap:N,collectionRef:f,children:c})};d.displayName=s;const r=t+"CollectionSlot",m=X(r),l=D.forwardRef((j,p)=>{const{scope:c,children:f}=j,N=x(r,c),S=W(p,N.collectionRef);return e.jsx(m,{ref:S,children:f})});l.displayName=r;const u=t+"CollectionItemSlot",h="data-radix-collection-item",b=X(u),g=D.forwardRef((j,p)=>{const{scope:c,children:f,...N}=j,S=D.useRef(null),A=W(p,S),T=x(u,c);return D.useEffect(()=>(T.itemMap.set(S,{ref:S,...N}),()=>void T.itemMap.delete(S))),e.jsx(b,{[h]:"",ref:A,children:f})});g.displayName=u;function v(j){const p=x(t+"CollectionConsumer",j);return D.useCallback(()=>{const f=p.collectionRef.current;if(!f)return[];const N=Array.from(f.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((T,F)=>N.indexOf(T.ref.current)-N.indexOf(F.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:d,Slot:l,ItemSlot:g},v,n]}var at=i.createContext(void 0);function fe(t){const s=i.useContext(at);return t||s||"ltr"}var J="rovingFocusGroup.onEntryFocus",nt={bubbles:!1,cancelable:!0},O="RovingFocusGroup",[q,ge,rt]=st(O),[lt,ye]=z(O,[rt]),[ot,it]=lt(O),ve=i.forwardRef((t,s)=>e.jsx(q.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(q.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(ct,{...t,ref:s})})}));ve.displayName=O;var ct=i.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:o=!1,dir:x,currentTabStopId:d,defaultCurrentTabStopId:r,onCurrentTabStopIdChange:m,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...h}=t,b=i.useRef(null),g=W(s,b),v=fe(x),[j,p]=pe({prop:d,defaultProp:r??null,onChange:m,caller:O}),[c,f]=i.useState(!1),N=Ue(l),S=ge(a),A=i.useRef(!1),[T,F]=i.useState(0);return i.useEffect(()=>{const y=b.current;if(y)return y.addEventListener(J,N),()=>y.removeEventListener(J,N)},[N]),e.jsx(ot,{scope:a,orientation:n,dir:v,loop:o,currentTabStopId:j,onItemFocus:i.useCallback(y=>p(y),[p]),onItemShiftTab:i.useCallback(()=>f(!0),[]),onFocusableItemAdd:i.useCallback(()=>F(y=>y+1),[]),onFocusableItemRemove:i.useCallback(()=>F(y=>y-1),[]),children:e.jsx(P.div,{tabIndex:c||T===0?-1:0,"data-orientation":n,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:L(t.onMouseDown,()=>{A.current=!0}),onFocus:L(t.onFocus,y=>{const k=!A.current;if(y.target===y.currentTarget&&k&&!c){const I=new CustomEvent(J,nt);if(y.currentTarget.dispatchEvent(I),!I.defaultPrevented){const E=S().filter(M=>M.focusable),De=E.find(M=>M.active),Me=E.find(M=>M.id===j),Pe=[De,Me,...E].filter(Boolean).map(M=>M.ref.current);Se(Pe,u)}}A.current=!1}),onBlur:L(t.onBlur,()=>f(!1))})})}),je="RovingFocusGroupItem",Ne=i.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:o=!1,tabStopId:x,children:d,...r}=t,m=he(),l=x||m,u=it(je,a),h=u.currentTabStopId===l,b=ge(a),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:j}=u;return i.useEffect(()=>{if(n)return g(),()=>v()},[n,g,v]),e.jsx(q.ItemSlot,{scope:a,id:l,focusable:n,active:o,children:e.jsx(P.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...r,ref:s,onMouseDown:L(t.onMouseDown,p=>{n?u.onItemFocus(l):p.preventDefault()}),onFocus:L(t.onFocus,()=>u.onItemFocus(l)),onKeyDown:L(t.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){u.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const c=xt(p,u.orientation,u.dir);if(c!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let N=b().filter(S=>S.focusable).map(S=>S.ref.current);if(c==="last")N.reverse();else if(c==="prev"||c==="next"){c==="prev"&&N.reverse();const S=N.indexOf(p.currentTarget);N=u.loop?mt(N,S+1):N.slice(S+1)}setTimeout(()=>Se(N))}}),children:typeof d=="function"?d({isCurrentTabStop:h,hasTabStop:j!=null}):d})})});Ne.displayName=je;var dt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ut(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function xt(t,s,a){const n=ut(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return dt[n]}function Se(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function mt(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var ht=ve,pt=Ne,B="Tabs",[bt]=z(B,[ye]),ke=ye(),[ft,Q]=bt(B),Te=i.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:o,defaultValue:x,orientation:d="horizontal",dir:r,activationMode:m="automatic",...l}=t,u=fe(r),[h,b]=pe({prop:n,onChange:o,defaultProp:x??"",caller:B});return e.jsx(ft,{scope:a,baseId:he(),value:h,onValueChange:b,orientation:d,dir:u,activationMode:m,children:e.jsx(P.div,{dir:u,"data-orientation":d,...l,ref:s})})});Te.displayName=B;var we="TabsList",Ce=i.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...o}=t,x=Q(we,a),d=ke(a);return e.jsx(ht,{asChild:!0,...d,orientation:x.orientation,dir:x.dir,loop:n,children:e.jsx(P.div,{role:"tablist","aria-orientation":x.orientation,...o,ref:s})})});Ce.displayName=we;var Ee="TabsTrigger",Ie=i.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:o=!1,...x}=t,d=Q(Ee,a),r=ke(a),m=_e(d.baseId,n),l=Le(d.baseId,n),u=n===d.value;return e.jsx(pt,{asChild:!0,...r,focusable:!o,active:u,children:e.jsx(P.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":l,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:m,...x,ref:s,onMouseDown:L(t.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?d.onValueChange(n):h.preventDefault()}),onKeyDown:L(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&d.onValueChange(n)}),onFocus:L(t.onFocus,()=>{const h=d.activationMode!=="manual";!u&&!o&&h&&d.onValueChange(n)})})})});Ie.displayName=Ee;var Ae="TabsContent",Re=i.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:o,children:x,...d}=t,r=Q(Ae,a),m=_e(r.baseId,n),l=Le(r.baseId,n),u=n===r.value,h=i.useRef(u);return i.useEffect(()=>{const b=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(b)},[]),e.jsx(Oe,{present:o||u,children:({present:b})=>e.jsx(P.div,{"data-state":u?"active":"inactive","data-orientation":r.orientation,role:"tabpanel","aria-labelledby":m,hidden:!b,id:l,tabIndex:0,...d,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:b&&x})})});Re.displayName=Ae;function _e(t,s){return`${t}-trigger-${s}`}function Le(t,s){return`${t}-content-${s}`}var gt=Te,yt=Ce,vt=Ie,$=Re;const jt=["default","hover","focus","focus-visible","active","disabled"],Nt=["light","dark","forced-colors-active","forced-colors-none"],St=["ltr","rtl"];function kt({value:t,onChange:s}){function a(o,x){return o.includes(x)?o.filter(d=>d!==x):[...o,x]}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:jt,selected:t.pseudoStates,onToggle:o=>s({...t,pseudoStates:a(t.pseudoStates,o)})}),e.jsx(G,{label:"Themes",all:Nt,selected:t.themes,onToggle:o=>s({...t,themes:a(t.themes,o)})}),e.jsx(G,{label:"Directions",all:St,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 x=a.includes(o);return e.jsx("button",{type:"button",onClick:()=>n(o),className:x?"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 Tt({value:t,onChange:s}){const[a,n]=i.useState(""),[o,x]=i.useState("");function d(l){l.preventDefault();const u=a.trim(),h=o.trim();!u||!h||(s({...t,[u]:h}),n(""),x(""))}function r(l){const u={...t};delete u[l],s(u)}const m=Object.entries(t);return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[m.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no aliases"}):e.jsx("ul",{className:"space-y-1",children:m.map(([l,u])=>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:`${l} → ${u}`,children:[l," ",e.jsx("span",{className:"text-slate-500",children:"→"})," ",u]}),e.jsx("button",{onClick:()=>r(l),className:"text-slate-500 hover:text-red-600 shrink-0","aria-label":`Remove alias ${l}`,children:"×"})]},l))}),e.jsxs("form",{onSubmit:d,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:l=>n(l.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:l=>x(l.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 se=be("billing-portal-client"),wt="https://api.wcagcheckr.com",Ct="wcagcheckr",Et=15e3;async function It(t){const s=`${wt}/v1/products/${Ct}/billing-portal`;try{const a=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(Et)}),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}:(se.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 se.warn("billing portal request failed",a),{ok:!1,error:a instanceof Error?a.message:String(a)}}}const ae=be("subscription-resume-client"),At="https://api.wcagcheckr.com",Rt="wcagcheckr",_t=1e4;async function Lt(t){try{const s=await fetch(`${At}/v1/products/${Rt}/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}:(ae.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 ae.warn("resume request failed",s),{ok:!1,error:s instanceof Error?s.message:String(s)}}}const Ft={trial:"Trial",free:"Free",solo:"Solo",team:"Team"},Dt={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)"},Mt=new Set(["solo-single-month"]);function Pt(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 U(t){return t?Dt[t]??t:"—"}function H(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 Ut({tier:t,onTierChange:s}){const[a,n]=i.useState(null),[o,x]=i.useState(null),[d,r]=i.useState(!1),[m,l]=i.useState(""),[u,h]=i.useState(!1),[b,g]=i.useState(null),[v,j]=i.useState(!1),[p,c]=i.useState(!1),f=i.useCallback(async y=>{const I=(await chrome.storage.local.get("licenseToken")).licenseToken??null;if(n(I),!I){x(null);return}try{const E=await w({type:"LICENSE_VALIDATE_REQUEST",token:I,forceRefresh:(y==null?void 0:y.forceRefresh)===!0});x(E)}catch{x(null)}},[]);i.useEffect(()=>(f({forceRefresh:!0}),Ke("LICENSE_CHANGED_EVENT",()=>{f()})),[f]);async function N(){if(m.trim()){h(!0),g(null);try{const y=await w({type:"LICENSE_SET_REQUEST",token:m.trim()}),k=await w({type:"LICENSE_VALIDATE_REQUEST",token:m.trim()});if(k.valid&&k.plan){const I=Gt(k.plan);s(I);let E=`Activated as ${U(k.plan)}.`;y.seatClaim.ok?y.seatClaim.overCapacity&&(E=`Activated as ${U(k.plan)}. Note: this license is currently OVER its seat cap (${y.seatClaim.seatsUsed} of ${y.seatClaim.seatsTotal} seats). Release one or upgrade.`):y.seatClaim.reason==="cap-reached"?E=`Activated as ${U(k.plan)}, BUT this license is at its seat capacity (${y.seatClaim.seatsUsed} of ${y.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.`:y.seatClaim.reason==="network"&&(E=`Activated as ${U(k.plan)}. (Seat-tracking ping failed — retrying in the background.)`),g(E),y.seatClaim.ok&&!y.seatClaim.overCapacity?R.polite(E):R.assertive(E),l(""),r(!1),await f()}else{const I="Token did not validate. Check the value and try again.";g(I),R.assertive(I)}}catch(y){const k=y instanceof Error?y.message:String(y);g(k),R.assertive(k)}finally{h(!1)}}}async function S(){if(a)try{await navigator.clipboard.writeText(a),j(!0),setTimeout(()=>j(!1),2e3)}catch{}}async function A(){if(window.confirm(`Remove the active license token from this extension?
|
|
1
|
+
import"./modulepreload-polyfill-B5Qt9EMX.js";import{a as z,R as M,u as W,j as e,b as X,r as i,d as he,P,e as L,f as pe,g as Ue,h as Oe,i as R,C as $e,A as K,k as Ge,c as Be}from"./styles-C4Kq0zOO.js";import{c as be,r as w,o as Ke,s as C,O as Z,a as Ve}from"./crash-reporter-Dc5lvxvY.js";import{T as He,P as _,r as Je,D as Ye,l as We,g as qe,a as ze,b as ee}from"./state-PELIq3oj.js";import{c as Qe,D as V,l as Xe,a as Ze}from"./ai-usage-log-Dj9Ub_DT.js";import{l as et,s as te,v as tt}from"./custom-rules-CAe0nbES.js";import"./_commonjsHelpers-Cpj98o6Y.js";function st(t){const s=t+"CollectionProvider",[a,n]=z(s),[r,x]=a(s,{collectionRef:{current:null},itemMap:new Map}),d=j=>{const{scope:p,children:c}=j,f=M.useRef(null),N=M.useRef(new Map).current;return e.jsx(r,{scope:p,itemMap:N,collectionRef:f,children:c})};d.displayName=s;const l=t+"CollectionSlot",m=X(l),o=M.forwardRef((j,p)=>{const{scope:c,children:f}=j,N=x(l,c),S=W(p,N.collectionRef);return e.jsx(m,{ref:S,children:f})});o.displayName=l;const u=t+"CollectionItemSlot",h="data-radix-collection-item",b=X(u),g=M.forwardRef((j,p)=>{const{scope:c,children:f,...N}=j,S=M.useRef(null),A=W(p,S),T=x(u,c);return M.useEffect(()=>(T.itemMap.set(S,{ref:S,...N}),()=>void T.itemMap.delete(S))),e.jsx(b,{[h]:"",ref:A,children:f})});g.displayName=u;function v(j){const p=x(t+"CollectionConsumer",j);return M.useCallback(()=>{const f=p.collectionRef.current;if(!f)return[];const N=Array.from(f.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((T,F)=>N.indexOf(T.ref.current)-N.indexOf(F.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:d,Slot:o,ItemSlot:g},v,n]}var at=i.createContext(void 0);function fe(t){const s=i.useContext(at);return t||s||"ltr"}var H="rovingFocusGroup.onEntryFocus",nt={bubbles:!1,cancelable:!0},O="RovingFocusGroup",[q,ge,rt]=st(O),[lt,ye]=z(O,[rt]),[ot,it]=lt(O),ve=i.forwardRef((t,s)=>e.jsx(q.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(q.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(ct,{...t,ref:s})})}));ve.displayName=O;var ct=i.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,orientation:n,loop:r=!1,dir:x,currentTabStopId:d,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:m,onEntryFocus:o,preventScrollOnEntryFocus:u=!1,...h}=t,b=i.useRef(null),g=W(s,b),v=fe(x),[j,p]=pe({prop:d,defaultProp:l??null,onChange:m,caller:O}),[c,f]=i.useState(!1),N=Ue(o),S=ge(a),A=i.useRef(!1),[T,F]=i.useState(0);return i.useEffect(()=>{const y=b.current;if(y)return y.addEventListener(H,N),()=>y.removeEventListener(H,N)},[N]),e.jsx(ot,{scope:a,orientation:n,dir:v,loop:r,currentTabStopId:j,onItemFocus:i.useCallback(y=>p(y),[p]),onItemShiftTab:i.useCallback(()=>f(!0),[]),onFocusableItemAdd:i.useCallback(()=>F(y=>y+1),[]),onFocusableItemRemove:i.useCallback(()=>F(y=>y-1),[]),children:e.jsx(P.div,{tabIndex:c||T===0?-1:0,"data-orientation":n,...h,ref:g,style:{outline:"none",...t.style},onMouseDown:L(t.onMouseDown,()=>{A.current=!0}),onFocus:L(t.onFocus,y=>{const k=!A.current;if(y.target===y.currentTarget&&k&&!c){const I=new CustomEvent(H,nt);if(y.currentTarget.dispatchEvent(I),!I.defaultPrevented){const E=S().filter(D=>D.focusable),Me=E.find(D=>D.active),De=E.find(D=>D.id===j),Pe=[Me,De,...E].filter(Boolean).map(D=>D.ref.current);Se(Pe,u)}}A.current=!1}),onBlur:L(t.onBlur,()=>f(!1))})})}),je="RovingFocusGroupItem",Ne=i.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:a,focusable:n=!0,active:r=!1,tabStopId:x,children:d,...l}=t,m=he(),o=x||m,u=it(je,a),h=u.currentTabStopId===o,b=ge(a),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:j}=u;return i.useEffect(()=>{if(n)return g(),()=>v()},[n,g,v]),e.jsx(q.ItemSlot,{scope:a,id:o,focusable:n,active:r,children:e.jsx(P.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...l,ref:s,onMouseDown:L(t.onMouseDown,p=>{n?u.onItemFocus(o):p.preventDefault()}),onFocus:L(t.onFocus,()=>u.onItemFocus(o)),onKeyDown:L(t.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){u.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const c=xt(p,u.orientation,u.dir);if(c!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let N=b().filter(S=>S.focusable).map(S=>S.ref.current);if(c==="last")N.reverse();else if(c==="prev"||c==="next"){c==="prev"&&N.reverse();const S=N.indexOf(p.currentTarget);N=u.loop?mt(N,S+1):N.slice(S+1)}setTimeout(()=>Se(N))}}),children:typeof d=="function"?d({isCurrentTabStop:h,hasTabStop:j!=null}):d})})});Ne.displayName=je;var dt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ut(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function xt(t,s,a){const n=ut(t.key,a);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return dt[n]}function Se(t,s=!1){const a=document.activeElement;for(const n of t)if(n===a||(n.focus({preventScroll:s}),document.activeElement!==a))return}function mt(t,s){return t.map((a,n)=>t[(s+n)%t.length])}var ht=ve,pt=Ne,B="Tabs",[bt]=z(B,[ye]),ke=ye(),[ft,Q]=bt(B),Te=i.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,onValueChange:r,defaultValue:x,orientation:d="horizontal",dir:l,activationMode:m="automatic",...o}=t,u=fe(l),[h,b]=pe({prop:n,onChange:r,defaultProp:x??"",caller:B});return e.jsx(ft,{scope:a,baseId:he(),value:h,onValueChange:b,orientation:d,dir:u,activationMode:m,children:e.jsx(P.div,{dir:u,"data-orientation":d,...o,ref:s})})});Te.displayName=B;var we="TabsList",Ce=i.forwardRef((t,s)=>{const{__scopeTabs:a,loop:n=!0,...r}=t,x=Q(we,a),d=ke(a);return e.jsx(ht,{asChild:!0,...d,orientation:x.orientation,dir:x.dir,loop:n,children:e.jsx(P.div,{role:"tablist","aria-orientation":x.orientation,...r,ref:s})})});Ce.displayName=we;var Ee="TabsTrigger",Ie=i.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,disabled:r=!1,...x}=t,d=Q(Ee,a),l=ke(a),m=_e(d.baseId,n),o=Le(d.baseId,n),u=n===d.value;return e.jsx(pt,{asChild:!0,...l,focusable:!r,active:u,children:e.jsx(P.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":o,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:m,...x,ref:s,onMouseDown:L(t.onMouseDown,h=>{!r&&h.button===0&&h.ctrlKey===!1?d.onValueChange(n):h.preventDefault()}),onKeyDown:L(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&d.onValueChange(n)}),onFocus:L(t.onFocus,()=>{const h=d.activationMode!=="manual";!u&&!r&&h&&d.onValueChange(n)})})})});Ie.displayName=Ee;var Ae="TabsContent",Re=i.forwardRef((t,s)=>{const{__scopeTabs:a,value:n,forceMount:r,children:x,...d}=t,l=Q(Ae,a),m=_e(l.baseId,n),o=Le(l.baseId,n),u=n===l.value,h=i.useRef(u);return i.useEffect(()=>{const b=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(b)},[]),e.jsx(Oe,{present:r||u,children:({present:b})=>e.jsx(P.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":m,hidden:!b,id:o,tabIndex:0,...d,ref:s,style:{...t.style,animationDuration:h.current?"0s":void 0},children:b&&x})})});Re.displayName=Ae;function _e(t,s){return`${t}-trigger-${s}`}function Le(t,s){return`${t}-content-${s}`}var gt=Te,yt=Ce,vt=Ie,$=Re;const jt=["default","hover","focus","focus-visible","active","disabled"],Nt=["light","dark","forced-colors-active","forced-colors-none"],St=["ltr","rtl"];function kt({value:t,onChange:s}){function a(r,x){return r.includes(x)?r.filter(d=>d!==x):[...r,x]}function n(){const r=t.ariaVariations.length===0?1:t.ariaVariations.length;return t.pseudoStates.length*r*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:jt,selected:t.pseudoStates,onToggle:r=>s({...t,pseudoStates:a(t.pseudoStates,r)})}),e.jsx(G,{label:"Themes",all:Nt,selected:t.themes,onToggle:r=>s({...t,themes:a(t.themes,r)})}),e.jsx(G,{label:"Directions",all:St,selected:t.directions,onToggle:r=>s({...t,directions:a(t.directions,r)})}),e.jsx(G,{label:"Breakpoints",all:t.breakpointPresets.map(r=>r.id),selected:t.breakpoints,onToggle:r=>s({...t,breakpoints:a(t.breakpoints,r)})}),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(r=>{const x=a.includes(r);return e.jsx("button",{type:"button",onClick:()=>n(r),className:x?"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:r},r)})})]})}function Tt({value:t,onChange:s}){const[a,n]=i.useState(""),[r,x]=i.useState("");function d(o){o.preventDefault();const u=a.trim(),h=r.trim();!u||!h||(s({...t,[u]:h}),n(""),x(""))}function l(o){const u={...t};delete u[o],s(u)}const m=Object.entries(t);return e.jsxs("div",{className:"space-y-3 border border-slate-200 rounded p-3 bg-white",children:[m.length===0?e.jsx("p",{className:"text-xs text-slate-500 italic",children:"no aliases"}):e.jsx("ul",{className:"space-y-1",children:m.map(([o,u])=>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:`${o} → ${u}`,children:[o," ",e.jsx("span",{className:"text-slate-500",children:"→"})," ",u]}),e.jsx("button",{onClick:()=>l(o),className:"text-slate-500 hover:text-red-600 shrink-0","aria-label":`Remove alias ${o}`,children:"×"})]},o))}),e.jsxs("form",{onSubmit:d,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:o=>n(o.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:r,onChange:o=>x(o.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()||!r.trim(),children:"Add"})]})]})}const se=be("billing-portal-client"),wt="https://api.wcagcheckr.com",Ct="wcagcheckr",Et=15e3;async function It(t){const s=`${wt}/v1/products/${Ct}/billing-portal`;try{const a=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({licenseToken:t.licenseToken}),signal:AbortSignal.timeout(Et)}),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}:(se.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 se.warn("billing portal request failed",a),{ok:!1,error:a instanceof Error?a.message:String(a)}}}const ae=be("subscription-resume-client"),At="https://api.wcagcheckr.com",Rt="wcagcheckr",_t=1e4;async function Lt(t){try{const s=await fetch(`${At}/v1/products/${Rt}/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}:(ae.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 ae.warn("resume request failed",s),{ok:!1,error:s instanceof Error?s.message:String(s)}}}const Ft={trial:"Trial",free:"Free",solo:"Solo",team:"Team"},Mt={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)"},Dt=new Set(["solo-single-month"]);function Pt(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 U(t){return t?Mt[t]??t:"—"}function J(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 Ut({tier:t,onTierChange:s}){const[a,n]=i.useState(null),[r,x]=i.useState(null),[d,l]=i.useState(!1),[m,o]=i.useState(""),[u,h]=i.useState(!1),[b,g]=i.useState(null),[v,j]=i.useState(!1),[p,c]=i.useState(!1),f=i.useCallback(async y=>{const I=(await chrome.storage.local.get("licenseToken")).licenseToken??null;if(n(I),!I){x(null);return}try{const E=await w({type:"LICENSE_VALIDATE_REQUEST",token:I,forceRefresh:(y==null?void 0:y.forceRefresh)===!0});x(E)}catch{x(null)}},[]);i.useEffect(()=>(f({forceRefresh:!0}),Ke("LICENSE_CHANGED_EVENT",()=>{f()})),[f]);async function N(){if(m.trim()){h(!0),g(null);try{const y=await w({type:"LICENSE_SET_REQUEST",token:m.trim()}),k=await w({type:"LICENSE_VALIDATE_REQUEST",token:m.trim()});if(k.valid&&k.plan){const I=Gt(k.plan);s(I);let E=`Activated as ${U(k.plan)}.`;y.seatClaim.ok?y.seatClaim.overCapacity&&(E=`Activated as ${U(k.plan)}. Note: this license is currently OVER its seat cap (${y.seatClaim.seatsUsed} of ${y.seatClaim.seatsTotal} seats). Release one or upgrade.`):y.seatClaim.reason==="cap-reached"?E=`Activated as ${U(k.plan)}, BUT this license is at its seat capacity (${y.seatClaim.seatsUsed} of ${y.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.`:y.seatClaim.reason==="network"&&(E=`Activated as ${U(k.plan)}. (Seat-tracking ping failed — retrying in the background.)`),g(E),y.seatClaim.ok&&!y.seatClaim.overCapacity?R.polite(E):R.assertive(E),o(""),l(!1),await f()}else{const I="Token did not validate. Check the value and try again.";g(I),R.assertive(I)}}catch(y){const k=y instanceof Error?y.message:String(y);g(k),R.assertive(k)}finally{h(!1)}}}async function S(){if(a)try{await navigator.clipboard.writeText(a),j(!0),setTimeout(()=>j(!1),2e3)}catch{}}async function A(){if(window.confirm(`Remove the active license token from this extension?
|
|
2
2
|
|
|
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 He(a),await chrome.storage.local.remove("licenseToken"),n(null),x(null);try{const k=await w({type:"TIER_GET"});s(k.tier)}catch{s("free")}R.polite("License token removed.")}}const T=Je[t],F=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:Ft[t]})]}),e.jsxs("ul",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("li",{children:["Components:"," ",Number.isFinite(T.maxComponents)?T.maxComponents:"unlimited"]}),e.jsxs("li",{children:["Baselines:"," ",Number.isFinite(T.maxBaselines)?T.maxBaselines:"unlimited"]}),e.jsxs("li",{children:["State matrix: ",T.stateMatrix]}),e.jsxs("li",{children:["Storybook auto-iterate: ",T.storybookAutoIterate?"yes":"no"]}),e.jsxs("li",{children:["JSON export: ",T.exportJson?"yes":"no"]}),e.jsxs("li",{children:["SARIF / JUnit export: ",T.exportSarif?"yes":"no"]})]}),F&&o?e.jsx(Ot,{token:a,info:o,copied:v,onCopy:S,onRemove:A,onUseDifferent:()=>r(!0),onManageSubscription:async()=>{const y=await It({licenseToken:a});y.ok?window.open(y.url,"_blank","noopener,noreferrer"):(g(`Couldn't open billing portal: ${y.error}`),R.assertive("Could not open billing portal."))},onResumeSubscription:async()=>{const y=await Lt({licenseToken:a});if(y.ok){const k=y.alreadyActive?"Subscription was already active — no change needed.":"Subscription resumed. Cancellation has been reversed.";g(k),R.polite(k),await f({forceRefresh:!0})}else g(`Couldn't resume subscription: ${y.error}`),R.assertive("Could not resume subscription.")},onRenew:()=>c(!0),message:b}):a?e.jsx($t,{token:a,onRemove:A,onUseDifferent:()=>r(!0)}):e.jsx(ne,{token:m,onTokenChange:l,submitting:u,message:b,onSubmit:N}),F&&d&&e.jsx(ne,{token:m,onTokenChange:l,submitting:u,message:b,onSubmit:N,replacing:!0,onCancel:()=>{r(!1),l(""),g(null)}}),!F&&(t==="trial"||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"}),": $",_.solo.monthlyUsd,"/mo (recurring) ·"," ","$",_.solo.yearlyUsd,"/yr (save ",Math.round(100-_.solo.yearlyUsd/(_.solo.monthlyUsd*12)*100),"%) ·"," ","$",_.solo.singleMonthUsd," single month (no recurring) · single user."]}),e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Team"}),": $",_.team.fiveSeatMonthlyUsd,"/mo for 5 seats ·"," ","$",_.team.fifteenSeatMonthlyUsd,"/mo for 15 seats."]}),e.jsx("button",{type:"button",onClick:()=>c(!0),className:"inline-block text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Upgrade →"})]}),e.jsx($e,{open:p,onClose:()=>c(!1)})]})}function Ot({token:t,info:s,copied:a,onCopy:n,onRemove:o,onUseDifferent:x,onManageSubscription:d,onResumeSubscription:r,onRenew:m,message:l}){const u=s.features,h=typeof(u==null?void 0:u.seatsUsed)=="number"?u.seatsUsed:null,b=typeof(u==null?void 0:u.seatsTotal)=="number"?u.seatsTotal:null,g=b!==null,v=h!==null&&b!==null&&h>b,j=h!==null&&b!==null&&h===b,p=s.plan?Mt.has(s.plan):!1,c=Pt(s.expiresAt),f=p&&c!==null&&c<=7;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:d,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:H(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 →"})]}),v&&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."]}),j&&!v&&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:U(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:[H(s.expiresAt),c!==null&&c>=0&&c<=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:c===0?"today":c===1?"1 day left":`${c} days left`}):null]}),s.trialEndsAt?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Trial ends"}),e.jsx("dd",{children:H(s.trialEndsAt)})]}):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:m,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 — $${_.solo.singleMonthUsd} →`:`Buy another month — $${_.solo.singleMonthUsd} →`}):e.jsx("button",{type:"button",onClick:d,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:x,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"})]}),l&&e.jsx("p",{className:"text-xs text-slate-600 pt-1",children:l})]})}function $t({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 ne({token:t,onTokenChange:s,submitting:a,message:n,onSubmit:o,replacing:x,onCancel:d}){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:x?"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…":x?"Replace":"Activate"}),x&&d&&e.jsx("button",{type:"button",onClick:d,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 Gt(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 Bt=new Set(Ye.map(t=>t.id));function Kt({presets:t,onChange:s}){const[a,n]=i.useState({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1});function o(r){r.preventDefault();const m=a.id.trim();!m||t.some(l=>l.id===m)||(s([...t,{...a,id:m,label:a.label.trim()||`${m} (${a.width}×${a.height})`}]),n({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1}))}function x(r){s(t.filter(m=>m.id!==r))}function d(r,m){s(t.map(l=>l.id===r?{...l,...m}:l))}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 m=Bt.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,m&&e.jsx("span",{className:"text-slate-500 font-normal ml-1",children:"(default)"})]}),e.jsx("input",{type:"number",value:r.width,onChange:l=>d(r.id,{width:Number(l.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:l=>d(r.id,{height:Number(l.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:l=>d(r.id,{mobile:l.target.checked})}),"mobile"]}),m?e.jsx("span",{className:"w-4","aria-hidden":"true"}):e.jsx("button",{onClick:()=>x(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 Vt({stateMatrix:t,componentIdAliases:s,onImport:a}){const n=i.useRef(null),[o,x]=i.useState(null);function d(){const m={schemaVersion:1,exportedAt:new Date().toISOString(),stateMatrix:t,componentIdAliases:s},l=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),u=URL.createObjectURL(l),h=document.createElement("a");h.href=u,h.download=`wcag-auditor-settings-${new Date().toISOString().slice(0,10)}.json`,h.click(),URL.revokeObjectURL(u),x("Exported.")}async function r(m){var l,u;x(null);try{const h=await m.text(),b=JSON.parse(h);if(b.schemaVersion!==1)throw new Error(`Unsupported schemaVersion: ${b.schemaVersion}`);if(!((l=b.stateMatrix)!=null&&l.pseudoStates)||!((u=b.stateMatrix)!=null&&u.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??{}}),x("Imported.")}catch(h){x(`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:d,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Export settings"}),e.jsx("button",{onClick:()=>{var m;return(m=n.current)==null?void 0:m.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:m=>{var u;const l=(u=m.target.files)==null?void 0:u[0];l&&r(l),m.target.value=""}})]}),o&&e.jsx("p",{className:"text-xs text-slate-600",children:o})]})}function Jt(){const[t,s]=i.useState(null);i.useEffect(()=>{chrome.storage.local.get(Z).then(n=>s(n[Z]===!0))},[]);async function a(){const n=!t;s(n),await Ve(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 Ht(){const[t,s]=i.useState(null);i.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)."})]})]})})}function Yt(){const[t,s]=i.useState(null),[a,n]=i.useState(!1);async function o(){const d=await chrome.storage.local.get(null),r=Object.keys(d).filter(m=>m.startsWith("auditCache:"));s(r.length)}i.useEffect(()=>{o()},[]);async function x(){n(!0);try{await Qe(),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:x,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 re="licenseToken";function le(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 Wt(t){return t.slice(0,8)+"…"}function qt(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 zt(){const[t,s]=i.useState(null),[a,n]=i.useState(null),[o,x]=i.useState(null),[d,r]=i.useState(0),[m,l]=i.useState(null),[u,h]=i.useState(!1),[b,g]=i.useState(null),v=i.useCallback(async()=>{h(!0),g(null);try{const c=(await chrome.storage.local.get(re))[re]??null;if(s(c),!c){n(null);return}const f=await We(c);if(!f){g("Could not load seats — check network or license validity.");return}n(f.seats),x(f.seatsTotal),r(f.seatsUsed),l(await qe())}finally{h(!1)}},[]);i.useEffect(()=>{v()},[v]);async function j(p){if(!t)return;const f=p===m?"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 v()}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:[d," of ",o," used",d>o&&e.jsx("span",{className:"ml-2 text-amber-700",children:"(over capacity — release to bring under limit)"})]})]}),e.jsx("button",{onClick:v,disabled:u,className:"text-xs px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:u?"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:Wt(p.deviceId)}),p.deviceId===m&&e.jsx("span",{className:"ml-1 text-[10px] text-brand-700",children:"(this device)"})]}),e.jsx("td",{className:"py-1 text-slate-700",children:qt(p.userAgent)}),e.jsx("td",{className:"py-1 text-slate-500",children:le(p.claimedAt)}),e.jsx("td",{className:"py-1 text-slate-500",children:le(p.lastSeenAt)}),e.jsx("td",{className:"py-1 text-right",children:e.jsx("button",{onClick:()=>j(p.deviceId),disabled:u,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 Qt=[{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 Xt(){const[t,s]=i.useState(""),[a,n]=i.useState([]),[o,x]=i.useState(!1),[d,r]=i.useState(null);i.useEffect(()=>{et().then(u=>{s(u.length>0?JSON.stringify(u,null,2):""),x(!0)})},[]);function m(){if(t.trim().length===0){te([]),n([]),r(Date.now());return}let u;try{u=JSON.parse(t)}catch(g){n([`Invalid JSON: ${g instanceof Error?g.message:String(g)}`]);return}const{valid:h,errors:b}=tt(u);if(b.length>0){n(b);return}n([]),te(h),r(Date.now()),s(JSON.stringify(h,null,2))}function l(){s(JSON.stringify(Qt,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:u=>s(u.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:m,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Save"}),e.jsx("button",{onClick:l,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50",children:"Load example rules"}),d&&a.length===0&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(d).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((u,h)=>e.jsx("div",{children:u},h))})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const oe="disabledRules";function Zt(){const[t,s]=i.useState(""),[a,n]=i.useState(!1),[o,x]=i.useState(null);i.useEffect(()=>{w({type:"SETTINGS_GET",key:oe}).then(r=>{const m=Array.isArray(r.data)?r.data:[];s(m.join(`
|
|
4
|
-
`)),n(!0)})},[]);function d(
|
|
5
|
-
`).map(
|
|
6
|
-
landmark-one-main`,className:"w-full text-xs font-mono border border-slate-300 rounded p-2 resize-y"}),o&&e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(o).toLocaleTimeString(),"."]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Full rule list:"," ",e.jsx("a",{href:"https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md",target:"_blank",rel:"noreferrer",className:"text-brand-600 hover:underline",children:"axe-core/doc/rule-descriptions.md"})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ie="githubRepoUrl",es=/^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/;function ts(){const[t,s]=i.useState(""),[a,n]=i.useState(!1),[o,x]=i.useState(null);i.useEffect(()=>{w({type:"SETTINGS_GET",key:ie}).then(r=>{const m=typeof r.data=="string"?r.data:"";s(m),n(!0)})},[]);function d(r){const m=r.trim().replace(/\/$/,"");if(m.length>0&&!es.test(m+"/")){x("Expected format: https://github.com/owner/repo");return}x(null),C({type:"SETTINGS_SET",key:ie,value:m})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your repository URL to enable "File GitHub issue" buttons in the Delta view. Issues are opened in a new tab with title and body pre-filled — you confirm and submit on GitHub.'}),e.jsx("input",{type:"url",value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),placeholder:"https://github.com/owner/repo",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),o&&e.jsx("p",{className:"text-[11px] text-rose-600",children:o})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ce="jiraInstanceUrl",ss=/^https:\/\/[^/]+\.atlassian\.net\/?$/;function as(){const[t,s]=i.useState(""),[a,n]=i.useState(!1),[o,x]=i.useState(null);i.useEffect(()=>{w({type:"SETTINGS_GET",key:ce}).then(r=>{const m=typeof r.data=="string"?r.data:"";s(m),n(!0)})},[]);function d(r){const m=r.trim().replace(/\/$/,"");if(m.length>0&&!ss.test(m+"/")){x("Expected format: https://your-team.atlassian.net");return}x(null),C({type:"SETTINGS_SET",key:ce,value:m})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your Jira Cloud instance URL to enable "File Jira issue" in the Delta view. Issues open in a new tab pre-filled — you confirm and submit on Jira.'}),e.jsx("input",{type:"url",value:t,onChange:r=>s(r.target.value),onBlur:r=>d(r.target.value),placeholder:"https://your-team.atlassian.net",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),o&&e.jsx("p",{className:"text-[11px] text-rose-600",children:o})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const de="cloudSyncEnabled",ue="cloudSyncEndpoint",ns="https://api.wcagcheckr.com";function rs(){const[t,s]=i.useState(!1),[a,n]=i.useState(ns),[o,x]=i.useState(!1),[d,r]=i.useState(!1),[m,l]=i.useState(null);i.useEffect(()=>{Promise.all([w({type:"SETTINGS_GET",key:de}),w({type:"SETTINGS_GET",key:ue})]).then(([g,v])=>{s(g.data===!0),typeof v.data=="string"&&v.data&&n(v.data),x(!0)})},[]);function u(g){s(g),C({type:"SETTINGS_SET",key:de,value:g})}function h(g){const v=g.trim().replace(/\/$/,"");n(v),C({type:"SETTINGS_SET",key:ue,value:v})}async function b(){r(!0),l(null);try{const g="To pull baselines now, reload the extension at chrome://extensions. The service worker pulls on every start.";l(g),R.polite(g)}finally{r(!1)}}return o?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Sync baselines across devices via your license. Disabled by default — local-first storage means the extension works fully offline. Cloud is mirror, not source of truth on the local machine."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:g=>u(g.target.checked)}),e.jsx("span",{children:"Enable cloud sync"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-500 block mb-1",children:"Sync endpoint"}),e.jsx("input",{type:"url",value:a,onChange:g=>n(g.target.value),onBlur:g=>h(g.target.value),disabled:!t,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50 disabled:text-slate-500"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Default points at the WCAG Auditor cloud-sync VPS. Replace with your own server URL if you self-host the baseline endpoints."})]}),e.jsx("button",{type:"button",onClick:b,disabled:!t||d,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:d?"Pulling…":"Pull now"}),m&&e.jsx("p",{className:"text-[11px] text-slate-500",children:m})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const xe="runsPerState";function ls(){const[t,s]=i.useState(1),[a,n]=i.useState(!1);i.useEffect(()=>{w({type:"SETTINGS_GET",key:xe}).then(x=>{const d=typeof x.data=="number"?x.data:1;s(d),n(!0)})},[]);function o(x){s(x),C({type:"SETTINGS_SET",key:xe,value:x})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Real-world pages are non-deterministic — animations, third-party scripts, lazy-loaded content can produce different violation counts on identical re-runs. Higher run counts let the auditor classify violations as ",e.jsx("strong",{children:"stable"})," (seen in every run) vs"," ",e.jsx("strong",{children:"flaky"})," (only some runs). Tradeoff: each step costs an extra audit pass."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{htmlFor:"reliability-runs-per-state",className:"text-xs text-slate-700",children:"Audit runs per state:"}),e.jsxs("select",{id:"reliability-runs-per-state",value:t,onChange:x=>o(Number(x.target.value)),className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:1,children:"1 (fastest)"}),e.jsx("option",{value:2,children:"2 (balanced)"}),e.jsx("option",{value:3,children:"3 (most reliable)"})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function os(){const[t,s]=i.useState("owner"),[a,n]=i.useState(!1);i.useEffect(()=>{w({type:"SETTINGS_GET",key:"userMode"}).then(x=>{const d=x.data;(d==="owner"||d==="dev")&&s(d),n(!0)})},[]);function o(x){s(x),C({type:"SETTINGS_SET",key:"userMode",value:x})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Switches the side panel between two surfaces. Owner mode is simpler and avoids jargon; developer mode shows the full feature set (visualizers, baselines, exports, AI fixit prompt)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(me,{active:t==="owner",icon:"🏪",label:"Site owner",desc:"Plain-language results, whole-site scan, send-to-developer report.",onClick:()=>o("owner")}),e.jsx(me,{active:t==="dev",icon:"⚙️",label:"Developer / agency",desc:"Full feature surface — visualizers, exports, baselines, IGT, AI fixit prompt.",onClick:()=>o("dev")})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function me({active:t,icon:s,label:a,desc:n,onClick:o}){return e.jsx("button",{type:"button",onClick:o,className:`text-left rounded p-3 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-2 ring-brand-500/30":"border-slate-300 bg-white hover:border-slate-400 hover:bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-xs",children:a}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:n})]})]})})}const Y="aiConfig";function is(){const[t,s]=i.useState(V),[a,n]=i.useState(!1),[o,x]=i.useState(!1),[d,r]=i.useState(null),[m,l]=i.useState(null),[u,h]=i.useState(!1);async function b(){r(await Xe(10))}i.useEffect(()=>{b()},[]);async function g(){h(!0),l(null);try{if(!t.apiKey){l({ok:!1,message:"No API key entered yet."});return}const c=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"x-api-key":t.apiKey,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:t.model||"claude-haiku-4-5",max_tokens:5,messages:[{role:"user",content:"ok"}]})}),f=await c.json().catch(()=>null);if(!f){l({ok:!1,message:`Provider returned no JSON (HTTP ${c.status}).`});return}if("error"in f){l({ok:!1,message:`${f.error.type}: ${f.error.message}`});return}l({ok:!0,message:`Authenticated, account funded. Test call used ${f.usage.input_tokens}+${f.usage.output_tokens} tokens (~$0.0001).`})}catch(c){l({ok:!1,message:c instanceof Error?c.message:String(c)})}finally{h(!1)}}async function v(){typeof confirm=="function"&&!confirm("Clear the local AI usage log? Provider-side billing records are unaffected.")||(await Ze(),await b())}i.useEffect(()=>{w({type:"SETTINGS_GET",key:Y}).then(c=>{const f=c.data;f&&s({...V,...f,enabledChecks:{...V.enabledChecks,...f.enabledChecks??{}}}),n(!0)})},[]);function j(c){const f={...t,...c};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}function p(c){const f={...t,enabledChecks:{...t.enabledChecks,...c}};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"Adds vision-verified alt-text checking, heading-quality judgment, sensory-language detection, and ARIA semantic verification to every audit. Each check uses a small AI call against your configured provider; per-audit cost is hard-capped to prevent surprise bills."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>j({enabled:c.target.checked})}),e.jsx("span",{children:e.jsx("strong",{children:"Enable AI augmentation"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-provider",className:"block text-xs text-slate-500 mb-1",children:"Provider"}),e.jsxs("select",{id:"ai-provider",value:t.provider,onChange:c=>j({provider:c.target.value}),disabled:!t.enabled,className:"text-xs border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"openai",children:"OpenAI (GPT) — coming soon"}),e.jsx("option",{value:"gemini",children:"Google (Gemini) — coming soon"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"ai-key",className:"block text-xs text-slate-500 mb-1",children:["API key",e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"stored locally; never sent anywhere except your chosen provider"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"ai-key",type:o?"text":"password",value:t.apiKey,onChange:c=>j({apiKey:c.target.value.trim()}),disabled:!t.enabled,placeholder:"sk-ant-…",className:"flex-1 text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("button",{type:"button",onClick:()=>x(!o),className:"text-[11px] px-2 border border-slate-300 rounded hover:bg-slate-50",children:o?"Hide":"Show"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-model",className:"block text-xs text-slate-500 mb-1",children:"Model override (optional)"}),e.jsx("input",{id:"ai-model",type:"text",value:t.model??"",onChange:c=>j({model:c.target.value.trim()}),disabled:!t.enabled,placeholder:"claude-3-5-sonnet-20241022 (default)",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Leave blank for provider default. Use a haiku-class model for cheap-fast checks."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-cap",className:"block text-xs text-slate-500 mb-1",children:"Per-audit cost cap (USD)"}),e.jsx("input",{id:"ai-cap",type:"number",step:.5,min:0,value:t.costCapUsd,onChange:c=>j({costCapUsd:Math.max(0,parseFloat(c.target.value)||0)}),disabled:!t.enabled,className:"w-32 text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Hard ceiling — once exceeded, remaining AI checks for the audit are skipped."})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Checks to run"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.altText,onChange:c=>p({altText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Alt text"})," — verify every image's alt accurately describes it (vision call, ~$0.005 each)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.headings,onChange:c=>p({headings:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Headings"})," — judge whether headings describe their sections (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.sensory,onChange:c=>p({sensory:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Sensory language"}),' — flag instructions like "click the round button" (text-only, cheap)']})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.aria,onChange:c=>p({aria:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"ARIA semantics"})," — verify role= attributes match element behavior (more expensive; opt-in)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.imageOfText,onChange:c=>p({imageOfText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Images of text"})," (WCAG 1.4.5) — flag banner / share-card / infographic images that bake text into the raster (vision; capped to ",t.imageOfTextMaxImages," largest images / audit)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.colorOnlyMeaning,onChange:c=>p({colorOnlyMeaning:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Color-only meaning"})," (WCAG 1.4.1) — flag status indicators / icons / instructions where only color conveys meaning (vision call)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.genericLinkText,onChange:c=>p({genericLinkText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Generic link text"}),` (WCAG 2.4.4) — flag "click here"-style links where surrounding context doesn't clarify the destination (text-only, cheap)`]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.wallOfText,onChange:c=>p({wallOfText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Wall of text"})," (WCAG 3.1.5) — flag long-form content with no subheadings, lists, or paragraph breaks (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.languageMismatch,onChange:c=>p({languageMismatch:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Language mismatch"})," (WCAG 3.1.1 / 3.1.2) — flag content that doesn't match the declared ",e.jsx("code",{children:"lang"})," attribute (text-only, cheap)"]})]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Connection test"}),e.jsx("p",{className:"text-[11px] text-slate-500 mb-2",children:"Fires a 5-token call to your provider to confirm the key authenticates and the account is funded. Costs ≈ $0.0001."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void g(),disabled:!t.apiKey||u,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:u?"Testing…":"Test connection"}),m&&e.jsxs("span",{className:`text-[11px] ${m.ok?"text-emerald-700":"text-rose-700"}`,children:[m.ok?"✓ ":"✗ ",m.message]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Local usage"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Tracked locally per audit. Providers don't expose live balance via API, so check"," ",e.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-brand-700 underline",children:"console.anthropic.com → Plans & Billing"})," ","for your real balance."]}),d&&d.totalAudits===0&&e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"No AI-augmented audits recorded yet."}),d&&d.totalAudits>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"All-time spent"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.totalSpentUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.totalAudits," audit",d.totalAudits===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"This month"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.spentThisMonthUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.auditsThisMonth," audit",d.auditsThisMonth===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"Avg / audit"}),e.jsx("div",{className:"font-semibold text-slate-800",children:d.averageCostUsd!=null?`$${d.averageCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"By check type"}),e.jsx("ul",{className:"mt-1 text-[11px] text-slate-700",children:Object.entries(d.byCheck).map(([c,f])=>e.jsxs("li",{className:"flex items-center justify-between py-0.5",children:[e.jsx("code",{className:"font-mono",children:c}),e.jsxs("span",{children:["$",(f??0).toFixed(4)]})]},c))})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"Recent audits (last 10)"}),e.jsxs("table",{className:"mt-1 w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-left",children:[e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"When"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"Target"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium text-right",children:"Cost"}),e.jsx("th",{className:"py-0.5 font-medium text-right",children:"Findings"})]})}),e.jsx("tbody",{children:d.recent.map((c,f)=>e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsx("td",{className:"py-0.5 pr-2 text-slate-600",children:new Date(c.at).toLocaleDateString()}),e.jsx("td",{className:"py-0.5 pr-2 text-slate-700 truncate max-w-[180px]",title:c.pageUrl,children:c.pageUrl}),e.jsxs("td",{className:"py-0.5 pr-2 text-right font-mono",children:["$",c.totalCostUsd.toFixed(4),c.capExceeded&&e.jsx("span",{className:"text-amber-700 ml-1",title:"Cost cap exceeded",children:"⚠"}),c.failureReason&&e.jsx("span",{className:"text-red-700 ml-1",title:`AI failure: ${c.failureReason}`,children:"✗"})]}),e.jsx("td",{className:"py-0.5 text-right",children:c.findingsCount})]},f))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>void v(),className:"text-[11px] text-slate-500 hover:text-rose-600 underline-offset-2 hover:underline",children:"Clear local usage log"})})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function cs(){const[t,s]=i.useState(null),[a,n]=i.useState("trial");i.useEffect(()=>{w({type:"SETTINGS_GET_ALL"}).then(l=>{const u=l.data??{};s({stateMatrix:u.stateMatrix??ee,componentIdAliases:u.componentIdAliases??{}})}),w({type:"TIER_GET"}).then(l=>n(l.tier))},[]);function o(l){t&&(s({...t,stateMatrix:l}),C({type:"SETTINGS_SET",key:"stateMatrix",value:l}))}function x(l){if(!t)return;const u=new Set(l.map(b=>b.id)),h=t.stateMatrix.breakpoints.filter(b=>u.has(b));o({...t.stateMatrix,breakpointPresets:l,breakpoints:h.length>0?h:l[0]?[l[0].id]:[]})}function d(l){t&&(s({...t,componentIdAliases:l}),C({type:"SETTINGS_SET",key:"componentIdAliases",value:l}))}function r(){t&&(typeof confirm=="function"&&!confirm("Reset state matrix to defaults?")||o(ee))}if(!t)return e.jsx("div",{className:"p-8 text-sm text-slate-500",children:"Loading…"});const m=a==="free";return e.jsxs("div",{className:"max-w-2xl mx-auto p-3 sm:p-6 space-y-6 text-sm",children:[e.jsxs("header",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Changes are saved automatically. Close this tab to return to the audit panel."})]}),e.jsx("button",{type:"button",onClick:()=>{window.close()},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 shrink-0",children:"Done"})]}),e.jsx("main",{"aria-label":"Settings",children:e.jsxs(gt,{defaultValue:"audit",className:"space-y-4",children:[e.jsx(yt,{className:"flex flex-wrap gap-1 border-b border-slate-200","aria-label":"Settings categories",children:[{value:"audit",label:"Audit"},{value:"integrations",label:"Integrations"},{value:"account",label:"Account"},{value:"advanced",label:"Advanced"}].map(l=>e.jsx(vt,{value:l.value,className:"text-xs px-3 py-1.5 text-slate-600 hover:text-slate-900 data-[state=active]:text-brand-700 data-[state=active]:border-b-2 data-[state=active]:border-brand-500 -mb-px",children:l.label},l.value))}),e.jsxs($,{value:"audit",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"State matrix"}),e.jsx("button",{onClick:r,className:"text-xs text-slate-500 hover:text-slate-900",children:"Reset to defaults"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Which states each audit covers. Larger matrix = more coverage but slower runs."}),m&&e.jsx("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"Free tier audits the default state only — your matrix selections below will be ignored until you upgrade."}),e.jsx(kt,{value:t.stateMatrix,onChange:o})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Breakpoint presets"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Customize widths/heights and add your own breakpoints. Toggle which ones audit under in the State matrix section above."}),e.jsx(Kt,{presets:t.stateMatrix.breakpointPresets,onChange:x})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Audit reliability"}),e.jsx(ls,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Disabled rules"}),e.jsx(Zt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Component identity aliases"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Map two component IDs to the same canonical ID — useful when the same component is identified differently across pages."}),e.jsx(Tt,{value:t.componentIdAliases,onChange:d})]})]}),e.jsxs($,{value:"integrations",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"GitHub issue tracker"}),e.jsx(ts,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Jira issue tracker"}),e.jsx(as,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Cloud sync (baselines)"}),e.jsx(rs,{})]})]}),e.jsxs($,{value:"account",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"User mode"}),e.jsx(os,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"License"}),e.jsx(Ut,{tier:a,onTierChange:n})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Crash reporting"}),e.jsx(Jt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI augmentation"}),e.jsx(is,{})]})]}),e.jsxs($,{value:"advanced",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Report download behavior"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Defense / evidence bundles default to a confirmation prompt before downloading. Power users who export many bundles can skip the prompt here."}),e.jsx(Ht,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Performance"}),e.jsx(Yt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Custom rules"}),e.jsx(Xt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Team"}),e.jsx("p",{className:"text-xs text-slate-500",children:"For Team plans: see every device that's claimed a seat under this license, and revoke any of them. The license token itself authenticates this section — anyone with the token can manage seats."}),e.jsx(zt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Import / export"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Share matrix + alias config with your team, or back up before major changes."}),e.jsx(Vt,{stateMatrix:t.stateMatrix,componentIdAliases:t.componentIdAliases,onImport:l=>s(l)})]})]})]})}),e.jsx(Ge,{})]})}const Fe=document.getElementById("root");if(!Fe)throw new Error("options: #root not found");Be(Fe).render(e.jsx(D.StrictMode,{children:e.jsx(cs,{})}));
|
|
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 Je(a),await chrome.storage.local.remove("licenseToken"),n(null),x(null);try{const k=await w({type:"TIER_GET"});s(k.tier)}catch{s("free")}R.polite("License token removed.")}}const T=He[t],F=a!==null&&(r==null?void 0:r.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:Ft[t]})]}),e.jsxs("ul",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("li",{children:["Components:"," ",Number.isFinite(T.maxComponents)?T.maxComponents:"unlimited"]}),e.jsxs("li",{children:["Baselines:"," ",Number.isFinite(T.maxBaselines)?T.maxBaselines:"unlimited"]}),e.jsxs("li",{children:["State matrix: ",T.stateMatrix]}),e.jsxs("li",{children:["Storybook auto-iterate: ",T.storybookAutoIterate?"yes":"no"]}),e.jsxs("li",{children:["JSON export: ",T.exportJson?"yes":"no"]}),e.jsxs("li",{children:["SARIF / JUnit export: ",T.exportSarif?"yes":"no"]})]}),F&&r?e.jsx(Ot,{token:a,info:r,copied:v,onCopy:S,onRemove:A,onUseDifferent:()=>l(!0),onManageSubscription:async()=>{const y=await It({licenseToken:a});y.ok?window.open(y.url,"_blank","noopener,noreferrer"):(g(`Couldn't open billing portal: ${y.error}`),R.assertive("Could not open billing portal."))},onResumeSubscription:async()=>{const y=await Lt({licenseToken:a});if(y.ok){const k=y.alreadyActive?"Subscription was already active — no change needed.":"Subscription resumed. Cancellation has been reversed.";g(k),R.polite(k),await f({forceRefresh:!0})}else g(`Couldn't resume subscription: ${y.error}`),R.assertive("Could not resume subscription.")},onRenew:()=>c(!0),message:b}):a?e.jsx($t,{token:a,onRemove:A,onUseDifferent:()=>l(!0)}):e.jsx(ne,{token:m,onTokenChange:o,submitting:u,message:b,onSubmit:N}),F&&d&&e.jsx(ne,{token:m,onTokenChange:o,submitting:u,message:b,onSubmit:N,replacing:!0,onCancel:()=>{l(!1),o(""),g(null)}}),!F&&(t==="trial"||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"}),": $",_.solo.monthlyUsd,"/mo (recurring) ·"," ","$",_.solo.yearlyUsd,"/yr (save ",Math.round(100-_.solo.yearlyUsd/(_.solo.monthlyUsd*12)*100),"%) ·"," ","$",_.solo.singleMonthUsd," single month (no recurring) · single user."]}),e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("strong",{children:"Team"}),": $",_.team.fiveSeatMonthlyUsd,"/mo for 5 seats ·"," ","$",_.team.fifteenSeatMonthlyUsd,"/mo for 15 seats."]}),e.jsx("button",{type:"button",onClick:()=>c(!0),className:"inline-block text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Upgrade →"})]}),e.jsx($e,{open:p,onClose:()=>c(!1)})]})}function Ot({token:t,info:s,copied:a,onCopy:n,onRemove:r,onUseDifferent:x,onManageSubscription:d,onResumeSubscription:l,onRenew:m,message:o}){const u=s.features,h=typeof(u==null?void 0:u.seatsUsed)=="number"?u.seatsUsed:null,b=typeof(u==null?void 0:u.seatsTotal)=="number"?u.seatsTotal:null,g=b!==null,v=h!==null&&b!==null&&h>b,j=h!==null&&b!==null&&h===b,p=s.plan?Dt.has(s.plan):!1,c=Pt(s.expiresAt),f=p&&c!==null&&c<=7;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:d,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:J(s.expiresAt)}),", then this license stops working."]}),e.jsx("button",{type:"button",onClick:l,className:"text-[11px] font-medium underline-offset-2 hover:underline",children:"Resume subscription →"})]}),v&&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."]}),j&&!v&&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:U(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:[J(s.expiresAt),c!==null&&c>=0&&c<=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:c===0?"today":c===1?"1 day left":`${c} days left`}):null]}),s.trialEndsAt?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-slate-500",children:"Trial ends"}),e.jsx("dd",{children:J(s.trialEndsAt)})]}):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:m,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 — $${_.solo.singleMonthUsd} →`:`Buy another month — $${_.solo.singleMonthUsd} →`}):e.jsx("button",{type:"button",onClick:d,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:x,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:r,className:"text-[11px] text-rose-700 hover:underline",children:"Remove license from this extension"})]}),o&&e.jsx("p",{className:"text-xs text-slate-600 pt-1",children:o})]})}function $t({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 ne({token:t,onTokenChange:s,submitting:a,message:n,onSubmit:r,replacing:x,onCancel:d}){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:x?"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:l=>s(l.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:r,disabled:a||!t.trim(),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:a?"Validating…":x?"Replace":"Activate"}),x&&d&&e.jsx("button",{type:"button",onClick:d,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 Gt(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 Bt=new Set(Ye.map(t=>t.id));function Kt({presets:t,onChange:s}){const[a,n]=i.useState({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1});function r(l){l.preventDefault();const m=a.id.trim();!m||t.some(o=>o.id===m)||(s([...t,{...a,id:m,label:a.label.trim()||`${m} (${a.width}×${a.height})`}]),n({id:"",label:"",width:1024,height:768,deviceScaleFactor:1,mobile:!1}))}function x(l){s(t.filter(m=>m.id!==l))}function d(l,m){s(t.map(o=>o.id===l?{...o,...m}:o))}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(l=>{const m=Bt.has(l.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:l.id,children:[l.label,m&&e.jsx("span",{className:"text-slate-500 font-normal ml-1",children:"(default)"})]}),e.jsx("input",{type:"number",value:l.width,onChange:o=>d(l.id,{width:Number(o.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Width for ${l.label}`,min:1}),e.jsx("input",{type:"number",value:l.height,onChange:o=>d(l.id,{height:Number(o.target.value)||0}),className:"text-xs border border-slate-300 rounded px-1.5 py-1 w-full","aria-label":`Height for ${l.label}`,min:1}),e.jsxs("label",{className:"flex items-center gap-1 text-slate-600",children:[e.jsx("input",{type:"checkbox",checked:l.mobile,onChange:o=>d(l.id,{mobile:o.target.checked})}),"mobile"]}),m?e.jsx("span",{className:"w-4","aria-hidden":"true"}):e.jsx("button",{onClick:()=>x(l.id),className:"text-slate-500 hover:text-red-600","aria-label":`Remove ${l.label}`,children:"×"})]},l.id)})}),e.jsxs("form",{onSubmit:r,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:l=>n({...a,id:l.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:l=>n({...a,label:l.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:l=>n({...a,width:Number(l.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:l=>n({...a,height:Number(l.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(l=>l.id===a.id.trim()),className:"text-xs px-3 py-1 bg-brand-500 text-white rounded disabled:opacity-50",children:"Add"})]})]})}function Vt({stateMatrix:t,componentIdAliases:s,onImport:a}){const n=i.useRef(null),[r,x]=i.useState(null);function d(){const m={schemaVersion:1,exportedAt:new Date().toISOString(),stateMatrix:t,componentIdAliases:s},o=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),u=URL.createObjectURL(o),h=document.createElement("a");h.href=u,h.download=`wcag-auditor-settings-${new Date().toISOString().slice(0,10)}.json`,h.click(),URL.revokeObjectURL(u),x("Exported.")}async function l(m){var o,u;x(null);try{const h=await m.text(),b=JSON.parse(h);if(b.schemaVersion!==1)throw new Error(`Unsupported schemaVersion: ${b.schemaVersion}`);if(!((o=b.stateMatrix)!=null&&o.pseudoStates)||!((u=b.stateMatrix)!=null&&u.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??{}}),x("Imported.")}catch(h){x(`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:d,className:"text-xs px-3 py-1 bg-slate-100 hover:bg-slate-200 rounded",children:"Export settings"}),e.jsx("button",{onClick:()=>{var m;return(m=n.current)==null?void 0:m.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:m=>{var u;const o=(u=m.target.files)==null?void 0:u[0];o&&l(o),m.target.value=""}})]}),r&&e.jsx("p",{className:"text-xs text-slate-600",children:r})]})}function Ht(){const[t,s]=i.useState(null);i.useEffect(()=>{chrome.storage.local.get(Z).then(n=>s(n[Z]===!0))},[]);async function a(){const n=!t;s(n),await Ve(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 Jt(){const[t,s]=i.useState(null);i.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)."})]})]})})}function Yt(){const[t,s]=i.useState(null),[a,n]=i.useState(!1);async function r(){const d=await chrome.storage.local.get(null),l=Object.keys(d).filter(m=>m.startsWith("auditCache:"));s(l.length)}i.useEffect(()=>{r()},[]);async function x(){n(!0);try{await Qe(),await r()}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:x,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 re="licenseToken";function le(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 r=Math.floor(n/24);return r<30?`${r}d ago`:new Date(t).toLocaleDateString()}function Wt(t){return t.slice(0,8)+"…"}function qt(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 zt(){const[t,s]=i.useState(null),[a,n]=i.useState(null),[r,x]=i.useState(null),[d,l]=i.useState(0),[m,o]=i.useState(null),[u,h]=i.useState(!1),[b,g]=i.useState(null),v=i.useCallback(async()=>{h(!0),g(null);try{const c=(await chrome.storage.local.get(re))[re]??null;if(s(c),!c){n(null);return}const f=await We(c);if(!f){g("Could not load seats — check network or license validity.");return}n(f.seats),x(f.seatsTotal),l(f.seatsUsed),o(await qe())}finally{h(!1)}},[]);i.useEffect(()=>{v()},[v]);async function j(p){if(!t)return;const f=p===m?"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 v()}finally{h(!1)}}}return t?r===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:[d," of ",r," used",d>r&&e.jsx("span",{className:"ml-2 text-amber-700",children:"(over capacity — release to bring under limit)"})]})]}),e.jsx("button",{onClick:v,disabled:u,className:"text-xs px-2 py-0.5 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:u?"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:Wt(p.deviceId)}),p.deviceId===m&&e.jsx("span",{className:"ml-1 text-[10px] text-brand-700",children:"(this device)"})]}),e.jsx("td",{className:"py-1 text-slate-700",children:qt(p.userAgent)}),e.jsx("td",{className:"py-1 text-slate-500",children:le(p.claimedAt)}),e.jsx("td",{className:"py-1 text-slate-500",children:le(p.lastSeenAt)}),e.jsx("td",{className:"py-1 text-right",children:e.jsx("button",{onClick:()=>j(p.deviceId),disabled:u,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 Qt=[{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 Xt(){const[t,s]=i.useState(""),[a,n]=i.useState([]),[r,x]=i.useState(!1),[d,l]=i.useState(null);i.useEffect(()=>{et().then(u=>{s(u.length>0?JSON.stringify(u,null,2):""),x(!0)})},[]);function m(){if(t.trim().length===0){te([]),n([]),l(Date.now());return}let u;try{u=JSON.parse(t)}catch(g){n([`Invalid JSON: ${g instanceof Error?g.message:String(g)}`]);return}const{valid:h,errors:b}=tt(u);if(b.length>0){n(b);return}n([]),te(h),l(Date.now()),s(JSON.stringify(h,null,2))}function o(){s(JSON.stringify(Qt,null,2)),n([])}return r?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:u=>s(u.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:m,className:"text-xs px-3 py-1 bg-brand-500 text-white rounded hover:bg-brand-600",children:"Save"}),e.jsx("button",{onClick:o,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50",children:"Load example rules"}),d&&a.length===0&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(d).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((u,h)=>e.jsx("div",{children:u},h))})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const Zt="com.wcagcheckr.native_host",es=5e3;async function ts(){return new Promise(t=>{let s=null;const a=Date.now(),n=setTimeout(()=>{try{s==null||s.disconnect()}catch{}t({reachable:!1,reason:"timeout after 5s"})},es);try{s=chrome.runtime.connectNative(Zt)}catch(r){clearTimeout(n),t({reachable:!1,reason:`connectNative failed: ${r instanceof Error?r.message:String(r)}`});return}s.onMessage.addListener(r=>{clearTimeout(n),(r==null?void 0:r.type)==="PONG"&&typeof r.version=="string"?t({reachable:!0,version:r.version,roundTripMs:Date.now()-a}):t({reachable:!1,reason:`unexpected response: ${JSON.stringify(r).slice(0,100)}`});try{s==null||s.disconnect()}catch{}}),s.onDisconnect.addListener(()=>{var x;clearTimeout(n);const r=(x=chrome.runtime.lastError)==null?void 0:x.message;t({reachable:!1,reason:r??"host disconnected before PONG (not installed?)"})});try{s.postMessage({type:"PING"})}catch(r){clearTimeout(n),t({reachable:!1,reason:`postMessage failed: ${r instanceof Error?r.message:String(r)}`})}})}function ss(){const[t,s]=i.useState(null),[a,n]=i.useState(!1);async function r(){n(!0);try{s(await ts())}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:"Native messaging host (optional)"}),e.jsxs("span",{className:"block text-slate-500 mt-0.5",children:["Alternative state-driver for environments where"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"chrome.debugger"})," is blocked by enterprise IT policy. Today's host responds to PING and reports its version; the full CDP attach replacement is on the roadmap. See ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"native-host/README.md"})," ","for installation instructions."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:r,disabled:a,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?"Testing…":"Test connection"}),t&&t.reachable&&e.jsxs("span",{className:"text-xs text-green-700",children:["Reachable — version ",t.version," (",t.roundTripMs,"ms)"]}),t&&!t.reachable&&e.jsxs("span",{className:"text-xs text-amber-700",children:["Not reachable: ",t.reason]})]})]})}const oe="disabledRules";function as(){const[t,s]=i.useState(""),[a,n]=i.useState(!1),[r,x]=i.useState(null);i.useEffect(()=>{w({type:"SETTINGS_GET",key:oe}).then(l=>{const m=Array.isArray(l.data)?l.data:[];s(m.join(`
|
|
4
|
+
`)),n(!0)})},[]);function d(l){const m=l.split(`
|
|
5
|
+
`).map(o=>o.trim()).filter(o=>o.length>0);C({type:"SETTINGS_SET",key:oe,value:m}),x(Date.now())}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Rule IDs to skip during audits. One per line. Use exact axe-core rule IDs (e.g.,"," ",e.jsx("code",{className:"bg-slate-100 text-slate-700 px-1 rounded",children:"color-contrast"}),","," ",e.jsx("code",{className:"bg-slate-100 text-slate-700 px-1 rounded",children:"region"}),","," ",e.jsx("code",{className:"bg-slate-100 text-slate-700 px-1 rounded",children:"landmark-one-main"}),")."]}),e.jsx("textarea",{value:t,onChange:l=>s(l.target.value),onBlur:l=>d(l.target.value),rows:6,spellCheck:!1,placeholder:`region
|
|
6
|
+
landmark-one-main`,className:"w-full text-xs font-mono border border-slate-300 rounded p-2 resize-y"}),r&&e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Saved at ",new Date(r).toLocaleTimeString(),"."]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["Full rule list:"," ",e.jsx("a",{href:"https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md",target:"_blank",rel:"noreferrer",className:"text-brand-600 hover:underline",children:"axe-core/doc/rule-descriptions.md"})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ie="githubRepoUrl",ns=/^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/;function rs(){const[t,s]=i.useState(""),[a,n]=i.useState(!1),[r,x]=i.useState(null);i.useEffect(()=>{w({type:"SETTINGS_GET",key:ie}).then(l=>{const m=typeof l.data=="string"?l.data:"";s(m),n(!0)})},[]);function d(l){const m=l.trim().replace(/\/$/,"");if(m.length>0&&!ns.test(m+"/")){x("Expected format: https://github.com/owner/repo");return}x(null),C({type:"SETTINGS_SET",key:ie,value:m})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your repository URL to enable "File GitHub issue" buttons in the Delta view. Issues are opened in a new tab with title and body pre-filled — you confirm and submit on GitHub.'}),e.jsx("input",{type:"url",value:t,onChange:l=>s(l.target.value),onBlur:l=>d(l.target.value),placeholder:"https://github.com/owner/repo",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),r&&e.jsx("p",{className:"text-[11px] text-rose-600",children:r})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const ce="jiraInstanceUrl",ls=/^https:\/\/[^/]+\.atlassian\.net\/?$/;function os(){const[t,s]=i.useState(""),[a,n]=i.useState(!1),[r,x]=i.useState(null);i.useEffect(()=>{w({type:"SETTINGS_GET",key:ce}).then(l=>{const m=typeof l.data=="string"?l.data:"";s(m),n(!0)})},[]);function d(l){const m=l.trim().replace(/\/$/,"");if(m.length>0&&!ls.test(m+"/")){x("Expected format: https://your-team.atlassian.net");return}x(null),C({type:"SETTINGS_SET",key:ce,value:m})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500",children:'Paste your Jira Cloud instance URL to enable "File Jira issue" in the Delta view. Issues open in a new tab pre-filled — you confirm and submit on Jira.'}),e.jsx("input",{type:"url",value:t,onChange:l=>s(l.target.value),onBlur:l=>d(l.target.value),placeholder:"https://your-team.atlassian.net",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),r&&e.jsx("p",{className:"text-[11px] text-rose-600",children:r})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const de="cloudSyncEnabled",ue="cloudSyncEndpoint",is="https://api.wcagcheckr.com";function cs(){const[t,s]=i.useState(!1),[a,n]=i.useState(is),[r,x]=i.useState(!1),[d,l]=i.useState(!1),[m,o]=i.useState(null);i.useEffect(()=>{Promise.all([w({type:"SETTINGS_GET",key:de}),w({type:"SETTINGS_GET",key:ue})]).then(([g,v])=>{s(g.data===!0),typeof v.data=="string"&&v.data&&n(v.data),x(!0)})},[]);function u(g){s(g),C({type:"SETTINGS_SET",key:de,value:g})}function h(g){const v=g.trim().replace(/\/$/,"");n(v),C({type:"SETTINGS_SET",key:ue,value:v})}async function b(){l(!0),o(null);try{const g="To pull baselines now, reload the extension at chrome://extensions. The service worker pulls on every start.";o(g),R.polite(g)}finally{l(!1)}}return r?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Sync baselines across devices via your license. Disabled by default — local-first storage means the extension works fully offline. Cloud is mirror, not source of truth on the local machine."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:g=>u(g.target.checked)}),e.jsx("span",{children:"Enable cloud sync"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-500 block mb-1",children:"Sync endpoint"}),e.jsx("input",{type:"url",value:a,onChange:g=>n(g.target.value),onBlur:g=>h(g.target.value),disabled:!t,className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5 disabled:bg-slate-50 disabled:text-slate-500"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Default points at the WCAG Auditor cloud-sync VPS. Replace with your own server URL if you self-host the baseline endpoints."})]}),e.jsx("button",{type:"button",onClick:b,disabled:!t||d,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:d?"Pulling…":"Pull now"}),m&&e.jsx("p",{className:"text-[11px] text-slate-500",children:m})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}const xe="runsPerState";function ds(){const[t,s]=i.useState(1),[a,n]=i.useState(!1);i.useEffect(()=>{w({type:"SETTINGS_GET",key:xe}).then(x=>{const d=typeof x.data=="number"?x.data:1;s(d),n(!0)})},[]);function r(x){s(x),C({type:"SETTINGS_SET",key:xe,value:x})}return a?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Real-world pages are non-deterministic — animations, third-party scripts, lazy-loaded content can produce different violation counts on identical re-runs. Higher run counts let the auditor classify violations as ",e.jsx("strong",{children:"stable"})," (seen in every run) vs"," ",e.jsx("strong",{children:"flaky"})," (only some runs). Tradeoff: each step costs an extra audit pass."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{htmlFor:"reliability-runs-per-state",className:"text-xs text-slate-700",children:"Audit runs per state:"}),e.jsxs("select",{id:"reliability-runs-per-state",value:t,onChange:x=>r(Number(x.target.value)),className:"text-xs border border-slate-300 rounded px-2 py-1",children:[e.jsx("option",{value:1,children:"1 (fastest)"}),e.jsx("option",{value:2,children:"2 (balanced)"}),e.jsx("option",{value:3,children:"3 (most reliable)"})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function us(){const[t,s]=i.useState("owner"),[a,n]=i.useState(!1);i.useEffect(()=>{w({type:"SETTINGS_GET",key:"userMode"}).then(x=>{const d=x.data;(d==="owner"||d==="dev")&&s(d),n(!0)})},[]);function r(x){s(x),C({type:"SETTINGS_SET",key:"userMode",value:x})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Switches the side panel between two surfaces. Owner mode is simpler and avoids jargon; developer mode shows the full feature set (visualizers, baselines, exports, AI fixit prompt)."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(me,{active:t==="owner",icon:"🏪",label:"Site owner",desc:"Plain-language results, whole-site scan, send-to-developer report.",onClick:()=>r("owner")}),e.jsx(me,{active:t==="dev",icon:"⚙️",label:"Developer / agency",desc:"Full feature surface — visualizers, exports, baselines, IGT, AI fixit prompt.",onClick:()=>r("dev")})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function me({active:t,icon:s,label:a,desc:n,onClick:r}){return e.jsx("button",{type:"button",onClick:r,className:`text-left rounded p-3 border transition-colors ${t?"border-brand-500 bg-brand-50 ring-2 ring-brand-500/30":"border-slate-300 bg-white hover:border-slate-400 hover:bg-slate-50"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-lg","aria-hidden":"true",children:s}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-xs",children:a}),e.jsx("div",{className:"text-[11px] text-slate-500 leading-snug mt-0.5",children:n})]})]})})}const Y="aiConfig";function xs(){const[t,s]=i.useState(V),[a,n]=i.useState(!1),[r,x]=i.useState(!1),[d,l]=i.useState(null),[m,o]=i.useState(null),[u,h]=i.useState(!1);async function b(){l(await Xe(10))}i.useEffect(()=>{b()},[]);async function g(){h(!0),o(null);try{if(!t.apiKey){o({ok:!1,message:"No API key entered yet."});return}const c=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"x-api-key":t.apiKey,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify({model:t.model||"claude-haiku-4-5",max_tokens:5,messages:[{role:"user",content:"ok"}]})}),f=await c.json().catch(()=>null);if(!f){o({ok:!1,message:`Provider returned no JSON (HTTP ${c.status}).`});return}if("error"in f){o({ok:!1,message:`${f.error.type}: ${f.error.message}`});return}o({ok:!0,message:`Authenticated, account funded. Test call used ${f.usage.input_tokens}+${f.usage.output_tokens} tokens (~$0.0001).`})}catch(c){o({ok:!1,message:c instanceof Error?c.message:String(c)})}finally{h(!1)}}async function v(){typeof confirm=="function"&&!confirm("Clear the local AI usage log? Provider-side billing records are unaffected.")||(await Ze(),await b())}i.useEffect(()=>{w({type:"SETTINGS_GET",key:Y}).then(c=>{const f=c.data;f&&s({...V,...f,enabledChecks:{...V.enabledChecks,...f.enabledChecks??{}}}),n(!0)})},[]);function j(c){const f={...t,...c};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}function p(c){const f={...t,enabledChecks:{...t.enabledChecks,...c}};s(f),C({type:"SETTINGS_SET",key:Y,value:f})}return a?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-slate-600 leading-snug",children:"Adds vision-verified alt-text checking, heading-quality judgment, sensory-language detection, and ARIA semantic verification to every audit. Each check uses a small AI call against your configured provider; per-audit cost is hard-capped to prevent surprise bills."}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>j({enabled:c.target.checked})}),e.jsx("span",{children:e.jsx("strong",{children:"Enable AI augmentation"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-provider",className:"block text-xs text-slate-500 mb-1",children:"Provider"}),e.jsxs("select",{id:"ai-provider",value:t.provider,onChange:c=>j({provider:c.target.value}),disabled:!t.enabled,className:"text-xs border border-slate-300 rounded px-2 py-1.5",children:[e.jsx("option",{value:"anthropic",children:"Anthropic (Claude)"}),e.jsx("option",{value:"openai",children:"OpenAI (GPT) — coming soon"}),e.jsx("option",{value:"gemini",children:"Google (Gemini) — coming soon"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"ai-key",className:"block text-xs text-slate-500 mb-1",children:["API key",e.jsx("span",{className:"text-[10px] text-slate-400 ml-2",children:"stored locally; never sent anywhere except your chosen provider"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:"ai-key",type:r?"text":"password",value:t.apiKey,onChange:c=>j({apiKey:c.target.value.trim()}),disabled:!t.enabled,placeholder:"sk-ant-…",className:"flex-1 text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("button",{type:"button",onClick:()=>x(!r),className:"text-[11px] px-2 border border-slate-300 rounded hover:bg-slate-50",children:r?"Hide":"Show"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-model",className:"block text-xs text-slate-500 mb-1",children:"Model override (optional)"}),e.jsx("input",{id:"ai-model",type:"text",value:t.model??"",onChange:c=>j({model:c.target.value.trim()}),disabled:!t.enabled,placeholder:"claude-3-5-sonnet-20241022 (default)",className:"w-full text-xs font-mono border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Leave blank for provider default. Use a haiku-class model for cheap-fast checks."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ai-cap",className:"block text-xs text-slate-500 mb-1",children:"Per-audit cost cap (USD)"}),e.jsx("input",{id:"ai-cap",type:"number",step:.5,min:0,value:t.costCapUsd,onChange:c=>j({costCapUsd:Math.max(0,parseFloat(c.target.value)||0)}),disabled:!t.enabled,className:"w-32 text-xs border border-slate-300 rounded px-2 py-1.5"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:"Hard ceiling — once exceeded, remaining AI checks for the audit are skipped."})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Checks to run"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.altText,onChange:c=>p({altText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Alt text"})," — verify every image's alt accurately describes it (vision call, ~$0.005 each)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.headings,onChange:c=>p({headings:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Headings"})," — judge whether headings describe their sections (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.sensory,onChange:c=>p({sensory:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Sensory language"}),' — flag instructions like "click the round button" (text-only, cheap)']})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.aria,onChange:c=>p({aria:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"ARIA semantics"})," — verify role= attributes match element behavior (more expensive; opt-in)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.imageOfText,onChange:c=>p({imageOfText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Images of text"})," (WCAG 1.4.5) — flag banner / share-card / infographic images that bake text into the raster (vision; capped to ",t.imageOfTextMaxImages," largest images / audit)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.colorOnlyMeaning,onChange:c=>p({colorOnlyMeaning:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Color-only meaning"})," (WCAG 1.4.1) — flag status indicators / icons / instructions where only color conveys meaning (vision call)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.genericLinkText,onChange:c=>p({genericLinkText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Generic link text"}),` (WCAG 2.4.4) — flag "click here"-style links where surrounding context doesn't clarify the destination (text-only, cheap)`]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.wallOfText,onChange:c=>p({wallOfText:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Wall of text"})," (WCAG 3.1.5) — flag long-form content with no subheadings, lists, or paragraph breaks (text-only, cheap)"]})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabledChecks.languageMismatch,onChange:c=>p({languageMismatch:c.target.checked}),disabled:!t.enabled}),e.jsxs("span",{children:[e.jsx("strong",{children:"Language mismatch"})," (WCAG 3.1.1 / 3.1.2) — flag content that doesn't match the declared ",e.jsx("code",{children:"lang"})," attribute (text-only, cheap)"]})]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Connection test"}),e.jsx("p",{className:"text-[11px] text-slate-500 mb-2",children:"Fires a 5-token call to your provider to confirm the key authenticates and the account is funded. Costs ≈ $0.0001."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void g(),disabled:!t.apiKey||u,className:"text-xs px-3 py-1 border border-slate-300 rounded hover:bg-slate-50 disabled:opacity-50",children:u?"Testing…":"Test connection"}),m&&e.jsxs("span",{className:`text-[11px] ${m.ok?"text-emerald-700":"text-rose-700"}`,children:[m.ok?"✓ ":"✗ ",m.message]})]})]}),e.jsxs("fieldset",{className:"border border-slate-200 rounded p-3",children:[e.jsx("legend",{className:"text-xs font-medium px-1",children:"Local usage"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mb-2",children:["Tracked locally per audit. Providers don't expose live balance via API, so check"," ",e.jsx("a",{href:"https://console.anthropic.com/settings/billing",target:"_blank",rel:"noopener noreferrer",className:"text-brand-700 underline",children:"console.anthropic.com → Plans & Billing"})," ","for your real balance."]}),d&&d.totalAudits===0&&e.jsx("p",{className:"text-[11px] text-slate-500 italic",children:"No AI-augmented audits recorded yet."}),d&&d.totalAudits>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"All-time spent"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.totalSpentUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.totalAudits," audit",d.totalAudits===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"This month"}),e.jsxs("div",{className:"font-semibold text-slate-800",children:["$",d.spentThisMonthUsd.toFixed(4)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[d.auditsThisMonth," audit",d.auditsThisMonth===1?"":"s"]})]}),e.jsxs("div",{className:"border border-slate-200 rounded p-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:"Avg / audit"}),e.jsx("div",{className:"font-semibold text-slate-800",children:d.averageCostUsd!=null?`$${d.averageCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"By check type"}),e.jsx("ul",{className:"mt-1 text-[11px] text-slate-700",children:Object.entries(d.byCheck).map(([c,f])=>e.jsxs("li",{className:"flex items-center justify-between py-0.5",children:[e.jsx("code",{className:"font-mono",children:c}),e.jsxs("span",{children:["$",(f??0).toFixed(4)]})]},c))})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"text-[11px] cursor-pointer text-slate-600",children:"Recent audits (last 10)"}),e.jsxs("table",{className:"mt-1 w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-left",children:[e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"When"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium",children:"Target"}),e.jsx("th",{className:"py-0.5 pr-2 font-medium text-right",children:"Cost"}),e.jsx("th",{className:"py-0.5 font-medium text-right",children:"Findings"})]})}),e.jsx("tbody",{children:d.recent.map((c,f)=>e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsx("td",{className:"py-0.5 pr-2 text-slate-600",children:new Date(c.at).toLocaleDateString()}),e.jsx("td",{className:"py-0.5 pr-2 text-slate-700 truncate max-w-[180px]",title:c.pageUrl,children:c.pageUrl}),e.jsxs("td",{className:"py-0.5 pr-2 text-right font-mono",children:["$",c.totalCostUsd.toFixed(4),c.capExceeded&&e.jsx("span",{className:"text-amber-700 ml-1",title:"Cost cap exceeded",children:"⚠"}),c.failureReason&&e.jsx("span",{className:"text-red-700 ml-1",title:`AI failure: ${c.failureReason}`,children:"✗"})]}),e.jsx("td",{className:"py-0.5 text-right",children:c.findingsCount})]},f))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>void v(),className:"text-[11px] text-slate-500 hover:text-rose-600 underline-offset-2 hover:underline",children:"Clear local usage log"})})]})]})]}):e.jsx("div",{className:"text-xs text-slate-500",children:"Loading…"})}function ms(){const[t,s]=i.useState(null),[a,n]=i.useState("trial");i.useEffect(()=>{w({type:"SETTINGS_GET_ALL"}).then(o=>{const u=o.data??{};s({stateMatrix:u.stateMatrix??ee,componentIdAliases:u.componentIdAliases??{}})}),w({type:"TIER_GET"}).then(o=>n(o.tier))},[]);function r(o){t&&(s({...t,stateMatrix:o}),C({type:"SETTINGS_SET",key:"stateMatrix",value:o}))}function x(o){if(!t)return;const u=new Set(o.map(b=>b.id)),h=t.stateMatrix.breakpoints.filter(b=>u.has(b));r({...t.stateMatrix,breakpointPresets:o,breakpoints:h.length>0?h:o[0]?[o[0].id]:[]})}function d(o){t&&(s({...t,componentIdAliases:o}),C({type:"SETTINGS_SET",key:"componentIdAliases",value:o}))}function l(){t&&(typeof confirm=="function"&&!confirm("Reset state matrix to defaults?")||r(ee))}if(!t)return e.jsx("div",{className:"p-8 text-sm text-slate-500",children:"Loading…"});const m=a==="free";return e.jsxs("div",{className:"max-w-2xl mx-auto p-3 sm:p-6 space-y-6 text-sm",children:[e.jsxs("header",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Settings"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Changes are saved automatically. Close this tab to return to the audit panel."})]}),e.jsx("button",{type:"button",onClick:()=>{window.close()},className:"text-xs px-3 py-1.5 bg-brand-500 text-white rounded hover:bg-brand-600 shrink-0",children:"Done"})]}),e.jsx("main",{"aria-label":"Settings",children:e.jsxs(gt,{defaultValue:"audit",className:"space-y-4",children:[e.jsx(yt,{className:"flex flex-wrap gap-1 border-b border-slate-200","aria-label":"Settings categories",children:[{value:"audit",label:"Audit"},{value:"integrations",label:"Integrations"},{value:"account",label:"Account"},{value:"advanced",label:"Advanced"}].map(o=>e.jsx(vt,{value:o.value,className:"text-xs px-3 py-1.5 text-slate-600 hover:text-slate-900 data-[state=active]:text-brand-700 data-[state=active]:border-b-2 data-[state=active]:border-brand-500 -mb-px",children:o.label},o.value))}),e.jsxs($,{value:"audit",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"State matrix"}),e.jsx("button",{onClick:l,className:"text-xs text-slate-500 hover:text-slate-900",children:"Reset to defaults"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"Which states each audit covers. Larger matrix = more coverage but slower runs."}),m&&e.jsx("div",{className:"text-xs bg-amber-50 border border-amber-200 rounded p-2 text-amber-900",children:"Free tier audits the default state only — your matrix selections below will be ignored until you upgrade."}),e.jsx(kt,{value:t.stateMatrix,onChange:r})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Breakpoint presets"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Customize widths/heights and add your own breakpoints. Toggle which ones audit under in the State matrix section above."}),e.jsx(Kt,{presets:t.stateMatrix.breakpointPresets,onChange:x})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Audit reliability"}),e.jsx(ds,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Disabled rules"}),e.jsx(as,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Component identity aliases"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Map two component IDs to the same canonical ID — useful when the same component is identified differently across pages."}),e.jsx(Tt,{value:t.componentIdAliases,onChange:d})]})]}),e.jsxs($,{value:"integrations",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"GitHub issue tracker"}),e.jsx(rs,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Jira issue tracker"}),e.jsx(os,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Cloud sync (baselines)"}),e.jsx(cs,{})]})]}),e.jsxs($,{value:"account",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"User mode"}),e.jsx(us,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"License"}),e.jsx(Ut,{tier:a,onTierChange:n})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Crash reporting"}),e.jsx(Ht,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"AI augmentation"}),e.jsx(xs,{})]})]}),e.jsxs($,{value:"advanced",className:"space-y-8 pt-2",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Report download behavior"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Defense / evidence bundles default to a confirmation prompt before downloading. Power users who export many bundles can skip the prompt here."}),e.jsx(Jt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Performance"}),e.jsx(Yt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Custom rules"}),e.jsx(Xt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Native messaging host"}),e.jsx(ss,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Team"}),e.jsx("p",{className:"text-xs text-slate-500",children:"For Team plans: see every device that's claimed a seat under this license, and revoke any of them. The license token itself authenticates this section — anyone with the token can manage seats."}),e.jsx(zt,{})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Import / export"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Share matrix + alias config with your team, or back up before major changes."}),e.jsx(Vt,{stateMatrix:t.stateMatrix,componentIdAliases:t.componentIdAliases,onImport:o=>s(o)})]})]})]})}),e.jsx(Ge,{})]})}const Fe=document.getElementById("root");if(!Fe)throw new Error("options: #root not found");Be(Fe).render(e.jsx(M.StrictMode,{children:e.jsx(ms,{})}));
|