@3fn/core 14.0.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1442) hide show
  1. package/.kiro/steering/AI-Collaboration-Principles.md +9 -3
  2. package/.kiro/steering/Agent-Directory.md +31 -7
  3. package/.kiro/steering/Civitas-System-Overview.md +5 -14
  4. package/.kiro/steering/DesignerPunk-Systems-Overview.md +3 -3
  5. package/.kiro/steering/Spec-Feedback-Protocol.md +2 -11
  6. package/.kiro/steering/Task-Completion-Protocol.md +17 -16
  7. package/.kiro/steering/start-up-tasks.md +15 -7
  8. package/CHANGELOG.md +74 -0
  9. package/README.md +26 -21
  10. package/application-mcp-server/src/__tests__/consumerRootLiveReindex.test.ts +118 -0
  11. package/application-mcp-server/src/__tests__/errorCatalogWiring.test.ts +73 -0
  12. package/application-mcp-server/src/__tests__/mcpDataRootsDeclaration.test.ts +107 -0
  13. package/application-mcp-server/src/__tests__/tool-boundary.contract.test.ts +55 -0
  14. package/application-mcp-server/src/index.ts +249 -59
  15. package/application-mcp-server/src/indexer/ComponentIndexer.ts +273 -46
  16. package/application-mcp-server/src/indexer/ModeClassifier.ts +23 -16
  17. package/application-mcp-server/src/indexer/SemanticOverrideReader.ts +113 -0
  18. package/application-mcp-server/src/indexer/TokenIndexer.ts +195 -3
  19. package/application-mcp-server/src/indexer/__tests__/MultiRootIndexing.test.ts +134 -0
  20. package/application-mcp-server/src/indexer/__tests__/ThemeResolution.test.ts +241 -0
  21. package/application-mcp-server/src/indexer/__tests__/ThemeRootFollowsIndex.test.ts +216 -0
  22. package/application-mcp-server/src/indexer/__tests__/fixtures/consumerFixture.ts +84 -0
  23. package/application-mcp-server/src/indexer/resolveThemeTierRoot.ts +61 -0
  24. package/application-mcp-server/src/watcher/FileWatcher.ts +20 -7
  25. package/dist/ComponentTokens.android.kt +12 -12
  26. package/dist/ComponentTokens.ios.swift +12 -12
  27. package/dist/ComponentTokens.web.css +3 -3
  28. package/dist/DesignTokens.android.kt +1 -5
  29. package/dist/DesignTokens.dtcg.json +388 -122
  30. package/dist/DesignTokens.figma.json +281 -941
  31. package/dist/DesignTokens.ios.swift +1 -5
  32. package/dist/DesignTokens.web.css +5 -5
  33. package/dist/browser/designerpunk.esm.js +174 -103
  34. package/dist/browser/designerpunk.esm.min.js +58 -55
  35. package/dist/browser/designerpunk.umd.js +174 -103
  36. package/dist/browser/designerpunk.umd.min.js +58 -55
  37. package/dist/browser/tokens.css +7 -7
  38. package/dist/build/platforms/AndroidMotionTokenFormatter.d.ts +101 -0
  39. package/dist/build/platforms/AndroidMotionTokenFormatter.js +220 -0
  40. package/dist/build/platforms/WebMotionTokenFormatter.d.ts +85 -0
  41. package/dist/build/platforms/WebMotionTokenFormatter.js +167 -0
  42. package/dist/build/platforms/iOSMotionTokenFormatter.d.ts +99 -0
  43. package/dist/build/platforms/iOSMotionTokenFormatter.js +221 -0
  44. package/dist/build/tokens/defineComponentTokens.d.ts +10 -0
  45. package/dist/build/tokens/defineComponentTokens.js +26 -0
  46. package/dist/build/validation/index.d.ts +0 -4
  47. package/dist/build/validation/index.js +1 -8
  48. package/dist/cli/attach.d.ts +153 -0
  49. package/dist/cli/attach.js +423 -0
  50. package/dist/cli/designerpunk.d.ts +46 -0
  51. package/dist/cli/designerpunk.js +171 -34
  52. package/dist/cli/figma-extract.js +10 -1
  53. package/dist/cli/figma-push.js +11 -2
  54. package/dist/cli/init.d.ts +36 -5
  55. package/dist/cli/init.js +348 -143
  56. package/dist/cli/loadComponentTokens.d.ts +25 -0
  57. package/dist/cli/loadComponentTokens.js +87 -8
  58. package/dist/cli/shared/bornRepo.d.ts +50 -0
  59. package/dist/cli/shared/bornRepo.js +199 -0
  60. package/dist/cli/shared/errorCatalog.d.ts +130 -0
  61. package/dist/cli/shared/errorCatalog.js +148 -0
  62. package/dist/cli/shared/mcpConfig/cc.d.ts +25 -0
  63. package/dist/cli/shared/mcpConfig/cc.js +156 -0
  64. package/dist/cli/shared/mcpConfig/kiro.d.ts +53 -0
  65. package/dist/cli/shared/mcpConfig/kiro.js +140 -0
  66. package/dist/cli/shared/mcpDataRoots.d.ts +88 -1
  67. package/dist/cli/shared/mcpDataRoots.js +76 -2
  68. package/dist/cli/shared/transforms.d.ts +64 -0
  69. package/dist/cli/shared/transforms.js +138 -0
  70. package/dist/cli/shared/vocabulary.d.ts +50 -0
  71. package/dist/cli/shared/vocabulary.js +62 -0
  72. package/dist/cli/sync/Applier.d.ts +25 -26
  73. package/dist/cli/sync/Applier.js +37 -73
  74. package/dist/cli/sync/Classifier.d.ts +70 -6
  75. package/dist/cli/sync/Classifier.js +123 -84
  76. package/dist/cli/sync/FileScanner.d.ts +19 -10
  77. package/dist/cli/sync/FileScanner.js +33 -25
  78. package/dist/cli/sync/KeyGrain.d.ts +106 -0
  79. package/dist/cli/sync/KeyGrain.js +301 -0
  80. package/dist/cli/sync/Manifest.d.ts +147 -12
  81. package/dist/cli/sync/Manifest.js +276 -21
  82. package/dist/cli/sync/Migration.d.ts +271 -0
  83. package/dist/cli/sync/Migration.js +764 -0
  84. package/dist/cli/sync/NameContract.d.ts +169 -0
  85. package/dist/cli/sync/NameContract.js +246 -0
  86. package/dist/cli/sync/RegionGrain.d.ts +118 -0
  87. package/dist/cli/sync/RegionGrain.js +167 -0
  88. package/dist/cli/sync/Reporter.d.ts +33 -4
  89. package/dist/cli/sync/Reporter.js +112 -53
  90. package/dist/cli/sync/SteeringDirCheck.d.ts +32 -4
  91. package/dist/cli/sync/SteeringDirCheck.js +62 -14
  92. package/dist/cli/sync/index.d.ts +125 -6
  93. package/dist/cli/sync/index.js +716 -66
  94. package/dist/color/OklchValidator.d.ts +43 -3
  95. package/dist/color/OklchValidator.js +46 -8
  96. package/dist/components/core/Avatar-Base/avatar.tokens.d.ts +21 -26
  97. package/dist/components/core/Avatar-Base/avatar.tokens.js +31 -34
  98. package/dist/components/core/Avatar-Base/index.d.ts +1 -1
  99. package/dist/components/core/Avatar-Base/index.js +2 -2
  100. package/dist/components/core/Button-CTA/Button-CTA.refs.d.ts +83 -0
  101. package/dist/components/core/Button-CTA/Button-CTA.refs.js +86 -0
  102. package/dist/components/core/Button-CTA/Button-CTA.tokens.d.ts +20 -10
  103. package/dist/components/core/Button-CTA/Button-CTA.tokens.js +21 -10
  104. package/dist/components/core/Button-CTA/index.d.ts +2 -2
  105. package/dist/components/core/Button-CTA/index.js +3 -3
  106. package/dist/components/core/Button-Icon/buttonIcon.tokens.d.ts +28 -14
  107. package/dist/components/core/Button-Icon/buttonIcon.tokens.js +35 -20
  108. package/dist/components/core/Button-VerticalList-Item/platforms/web/ButtonVerticalListItem.web.d.ts +11 -30
  109. package/dist/components/core/Button-VerticalList-Item/platforms/web/ButtonVerticalListItem.web.js +16 -49
  110. package/dist/components/core/Container-Base/Container-Base.refs.d.ts +181 -0
  111. package/dist/components/core/Container-Base/Container-Base.refs.js +223 -0
  112. package/dist/components/core/Container-Base/index.d.ts +2 -2
  113. package/dist/components/core/Container-Base/index.js +10 -10
  114. package/dist/components/core/Container-Base/platforms/web/ContainerBase.web.js +1 -1
  115. package/dist/components/core/Container-Base/platforms/web/token-mapping.d.ts +27 -9
  116. package/dist/components/core/Container-Base/platforms/web/token-mapping.js +50 -22
  117. package/dist/components/core/Container-Card-Base/Container-Card-Base.refs.d.ts +149 -0
  118. package/dist/components/core/Container-Card-Base/Container-Card-Base.refs.js +207 -0
  119. package/dist/components/core/Container-Card-Base/index.d.ts +1 -1
  120. package/dist/components/core/Container-Card-Base/index.js +19 -19
  121. package/dist/components/core/Container-Card-Base/platforms/web/ContainerCardBase.web.js +7 -6
  122. package/dist/components/core/Input-Radio-Base/platforms/web/InputRadioBase.web.d.ts +15 -0
  123. package/dist/components/core/Input-Radio-Base/platforms/web/InputRadioBase.web.js +41 -1
  124. package/dist/components/core/Input-Text-Base/Input-Text-Base.refs.d.ts +331 -0
  125. package/dist/components/core/Input-Text-Base/Input-Text-Base.refs.js +164 -0
  126. package/dist/components/core/Input-Text-Base/platforms/web/InputTextBase.web.js +1 -1
  127. package/dist/components/core/Input-Text-Email/Input-Text-Email.refs.d.ts +20 -0
  128. package/dist/components/core/Input-Text-Email/Input-Text-Email.refs.js +34 -0
  129. package/dist/components/core/Input-Text-Password/Input-Text-Password.refs.d.ts +20 -0
  130. package/dist/components/core/Input-Text-Password/Input-Text-Password.refs.js +34 -0
  131. package/dist/components/core/Input-Text-Password/platforms/web/InputTextPassword.web.d.ts +30 -0
  132. package/dist/components/core/Input-Text-Password/platforms/web/InputTextPassword.web.js +72 -3
  133. package/dist/components/core/Input-Text-PhoneNumber/Input-Text-PhoneNumber.refs.d.ts +20 -0
  134. package/dist/components/core/Input-Text-PhoneNumber/Input-Text-PhoneNumber.refs.js +34 -0
  135. package/dist/consumer-canonical/agents/ada.md +331 -0
  136. package/dist/consumer-canonical/agents/data.md +429 -0
  137. package/dist/consumer-canonical/agents/kenya.md +400 -0
  138. package/dist/consumer-canonical/agents/leonardo.md +524 -0
  139. package/dist/consumer-canonical/agents/lina.md +501 -0
  140. package/dist/consumer-canonical/agents/sparky.md +395 -0
  141. package/dist/consumer-canonical/agents/stacy.md +515 -0
  142. package/dist/consumer-canonical/agents/thurgood.md +463 -0
  143. package/dist/consumer-canonical/always-set/agent-directory.dispositions.yaml +21 -0
  144. package/dist/consumer-canonical/always-set/agent-directory.overlay.md +51 -0
  145. package/dist/consumer-canonical/always-set/ai-collaboration-principles.dispositions.yaml +15 -0
  146. package/dist/consumer-canonical/always-set/ai-collaboration-principles.overlay.md +26 -0
  147. package/dist/consumer-canonical/always-set/civitas-system-overview.dispositions.yaml +15 -0
  148. package/dist/consumer-canonical/always-set/civitas-system-overview.overlay.md +70 -0
  149. package/dist/consumer-canonical/always-set/core-goals.dispositions.yaml +9 -0
  150. package/dist/consumer-canonical/always-set/core-goals.overlay.md +74 -0
  151. package/dist/consumer-canonical/always-set/designerpunk-systems-overview.dispositions.yaml +16 -0
  152. package/dist/consumer-canonical/always-set/designerpunk-systems-overview.overlay.md +44 -0
  153. package/dist/consumer-canonical/always-set/spec-feedback-protocol.dispositions.yaml +21 -0
  154. package/dist/consumer-canonical/always-set/spec-feedback-protocol.overlay.md +44 -0
  155. package/dist/consumer-canonical/always-set/start-up-tasks.dispositions.yaml +15 -0
  156. package/dist/consumer-canonical/always-set/start-up-tasks.overlay.md +25 -0
  157. package/dist/consumer-canonical/always-set/task-completion-protocol.dispositions.yaml +19 -0
  158. package/dist/consumer-canonical/always-set/task-completion-protocol.overlay.md +116 -0
  159. package/dist/consumer-canonical/consumer-profile.yaml +9 -0
  160. package/dist/consumer-canonical/shared/always-set.yaml +113 -0
  161. package/dist/consumer-canonical/shared/field-dispositions.yaml +85 -0
  162. package/dist/consumer-canonical/shared/shared-catalog.yaml +19 -0
  163. package/dist/consumer-canonical/shared/skills-map.yaml +33 -0
  164. package/dist/consumer-canonical/skills/adaptive/SKILL.md +301 -0
  165. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/flexbox/container-behavior.md +112 -0
  166. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/flexbox/get-started.md +69 -0
  167. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/flexbox/index.md +81 -0
  168. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/flexbox/item-behavior.md +170 -0
  169. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/grid/container-properties.md +238 -0
  170. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/grid/get-started.md +51 -0
  171. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/grid/index.md +73 -0
  172. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/grid/item-properties.md +168 -0
  173. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/layouts/adaptive/mediaquery/index.md +329 -0
  174. package/dist/consumer-canonical/skills/adaptive/references/android/develop/ui/compose/tooling/debug.md +114 -0
  175. package/dist/consumer-canonical/skills/adaptive/references/android/guide/navigation/navigation-3/recipes/material-listdetail.md +141 -0
  176. package/dist/consumer-canonical/skills/edge-to-edge/SKILL.md +426 -0
  177. package/dist/consumer-canonical/skills/impeccable/SKILL.md +237 -0
  178. package/dist/consumer-canonical/skills/impeccable/detector-exclusions.md +42 -0
  179. package/dist/consumer-canonical/skills/impeccable/reference/adapt.md +190 -0
  180. package/dist/consumer-canonical/skills/impeccable/reference/animate.md +194 -0
  181. package/dist/consumer-canonical/skills/impeccable/reference/audit.md +150 -0
  182. package/dist/consumer-canonical/skills/impeccable/reference/bolder.md +113 -0
  183. package/dist/consumer-canonical/skills/impeccable/reference/brand-dp.md +103 -0
  184. package/dist/consumer-canonical/skills/impeccable/reference/clarify.md +174 -0
  185. package/dist/consumer-canonical/skills/impeccable/reference/codex.md +105 -0
  186. package/dist/consumer-canonical/skills/impeccable/reference/cognitive-load.md +106 -0
  187. package/dist/consumer-canonical/skills/impeccable/reference/color-and-contrast.md +122 -0
  188. package/dist/consumer-canonical/skills/impeccable/reference/colorize.md +155 -0
  189. package/dist/consumer-canonical/skills/impeccable/reference/craft.md +123 -0
  190. package/dist/consumer-canonical/skills/impeccable/reference/critique.md +245 -0
  191. package/dist/consumer-canonical/skills/impeccable/reference/delight.md +302 -0
  192. package/dist/consumer-canonical/skills/impeccable/reference/distill.md +111 -0
  193. package/dist/consumer-canonical/skills/impeccable/reference/extract-dp.md +43 -0
  194. package/dist/consumer-canonical/skills/impeccable/reference/harden.md +347 -0
  195. package/dist/consumer-canonical/skills/impeccable/reference/heuristics-scoring.md +234 -0
  196. package/dist/consumer-canonical/skills/impeccable/reference/interaction-design.md +195 -0
  197. package/dist/consumer-canonical/skills/impeccable/reference/layout.md +141 -0
  198. package/dist/consumer-canonical/skills/impeccable/reference/live.md +622 -0
  199. package/dist/consumer-canonical/skills/impeccable/reference/motion-design.md +109 -0
  200. package/dist/consumer-canonical/skills/impeccable/reference/onboard.md +234 -0
  201. package/dist/consumer-canonical/skills/impeccable/reference/optimize.md +258 -0
  202. package/dist/consumer-canonical/skills/impeccable/reference/overdrive.md +130 -0
  203. package/dist/consumer-canonical/skills/impeccable/reference/personas.md +179 -0
  204. package/dist/consumer-canonical/skills/impeccable/reference/polish.md +242 -0
  205. package/dist/consumer-canonical/skills/impeccable/reference/product-dp.md +79 -0
  206. package/dist/consumer-canonical/skills/impeccable/reference/quieter.md +99 -0
  207. package/dist/consumer-canonical/skills/impeccable/reference/responsive-design.md +114 -0
  208. package/dist/consumer-canonical/skills/impeccable/reference/shape.md +165 -0
  209. package/dist/consumer-canonical/skills/impeccable/reference/spatial-design.md +100 -0
  210. package/dist/consumer-canonical/skills/impeccable/reference/typeset.md +126 -0
  211. package/dist/consumer-canonical/skills/impeccable/reference/typography.md +159 -0
  212. package/dist/consumer-canonical/skills/impeccable/reference/ux-writing.md +107 -0
  213. package/dist/consumer-canonical/skills/impeccable/scripts/detect.mjs +21 -0
  214. package/dist/consumer-canonical/skills/impeccable/scripts/detector/browser/injected/index.mjs +1725 -0
  215. package/dist/consumer-canonical/skills/impeccable/scripts/detector/cli/main.mjs +244 -0
  216. package/dist/consumer-canonical/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +4567 -0
  217. package/dist/consumer-canonical/skills/impeccable/scripts/detector/detect-antipatterns.mjs +43 -0
  218. package/dist/consumer-canonical/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +252 -0
  219. package/dist/consumer-canonical/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +535 -0
  220. package/dist/consumer-canonical/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +986 -0
  221. package/dist/consumer-canonical/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +208 -0
  222. package/dist/consumer-canonical/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  223. package/dist/consumer-canonical/skills/impeccable/scripts/detector/findings.mjs +12 -0
  224. package/dist/consumer-canonical/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
  225. package/dist/consumer-canonical/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
  226. package/dist/consumer-canonical/skills/impeccable/scripts/detector/registry/antipatterns.mjs +419 -0
  227. package/dist/consumer-canonical/skills/impeccable/scripts/detector/rules/checks.mjs +2316 -0
  228. package/dist/consumer-canonical/skills/impeccable/scripts/detector/shared/color.mjs +156 -0
  229. package/dist/consumer-canonical/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
  230. package/dist/consumer-canonical/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
  231. package/dist/consumer-canonical/skills/navigation-3/SKILL.md +110 -0
  232. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/index.md +38 -0
  233. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/migration-guide.md +498 -0
  234. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/animations.md +147 -0
  235. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/basic.md +89 -0
  236. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/basicdsl.md +85 -0
  237. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/basicsaveable.md +90 -0
  238. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/bottomsheet.md +195 -0
  239. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/common-ui.md +200 -0
  240. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/conditional.md +230 -0
  241. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/deeplinks-advanced.md +155 -0
  242. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/deeplinks-basic.md +744 -0
  243. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/dialog.md +107 -0
  244. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/material-listdetail.md +141 -0
  245. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/material-supportingpane.md +145 -0
  246. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/modular-hilt.md +283 -0
  247. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/modular-koin.md +287 -0
  248. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/multiple-backstacks.md +436 -0
  249. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/passingarguments.md +371 -0
  250. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/results-event.md +272 -0
  251. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/results-state.md +266 -0
  252. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/scenes-listdetail.md +435 -0
  253. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/navigation-3/recipes/scenes-twopane.md +244 -0
  254. package/dist/consumer-canonical/skills/navigation-3/references/android/guide/navigation/type-safe-destinations.md +129 -0
  255. package/dist/consumer-canonical/skills/theming-styles/SKILL.md +220 -0
  256. package/dist/consumer-canonical/skills/theming-styles/references/android/develop/ui/compose/designsystems/custom.md +459 -0
  257. package/dist/consumer-canonical/skills/theming-styles/references/android/develop/ui/compose/styles/fundamentals.md +420 -0
  258. package/dist/consumer-canonical/skills/theming-styles/references/android/develop/ui/compose/styles/state-animations.md +461 -0
  259. package/dist/consumer-canonical/skills/theming-styles/references/android/develop/ui/compose/styles/styles-vs-modifiers.md +48 -0
  260. package/dist/consumer-canonical/skills/theming-styles/references/android/develop/ui/compose/styles/theming.md +257 -0
  261. package/dist/generator/consumer-entry.js +5939 -0
  262. package/dist/generators/DTCGFormatGenerator.d.ts +14 -4
  263. package/dist/generators/DTCGFormatGenerator.js +35 -18
  264. package/dist/generators/TokenFileGenerator.js +20 -15
  265. package/dist/generators/generateTokenIndex.d.ts +14 -0
  266. package/dist/generators/generateTokenIndex.js +23 -0
  267. package/dist/generators/transformers/FigmaTransformer.d.ts +35 -0
  268. package/dist/generators/transformers/FigmaTransformer.js +101 -13
  269. package/dist/generators/types/DTCGTypes.d.ts +10 -0
  270. package/dist/mcp/application-mcp.js +1062 -261
  271. package/dist/mcp/docs-mcp.js +93 -13
  272. package/dist/mcp/product-mcp.js +539 -41
  273. package/dist/mcp/tool-manifest.json +184 -0
  274. package/dist/name-contract.json +4283 -0
  275. package/dist/tokens/BlurTokens.d.ts +3 -1
  276. package/dist/tokens/BlurTokens.js +6 -4
  277. package/dist/tokens/ShadowOffsetTokens.js +14 -14
  278. package/dist/tokens/SizingTokens.js +3 -3
  279. package/dist/tokens/TapAreaTokens.d.ts +13 -2
  280. package/dist/tokens/TapAreaTokens.js +19 -8
  281. package/dist/tokens/component/progress.d.ts +65 -5
  282. package/dist/tokens/component/progress.js +79 -18
  283. package/dist/tokens/semantic/ColorTokens.js +50 -5
  284. package/dist/tokens/semantic/TypographyTokens.js +10 -10
  285. package/dist/tokens/themes/dark/SemanticOverrides.js +21 -4
  286. package/dist/tools/integrity/Invariants.d.ts +23 -8
  287. package/dist/tools/integrity/Invariants.js +27 -8
  288. package/dist/tools/integrity/cli/run-audit.js +1 -1
  289. package/dist/types/PrimitiveToken.d.ts +15 -1
  290. package/dist/types/generated/TokenTypes.d.ts +1 -1
  291. package/dist/types/generated/TokenTypes.js +1 -1
  292. package/dist/types/index.d.ts +1 -0
  293. package/governance/AI-Collaboration-Framework.md +19 -10
  294. package/governance/BUILD-SYSTEM-SETUP.md +1 -2
  295. package/governance/Component-Development-Guide.md +1 -1
  296. package/governance/Component-Development-Standards.md +19 -18
  297. package/governance/Component-Family-Avatar.md +6 -6
  298. package/governance/Component-Family-Badge.md +19 -19
  299. package/governance/Component-Family-Button.md +26 -26
  300. package/governance/Component-Family-Chip.md +14 -14
  301. package/governance/Component-Family-Container.md +12 -12
  302. package/governance/Component-Family-Form-Inputs.md +61 -61
  303. package/governance/Component-Family-Icon.md +8 -8
  304. package/governance/Component-Family-Navigation.md +3 -3
  305. package/governance/Component-Inheritance-Structures.md +29 -28
  306. package/governance/Component-Readiness-Status.md +6 -7
  307. package/governance/Component-Templates.md +26 -26
  308. package/governance/Contract-System-Reference.md +1 -1
  309. package/governance/DTCG-Integration-Guide.md +63 -36
  310. package/governance/DesignerPunk-Integration-Guide.md +57 -61
  311. package/governance/Figma-Workflow-Guide.md +15 -8
  312. package/governance/Process-Development-Workflow.md +4 -4
  313. package/governance/Process-File-Organization.md +1 -4
  314. package/governance/Process-Hook-Operations.md +6 -7
  315. package/governance/Process-Integration-Methodology.md +5 -5
  316. package/governance/Process-Spec-Planning.md +187 -68
  317. package/governance/Product-Handoff-Protocol.md +27 -2
  318. package/governance/Rosetta-System-Architecture.md +7 -5
  319. package/governance/Test-Behavioral-Contract-Validation.md +5 -0
  320. package/governance/Test-Development-Standards.md +4 -4
  321. package/governance/Token-Family-Accessibility.md +18 -14
  322. package/governance/Token-Family-Blend.md +5 -4
  323. package/governance/Token-Family-Blur.md +8 -8
  324. package/governance/Token-Family-Color.md +40 -22
  325. package/governance/Token-Family-Glow.md +26 -24
  326. package/governance/Token-Family-Layering.md +1 -0
  327. package/governance/Token-Family-Motion.md +22 -13
  328. package/governance/Token-Family-Opacity.md +20 -34
  329. package/governance/Token-Family-Radius.md +4 -2
  330. package/governance/Token-Family-Responsive.md +4 -4
  331. package/governance/Token-Family-Shadow.md +69 -46
  332. package/governance/Token-Family-Spacing.md +22 -12
  333. package/governance/Token-Family-Typography.md +86 -85
  334. package/governance/Token-Governance.md +5 -1
  335. package/governance/Token-Quick-Reference.md +97 -80
  336. package/governance/Transformer-Development-Guide.md +5 -4
  337. package/governance/Web-Authoring-Standards.md +1 -1
  338. package/governance/classification-map.md +706 -10
  339. package/governance/completion-documentation-guide.md +298 -33
  340. package/governance/platform-implementation-guidelines.md +3 -3
  341. package/governance/release-management-system.md +28 -63
  342. package/mcp-server/src/index.ts +16 -12
  343. package/mcp-server/src/relocation-integrity-gate/__tests__/relocation-integrity-gate.test.ts +3 -3
  344. package/mcp-server/src/relocation-integrity-gate/relocation-integrity-gate.ts +70 -49
  345. package/mcp-server/src/tools/find-docs.ts +1 -0
  346. package/mcp-server/src/tools/get-document-full.ts +1 -0
  347. package/mcp-server/src/tools/get-document-summary.ts +1 -0
  348. package/mcp-server/src/tools/get-index-health.ts +1 -0
  349. package/mcp-server/src/tools/get-section.ts +1 -0
  350. package/mcp-server/src/tools/list-cross-references.ts +1 -0
  351. package/mcp-server/src/tools/rebuild-index.ts +1 -0
  352. package/mcp-server/src/tools/validate-metadata.ts +1 -0
  353. package/package.json +76 -16
  354. package/src/build/tokens/defineComponentTokens.ts +43 -1
  355. package/src/cli/templates/mcp-config.json.template +15 -20
  356. package/src/components/core/Avatar-Base/platforms/android/AvatarPreview.kt +9 -2
  357. package/src/components/core/Container-Base/Container-Base.schema.yaml +9 -11
  358. package/src/components/core/Container-Base/platforms/android/ContainerBase.android.kt +5 -5
  359. package/src/components/core/Container-Base/platforms/ios/ContainerBase.ios.swift +5 -5
  360. package/src/components/core/Container-Card-Base/platforms/android/ContainerCardBase.android.kt +3 -3
  361. package/src/components/core/Container-Card-Base/platforms/ios/ContainerCardBase.ios.swift +2 -2
  362. package/src/components/core/Nav-Header-App/contracts.yaml +1 -1
  363. package/src/components/core/Nav-Header-Base/component-meta.yaml +0 -1
  364. package/src/components/core/Nav-Header-Base/contracts.yaml +1 -1
  365. package/src/components/core/Nav-Header-Page/contracts.yaml +1 -1
  366. package/src/components/core/Nav-TabBar-Base/contracts.yaml +1 -1
  367. package/src/components/core/Progress-Bar-Base/contracts.yaml +1 -1
  368. package/src/tokens/BlurTokens.ts +6 -4
  369. package/src/tokens/ShadowOffsetTokens.ts +14 -14
  370. package/src/tokens/SizingTokens.ts +3 -3
  371. package/src/tokens/TapAreaTokens.ts +20 -8
  372. package/src/tokens/__tests__/BaselineGridAlignmentFlag.test.ts +116 -0
  373. package/src/tokens/__tests__/BlurTokens.test.ts +10 -2
  374. package/src/tokens/__tests__/ProgressTokenCompliance.test.ts +5 -3
  375. package/src/tokens/__tests__/ProgressTokenFormulas.test.ts +11 -11
  376. package/src/tokens/__tests__/ProgressTokenTranslation.test.ts +22 -20
  377. package/src/tokens/__tests__/SemanticColorContrast.test.ts +339 -0
  378. package/src/tokens/__tests__/ShadowOffsetTokens.test.ts +8 -7
  379. package/src/tokens/__tests__/SizingTokens.test.ts +10 -2
  380. package/src/tokens/__tests__/TokenCategories.test.ts +1 -1
  381. package/src/tokens/__tests__/neutral-partition.test.ts +28 -0
  382. package/src/tokens/component/progress.ts +83 -21
  383. package/src/tokens/semantic/AccessibilityTokens.README.md +2 -2
  384. package/src/tokens/semantic/ColorTokens.ts +50 -5
  385. package/src/tokens/semantic/TypographyTokens.ts +10 -10
  386. package/src/tokens/semantic/__tests__/ColorTokens.test.ts +8 -4
  387. package/src/tokens/themes/dark/SemanticOverrides.ts +23 -4
  388. package/src/types/PrimitiveToken.ts +15 -1
  389. package/token-index/components.yaml +8 -8
  390. package/token-index/meta.json +3 -0
  391. package/token-index/semantics.yaml +21 -15
  392. package/.kiro/agents/ada-prompt.md +0 -213
  393. package/.kiro/agents/ada-prompt.md.attribution.json +0 -45
  394. package/.kiro/agents/ada.json +0 -72
  395. package/.kiro/agents/ada.json.attribution.json +0 -13
  396. package/.kiro/agents/data-prompt.md +0 -324
  397. package/.kiro/agents/data-prompt.md.attribution.json +0 -53
  398. package/.kiro/agents/data.json +0 -51
  399. package/.kiro/agents/data.json.attribution.json +0 -13
  400. package/.kiro/agents/kenya-prompt.md +0 -309
  401. package/.kiro/agents/kenya-prompt.md.attribution.json +0 -53
  402. package/.kiro/agents/kenya.json +0 -46
  403. package/.kiro/agents/kenya.json.attribution.json +0 -13
  404. package/.kiro/agents/leonardo-prompt.md +0 -359
  405. package/.kiro/agents/leonardo-prompt.md.attribution.json +0 -45
  406. package/.kiro/agents/leonardo.json +0 -47
  407. package/.kiro/agents/leonardo.json.attribution.json +0 -13
  408. package/.kiro/agents/lina-prompt.md +0 -344
  409. package/.kiro/agents/lina-prompt.md.attribution.json +0 -53
  410. package/.kiro/agents/lina.json +0 -64
  411. package/.kiro/agents/lina.json.attribution.json +0 -13
  412. package/.kiro/agents/sparky-prompt.md +0 -312
  413. package/.kiro/agents/sparky-prompt.md.attribution.json +0 -53
  414. package/.kiro/agents/sparky.json +0 -56
  415. package/.kiro/agents/sparky.json.attribution.json +0 -13
  416. package/.kiro/agents/stacy-prompt.md +0 -304
  417. package/.kiro/agents/stacy-prompt.md.attribution.json +0 -45
  418. package/.kiro/agents/stacy.json +0 -46
  419. package/.kiro/agents/stacy.json.attribution.json +0 -13
  420. package/.kiro/agents/thurgood-prompt.md +0 -363
  421. package/.kiro/agents/thurgood-prompt.md.attribution.json +0 -45
  422. package/.kiro/agents/thurgood.json +0 -47
  423. package/.kiro/agents/thurgood.json.attribution.json +0 -13
  424. package/.kiro/steering/personal-note.md +0 -35
  425. package/designerpunk.config.ts +0 -27
  426. package/dist/android/DesignTokens.android.kt +0 -695
  427. package/dist/components/core/Input-Text-Base/platforms/web/InputTextBase.browser.d.ts +0 -26
  428. package/dist/components/core/Input-Text-Base/platforms/web/InputTextBase.browser.js +0 -224
  429. package/dist/components/core/Input-Text-Email/platforms/web/InputTextEmail.browser.d.ts +0 -30
  430. package/dist/components/core/Input-Text-Email/platforms/web/InputTextEmail.browser.js +0 -254
  431. package/dist/components/core/Input-Text-Password/platforms/web/InputTextPassword.browser.d.ts +0 -44
  432. package/dist/components/core/Input-Text-Password/platforms/web/InputTextPassword.browser.js +0 -376
  433. package/dist/components/core/Input-Text-PhoneNumber/platforms/web/InputTextPhoneNumber.browser.d.ts +0 -38
  434. package/dist/components/core/Input-Text-PhoneNumber/platforms/web/InputTextPhoneNumber.browser.js +0 -328
  435. package/dist/ios/DesignTokens.ios.swift +0 -697
  436. package/dist/web/DesignTokens.web.css +0 -929
  437. package/product-template/agents/README.md +0 -73
  438. package/product-template/agents/ada-prompt.md +0 -83
  439. package/product-template/agents/data-prompt.md +0 -74
  440. package/product-template/agents/kenya-prompt.md +0 -74
  441. package/product-template/agents/leonardo-prompt.md +0 -99
  442. package/product-template/agents/lina-prompt.md +0 -61
  443. package/product-template/agents/sparky-prompt.md +0 -66
  444. package/product-template/agents/stacy-prompt.md +0 -51
  445. package/product-template/agents/thurgood-prompt.md +0 -64
  446. package/src/TokenEngine.ts +0 -628
  447. package/src/__tests__/BuildSystemIntegration.test.ts +0 -485
  448. package/src/__tests__/ProductMCPIntegration.test.ts +0 -204
  449. package/src/__tests__/__mocks__/styleMock.js +0 -18
  450. package/src/__tests__/browser-distribution/build-error-handling.test.ts +0 -143
  451. package/src/__tests__/browser-distribution/bundle-loading.test.ts +0 -353
  452. package/src/__tests__/browser-distribution/bundler-resolution.test.ts +0 -223
  453. package/src/__tests__/browser-distribution/component-registration.test.ts +0 -217
  454. package/src/__tests__/browser-distribution/css-bundling.test.ts +0 -233
  455. package/src/__tests__/browser-distribution/demo-system.test.ts +0 -588
  456. package/src/__tests__/browser-distribution/mcp-format-compliance.property.test.ts +0 -379
  457. package/src/__tests__/browser-distribution/mcp-queryability.test.ts +0 -342
  458. package/src/__tests__/browser-distribution/minification-effectiveness.property.test.ts +0 -188
  459. package/src/__tests__/browser-distribution/registration-idempotency.property.test.ts +0 -372
  460. package/src/__tests__/browser-distribution/soft-ceiling-warning.test.ts +0 -161
  461. package/src/__tests__/browser-distribution/token-completeness.property.test.ts +0 -412
  462. package/src/__tests__/browser-distribution/token-loading.test.ts +0 -344
  463. package/src/__tests__/browser-distribution/umd-bundle-loading.test.ts +0 -169
  464. package/src/__tests__/console-allowlist.json +0 -14
  465. package/src/__tests__/console-fail-setup.ts +0 -169
  466. package/src/__tests__/examples/improved-test-example.test.ts +0 -120
  467. package/src/__tests__/expected-exports.json +0 -66
  468. package/src/__tests__/export-contracts.test.ts +0 -83
  469. package/src/__tests__/fixtures/acknowledged-differences.json +0 -127
  470. package/src/__tests__/fixtures/acknowledged-differences.schema.json +0 -113
  471. package/src/__tests__/fixtures/acknowledged-differences.types.ts +0 -230
  472. package/src/__tests__/fixtures/tokenFixtures.ts +0 -248
  473. package/src/__tests__/helpers/configModuleLoader.ts +0 -20
  474. package/src/__tests__/helpers/tsModuleLoader.ts +0 -24
  475. package/src/__tests__/helpers/web-component-test-utils.ts +0 -39
  476. package/src/__tests__/integration/BlendCrossPlatformConsistency.test.ts +0 -505
  477. package/src/__tests__/integration/BuildSystemCompatibility.test.ts +0 -551
  478. package/src/__tests__/integration/CrossPlatformConsistency.test.ts +0 -855
  479. package/src/__tests__/integration/EndToEndWorkflow.test.ts +0 -601
  480. package/src/__tests__/integration/ErrorHandling.test.ts +0 -459
  481. package/src/__tests__/integration/OpacityPlatformTranslation.test.ts +0 -364
  482. package/src/__tests__/integration/PerformanceValidation.test.ts +0 -887
  483. package/src/__tests__/integration/SemanticTokenGeneration.test.ts +0 -451
  484. package/src/__tests__/integration/Spec107-DesignLanguageContext.test.ts +0 -139
  485. package/src/__tests__/integration/TokenSystemIntegration.test.ts +0 -890
  486. package/src/__tests__/integration/ValidationPipeline.test.ts +0 -404
  487. package/src/__tests__/package-drift-validation.test.ts +0 -249
  488. package/src/__tests__/performance/GenerationPerformance.test.ts +0 -409
  489. package/src/__tests__/performance/OptimizationValidation.test.ts +0 -509
  490. package/src/__tests__/platform-parity/ProgressPlatformParity.test.ts +0 -546
  491. package/src/__tests__/spec073-opacity-architecture.test.ts +0 -344
  492. package/src/__tests__/stemma-system/behavioral-contract-validation.test.ts +0 -520
  493. package/src/__tests__/stemma-system/composition-compliance-validation.test.ts +0 -162
  494. package/src/__tests__/stemma-system/contract-catalog-name-validation.test.ts +0 -184
  495. package/src/__tests__/stemma-system/contract-existence-validation.test.ts +0 -43
  496. package/src/__tests__/stemma-system/contract-test-reporter.ts +0 -269
  497. package/src/__tests__/stemma-system/cross-platform-consistency.test.ts +0 -564
  498. package/src/__tests__/stemma-system/form-inputs-contracts.test.ts +0 -710
  499. package/src/__tests__/stemma-system/input-text-native-base-call-alignment.test.ts +0 -298
  500. package/src/__tests__/stemma-system/mcp-component-integration.test.ts +0 -445
  501. package/src/analytics/PrimitiveTokenFallbackTracker.ts +0 -228
  502. package/src/analytics/SemanticTokenUsageTracker.ts +0 -193
  503. package/src/analytics/StrategicFlexibilityTracker.ts +0 -226
  504. package/src/analytics/TokenUsageTracker.ts +0 -177
  505. package/src/analytics/UsagePatternAnalyzer.ts +0 -177
  506. package/src/analytics/__tests__/UsageTracking.test.ts +0 -647
  507. package/src/analytics/index.ts +0 -42
  508. package/src/assets/fonts/__tests__/androidFontLoadingValidation.test.ts +0 -600
  509. package/src/assets/fonts/__tests__/fontLoading.test.ts +0 -341
  510. package/src/assets/fonts/__tests__/iosFontConfiguration.test.ts +0 -256
  511. package/src/assets/fonts/__tests__/iosFontLoadingValidation.test.ts +0 -465
  512. package/src/assets/fonts/inter/Inter-Bold.ttf +0 -0
  513. package/src/assets/fonts/inter/Inter-Bold.woff2 +0 -0
  514. package/src/assets/fonts/inter/Inter-Medium.ttf +0 -0
  515. package/src/assets/fonts/inter/Inter-Medium.woff2 +0 -0
  516. package/src/assets/fonts/inter/Inter-Regular.ttf +0 -0
  517. package/src/assets/fonts/inter/Inter-Regular.woff2 +0 -0
  518. package/src/assets/fonts/inter/Inter-SemiBold.ttf +0 -0
  519. package/src/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
  520. package/src/assets/fonts/inter/inter.css +0 -49
  521. package/src/blend/BlendCalculator.ts +0 -120
  522. package/src/blend/ColorSpaceUtils.ts +0 -325
  523. package/src/blend/OklchBlendCalculator.ts +0 -82
  524. package/src/blend/ThemeAwareBlendUtilities.web.ts +0 -323
  525. package/src/blend/__tests__/BlendCalculator.test.ts +0 -393
  526. package/src/blend/__tests__/BlendUtilities.property.test.ts +0 -600
  527. package/src/blend/__tests__/ColorSpaceUtils.test.ts +0 -885
  528. package/src/blend/__tests__/InteractionStateAudit.test.ts +0 -238
  529. package/src/blend/__tests__/OklchBlendCalculator.test.ts +0 -134
  530. package/src/blend/__tests__/ThemeAwareBlendUtilities.test.ts +0 -200
  531. package/src/blend/__tests__/ThemeSwitching.test.ts +0 -508
  532. package/src/blend/index.ts +0 -37
  533. package/src/browser-entry.ts +0 -270
  534. package/src/build/.gitkeep +0 -1
  535. package/src/build/BuildOrchestrator.ts +0 -663
  536. package/src/build/__tests__/AndroidBuildIntegration.test.ts +0 -437
  537. package/src/build/__tests__/AndroidMotionTokenGeneration.test.ts +0 -256
  538. package/src/build/__tests__/BuildOrchestrator.test.ts +0 -562
  539. package/src/build/__tests__/MotionTokenCrossPlatformIntegration.test.ts +0 -424
  540. package/src/build/__tests__/WebCSSTokenGeneration.test.ts +0 -271
  541. package/src/build/__tests__/WebMotionTokenGeneration.test.ts +0 -305
  542. package/src/build/__tests__/WebNPMPackageStructure.test.ts +0 -447
  543. package/src/build/__tests__/iOSMotionTokenGeneration.test.ts +0 -298
  544. package/src/build/errors/BuildError.ts +0 -140
  545. package/src/build/errors/ErrorDocumentation.ts +0 -638
  546. package/src/build/errors/ErrorHandler.ts +0 -406
  547. package/src/build/errors/ErrorReporter.ts +0 -573
  548. package/src/build/errors/PlatformGenerationError.ts +0 -201
  549. package/src/build/errors/README.md +0 -486
  550. package/src/build/errors/RecoveryStrategy.ts +0 -393
  551. package/src/build/errors/TokenGenerationError.ts +0 -196
  552. package/src/build/errors/TokenReferenceError.ts +0 -204
  553. package/src/build/errors/__tests__/BuildError.test.ts +0 -212
  554. package/src/build/errors/__tests__/ErrorDocumentation.example.ts +0 -272
  555. package/src/build/errors/__tests__/ErrorDocumentation.test.ts +0 -458
  556. package/src/build/errors/__tests__/ErrorHandler.integration.test.ts +0 -303
  557. package/src/build/errors/__tests__/ErrorHandler.test.ts +0 -502
  558. package/src/build/errors/__tests__/ErrorReporter.test.ts +0 -581
  559. package/src/build/errors/__tests__/MotionTokenErrors.test.ts +0 -392
  560. package/src/build/errors/__tests__/RecoveryStrategy.test.ts +0 -643
  561. package/src/build/errors/index.ts +0 -90
  562. package/src/build/index.ts +0 -73
  563. package/src/build/orchestration/IncrementalBuilder.ts +0 -532
  564. package/src/build/orchestration/ParallelExecutor.ts +0 -336
  565. package/src/build/orchestration/ProgressTracker.ts +0 -582
  566. package/src/build/orchestration/SequentialExecutor.ts +0 -305
  567. package/src/build/orchestration/__tests__/IncrementalBuilder.test.ts +0 -354
  568. package/src/build/orchestration/__tests__/ParallelExecutor.integration.test.ts +0 -295
  569. package/src/build/orchestration/__tests__/ParallelExecutor.test.ts +0 -493
  570. package/src/build/orchestration/__tests__/ProgressTracker.test.ts +0 -529
  571. package/src/build/orchestration/__tests__/SequentialExecutor.integration.test.ts +0 -202
  572. package/src/build/orchestration/__tests__/SequentialExecutor.test.ts +0 -232
  573. package/src/build/orchestration/index.ts +0 -35
  574. package/src/build/platforms/.gitkeep +0 -1
  575. package/src/build/platforms/AndroidBuilder.ts +0 -1366
  576. package/src/build/platforms/AndroidShadowGenerator.ts +0 -394
  577. package/src/build/platforms/IOSShadowGenerator.ts +0 -324
  578. package/src/build/platforms/PlatformBuilder.ts +0 -131
  579. package/src/build/platforms/WebBuilder.ts +0 -1414
  580. package/src/build/platforms/WebShadowGenerator.ts +0 -288
  581. package/src/build/platforms/__tests__/AndroidBuilder.tokenGeneration.test.ts +0 -146
  582. package/src/build/platforms/__tests__/AndroidShadowGenerator.test.ts +0 -195
  583. package/src/build/platforms/__tests__/IOSShadowGenerator.test.ts +0 -156
  584. package/src/build/platforms/__tests__/WebShadowGenerator.test.ts +0 -123
  585. package/src/build/platforms/__tests__/iOSBuilder.test.ts +0 -1599
  586. package/src/build/platforms/iOSBuilder.ts +0 -1746
  587. package/src/build/platforms/index.ts +0 -9
  588. package/src/build/product/ProductTokenGenerator.ts +0 -162
  589. package/src/build/product/TokenIndexReader.ts +0 -78
  590. package/src/build/product/__tests__/KotlinEmitter.test.ts +0 -109
  591. package/src/build/product/__tests__/ProductTokenGenerator.test.ts +0 -135
  592. package/src/build/product/__tests__/SwiftEmitter.test.ts +0 -90
  593. package/src/build/product/__tests__/TokenIndexReader.test.ts +0 -85
  594. package/src/build/product/__tests__/WebEmitter.test.ts +0 -111
  595. package/src/build/product/__tests__/fixtures/tokens/layout.yaml +0 -21
  596. package/src/build/product/__tests__/fixtures/tokens/motion.yaml +0 -11
  597. package/src/build/product/__tests__/fixtures/tokens/visualization.yaml +0 -8
  598. package/src/build/product/emitters/KotlinEmitter.ts +0 -83
  599. package/src/build/product/emitters/SwiftEmitter.ts +0 -95
  600. package/src/build/product/emitters/WebEmitter.ts +0 -69
  601. package/src/build/tokens/.gitkeep +0 -1
  602. package/src/build/tokens/__tests__/ClassInvariantGuard.test.ts +0 -167
  603. package/src/build/tokens/__tests__/ComponentTokenGenerator.test.ts +0 -285
  604. package/src/build/tokens/__tests__/TokenIntegrator.test.ts +0 -319
  605. package/src/build/tokens/__tests__/TokenSelector.test.ts +0 -264
  606. package/src/build/tokens/__tests__/UnitConverter.applyScaleWithRounding.test.ts +0 -160
  607. package/src/build/tokens/__tests__/UnitConverter.test.ts +0 -331
  608. package/src/build/tokens/__tests__/brand-dual-instance.test.ts +0 -135
  609. package/src/build/tokens/__tests__/defineComponentTokens.test.ts +0 -440
  610. package/src/build/types/.gitkeep +0 -1
  611. package/src/build/types/BuildConfig.ts +0 -123
  612. package/src/build/types/BuildOrchestrator.ts +0 -114
  613. package/src/build/types/BuildResult.ts +0 -125
  614. package/src/build/types/index.ts +0 -39
  615. package/src/build/validation/.gitkeep +0 -1
  616. package/src/build/validation/AndroidBuildValidator.ts +0 -630
  617. package/src/build/validation/CrossPlatformValidationReporter.ts +0 -1267
  618. package/src/build/validation/InterfaceContractValidator.ts +0 -417
  619. package/src/build/validation/InterfaceValidator.ts +0 -326
  620. package/src/build/validation/MathematicalConsistencyValidator.ts +0 -874
  621. package/src/build/validation/MethodSignatureValidator.ts +0 -374
  622. package/src/build/validation/PropertyTypeValidator.ts +0 -312
  623. package/src/build/validation/TokenComparator.ts +0 -796
  624. package/src/build/validation/ValidationReporter.example.ts +0 -310
  625. package/src/build/validation/ValidationReporter.ts +0 -745
  626. package/src/build/validation/WebBuildValidator.ts +0 -583
  627. package/src/build/validation/__tests__/AndroidBuildValidator.test.ts +0 -522
  628. package/src/build/validation/__tests__/CrossPlatformValidationReporter.test.ts +0 -593
  629. package/src/build/validation/__tests__/InterfaceContractValidator.test.ts +0 -647
  630. package/src/build/validation/__tests__/InterfaceValidation.functional.test.ts +0 -360
  631. package/src/build/validation/__tests__/InterfaceValidator.test.ts +0 -318
  632. package/src/build/validation/__tests__/MethodSignatureValidator.test.ts +0 -625
  633. package/src/build/validation/__tests__/MotionTokenCrossPlatformValidation.test.ts +0 -305
  634. package/src/build/validation/__tests__/MotionTokenValidation.test.ts +0 -309
  635. package/src/build/validation/__tests__/PropertyTypeValidator.test.ts +0 -557
  636. package/src/build/validation/__tests__/TokenComparator.test.ts +0 -358
  637. package/src/build/validation/__tests__/ValidationReporter.integration.test.ts +0 -424
  638. package/src/build/validation/__tests__/ValidationReporter.test.ts +0 -793
  639. package/src/build/validation/__tests__/WebBuildValidator.test.ts +0 -495
  640. package/src/build/validation/iOSBuildValidator.ts +0 -783
  641. package/src/build/validation/index.ts +0 -74
  642. package/src/build/validation/types/InterfaceDefinition.ts +0 -101
  643. package/src/build/validation/types/ValidationResult.ts +0 -114
  644. package/src/build/workflow/BuildMode.ts +0 -336
  645. package/src/build/workflow/CICDIntegration.ts +0 -503
  646. package/src/build/workflow/ConfigHelpers.example.ts +0 -317
  647. package/src/build/workflow/ConfigHelpers.ts +0 -834
  648. package/src/build/workflow/README.md +0 -327
  649. package/src/build/workflow/SourceMapGenerator.ts +0 -362
  650. package/src/build/workflow/__tests__/BuildMode.test.ts +0 -544
  651. package/src/build/workflow/__tests__/CICDIntegration.test.ts +0 -602
  652. package/src/build/workflow/__tests__/ConfigHelpers.test.ts +0 -559
  653. package/src/build/workflow/__tests__/SourceMapGenerator.test.ts +0 -421
  654. package/src/build/workflow/index.ts +0 -42
  655. package/src/cli/__tests__/Applier.test.ts +0 -202
  656. package/src/cli/__tests__/Classifier.test.ts +0 -187
  657. package/src/cli/__tests__/FileScanner.test.ts +0 -108
  658. package/src/cli/__tests__/IgnoreFilter.test.ts +0 -92
  659. package/src/cli/__tests__/Manifest.test.ts +0 -107
  660. package/src/cli/__tests__/PackageResolver.test.ts +0 -66
  661. package/src/cli/__tests__/Prompter.test.ts +0 -165
  662. package/src/cli/__tests__/Reporter.test.ts +0 -128
  663. package/src/cli/__tests__/backward-compat.test.ts +0 -142
  664. package/src/cli/__tests__/figma-extract.test.ts +0 -342
  665. package/src/cli/__tests__/figma-push.test.ts +0 -350
  666. package/src/cli/__tests__/init.test.ts +0 -293
  667. package/src/cli/__tests__/loadComponentTokens.test.ts +0 -187
  668. package/src/cli/__tests__/pipeline-independence.test.ts +0 -127
  669. package/src/cli/__tests__/product-only.test.ts +0 -130
  670. package/src/cli/__tests__/resolveTokens.test.ts +0 -88
  671. package/src/cli/__tests__/staleness.test.ts +0 -132
  672. package/src/cli/__tests__/sync.test.ts +0 -199
  673. package/src/cli/__tests__/validate.test.ts +0 -69
  674. package/src/cli/designerpunk.ts +0 -410
  675. package/src/cli/figma-extract.ts +0 -331
  676. package/src/cli/figma-push.ts +0 -288
  677. package/src/cli/generateProductTokens.ts +0 -69
  678. package/src/cli/init.ts +0 -481
  679. package/src/cli/loadComponentTokens.ts +0 -145
  680. package/src/cli/resolveTokens.ts +0 -123
  681. package/src/cli/shared/mcpDataRoots.ts +0 -122
  682. package/src/cli/shared/resolvePackageRoot.ts +0 -58
  683. package/src/cli/shared/transforms.ts +0 -18
  684. package/src/cli/staleness.ts +0 -81
  685. package/src/cli/sync/Applier.ts +0 -128
  686. package/src/cli/sync/Classifier.ts +0 -130
  687. package/src/cli/sync/FileScanner.ts +0 -64
  688. package/src/cli/sync/IgnoreFilter.ts +0 -44
  689. package/src/cli/sync/Manifest.ts +0 -64
  690. package/src/cli/sync/PackageResolver.ts +0 -40
  691. package/src/cli/sync/Prompter.ts +0 -173
  692. package/src/cli/sync/Reporter.ts +0 -78
  693. package/src/cli/sync/SteeringDirCheck.ts +0 -166
  694. package/src/cli/sync/index.ts +0 -115
  695. package/src/cli/validate.ts +0 -135
  696. package/src/cli/validateProductTokens.ts +0 -55
  697. package/src/color/OklchConverter.ts +0 -284
  698. package/src/color/OklchValidator.ts +0 -186
  699. package/src/color/__tests__/OklchConverter.test.ts +0 -232
  700. package/src/color/__tests__/OklchRegression.test.ts +0 -101
  701. package/src/color/__tests__/OklchValidator.test.ts +0 -199
  702. package/src/color/__tests__/WcagContrast.test.ts +0 -76
  703. package/src/components/__tests__/BlendTokenUsageValidation.test.ts +0 -726
  704. package/src/components/__tests__/DynamicImportGuard.test.ts +0 -226
  705. package/src/components/__tests__/ExtensionLintPolicy.test.ts +0 -113
  706. package/src/components/__tests__/TokenCompliance.test.ts +0 -921
  707. package/src/components/__tests__/colorInheritanceValidation.test.ts +0 -267
  708. package/src/components/__tests__/componentTypographyInheritance.test.ts +0 -326
  709. package/src/components/core/Avatar-Base/README.md +0 -366
  710. package/src/components/core/Avatar-Base/__tests__/.gitkeep +0 -3
  711. package/src/components/core/Avatar-Base/__tests__/Avatar.accessibility.test.ts +0 -597
  712. package/src/components/core/Avatar-Base/__tests__/Avatar.icon-integration.test.ts +0 -656
  713. package/src/components/core/Avatar-Base/__tests__/Avatar.image.test.ts +0 -396
  714. package/src/components/core/Avatar-Base/__tests__/Avatar.lifecycle.test.ts +0 -545
  715. package/src/components/core/Avatar-Base/__tests__/Avatar.rendering.test.ts +0 -505
  716. package/src/components/core/Avatar-Base/__tests__/Avatar.test.ts +0 -701
  717. package/src/components/core/Avatar-Base/avatar.tokens.ts +0 -376
  718. package/src/components/core/Avatar-Base/index.ts +0 -25
  719. package/src/components/core/Avatar-Base/platforms/ios/.gitkeep +0 -3
  720. package/src/components/core/Avatar-Base/platforms/web/.gitkeep +0 -3
  721. package/src/components/core/Avatar-Base/platforms/web/Avatar.styles.css +0 -595
  722. package/src/components/core/Avatar-Base/platforms/web/Avatar.web.ts +0 -892
  723. package/src/components/core/Avatar-Base/platforms/web/hexagon-clip.svg +0 -87
  724. package/src/components/core/Avatar-Base/tokens/.gitkeep +0 -4
  725. package/src/components/core/Avatar-Base/types.ts +0 -86
  726. package/src/components/core/Badge-Count-Base/README.md +0 -323
  727. package/src/components/core/Badge-Count-Base/__tests__/BadgeCountBase.stemma.test.ts +0 -548
  728. package/src/components/core/Badge-Count-Base/__tests__/BadgeCountBase.test.ts +0 -452
  729. package/src/components/core/Badge-Count-Base/__tests__/test-utils.ts +0 -244
  730. package/src/components/core/Badge-Count-Base/index.ts +0 -37
  731. package/src/components/core/Badge-Count-Base/platforms/ios/.gitkeep +0 -1
  732. package/src/components/core/Badge-Count-Base/platforms/web/BadgeCountBase.styles.css +0 -148
  733. package/src/components/core/Badge-Count-Base/platforms/web/BadgeCountBase.web.ts +0 -363
  734. package/src/components/core/Badge-Count-Base/types.ts +0 -150
  735. package/src/components/core/Badge-Count-Notification/README.md +0 -396
  736. package/src/components/core/Badge-Count-Notification/__tests__/BadgeCountNotification.stemma.test.ts +0 -571
  737. package/src/components/core/Badge-Count-Notification/__tests__/BadgeCountNotification.test.ts +0 -490
  738. package/src/components/core/Badge-Count-Notification/__tests__/test-utils.ts +0 -256
  739. package/src/components/core/Badge-Count-Notification/index.ts +0 -60
  740. package/src/components/core/Badge-Count-Notification/platforms/web/BadgeCountNotification.styles.css +0 -182
  741. package/src/components/core/Badge-Count-Notification/platforms/web/BadgeCountNotification.web.ts +0 -401
  742. package/src/components/core/Badge-Count-Notification/tokens.ts +0 -124
  743. package/src/components/core/Badge-Count-Notification/types.ts +0 -119
  744. package/src/components/core/Badge-Label-Base/README.md +0 -251
  745. package/src/components/core/Badge-Label-Base/__tests__/BadgeLabelBase.stemma.test.ts +0 -549
  746. package/src/components/core/Badge-Label-Base/__tests__/BadgeLabelBase.test.ts +0 -439
  747. package/src/components/core/Badge-Label-Base/__tests__/test-utils.ts +0 -269
  748. package/src/components/core/Badge-Label-Base/__tests__/tokens.test.ts +0 -88
  749. package/src/components/core/Badge-Label-Base/index.ts +0 -41
  750. package/src/components/core/Badge-Label-Base/platforms/web/BadgeLabelBase.styles.css +0 -166
  751. package/src/components/core/Badge-Label-Base/platforms/web/BadgeLabelBase.web.ts +0 -340
  752. package/src/components/core/Badge-Label-Base/tokens.ts +0 -80
  753. package/src/components/core/Badge-Label-Base/types.ts +0 -148
  754. package/src/components/core/Button-CTA/Button-CTA.tokens.ts +0 -79
  755. package/src/components/core/Button-CTA/README.md +0 -293
  756. package/src/components/core/Button-CTA/__tests__/ButtonCTA.alignment.test.ts +0 -355
  757. package/src/components/core/Button-CTA/__tests__/ButtonCTA.test.ts +0 -698
  758. package/src/components/core/Button-CTA/__tests__/ButtonCTA.tokens.test.ts +0 -89
  759. package/src/components/core/Button-CTA/__tests__/setup.test.ts +0 -209
  760. package/src/components/core/Button-CTA/__tests__/test-utils.ts +0 -185
  761. package/src/components/core/Button-CTA/examples/BasicUsage.html +0 -133
  762. package/src/components/core/Button-CTA/examples/BasicUsage.tsx +0 -219
  763. package/src/components/core/Button-CTA/examples/Variants.html +0 -263
  764. package/src/components/core/Button-CTA/examples/WithIcon.html +0 -166
  765. package/src/components/core/Button-CTA/index.ts +0 -20
  766. package/src/components/core/Button-CTA/platforms/web/ButtonCTA.web.css +0 -395
  767. package/src/components/core/Button-CTA/platforms/web/ButtonCTA.web.ts +0 -644
  768. package/src/components/core/Button-CTA/platforms/web/__tests__/ButtonCTA.icon-integration.test.ts +0 -476
  769. package/src/components/core/Button-CTA/types.ts +0 -239
  770. package/src/components/core/Button-Icon/README.md +0 -371
  771. package/src/components/core/Button-Icon/__tests__/ButtonIcon.alignment.test.ts +0 -358
  772. package/src/components/core/Button-Icon/__tests__/ButtonIcon.properties-8-13.test.ts +0 -953
  773. package/src/components/core/Button-Icon/__tests__/ButtonIcon.properties.test.ts +0 -920
  774. package/src/components/core/Button-Icon/__tests__/ButtonIcon.stemma.test.ts +0 -622
  775. package/src/components/core/Button-Icon/__tests__/ButtonIcon.unit.test.ts +0 -560
  776. package/src/components/core/Button-Icon/__tests__/setup.test.ts +0 -361
  777. package/src/components/core/Button-Icon/__tests__/test-utils.ts +0 -248
  778. package/src/components/core/Button-Icon/buttonIcon.tokens.ts +0 -202
  779. package/src/components/core/Button-Icon/platforms/web/.gitkeep +0 -4
  780. package/src/components/core/Button-Icon/platforms/web/ButtonIcon.web.css +0 -600
  781. package/src/components/core/Button-Icon/platforms/web/ButtonIcon.web.ts +0 -625
  782. package/src/components/core/Button-Icon/types.ts +0 -186
  783. package/src/components/core/Button-VerticalList-Item/Button-VerticalList-Item.tokens.ts +0 -112
  784. package/src/components/core/Button-VerticalList-Item/README.md +0 -450
  785. package/src/components/core/Button-VerticalList-Item/__tests__/.gitkeep +0 -2
  786. package/src/components/core/Button-VerticalList-Item/__tests__/ButtonVerticalListItem.alignment.test.ts +0 -271
  787. package/src/components/core/Button-VerticalList-Item/__tests__/ButtonVerticalListItem.failLoudly.test.ts +0 -106
  788. package/src/components/core/Button-VerticalList-Item/__tests__/ButtonVerticalListItem.integration.test.ts +0 -480
  789. package/src/components/core/Button-VerticalList-Item/__tests__/ButtonVerticalListItem.properties.test.ts +0 -634
  790. package/src/components/core/Button-VerticalList-Item/__tests__/ButtonVerticalListItem.unit.test.ts +0 -746
  791. package/src/components/core/Button-VerticalList-Item/__tests__/rtlSupport.test.ts +0 -206
  792. package/src/components/core/Button-VerticalList-Item/__tests__/test-utils.ts +0 -297
  793. package/src/components/core/Button-VerticalList-Item/__tests__/visualStateMapping.test.ts +0 -419
  794. package/src/components/core/Button-VerticalList-Item/index.ts +0 -49
  795. package/src/components/core/Button-VerticalList-Item/platforms/android/VerticalListButtonItemTest.kt +0 -1109
  796. package/src/components/core/Button-VerticalList-Item/platforms/ios/.gitkeep +0 -2
  797. package/src/components/core/Button-VerticalList-Item/platforms/ios/VerticalListButtonItemTests.swift +0 -794
  798. package/src/components/core/Button-VerticalList-Item/platforms/web/.gitkeep +0 -2
  799. package/src/components/core/Button-VerticalList-Item/platforms/web/ButtonVerticalListItem.styles.css +0 -459
  800. package/src/components/core/Button-VerticalList-Item/platforms/web/ButtonVerticalListItem.web.ts +0 -1030
  801. package/src/components/core/Button-VerticalList-Item/platforms/web/visualStateMapping.ts +0 -411
  802. package/src/components/core/Button-VerticalList-Item/types.ts +0 -338
  803. package/src/components/core/Button-VerticalList-Set/README.md +0 -578
  804. package/src/components/core/Button-VerticalList-Set/__tests__/.gitkeep +0 -5
  805. package/src/components/core/Button-VerticalList-Set/__tests__/ButtonVerticalListSet.integration.test.ts +0 -676
  806. package/src/components/core/Button-VerticalList-Set/__tests__/ButtonVerticalListSet.property.test.ts +0 -786
  807. package/src/components/core/Button-VerticalList-Set/__tests__/ButtonVerticalListSet.property2.test.ts +0 -1109
  808. package/src/components/core/Button-VerticalList-Set/__tests__/ButtonVerticalListSet.unit.test.ts +0 -924
  809. package/src/components/core/Button-VerticalList-Set/__tests__/animationTiming.test.ts +0 -182
  810. package/src/components/core/Button-VerticalList-Set/__tests__/crossPlatformConsistency.test.ts +0 -685
  811. package/src/components/core/Button-VerticalList-Set/__tests__/deriveItemStates.test.ts +0 -179
  812. package/src/components/core/Button-VerticalList-Set/__tests__/validation.test.ts +0 -275
  813. package/src/components/core/Button-VerticalList-Set/index.ts +0 -32
  814. package/src/components/core/Button-VerticalList-Set/platforms/android/ButtonVerticalListSetTest.kt +0 -961
  815. package/src/components/core/Button-VerticalList-Set/platforms/ios/.gitkeep +0 -0
  816. package/src/components/core/Button-VerticalList-Set/platforms/ios/ButtonVerticalListSetTests.swift +0 -475
  817. package/src/components/core/Button-VerticalList-Set/platforms/web/.gitkeep +0 -4
  818. package/src/components/core/Button-VerticalList-Set/platforms/web/Button-VerticalList-Set.styles.css +0 -167
  819. package/src/components/core/Button-VerticalList-Set/platforms/web/ButtonVerticalListSet.web.ts +0 -1446
  820. package/src/components/core/Button-VerticalList-Set/types.ts +0 -788
  821. package/src/components/core/Chip-Base/__tests__/ChipBase.test.ts +0 -534
  822. package/src/components/core/Chip-Base/index.ts +0 -40
  823. package/src/components/core/Chip-Base/platforms/ios/.gitkeep +0 -3
  824. package/src/components/core/Chip-Base/platforms/web/.gitkeep +0 -5
  825. package/src/components/core/Chip-Base/platforms/web/ChipBase.styles.css +0 -280
  826. package/src/components/core/Chip-Base/platforms/web/ChipBase.web.ts +0 -480
  827. package/src/components/core/Chip-Base/types.ts +0 -189
  828. package/src/components/core/Chip-Filter/__tests__/ChipFilter.test.ts +0 -592
  829. package/src/components/core/Chip-Filter/index.ts +0 -34
  830. package/src/components/core/Chip-Filter/platforms/web/ChipFilter.styles.css +0 -105
  831. package/src/components/core/Chip-Filter/platforms/web/ChipFilter.web.ts +0 -539
  832. package/src/components/core/Chip-Filter/types.ts +0 -47
  833. package/src/components/core/Chip-Input/__tests__/ChipInput.test.ts +0 -472
  834. package/src/components/core/Chip-Input/index.ts +0 -35
  835. package/src/components/core/Chip-Input/platforms/ios/.gitkeep +0 -3
  836. package/src/components/core/Chip-Input/platforms/web/ChipInput.styles.css +0 -99
  837. package/src/components/core/Chip-Input/platforms/web/ChipInput.web.ts +0 -485
  838. package/src/components/core/Chip-Input/types.ts +0 -35
  839. package/src/components/core/Container-Base/README.md +0 -450
  840. package/src/components/core/Container-Base/__tests__/ContainerBase.test.ts +0 -712
  841. package/src/components/core/Container-Base/index.ts +0 -47
  842. package/src/components/core/Container-Base/platforms/web/ContainerBase.web.ts +0 -405
  843. package/src/components/core/Container-Base/platforms/web/styles.css +0 -198
  844. package/src/components/core/Container-Base/platforms/web/token-mapping.ts +0 -573
  845. package/src/components/core/Container-Base/tokens.ts +0 -241
  846. package/src/components/core/Container-Base/types.ts +0 -307
  847. package/src/components/core/Container-Card-Base/README.md +0 -506
  848. package/src/components/core/Container-Card-Base/__tests__/ContainerCardBase.composition.test.ts +0 -167
  849. package/src/components/core/Container-Card-Base/__tests__/ContainerCardBase.test.ts +0 -646
  850. package/src/components/core/Container-Card-Base/index.ts +0 -64
  851. package/src/components/core/Container-Card-Base/platforms/web/ContainerCardBase.web.ts +0 -373
  852. package/src/components/core/Container-Card-Base/tokens.ts +0 -224
  853. package/src/components/core/Container-Card-Base/types.ts +0 -332
  854. package/src/components/core/Icon-Base/README.md +0 -168
  855. package/src/components/core/Icon-Base/__tests__/IconBase.test.ts +0 -192
  856. package/src/components/core/Icon-Base/index.ts +0 -34
  857. package/src/components/core/Icon-Base/platforms/ios/ASSET_CATALOG_SETUP.md +0 -239
  858. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Contents.json +0 -6
  859. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/Contents.json +0 -9
  860. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/alert-circle.imageset/Contents.json +0 -15
  861. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/alert-circle.imageset/alert-circle.svg +0 -1
  862. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-down.imageset/Contents.json +0 -15
  863. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-down.imageset/arrow-down.svg +0 -1
  864. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-left.imageset/Contents.json +0 -15
  865. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-left.imageset/arrow-left.svg +0 -1
  866. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-right.imageset/Contents.json +0 -15
  867. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-right.imageset/arrow-right.svg +0 -1
  868. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-up.imageset/Contents.json +0 -15
  869. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/arrow-up.imageset/arrow-up.svg +0 -1
  870. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/award.imageset/Contents.json +0 -15
  871. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/award.imageset/award.svg +0 -1
  872. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/bell.imageset/Contents.json +0 -15
  873. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/bell.imageset/bell.svg +0 -1
  874. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/briefcase.imageset/Contents.json +0 -15
  875. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/briefcase.imageset/briefcase.svg +0 -1
  876. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/calendar.imageset/Contents.json +0 -15
  877. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/calendar.imageset/calendar.svg +0 -1
  878. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/check-circle.imageset/Contents.json +0 -15
  879. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/check-circle.imageset/check-circle.svg +0 -1
  880. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/check.imageset/Contents.json +0 -15
  881. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/check.imageset/check.svg +0 -1
  882. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/chevron-down.imageset/Contents.json +0 -15
  883. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/chevron-down.imageset/chevron-down.svg +0 -1
  884. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/chevron-left.imageset/Contents.json +0 -15
  885. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/chevron-left.imageset/chevron-left.svg +0 -1
  886. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/chevron-right.imageset/Contents.json +0 -15
  887. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/chevron-right.imageset/chevron-right.svg +0 -1
  888. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/circle.imageset/Contents.json +0 -15
  889. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/circle.imageset/circle.svg +0 -1
  890. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/clock.imageset/Contents.json +0 -15
  891. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/clock.imageset/clock.svg +0 -1
  892. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/credit-card.imageset/Contents.json +0 -15
  893. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/credit-card.imageset/credit-card.svg +0 -1
  894. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/dollar-sign.imageset/Contents.json +0 -15
  895. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/dollar-sign.imageset/dollar-sign.svg +0 -1
  896. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/external-link.imageset/Contents.json +0 -15
  897. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/external-link.imageset/external-link.svg +0 -1
  898. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/eye-off.imageset/Contents.json +0 -15
  899. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/eye-off.imageset/eye-off.svg +0 -1
  900. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/eye.imageset/Contents.json +0 -15
  901. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/eye.imageset/eye.svg +0 -1
  902. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/file-text.imageset/Contents.json +0 -15
  903. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/file-text.imageset/file-text.svg +0 -1
  904. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/filter.imageset/Contents.json +0 -15
  905. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/filter.imageset/filter.svg +0 -1
  906. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/globe.imageset/Contents.json +0 -15
  907. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/globe.imageset/globe.svg +0 -1
  908. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/heart.imageset/Contents.json +0 -15
  909. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/heart.imageset/heart.svg +0 -1
  910. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/info.imageset/Contents.json +0 -15
  911. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/info.imageset/info.svg +0 -1
  912. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/mail.imageset/Contents.json +0 -15
  913. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/mail.imageset/mail.svg +0 -1
  914. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/map-pin.imageset/Contents.json +0 -15
  915. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/map-pin.imageset/map-pin.svg +0 -1
  916. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/minus.imageset/Contents.json +0 -15
  917. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/minus.imageset/minus.svg +0 -1
  918. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/more-horizontal.imageset/Contents.json +0 -15
  919. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/more-horizontal.imageset/more-horizontal.svg +0 -1
  920. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/more-vertical.imageset/Contents.json +0 -15
  921. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/more-vertical.imageset/more-vertical.svg +0 -1
  922. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/phone.imageset/Contents.json +0 -15
  923. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/phone.imageset/phone.svg +0 -1
  924. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/plus.imageset/Contents.json +0 -15
  925. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/plus.imageset/plus.svg +0 -1
  926. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/refresh-cw.imageset/Contents.json +0 -15
  927. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/refresh-cw.imageset/refresh-cw.svg +0 -1
  928. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/save.imageset/Contents.json +0 -15
  929. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/save.imageset/save.svg +0 -1
  930. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/search.imageset/Contents.json +0 -15
  931. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/search.imageset/search.svg +0 -1
  932. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/settings.imageset/Contents.json +0 -15
  933. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/settings.imageset/settings.svg +0 -1
  934. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/share-2.imageset/Contents.json +0 -15
  935. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/share-2.imageset/share-2.svg +0 -1
  936. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/share.imageset/Contents.json +0 -15
  937. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/share.imageset/share.svg +0 -1
  938. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/shield.imageset/Contents.json +0 -15
  939. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/shield.imageset/shield.svg +0 -1
  940. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/smartphone.imageset/Contents.json +0 -15
  941. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/smartphone.imageset/smartphone.svg +0 -1
  942. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/smile.imageset/Contents.json +0 -15
  943. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/smile.imageset/smile.svg +0 -1
  944. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/star.imageset/Contents.json +0 -15
  945. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/star.imageset/star.svg +0 -1
  946. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/trending-up.imageset/Contents.json +0 -15
  947. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/trending-up.imageset/trending-up.svg +0 -1
  948. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/user-check.imageset/Contents.json +0 -15
  949. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/user-check.imageset/user-check.svg +0 -1
  950. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/user-x.imageset/Contents.json +0 -15
  951. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/user-x.imageset/user-x.svg +0 -1
  952. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/user.imageset/Contents.json +0 -15
  953. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/user.imageset/user.svg +0 -1
  954. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/users.imageset/Contents.json +0 -15
  955. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/users.imageset/users.svg +0 -1
  956. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/wifi.imageset/Contents.json +0 -15
  957. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/wifi.imageset/wifi.svg +0 -1
  958. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/x.imageset/Contents.json +0 -15
  959. package/src/components/core/Icon-Base/platforms/ios/Icons.xcassets/Icons/x.imageset/x.svg +0 -1
  960. package/src/components/core/Icon-Base/platforms/web/IconBase.web.ts +0 -553
  961. package/src/components/core/Icon-Base/platforms/web/assets/alert-circle.svg +0 -1
  962. package/src/components/core/Icon-Base/platforms/web/assets/arrow-down.svg +0 -1
  963. package/src/components/core/Icon-Base/platforms/web/assets/arrow-left.svg +0 -1
  964. package/src/components/core/Icon-Base/platforms/web/assets/arrow-right.svg +0 -1
  965. package/src/components/core/Icon-Base/platforms/web/assets/arrow-up.svg +0 -1
  966. package/src/components/core/Icon-Base/platforms/web/assets/award.svg +0 -1
  967. package/src/components/core/Icon-Base/platforms/web/assets/bell.svg +0 -1
  968. package/src/components/core/Icon-Base/platforms/web/assets/briefcase.svg +0 -1
  969. package/src/components/core/Icon-Base/platforms/web/assets/calendar.svg +0 -1
  970. package/src/components/core/Icon-Base/platforms/web/assets/check-circle.svg +0 -1
  971. package/src/components/core/Icon-Base/platforms/web/assets/check.svg +0 -1
  972. package/src/components/core/Icon-Base/platforms/web/assets/chevron-down.svg +0 -1
  973. package/src/components/core/Icon-Base/platforms/web/assets/chevron-left.svg +0 -1
  974. package/src/components/core/Icon-Base/platforms/web/assets/chevron-right.svg +0 -1
  975. package/src/components/core/Icon-Base/platforms/web/assets/circle.svg +0 -1
  976. package/src/components/core/Icon-Base/platforms/web/assets/clock.svg +0 -1
  977. package/src/components/core/Icon-Base/platforms/web/assets/credit-card.svg +0 -1
  978. package/src/components/core/Icon-Base/platforms/web/assets/dollar-sign.svg +0 -1
  979. package/src/components/core/Icon-Base/platforms/web/assets/external-link.svg +0 -1
  980. package/src/components/core/Icon-Base/platforms/web/assets/eye-off.svg +0 -1
  981. package/src/components/core/Icon-Base/platforms/web/assets/eye.svg +0 -1
  982. package/src/components/core/Icon-Base/platforms/web/assets/file-text.svg +0 -1
  983. package/src/components/core/Icon-Base/platforms/web/assets/filter.svg +0 -1
  984. package/src/components/core/Icon-Base/platforms/web/assets/globe.svg +0 -1
  985. package/src/components/core/Icon-Base/platforms/web/assets/heart.svg +0 -1
  986. package/src/components/core/Icon-Base/platforms/web/assets/info.svg +0 -1
  987. package/src/components/core/Icon-Base/platforms/web/assets/mail.svg +0 -1
  988. package/src/components/core/Icon-Base/platforms/web/assets/map-pin.svg +0 -1
  989. package/src/components/core/Icon-Base/platforms/web/assets/minus.svg +0 -1
  990. package/src/components/core/Icon-Base/platforms/web/assets/more-horizontal.svg +0 -1
  991. package/src/components/core/Icon-Base/platforms/web/assets/more-vertical.svg +0 -1
  992. package/src/components/core/Icon-Base/platforms/web/assets/phone.svg +0 -1
  993. package/src/components/core/Icon-Base/platforms/web/assets/plus.svg +0 -1
  994. package/src/components/core/Icon-Base/platforms/web/assets/refresh-cw.svg +0 -1
  995. package/src/components/core/Icon-Base/platforms/web/assets/save.svg +0 -1
  996. package/src/components/core/Icon-Base/platforms/web/assets/search.svg +0 -1
  997. package/src/components/core/Icon-Base/platforms/web/assets/settings.svg +0 -1
  998. package/src/components/core/Icon-Base/platforms/web/assets/share-2.svg +0 -1
  999. package/src/components/core/Icon-Base/platforms/web/assets/share.svg +0 -1
  1000. package/src/components/core/Icon-Base/platforms/web/assets/shield.svg +0 -1
  1001. package/src/components/core/Icon-Base/platforms/web/assets/smartphone.svg +0 -1
  1002. package/src/components/core/Icon-Base/platforms/web/assets/smile.svg +0 -1
  1003. package/src/components/core/Icon-Base/platforms/web/assets/star.svg +0 -1
  1004. package/src/components/core/Icon-Base/platforms/web/assets/trending-up.svg +0 -1
  1005. package/src/components/core/Icon-Base/platforms/web/assets/user-check.svg +0 -1
  1006. package/src/components/core/Icon-Base/platforms/web/assets/user-x.svg +0 -1
  1007. package/src/components/core/Icon-Base/platforms/web/assets/user.svg +0 -1
  1008. package/src/components/core/Icon-Base/platforms/web/assets/users.svg +0 -1
  1009. package/src/components/core/Icon-Base/platforms/web/assets/wifi.svg +0 -1
  1010. package/src/components/core/Icon-Base/platforms/web/assets/x.svg +0 -1
  1011. package/src/components/core/Icon-Base/platforms/web/styles.css +0 -203
  1012. package/src/components/core/Icon-Base/types.ts +0 -338
  1013. package/src/components/core/Input-Checkbox-Base/README.md +0 -390
  1014. package/src/components/core/Input-Checkbox-Base/__tests__/InputCheckboxBase.stemma.test.ts +0 -552
  1015. package/src/components/core/Input-Checkbox-Base/__tests__/InputCheckboxBase.test.ts +0 -878
  1016. package/src/components/core/Input-Checkbox-Base/checkbox-sizing.tokens.ts +0 -37
  1017. package/src/components/core/Input-Checkbox-Base/platforms/web/InputCheckboxBase.web.css +0 -477
  1018. package/src/components/core/Input-Checkbox-Base/platforms/web/InputCheckboxBase.web.ts +0 -561
  1019. package/src/components/core/Input-Checkbox-Base/types.ts +0 -399
  1020. package/src/components/core/Input-Checkbox-Legal/README.md +0 -554
  1021. package/src/components/core/Input-Checkbox-Legal/__tests__/InputCheckboxLegal.test.ts +0 -727
  1022. package/src/components/core/Input-Checkbox-Legal/platforms/ios/.gitkeep +0 -2
  1023. package/src/components/core/Input-Checkbox-Legal/platforms/web/InputCheckboxLegal.web.css +0 -112
  1024. package/src/components/core/Input-Checkbox-Legal/platforms/web/InputCheckboxLegal.web.ts +0 -505
  1025. package/src/components/core/Input-Checkbox-Legal/types.ts +0 -348
  1026. package/src/components/core/Input-Radio-Base/.gitkeep +0 -2
  1027. package/src/components/core/Input-Radio-Base/README.md +0 -427
  1028. package/src/components/core/Input-Radio-Base/__tests__/.gitkeep +0 -1
  1029. package/src/components/core/Input-Radio-Base/__tests__/InputRadioBase.form.test.ts +0 -299
  1030. package/src/components/core/Input-Radio-Base/__tests__/InputRadioBase.stemma.test.ts +0 -543
  1031. package/src/components/core/Input-Radio-Base/__tests__/InputRadioBase.test.ts +0 -429
  1032. package/src/components/core/Input-Radio-Base/platforms/ios/.gitkeep +0 -1
  1033. package/src/components/core/Input-Radio-Base/platforms/web/.gitkeep +0 -1
  1034. package/src/components/core/Input-Radio-Base/platforms/web/InputRadioBase.web.css +0 -504
  1035. package/src/components/core/Input-Radio-Base/platforms/web/InputRadioBase.web.ts +0 -648
  1036. package/src/components/core/Input-Radio-Base/radio-sizing.tokens.ts +0 -37
  1037. package/src/components/core/Input-Radio-Base/types.ts +0 -362
  1038. package/src/components/core/Input-Radio-Set/README.md +0 -373
  1039. package/src/components/core/Input-Radio-Set/__tests__/.gitkeep +0 -0
  1040. package/src/components/core/Input-Radio-Set/__tests__/InputRadioSet.stemma.test.ts +0 -493
  1041. package/src/components/core/Input-Radio-Set/__tests__/InputRadioSet.test.ts +0 -499
  1042. package/src/components/core/Input-Radio-Set/platforms/web/InputRadioSet.web.css +0 -99
  1043. package/src/components/core/Input-Radio-Set/platforms/web/InputRadioSet.web.ts +0 -790
  1044. package/src/components/core/Input-Radio-Set/types.ts +0 -301
  1045. package/src/components/core/Input-Text-Base/README.md +0 -258
  1046. package/src/components/core/Input-Text-Base/__tests__/focusIndicators.test.ts +0 -311
  1047. package/src/components/core/Input-Text-Base/__tests__/keyboardNavigation.test.ts +0 -444
  1048. package/src/components/core/Input-Text-Base/__tests__/labelAssociation.test.ts +0 -418
  1049. package/src/components/core/Input-Text-Base/__tests__/screenReaderSupport.test.ts +0 -405
  1050. package/src/components/core/Input-Text-Base/__tests__/setup.ts +0 -17
  1051. package/src/components/core/Input-Text-Base/__tests__/stateManagement.test.ts +0 -718
  1052. package/src/components/core/Input-Text-Base/__tests__/test-utils.ts +0 -81
  1053. package/src/components/core/Input-Text-Base/__tests__/touchTargetSizing.test.ts +0 -319
  1054. package/src/components/core/Input-Text-Base/platforms/web/InputTextBase.browser.ts +0 -241
  1055. package/src/components/core/Input-Text-Base/platforms/web/InputTextBase.web.css +0 -293
  1056. package/src/components/core/Input-Text-Base/platforms/web/InputTextBase.web.ts +0 -448
  1057. package/src/components/core/Input-Text-Base/stateManagement.ts +0 -267
  1058. package/src/components/core/Input-Text-Base/tokens.ts +0 -210
  1059. package/src/components/core/Input-Text-Base/types.ts +0 -114
  1060. package/src/components/core/Input-Text-Email/README.md +0 -252
  1061. package/src/components/core/Input-Text-Email/__tests__/validation.test.ts +0 -127
  1062. package/src/components/core/Input-Text-Email/platforms/web/InputTextEmail.browser.ts +0 -276
  1063. package/src/components/core/Input-Text-Email/platforms/web/InputTextEmail.web.ts +0 -319
  1064. package/src/components/core/Input-Text-Email/stateManagement.ts +0 -160
  1065. package/src/components/core/Input-Text-Email/tokens.ts +0 -33
  1066. package/src/components/core/Input-Text-Email/types.ts +0 -72
  1067. package/src/components/core/Input-Text-Email/validation.ts +0 -130
  1068. package/src/components/core/Input-Text-Password/README.md +0 -360
  1069. package/src/components/core/Input-Text-Password/__tests__/validation.test.ts +0 -362
  1070. package/src/components/core/Input-Text-Password/platforms/web/InputTextPassword.browser.ts +0 -434
  1071. package/src/components/core/Input-Text-Password/platforms/web/InputTextPassword.web.ts +0 -512
  1072. package/src/components/core/Input-Text-Password/stateManagement.ts +0 -244
  1073. package/src/components/core/Input-Text-Password/tokens.ts +0 -32
  1074. package/src/components/core/Input-Text-Password/types.ts +0 -177
  1075. package/src/components/core/Input-Text-Password/validation.ts +0 -207
  1076. package/src/components/core/Input-Text-PhoneNumber/README.md +0 -276
  1077. package/src/components/core/Input-Text-PhoneNumber/__tests__/validation.test.ts +0 -301
  1078. package/src/components/core/Input-Text-PhoneNumber/platforms/web/InputTextPhoneNumber.browser.ts +0 -370
  1079. package/src/components/core/Input-Text-PhoneNumber/platforms/web/InputTextPhoneNumber.web.ts +0 -393
  1080. package/src/components/core/Input-Text-PhoneNumber/stateManagement.ts +0 -250
  1081. package/src/components/core/Input-Text-PhoneNumber/tokens.ts +0 -33
  1082. package/src/components/core/Input-Text-PhoneNumber/types.ts +0 -135
  1083. package/src/components/core/Input-Text-PhoneNumber/validation.ts +0 -302
  1084. package/src/components/core/Nav-Header-App/README.md +0 -29
  1085. package/src/components/core/Nav-Header-App/index.ts +0 -5
  1086. package/src/components/core/Nav-Header-App/platforms/web/NavHeaderApp.web.ts +0 -37
  1087. package/src/components/core/Nav-Header-App/types.ts +0 -32
  1088. package/src/components/core/Nav-Header-Base/README.md +0 -21
  1089. package/src/components/core/Nav-Header-Base/index.ts +0 -12
  1090. package/src/components/core/Nav-Header-Base/platforms/web/NavHeaderBase.styles.css +0 -75
  1091. package/src/components/core/Nav-Header-Base/platforms/web/NavHeaderBase.web.ts +0 -120
  1092. package/src/components/core/Nav-Header-Base/types.ts +0 -63
  1093. package/src/components/core/Nav-Header-Page/README.md +0 -34
  1094. package/src/components/core/Nav-Header-Page/__tests__/NavHeaderPage.test.ts +0 -250
  1095. package/src/components/core/Nav-Header-Page/index.ts +0 -12
  1096. package/src/components/core/Nav-Header-Page/platforms/web/NavHeaderPage.styles.css +0 -90
  1097. package/src/components/core/Nav-Header-Page/platforms/web/NavHeaderPage.web.ts +0 -169
  1098. package/src/components/core/Nav-Header-Page/types.ts +0 -55
  1099. package/src/components/core/Nav-SegmentedChoice-Base/README.md +0 -327
  1100. package/src/components/core/Nav-SegmentedChoice-Base/__tests__/NavSegmentedChoiceBase.android.test.ts +0 -218
  1101. package/src/components/core/Nav-SegmentedChoice-Base/__tests__/NavSegmentedChoiceBase.interaction.test.ts +0 -419
  1102. package/src/components/core/Nav-SegmentedChoice-Base/__tests__/NavSegmentedChoiceBase.ios.test.ts +0 -207
  1103. package/src/components/core/Nav-SegmentedChoice-Base/__tests__/NavSegmentedChoiceBase.visual.test.ts +0 -371
  1104. package/src/components/core/Nav-SegmentedChoice-Base/index.ts +0 -38
  1105. package/src/components/core/Nav-SegmentedChoice-Base/platforms/web/NavSegmentedChoiceBase.styles.css +0 -160
  1106. package/src/components/core/Nav-SegmentedChoice-Base/platforms/web/NavSegmentedChoiceBase.web.ts +0 -477
  1107. package/src/components/core/Nav-SegmentedChoice-Base/types.ts +0 -65
  1108. package/src/components/core/Nav-TabBar-Base/README.md +0 -264
  1109. package/src/components/core/Nav-TabBar-Base/__tests__/NavTabBarBase.android.test.ts +0 -270
  1110. package/src/components/core/Nav-TabBar-Base/__tests__/NavTabBarBase.ios.test.ts +0 -221
  1111. package/src/components/core/Nav-TabBar-Base/__tests__/NavTabBarBase.test.ts +0 -421
  1112. package/src/components/core/Nav-TabBar-Base/examples/BasicUsage.html +0 -2
  1113. package/src/components/core/Nav-TabBar-Base/examples/BasicUsage.tsx +0 -2
  1114. package/src/components/core/Nav-TabBar-Base/index.ts +0 -20
  1115. package/src/components/core/Nav-TabBar-Base/platforms/web/NavTabBarBase.styles.css +0 -281
  1116. package/src/components/core/Nav-TabBar-Base/platforms/web/NavTabBarBase.web.ts +0 -420
  1117. package/src/components/core/Nav-TabBar-Base/types.ts +0 -43
  1118. package/src/components/core/Progress-Bar-Base/README.md +0 -31
  1119. package/src/components/core/Progress-Bar-Base/__tests__/ProgressBarBase.test.ts +0 -202
  1120. package/src/components/core/Progress-Bar-Base/index.ts +0 -6
  1121. package/src/components/core/Progress-Bar-Base/platforms/web/ProgressBarBase.styles.css +0 -52
  1122. package/src/components/core/Progress-Bar-Base/platforms/web/ProgressBarBase.web.ts +0 -135
  1123. package/src/components/core/Progress-Bar-Base/types.ts +0 -46
  1124. package/src/components/core/Progress-Indicator-Connector-Base/README.md +0 -169
  1125. package/src/components/core/Progress-Indicator-Connector-Base/index.ts +0 -33
  1126. package/src/components/core/Progress-Indicator-Connector-Base/platforms/web/ProgressIndicatorConnectorBase.styles.css +0 -50
  1127. package/src/components/core/Progress-Indicator-Connector-Base/platforms/web/ProgressIndicatorConnectorBase.web.ts +0 -141
  1128. package/src/components/core/Progress-Indicator-Connector-Base/types.ts +0 -67
  1129. package/src/components/core/Progress-Indicator-Label-Base/README.md +0 -191
  1130. package/src/components/core/Progress-Indicator-Label-Base/index.ts +0 -28
  1131. package/src/components/core/Progress-Indicator-Label-Base/platforms/web/ProgressIndicatorLabelBase.styles.css +0 -81
  1132. package/src/components/core/Progress-Indicator-Label-Base/platforms/web/ProgressIndicatorLabelBase.web.ts +0 -174
  1133. package/src/components/core/Progress-Indicator-Label-Base/types.ts +0 -64
  1134. package/src/components/core/Progress-Indicator-Node-Base/README.md +0 -206
  1135. package/src/components/core/Progress-Indicator-Node-Base/__tests__/VisualStates.test.ts +0 -259
  1136. package/src/components/core/Progress-Indicator-Node-Base/index.ts +0 -36
  1137. package/src/components/core/Progress-Indicator-Node-Base/platforms/web/ProgressIndicatorNodeBase.styles.css +0 -193
  1138. package/src/components/core/Progress-Indicator-Node-Base/platforms/web/ProgressIndicatorNodeBase.web.ts +0 -226
  1139. package/src/components/core/Progress-Indicator-Node-Base/types.ts +0 -142
  1140. package/src/components/core/Progress-Pagination-Base/README.md +0 -290
  1141. package/src/components/core/Progress-Pagination-Base/__tests__/PaginationBase.test.ts +0 -290
  1142. package/src/components/core/Progress-Pagination-Base/index.ts +0 -40
  1143. package/src/components/core/Progress-Pagination-Base/platforms/web/ProgressPaginationBase.styles.css +0 -80
  1144. package/src/components/core/Progress-Pagination-Base/platforms/web/ProgressPaginationBase.web.ts +0 -293
  1145. package/src/components/core/Progress-Pagination-Base/types.ts +0 -112
  1146. package/src/components/core/Progress-Stepper-Base/README.md +0 -311
  1147. package/src/components/core/Progress-Stepper-Base/__tests__/StepperBase.test.ts +0 -345
  1148. package/src/components/core/Progress-Stepper-Base/index.ts +0 -43
  1149. package/src/components/core/Progress-Stepper-Base/platforms/web/ProgressStepperBase.styles.css +0 -49
  1150. package/src/components/core/Progress-Stepper-Base/platforms/web/ProgressStepperBase.web.ts +0 -288
  1151. package/src/components/core/Progress-Stepper-Base/types.ts +0 -175
  1152. package/src/components/core/Progress-Stepper-Detailed/README.md +0 -401
  1153. package/src/components/core/Progress-Stepper-Detailed/__tests__/StepperDetailed.test.ts +0 -481
  1154. package/src/components/core/Progress-Stepper-Detailed/index.ts +0 -48
  1155. package/src/components/core/Progress-Stepper-Detailed/platforms/web/ProgressStepperDetailed.styles.css +0 -106
  1156. package/src/components/core/Progress-Stepper-Detailed/platforms/web/ProgressStepperDetailed.web.ts +0 -336
  1157. package/src/components/core/Progress-Stepper-Detailed/types.ts +0 -195
  1158. package/src/composition/BlendComposition.ts +0 -46
  1159. package/src/composition/BlendCompositionParser.ts +0 -215
  1160. package/src/composition/OpacityComposition.ts +0 -62
  1161. package/src/composition/OpacityCompositionParser.ts +0 -308
  1162. package/src/composition/__tests__/BlendCompositionParser.test.ts +0 -431
  1163. package/src/composition/__tests__/OpacityCompositionParser.test.ts +0 -539
  1164. package/src/composition/index.ts +0 -20
  1165. package/src/config/ConfigLoader.ts +0 -143
  1166. package/src/config/__resolution-matrix__/README.md +0 -76
  1167. package/src/config/__resolution-matrix__/fixtures/faithful-cjs/compiled/defineConfig.js +0 -9
  1168. package/src/config/__resolution-matrix__/fixtures/faithful-cjs/designerpunk.config.ts +0 -20
  1169. package/src/config/__resolution-matrix__/fixtures/faithful-cjs/my-overrides.ts +0 -8
  1170. package/src/config/__resolution-matrix__/fixtures/faithful-esm/compiled/defineConfig.js +0 -11
  1171. package/src/config/__resolution-matrix__/fixtures/faithful-esm/designerpunk.config.ts +0 -23
  1172. package/src/config/__resolution-matrix__/fixtures/faithful-esm/my-overrides.ts +0 -6
  1173. package/src/config/__resolution-matrix__/fixtures/source-dir-cjs/designerpunk.config.ts +0 -11
  1174. package/src/config/__resolution-matrix__/fixtures/source-dir-cjs/src/config/index.ts +0 -15
  1175. package/src/config/__resolution-matrix__/fixtures/source-dir-esm/designerpunk.config.ts +0 -15
  1176. package/src/config/__resolution-matrix__/fixtures/source-dir-esm/src/config/index.ts +0 -13
  1177. package/src/config/__resolution-matrix__/run-matrix.js +0 -107
  1178. package/src/config/__resolution-matrix__/runner.js +0 -153
  1179. package/src/config/__resolution-matrix__/verify-real-loadconfig.js +0 -122
  1180. package/src/config/__tests__/ConfigLoader.test.ts +0 -115
  1181. package/src/config/defineConfig.ts +0 -71
  1182. package/src/config/index.ts +0 -7
  1183. package/src/config/scopedTsRequire.ts +0 -62
  1184. package/src/constants/BaselineGrid.ts +0 -41
  1185. package/src/constants/SpacingTokens.ts +0 -55
  1186. package/src/figma/ComponentAnalysis.ts +0 -292
  1187. package/src/figma/ComponentAnalysisGenerator.ts +0 -444
  1188. package/src/figma/ConsoleMCPClient.ts +0 -168
  1189. package/src/figma/ConsoleMCPClientImpl.ts +0 -1034
  1190. package/src/figma/DesignExtractor.ts +0 -3620
  1191. package/src/figma/TokenSyncWorkflow.ts +0 -915
  1192. package/src/figma/TokenTranslator.ts +0 -891
  1193. package/src/figma/VariantAnalyzer.ts +0 -712
  1194. package/src/figma/__tests__/ComponentAnalysisGenerator.json.test.ts +0 -429
  1195. package/src/figma/__tests__/ComponentAnalysisGenerator.markdown.test.ts +0 -428
  1196. package/src/figma/__tests__/ConsoleMCPClient.bugfix.test.ts +0 -261
  1197. package/src/figma/__tests__/ConsoleMCPClient.preservation.test.ts +0 -395
  1198. package/src/figma/__tests__/ConsoleMCPClient.test.ts +0 -375
  1199. package/src/figma/__tests__/DesignExtractor.boundVariableResolution.test.ts +0 -580
  1200. package/src/figma/__tests__/DesignExtractor.buildNodeTree.test.ts +0 -535
  1201. package/src/figma/__tests__/DesignExtractor.captureComponentScreenshot.test.ts +0 -176
  1202. package/src/figma/__tests__/DesignExtractor.detectBehavioralContracts.test.ts +0 -263
  1203. package/src/figma/__tests__/DesignExtractor.detectComponentTokenDecisions.test.ts +0 -379
  1204. package/src/figma/__tests__/DesignExtractor.detectCompositionPatterns.test.ts +0 -507
  1205. package/src/figma/__tests__/DesignExtractor.detectPlatformParity.test.ts +0 -406
  1206. package/src/figma/__tests__/DesignExtractor.queryContext.test.ts +0 -214
  1207. package/src/figma/__tests__/DesignExtractor.readFigmaComponent.test.ts +0 -431
  1208. package/src/figma/__tests__/DesignExtractor.readStyles.test.ts +0 -204
  1209. package/src/figma/__tests__/DesignExtractor.readTokenBindings.test.ts +0 -268
  1210. package/src/figma/__tests__/DesignExtractor.reconstructCompositeTokens.test.ts +0 -403
  1211. package/src/figma/__tests__/DesignExtractor.resolveUnknownVariableIds.test.ts +0 -259
  1212. package/src/figma/__tests__/DesignExtractor.translateTokens.test.ts +0 -433
  1213. package/src/figma/__tests__/DesignExtractor.validateModes.test.ts +0 -350
  1214. package/src/figma/__tests__/TokenSyncWorkflow.batch.test.ts +0 -277
  1215. package/src/figma/__tests__/TokenSyncWorkflow.drift.test.ts +0 -187
  1216. package/src/figma/__tests__/TokenSyncWorkflow.preservation.test.ts +0 -544
  1217. package/src/figma/__tests__/TokenSyncWorkflow.styles.test.ts +0 -245
  1218. package/src/figma/__tests__/TokenSyncWorkflow.sync.test.ts +0 -217
  1219. package/src/figma/__tests__/TokenTranslator.test.ts +0 -757
  1220. package/src/figma/__tests__/VariantAnalyzer.detectConflicts.test.ts +0 -126
  1221. package/src/figma/__tests__/VariantAnalyzer.test.ts +0 -633
  1222. package/src/figma/__tests__/error-reporting.test.ts +0 -254
  1223. package/src/figma/__tests__/preflight.test.ts +0 -94
  1224. package/src/figma/error-reporting.ts +0 -260
  1225. package/src/figma/index.ts +0 -98
  1226. package/src/figma/portCleanup.ts +0 -86
  1227. package/src/figma/preflight.ts +0 -120
  1228. package/src/generators/BlendUtilityGenerator.ts +0 -847
  1229. package/src/generators/BlendValueGenerator.ts +0 -198
  1230. package/src/generators/DTCGFormatGenerator.ts +0 -1355
  1231. package/src/generators/DTCGGeneratorConfig.ts +0 -46
  1232. package/src/generators/ModeResolvedTokens.ts +0 -58
  1233. package/src/generators/ResponsiveGridGenerator.ts +0 -273
  1234. package/src/generators/TokenFileGenerator.ts +0 -2070
  1235. package/src/generators/__tests__/AccessibilityTokenGeneration.test.ts +0 -350
  1236. package/src/generators/__tests__/BlendUtilityGenerator.test.ts +0 -829
  1237. package/src/generators/__tests__/BlendValueGenerator.test.ts +0 -200
  1238. package/src/generators/__tests__/BreakpointTokenGeneration.test.ts +0 -172
  1239. package/src/generators/__tests__/CSSThemeScoping.test.ts +0 -153
  1240. package/src/generators/__tests__/DTCGConfigOptions.test.ts +0 -271
  1241. package/src/generators/__tests__/DTCGErrorHandling.test.ts +0 -139
  1242. package/src/generators/__tests__/DTCGFormatGenerator.integration.test.ts +0 -346
  1243. package/src/generators/__tests__/DTCGFormatGenerator.property.test.ts +0 -497
  1244. package/src/generators/__tests__/DTCGFormatGenerator.test.ts +0 -469
  1245. package/src/generators/__tests__/FigmaTransformer.styles.test.ts +0 -398
  1246. package/src/generators/__tests__/FigmaTransformer.variables.test.ts +0 -540
  1247. package/src/generators/__tests__/GridSpacingTokenGeneration.test.ts +0 -254
  1248. package/src/generators/__tests__/IconTokenGeneration.test.ts +0 -452
  1249. package/src/generators/__tests__/KotlinThemeTypes.test.ts +0 -110
  1250. package/src/generators/__tests__/ModeAwareGeneration.test.ts +0 -160
  1251. package/src/generators/__tests__/NativeOklchOutput.test.ts +0 -56
  1252. package/src/generators/__tests__/OklchExport.test.ts +0 -71
  1253. package/src/generators/__tests__/ProductRepoSimulation.test.ts +0 -91
  1254. package/src/generators/__tests__/ResponsiveGridGeneration.test.ts +0 -291
  1255. package/src/generators/__tests__/Spec076TokenMigration.test.ts +0 -106
  1256. package/src/generators/__tests__/Spec077ModesVerification.test.ts +0 -52
  1257. package/src/generators/__tests__/SwiftThemeTypes.test.ts +0 -122
  1258. package/src/generators/__tests__/TokenFileGenerator.test.ts +0 -914
  1259. package/src/generators/__tests__/TransformerRegistry.test.ts +0 -118
  1260. package/src/generators/__tests__/WcagValueExportSupport.test.ts +0 -84
  1261. package/src/generators/__tests__/WcagValueInfrastructure.test.ts +0 -122
  1262. package/src/generators/__tests__/WebOklchOutput.test.ts +0 -72
  1263. package/src/generators/__tests__/generateTokenIndex.test.ts +0 -204
  1264. package/src/generators/__tests__/helpers/defaultSemanticOptions.ts +0 -24
  1265. package/src/generators/generateTokenFiles.ts +0 -337
  1266. package/src/generators/generateTokenIndex.ts +0 -258
  1267. package/src/generators/oklch/OklchExportUtils.ts +0 -57
  1268. package/src/generators/oklch/OklchTokenIndexMetadata.ts +0 -30
  1269. package/src/generators/transformers/FigmaTransformer.ts +0 -912
  1270. package/src/generators/transformers/ITokenTransformer.ts +0 -56
  1271. package/src/generators/transformers/TransformerRegistry.ts +0 -63
  1272. package/src/generators/transformers/index.ts +0 -52
  1273. package/src/generators/types/DTCGTypes.ts +0 -101
  1274. package/src/integration/BuildErrorHandler.ts +0 -440
  1275. package/src/integration/BuildSystemInterface.ts +0 -338
  1276. package/src/integration/PlatformFileSelector.ts +0 -288
  1277. package/src/integration/RegistryCoordinator.ts +0 -404
  1278. package/src/integration/TranslationCoordinator.ts +0 -458
  1279. package/src/integration/TreeShakingOptimizer.ts +0 -350
  1280. package/src/integration/ValidationCoordinator.ts +0 -780
  1281. package/src/integration/__tests__/ComponentTokenValidation.test.ts +0 -762
  1282. package/src/integration/__tests__/ValidationCoordinator.test.ts +0 -609
  1283. package/src/integration/__tests__/performance/ComponentTokenValidationPerformance.test.ts +0 -161
  1284. package/src/integration/index.ts +0 -55
  1285. package/src/naming/NamingConventionManager.ts +0 -318
  1286. package/src/naming/PlatformNamingRules.ts +0 -278
  1287. package/src/naming/__tests__/NamingConventions.test.ts +0 -224
  1288. package/src/naming/index.ts +0 -23
  1289. package/src/parent-completion.md +0 -1
  1290. package/src/performance/CachingStrategy.ts +0 -426
  1291. package/src/performance/FileGenerationOptimizer.ts +0 -294
  1292. package/src/performance/PerformanceMonitor.ts +0 -185
  1293. package/src/performance/PerformanceOptimizer.ts +0 -348
  1294. package/src/performance/index.ts +0 -30
  1295. package/src/providers/AndroidFileOrganizer.ts +0 -241
  1296. package/src/providers/AndroidFormatGenerator.ts +0 -750
  1297. package/src/providers/AndroidUnitConverter.ts +0 -177
  1298. package/src/providers/FormatProvider.ts +0 -187
  1299. package/src/providers/PathProvider.ts +0 -197
  1300. package/src/providers/UnitProvider.ts +0 -106
  1301. package/src/providers/WebFileOrganizer.ts +0 -121
  1302. package/src/providers/WebFormatGenerator.ts +0 -611
  1303. package/src/providers/WebUnitConverter.ts +0 -116
  1304. package/src/providers/__tests__/AndroidAccessibilityTokens.test.ts +0 -86
  1305. package/src/providers/__tests__/AndroidFormatGenerator-semantic.test.ts +0 -494
  1306. package/src/providers/__tests__/FormatProviders.test.ts +0 -828
  1307. package/src/providers/__tests__/InsetTokenGeneration.test.ts +0 -627
  1308. package/src/providers/__tests__/PathProviders.test.ts +0 -512
  1309. package/src/providers/__tests__/PlatformOutputFormat.test.ts +0 -252
  1310. package/src/providers/__tests__/UnitProviders.test.ts +0 -721
  1311. package/src/providers/__tests__/WebFormatGenerator-semantic.test.ts +0 -293
  1312. package/src/providers/__tests__/iOSFormatGenerator-semantic.test.ts +0 -410
  1313. package/src/providers/iOSFileOrganizer.ts +0 -162
  1314. package/src/providers/iOSFormatGenerator.ts +0 -599
  1315. package/src/providers/iOSUnitConverter.ts +0 -125
  1316. package/src/providers/index.ts +0 -26
  1317. package/src/registries/ComponentTokenRegistry.ts +0 -292
  1318. package/src/registries/IRegistry.ts +0 -170
  1319. package/src/registries/__tests__/ComponentTokenRegistry.test.ts +0 -446
  1320. package/src/registries/__tests__/IRegistry.test.ts +0 -250
  1321. package/src/registries/__tests__/PrimitiveTokenRegistry.test.ts +0 -342
  1322. package/src/registries/__tests__/SemanticTokenRegistry.test.ts +0 -444
  1323. package/src/resolvers/AndroidColorResolver.ts +0 -333
  1324. package/src/resolvers/ModeThemeResolver.ts +0 -152
  1325. package/src/resolvers/SemanticOverrideResolver.ts +0 -155
  1326. package/src/resolvers/SemanticValueResolver.ts +0 -133
  1327. package/src/resolvers/WebColorResolver.ts +0 -240
  1328. package/src/resolvers/__tests__/AndroidColorResolver.test.ts +0 -507
  1329. package/src/resolvers/__tests__/ModeThemeResolver.test.ts +0 -411
  1330. package/src/resolvers/__tests__/SemanticOverrideResolver.test.ts +0 -186
  1331. package/src/resolvers/__tests__/WebColorResolver.test.ts +0 -405
  1332. package/src/resolvers/__tests__/iOSColorResolver.test.ts +0 -432
  1333. package/src/resolvers/iOSColorResolver.ts +0 -224
  1334. package/src/resolvers/index.ts +0 -11
  1335. package/src/security/AIAgentRestrictions.ts +0 -298
  1336. package/src/security/ContaminationAuditor.ts +0 -393
  1337. package/src/security/ContaminationPrevention.ts +0 -275
  1338. package/src/security/DocumentationGuard.ts +0 -258
  1339. package/src/security/FlexibilityTokenGuard.ts +0 -256
  1340. package/src/security/HumanApprovalWorkflow.ts +0 -319
  1341. package/src/security/__tests__/AIAgentRestrictions.test.ts +0 -482
  1342. package/src/security/__tests__/ContaminationPrevention.test.ts +0 -424
  1343. package/src/security/__tests__/SecurityIntegration.test.ts +0 -505
  1344. package/src/security/index.ts +0 -48
  1345. package/src/testing/__tests__/utilities.test.ts +0 -175
  1346. package/src/testing/index.ts +0 -154
  1347. package/src/testing/jest-preset.ts +0 -62
  1348. package/src/testing/style-mock.ts +0 -7
  1349. package/src/testing/validators.ts +0 -10
  1350. package/src/themes/ResolvedThemeSet.ts +0 -22
  1351. package/src/themes/ThemeRegistry.ts +0 -97
  1352. package/src/themes/__tests__/ThemeRegistry.test.ts +0 -162
  1353. package/src/tools/ThemeFileGenerator.ts +0 -109
  1354. package/src/tools/integrity/DiskFreshGenerator.ts +0 -36
  1355. package/src/tools/integrity/GenerationIntegrityCheck.ts +0 -132
  1356. package/src/tools/integrity/Invariants.ts +0 -228
  1357. package/src/tools/integrity/Normalizer.ts +0 -94
  1358. package/src/tools/integrity/SemanticComparator.ts +0 -127
  1359. package/src/tools/integrity/__tests__/GenerationIntegrityCheck.test.ts +0 -132
  1360. package/src/tools/integrity/__tests__/Invariants.test.ts +0 -142
  1361. package/src/tools/integrity/__tests__/Normalizer.test.ts +0 -65
  1362. package/src/tools/integrity/__tests__/SemanticComparator.test.ts +0 -62
  1363. package/src/tools/integrity/__tests__/consumer-package-mode.test.ts +0 -205
  1364. package/src/tools/integrity/cli/run-audit.ts +0 -150
  1365. package/src/tools/integrity/inventory.ts +0 -51
  1366. package/src/tools/integrity/manifest.ts +0 -56
  1367. package/src/tools/integrity/types/index.ts +0 -183
  1368. package/src/tools/release/__tests__/ChangeClassifier.test.ts +0 -133
  1369. package/src/tools/release/__tests__/ChangeExtractor.test.ts +0 -222
  1370. package/src/tools/release/__tests__/GitHubPublisher.test.ts +0 -240
  1371. package/src/tools/release/__tests__/NotesRenderer.test.ts +0 -142
  1372. package/src/tools/release/__tests__/NpmPublisher.test.ts +0 -289
  1373. package/src/tools/release/__tests__/PipelineIntegration.test.ts +0 -188
  1374. package/src/tools/release/__tests__/ReleasePipeline.test.ts +0 -192
  1375. package/src/tools/release/__tests__/SemanticVersionValidator.test.ts +0 -49
  1376. package/src/tools/release/__tests__/SummaryScanner.test.ts +0 -141
  1377. package/src/tools/release/__tests__/TagResolver.test.ts +0 -91
  1378. package/src/tools/release/__tests__/VersionCalculator.test.ts +0 -270
  1379. package/src/tools/release/__tests__/helpers/NpmMockHelper.ts +0 -80
  1380. package/src/tools/release/cli/ReleasePipeline.ts +0 -165
  1381. package/src/tools/release/cli/release-tool.ts +0 -107
  1382. package/src/tools/release/pipeline/ChangeClassifier.ts +0 -61
  1383. package/src/tools/release/pipeline/ChangeExtractor.ts +0 -87
  1384. package/src/tools/release/pipeline/NotesRenderer.ts +0 -66
  1385. package/src/tools/release/pipeline/SummaryScanner.ts +0 -70
  1386. package/src/tools/release/pipeline/TagResolver.ts +0 -40
  1387. package/src/tools/release/pipeline/VersionCalculator.ts +0 -375
  1388. package/src/tools/release/publishers/GitHubPublisher.ts +0 -228
  1389. package/src/tools/release/publishers/NpmPublisher.ts +0 -196
  1390. package/src/tools/release/release-config.json +0 -5
  1391. package/src/tools/release/types/index.ts +0 -282
  1392. package/src/tools/release/validators/SemanticVersionValidator.ts +0 -67
  1393. package/src/types/ComponentTypes.ts +0 -76
  1394. package/src/types/TranslationOutput.ts +0 -105
  1395. package/src/types/ValidationResult.ts +0 -74
  1396. package/src/types/__tests__/ComponentTypes.test.ts +0 -73
  1397. package/src/types/css.d.ts +0 -35
  1398. package/src/types/generated/TokenTypes.ts +0 -142
  1399. package/src/types/index.ts +0 -42
  1400. package/src/validators/BaselineGridValidator.ts +0 -119
  1401. package/src/validators/CompositionPatternValidator.ts +0 -259
  1402. package/src/validators/CrossPlatformConsistencyValidator.ts +0 -498
  1403. package/src/validators/ErrorValidator.ts +0 -998
  1404. package/src/validators/IValidator.ts +0 -273
  1405. package/src/validators/MathematicalRelationshipParser.ts +0 -434
  1406. package/src/validators/ModeParity.ts +0 -123
  1407. package/src/validators/PassValidator.ts +0 -533
  1408. package/src/validators/PlatformConstraintHandler.ts +0 -453
  1409. package/src/validators/PrimitiveReferenceValidator.ts +0 -284
  1410. package/src/validators/SemanticTokenValidator.ts +0 -496
  1411. package/src/validators/StemmaComponentNamingValidator.ts +0 -524
  1412. package/src/validators/StemmaErrorGuidanceSystem.ts +0 -1600
  1413. package/src/validators/StemmaPropertyAccessibilityValidator.ts +0 -823
  1414. package/src/validators/StemmaTokenUsageValidator.ts +0 -651
  1415. package/src/validators/SyntaxValidator.ts +0 -537
  1416. package/src/validators/ThreeTierValidator.ts +0 -822
  1417. package/src/validators/ToleranceCalculator.ts +0 -324
  1418. package/src/validators/ValidationReasoning.ts +0 -464
  1419. package/src/validators/WCAGValidator.ts +0 -219
  1420. package/src/validators/WarningValidator.ts +0 -626
  1421. package/src/validators/__tests__/BaselineGridValidator.test.ts +0 -292
  1422. package/src/validators/__tests__/BorderWidthValidation.test.ts +0 -595
  1423. package/src/validators/__tests__/CompositionPatterns.test.ts +0 -463
  1424. package/src/validators/__tests__/CrossPlatformConsistency.test.ts +0 -834
  1425. package/src/validators/__tests__/IValidator.test.ts +0 -258
  1426. package/src/validators/__tests__/MathematicalRelationshipParser.test.ts +0 -465
  1427. package/src/validators/__tests__/PlatformConstraints.test.ts +0 -486
  1428. package/src/validators/__tests__/SemanticTokenValidator.test.ts +0 -723
  1429. package/src/validators/__tests__/StemmaComponentNamingValidator.test.ts +0 -597
  1430. package/src/validators/__tests__/StemmaErrorGuidanceSystem.test.ts +0 -717
  1431. package/src/validators/__tests__/StemmaPropertyAccessibilityValidator.test.ts +0 -349
  1432. package/src/validators/__tests__/StemmaTokenUsageValidator.test.ts +0 -432
  1433. package/src/validators/__tests__/SyntaxValidator.test.ts +0 -360
  1434. package/src/validators/__tests__/ThreeTierValidator.test.ts +0 -906
  1435. package/src/validators/__tests__/ValidationReasoning.test.ts +0 -636
  1436. package/src/validators/__tests__/WCAGValidator.test.ts +0 -243
  1437. package/src/validators/buildValidation.ts +0 -170
  1438. package/src/validators/index.ts +0 -144
  1439. package/src/workflows/ConsistencyValidator.ts +0 -339
  1440. package/src/workflows/TokenGenerationWorkflow.ts +0 -460
  1441. package/src/workflows/ValidationPipeline.ts +0 -284
  1442. package/src/workflows/WorkflowErrorHandler.ts +0 -441
@@ -0,0 +1,4567 @@
1
+ /**
2
+ * Anti-Pattern Browser Detector for Impeccable
3
+ * Copyright (c) 2026 Paul Bakaus
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * GENERATED -- do not edit. Source: cli/engine/browser/injected/index.mjs
7
+ * Rebuild: node scripts/build-browser-detector.js
8
+ *
9
+ * Usage: <script src="detect-antipatterns-browser.js"></script>
10
+ * Re-scan: window.impeccableScan()
11
+ */
12
+ (function () {
13
+ if (typeof window === 'undefined') return;
14
+ // --- cli/engine/shared/constants.mjs ---
15
+ // ─── Section 1: Constants ───────────────────────────────────────────────────
16
+
17
+ const SAFE_TAGS = new Set([
18
+ 'blockquote', 'nav', 'a', 'input', 'textarea', 'select',
19
+ 'pre', 'code', 'span', 'th', 'td', 'tr', 'li', 'label',
20
+ 'button', 'hr', 'html', 'head', 'body', 'script', 'style',
21
+ 'link', 'meta', 'title', 'br', 'img', 'svg', 'path', 'circle',
22
+ 'rect', 'line', 'polyline', 'polygon', 'g', 'defs', 'use',
23
+ ]);
24
+
25
+ // Per-check safe-tags override for the border (side-tab / border-accent)
26
+ // rule. We intentionally re-allow <label> here because card-shaped clickable
27
+ // labels (e.g. .checklist-item wrapping a checkbox + content) are one of the
28
+ // canonical side-tab anti-pattern shapes and must be detected. The rule's
29
+ // other preconditions (non-neutral color, width >= 2px on a single side,
30
+ // radius > 0 or width >= 3, element size >= 20x20 in the browser path)
31
+ // already filter out plain inline form labels so this does not introduce
32
+ // false positives. See modern-color-borders.html for the test matrix.
33
+ const BORDER_SAFE_TAGS = new Set(
34
+ [...SAFE_TAGS].filter(t => t !== 'label')
35
+ );
36
+
37
+ const OVERUSED_FONTS = new Set([
38
+ // Older monoculture (still ubiquitous):
39
+ 'inter', 'roboto', 'open sans', 'lato', 'montserrat', 'arial', 'helvetica',
40
+ // Newer monoculture (the Anthropic-skill / Vercel / GitHub default wave):
41
+ 'fraunces', 'instrument sans', 'instrument serif',
42
+ 'geist', 'geist sans', 'geist mono',
43
+ 'mona sans',
44
+ 'plus jakarta sans', 'space grotesk', 'recoleta',
45
+ ]);
46
+
47
+ // Brand-associated fonts: don't flag these as "overused" on the brand's own domains.
48
+ // Keys are font names, values are arrays of hostname suffixes where the font is allowed.
49
+ const GOOGLE_DOMAINS = [
50
+ 'google.com', 'youtube.com', 'android.com', 'chromium.org',
51
+ 'chrome.com', 'web.dev', 'gstatic.com', 'firebase.google.com',
52
+ ];
53
+ const VERCEL_DOMAINS = ['vercel.com', 'nextjs.org', 'v0.app'];
54
+ const GITHUB_DOMAINS = ['github.com', 'githubnext.com'];
55
+ const BRAND_FONT_DOMAINS = {
56
+ 'roboto': GOOGLE_DOMAINS,
57
+ 'google sans': GOOGLE_DOMAINS,
58
+ 'product sans': GOOGLE_DOMAINS,
59
+ 'geist': VERCEL_DOMAINS,
60
+ 'geist sans': VERCEL_DOMAINS,
61
+ 'geist mono': VERCEL_DOMAINS,
62
+ 'mona sans': GITHUB_DOMAINS,
63
+ };
64
+
65
+ function isBrandFontOnOwnDomain(font) {
66
+ if (typeof location === 'undefined') return false;
67
+ const allowed = BRAND_FONT_DOMAINS[font];
68
+ if (!allowed) return false;
69
+ const host = location.hostname.toLowerCase();
70
+ return allowed.some(suffix => host === suffix || host.endsWith('.' + suffix));
71
+ }
72
+
73
+ const GENERIC_FONTS = new Set([
74
+ 'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy',
75
+ 'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded',
76
+ '-apple-system', 'blinkmacsystemfont', 'segoe ui',
77
+ 'inherit', 'initial', 'unset', 'revert',
78
+ ]);
79
+
80
+ // WCAG large text thresholds are defined in points: 18pt normal text and
81
+ // 14pt bold text. Browsers expose font-size in CSS pixels at 96px per inch.
82
+ const WCAG_LARGE_TEXT_PX = 18 * (96 / 72);
83
+ const WCAG_LARGE_BOLD_TEXT_PX = 14 * (96 / 72);
84
+
85
+ // Serif faces that show up in italic-display heroes. The rule also fires when
86
+ // the primary face is unknown but the stack ends in the generic `serif` token,
87
+ // which catches custom/private faces with a serif fallback.
88
+ const KNOWN_SERIF_FONTS = new Set([
89
+ 'fraunces', 'recoleta', 'newsreader', 'playfair display', 'playfair',
90
+ 'cormorant', 'cormorant garamond', 'garamond', 'eb garamond',
91
+ 'tiempos', 'tiempos headline', 'tiempos text',
92
+ 'lora', 'vollkorn', 'spectral',
93
+ 'source serif pro', 'source serif 4', 'source serif',
94
+ 'ibm plex serif', 'merriweather',
95
+ 'libre caslon', 'libre baskerville', 'baskerville',
96
+ 'georgia', 'times new roman', 'times',
97
+ 'dm serif display', 'dm serif text',
98
+ 'instrument serif', 'gt sectra', 'ogg', 'canela',
99
+ 'freight display', 'freight text',
100
+ ]);
101
+
102
+ // --- cli/engine/registry/antipatterns.mjs ---
103
+ const ANTIPATTERNS = [
104
+ // ── AI slop: tells that something was AI-generated ──
105
+ {
106
+ id: 'side-tab',
107
+ category: 'slop',
108
+ name: 'Side-tab accent border',
109
+ description:
110
+ 'Thick colored border on one side of a card — the most recognizable tell of AI-generated UIs. Use a subtler accent or remove it entirely.',
111
+ skillSection: 'Visual Details',
112
+ skillGuideline: 'colored accent stripe',
113
+ },
114
+ {
115
+ id: 'border-accent-on-rounded',
116
+ category: 'slop',
117
+ name: 'Border accent on rounded element',
118
+ description:
119
+ 'Thick accent border on a rounded card — the border clashes with the rounded corners. Remove the border or the border-radius.',
120
+ skillSection: 'Visual Details',
121
+ skillGuideline: 'colored accent stripe',
122
+ },
123
+ {
124
+ id: 'overused-font',
125
+ category: 'slop',
126
+ name: 'Overused font',
127
+ description:
128
+ 'Inter, Roboto, Fraunces, Geist, Plus Jakarta Sans, and Space Grotesk are used on so many sites they no longer feel distinctive. Each new wave of AI-generated UIs converges on the same handful of faces. Choose a face that gives your interface personality.',
129
+ skillSection: 'Typography',
130
+ skillGuideline: 'overused fonts like Inter',
131
+ },
132
+ {
133
+ id: 'single-font',
134
+ category: 'slop',
135
+ name: 'Single font for everything',
136
+ description:
137
+ 'Only one font family is used for the entire page. Pair a distinctive display font with a refined body font to create typographic hierarchy.',
138
+ skillSection: 'Typography',
139
+ skillGuideline: 'only one font family for the entire page',
140
+ },
141
+ {
142
+ id: 'flat-type-hierarchy',
143
+ category: 'slop',
144
+ name: 'Flat type hierarchy',
145
+ description:
146
+ 'Font sizes are too close together — no clear visual hierarchy. Use fewer sizes with more contrast (aim for at least a 1.25 ratio between steps).',
147
+ skillSection: 'Typography',
148
+ skillGuideline: 'flat type hierarchy',
149
+ },
150
+ {
151
+ id: 'gradient-text',
152
+ category: 'slop',
153
+ name: 'Gradient text',
154
+ description:
155
+ 'Gradient text is decorative rather than meaningful — a common AI tell, especially on headings and metrics. Use solid colors for text.',
156
+ skillSection: 'Color & Contrast',
157
+ skillGuideline: 'gradient text for',
158
+ },
159
+ {
160
+ id: 'ai-color-palette',
161
+ category: 'slop',
162
+ name: 'AI color palette',
163
+ description:
164
+ 'Purple/violet gradients and cyan-on-dark are the most recognizable tells of AI-generated UIs. Choose a distinctive, intentional palette.',
165
+ skillSection: 'Color & Contrast',
166
+ skillGuideline: 'AI color palette',
167
+ },
168
+ {
169
+ id: 'cream-palette',
170
+ category: 'slop',
171
+ name: 'Cream / beige palette',
172
+ description:
173
+ 'A warm cream or beige page background has become the default "tasteful" AI surface, reached for by reflex. Choose a background that comes from a deliberate palette, not the safe warm off-white.',
174
+ skillSection: 'Color & Contrast',
175
+ skillGuideline: 'cream and beige as the default surface',
176
+ },
177
+ {
178
+ id: 'nested-cards',
179
+ category: 'slop',
180
+ name: 'Nested cards',
181
+ description:
182
+ 'Cards inside cards create visual noise and excessive depth. Flatten the hierarchy — use spacing, typography, and dividers instead of nesting containers.',
183
+ skillSection: 'Layout & Space',
184
+ skillGuideline: 'Nest cards inside cards',
185
+ },
186
+ {
187
+ id: 'monotonous-spacing',
188
+ category: 'slop',
189
+ name: 'Monotonous spacing',
190
+ description:
191
+ 'The same spacing value used everywhere — no rhythm, no variation. Use tight groupings for related items and generous separations between sections.',
192
+ skillSection: 'Layout & Space',
193
+ skillGuideline: 'same spacing everywhere',
194
+ },
195
+ {
196
+ id: 'bounce-easing',
197
+ category: 'slop',
198
+ name: 'Bounce or elastic easing',
199
+ description:
200
+ 'Bounce and elastic easing feel dated and tacky. Real objects decelerate smoothly — use exponential easing (ease-out-quart/quint/expo) instead.',
201
+ skillSection: 'Motion',
202
+ skillGuideline: 'bounce or elastic easing',
203
+ },
204
+ {
205
+ id: 'dark-glow',
206
+ category: 'slop',
207
+ name: 'Dark mode with glowing accents',
208
+ description:
209
+ 'Dark backgrounds with colored box-shadow glows are the default "cool" look of AI-generated UIs. Use subtle, purposeful lighting instead — or skip the dark theme entirely.',
210
+ skillSection: 'Color & Contrast',
211
+ skillGuideline: 'dark mode with glowing accents',
212
+ },
213
+ {
214
+ id: 'icon-tile-stack',
215
+ category: 'slop',
216
+ name: 'Icon tile stacked above heading',
217
+ description:
218
+ 'A small rounded-square icon container above a heading is the universal AI feature-card template — every generator outputs this exact shape. Try a side-by-side icon and heading, or let the icon sit in flow without its own container.',
219
+ skillSection: 'Typography',
220
+ skillGuideline: 'large icons with rounded corners above every heading',
221
+ },
222
+ {
223
+ id: 'italic-serif-display',
224
+ category: 'slop',
225
+ name: 'Italic serif display headline',
226
+ description:
227
+ 'Oversized italic serif (Fraunces, Recoleta, Playfair, Newsreader-italic) as the primary hero headline reads as taste in isolation but has become the universal AI-startup landing page hero. Set roman, or move to a non-serif display face. Editorial / magazine register may legitimately want this — judge by context.',
228
+ skillSection: 'Typography',
229
+ skillGuideline: 'oversized italic serif as the hero headline',
230
+ },
231
+ {
232
+ id: 'hero-eyebrow-chip',
233
+ category: 'slop',
234
+ name: 'Hero eyebrow / pill chip',
235
+ description:
236
+ 'A tiny uppercase letter-spaced label sitting immediately above an oversized hero headline — or the same shape rendered as a pill chip — is now the default AI SaaS hero. Drop the eyebrow, integrate the kicker into the headline, or run it as a navigation breadcrumb instead.',
237
+ skillSection: 'Typography',
238
+ skillGuideline: 'tiny uppercase tracked label above the hero headline',
239
+ },
240
+ {
241
+ id: 'repeated-section-kickers',
242
+ category: 'slop',
243
+ severity: 'advisory',
244
+ name: 'Repeated section kicker labels',
245
+ description:
246
+ 'Repeating tiny uppercase tracked labels above section headings turns a brand page into AI editorial scaffolding. Replace them with stronger structure, artifacts, imagery, or a deliberate brand system.',
247
+ skillSection: 'Typography',
248
+ skillGuideline: 'repeated eyebrow or kicker labels as section scaffolding',
249
+ },
250
+ {
251
+ id: 'numbered-section-markers',
252
+ category: 'slop',
253
+ severity: 'advisory',
254
+ name: 'Numbered section markers (01 / 02 / 03)',
255
+ description:
256
+ 'Numbered display markers as section labels (01, 02, 03) are the AI editorial scaffold one tier deeper than tracked eyebrow chips. If you find yourself reaching for them, choose a different section cadence.',
257
+ skillSection: 'Layout & Space',
258
+ skillGuideline: 'numbered section markers',
259
+ },
260
+ {
261
+ id: 'em-dash-overuse',
262
+ category: 'slop',
263
+ name: 'Em-dash overuse',
264
+ description:
265
+ 'More than two em-dashes (— or --) in body copy is an AI cadence tell. Use commas, colons, periods, or parentheses instead.',
266
+ skillSection: 'Copy',
267
+ skillGuideline: 'no em dashes',
268
+ },
269
+ {
270
+ id: 'marketing-buzzword',
271
+ category: 'slop',
272
+ name: 'Marketing buzzword',
273
+ description:
274
+ 'Generic SaaS phrases (streamline / empower / supercharge / world-class / enterprise-grade / next-generation / cutting-edge / etc) are instant AI tells. Pick a specific verb and noun that says what the product literally does.',
275
+ skillSection: 'Copy',
276
+ skillGuideline: 'marketing buzzwords',
277
+ },
278
+ {
279
+ id: 'aphoristic-cadence',
280
+ category: 'slop',
281
+ name: 'Aphoristic-cadence copy',
282
+ description:
283
+ 'Three or more sections landing on a short rebuttal sentence ("X. No Y." / "X. Just Y.") or a manufactured-contrast aphorism ("Not a feature. A platform.") reads as AI cadence, not voice. Once is fine; the pattern is the tell.',
284
+ skillSection: 'Copy',
285
+ skillGuideline: 'aphoristic cadence',
286
+ },
287
+ {
288
+ id: 'oversized-h1',
289
+ category: 'slop',
290
+ name: 'Oversized hero headline',
291
+ description:
292
+ 'A full-sentence headline set at display size ends up dominating the viewport, leaving no room for anything else above the fold. A punchy one- or two-word headline at that size is fine — the problem is a long headline blown up too large. Set long headlines smaller, or tighten the copy.',
293
+ skillSection: 'Typography',
294
+ skillGuideline: 'long headline set at display size',
295
+ },
296
+ {
297
+ id: 'extreme-negative-tracking',
298
+ category: 'slop',
299
+ name: 'Crushed letter spacing',
300
+ description:
301
+ 'Letter-spacing pulled tighter than the point where characters keep their own shapes costs legibility. Tighten display type optically, not destructively.',
302
+ skillSection: 'Typography',
303
+ skillGuideline: 'letter spacing crushed past legibility',
304
+ },
305
+ {
306
+ id: 'broken-image',
307
+ category: 'quality',
308
+ name: 'Broken or placeholder image',
309
+ description:
310
+ '<img> tags with empty src, missing src, or placeholder values ship as broken-image boxes. Use real images, generated assets, or remove the tag.',
311
+ skillSection: 'Imagery',
312
+ skillGuideline: 'broken image references',
313
+ },
314
+
315
+ // ── Quality: general design and accessibility issues ──
316
+ {
317
+ id: 'gray-on-color',
318
+ category: 'quality',
319
+ name: 'Gray text on colored background',
320
+ description:
321
+ 'Gray text looks washed out on colored backgrounds. Use a darker shade of the background color instead, or white/near-white for contrast.',
322
+ skillSection: 'Color & Contrast',
323
+ skillGuideline: 'gray text on colored backgrounds',
324
+ },
325
+ {
326
+ id: 'low-contrast',
327
+ category: 'quality',
328
+ name: 'Low contrast text',
329
+ description:
330
+ 'Text does not meet WCAG AA contrast requirements (4.5:1 for body, 3:1 for large text). Increase the contrast between text and background.',
331
+ },
332
+ {
333
+ id: 'layout-transition',
334
+ category: 'quality',
335
+ name: 'Layout property animation',
336
+ description:
337
+ 'Animating width, height, padding, or margin causes layout thrash and janky performance. Use transform and opacity instead, or grid-template-rows for height animations.',
338
+ skillSection: 'Motion',
339
+ skillGuideline: 'Animate layout properties',
340
+ },
341
+ {
342
+ id: 'line-length',
343
+ category: 'quality',
344
+ name: 'Line length too long',
345
+ description:
346
+ 'Text lines wider than ~80 characters are hard to read. The eye loses its place tracking back to the start of the next line. Add a max-width (65ch to 75ch) to text containers.',
347
+ skillSection: 'Layout & Space',
348
+ skillGuideline: 'wrap beyond ~80 characters',
349
+ },
350
+ {
351
+ id: 'cramped-padding',
352
+ category: 'quality',
353
+ name: 'Cramped padding',
354
+ description:
355
+ 'Text is too close to the edge of its container. Two shapes: (1) an element with its own text where the padding is too low for the font size, and (2) a wrapper with text-bearing children and near-zero padding against a visible boundary (border, outline, or non-transparent background) — children land flush against the boundary line. Add at least 8px (ideally 12–16px) of padding inside bordered, outlined, or colored containers.',
356
+ skillSection: 'Layout & Space',
357
+ skillGuideline: 'inside bordered or colored containers',
358
+ },
359
+ {
360
+ id: 'body-text-viewport-edge',
361
+ category: 'quality',
362
+ name: 'Body text touching viewport edge',
363
+ description:
364
+ 'Body paragraphs render flush against the left or right viewport edge with no container providing horizontal padding. Wrap content in a container with at least 16px (ideally 24-32px) of horizontal padding, or apply max-width with mx-auto.',
365
+ },
366
+ {
367
+ id: 'tight-leading',
368
+ category: 'quality',
369
+ name: 'Tight line height',
370
+ description:
371
+ 'Line height below 1.3x the font size makes multi-line text hard to read. Use 1.5 to 1.7 for body text so lines have room to breathe.',
372
+ },
373
+ {
374
+ id: 'skipped-heading',
375
+ category: 'quality',
376
+ name: 'Skipped heading level',
377
+ description:
378
+ 'Heading levels should not skip (e.g. h1 then h3 with no h2). Screen readers use heading hierarchy for navigation. Skipping levels breaks the document outline.',
379
+ },
380
+ {
381
+ id: 'justified-text',
382
+ category: 'quality',
383
+ name: 'Justified text',
384
+ description:
385
+ 'Justified text without hyphenation creates uneven word spacing ("rivers of white"). Use text-align: left for body text, or enable hyphens: auto if you must justify.',
386
+ },
387
+ {
388
+ id: 'tiny-text',
389
+ category: 'quality',
390
+ name: 'Tiny body text',
391
+ description:
392
+ 'Body text below 12px is hard to read, especially on high-DPI screens. Use at least 14px for body content, 16px is ideal.',
393
+ },
394
+ {
395
+ id: 'all-caps-body',
396
+ category: 'quality',
397
+ name: 'All-caps body text',
398
+ description:
399
+ 'Long passages in uppercase are hard to read. We recognize words by shape (ascenders and descenders), which all-caps removes. Reserve uppercase for short labels and headings.',
400
+ skillSection: 'Typography',
401
+ skillGuideline: 'long body passages in uppercase',
402
+ },
403
+ {
404
+ id: 'wide-tracking',
405
+ category: 'quality',
406
+ name: 'Wide letter spacing on body text',
407
+ description:
408
+ 'Letter spacing above 0.05em on body text disrupts natural character groupings and slows reading. Reserve wide tracking for short uppercase labels only.',
409
+ },
410
+ {
411
+ id: 'text-overflow',
412
+ category: 'quality',
413
+ name: 'Content overflowing its container',
414
+ description:
415
+ 'Content renders wider than its container, spilling out or forcing a horizontal scrollbar. Let text wrap, constrain widths, or give the region a deliberate scroll affordance.',
416
+ skillSection: 'Layout & Space',
417
+ skillGuideline: 'content wider than its container',
418
+ },
419
+ {
420
+ id: 'clipped-overflow-container',
421
+ category: 'quality',
422
+ name: 'Positioned child clipped by overflow container',
423
+ description:
424
+ 'A clipping container (overflow hidden or clip) wrapping an absolutely-positioned child cuts off tooltips, menus, and popovers that need to escape. Let the overflow be visible, or move the positioned layer out of the clip.',
425
+ skillSection: 'Layout & Space',
426
+ skillGuideline: 'overflow container clipping positioned children',
427
+ },
428
+
429
+ // ── Provider tells: opt-in via --gpt / --gemini (gated off by default) ──
430
+ {
431
+ id: 'gpt-thin-border-wide-shadow',
432
+ category: 'slop',
433
+ severity: 'advisory',
434
+ gated: 'gpt',
435
+ name: 'Hairline border with wide shadow',
436
+ description:
437
+ 'A hairline border paired with a wide, diffuse shadow is a recurring generated-UI signature. Commit to one — a defined edge or a soft elevation — rather than both at once.',
438
+ skillSection: 'Visual Details',
439
+ skillGuideline: 'hairline border plus wide diffuse shadow',
440
+ },
441
+ {
442
+ id: 'repeating-stripes-gradient',
443
+ category: 'slop',
444
+ severity: 'advisory',
445
+ gated: 'gpt',
446
+ name: 'Repeating-gradient stripes',
447
+ description:
448
+ 'Repeating-gradient stripes used as surface decoration are a recurring generated-UI signature. Reach for a deliberate texture or leave the surface plain.',
449
+ skillSection: 'Visual Details',
450
+ skillGuideline: 'repeating-gradient decorative stripes',
451
+ },
452
+ {
453
+ id: 'theater-slop-phrase',
454
+ category: 'slop',
455
+ severity: 'advisory',
456
+ gated: 'gpt',
457
+ name: 'Theater framing copy',
458
+ description:
459
+ 'Dismissing something as "theater" is a recurring generated-copy tic. Say plainly what the thing does or does not do.',
460
+ skillSection: 'Copy',
461
+ skillGuideline: 'theater framing copy',
462
+ },
463
+ {
464
+ id: 'image-hover-transform',
465
+ category: 'slop',
466
+ severity: 'advisory',
467
+ gated: 'gemini',
468
+ name: 'Image hover transform',
469
+ description:
470
+ 'Scaling or rotating an image on hover is a recurring generated-UI signature. Let imagery sit still, or use a subtler, purposeful interaction.',
471
+ skillSection: 'Motion',
472
+ skillGuideline: 'image scale or rotate on hover',
473
+ },
474
+ ];
475
+
476
+ // --- cli/engine/shared/color.mjs ---
477
+ // ─── Section 2: Color Utilities ─────────────────────────────────────────────
478
+
479
+ function isNeutralColor(color) {
480
+ if (!color || color === 'transparent') return true;
481
+
482
+ // rgb/rgba — use channel spread. Threshold 30 ≈ 11.7% of the 0–255 range.
483
+ const rgb = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
484
+ if (rgb) {
485
+ return (Math.max(+rgb[1], +rgb[2], +rgb[3]) - Math.min(+rgb[1], +rgb[2], +rgb[3])) < 30;
486
+ }
487
+
488
+ // oklch()/lch() — chroma is the second numeric component.
489
+ // oklch chroma is ~0–0.4 in sRGB gamut; >= 0.02 reads as tinted, not gray.
490
+ // lch chroma is ~0–150; >= 3 reads as tinted. jsdom emits both formats
491
+ // literally (it does NOT convert them to rgb).
492
+ const oklch = color.match(/oklch\(\s*[\d.]+%?\s*([\d.-]+)/i);
493
+ if (oklch) return parseFloat(oklch[1]) < 0.02;
494
+ const lch = color.match(/lch\(\s*[\d.]+%?\s*([\d.-]+)/i);
495
+ if (lch) return parseFloat(lch[1]) < 3;
496
+
497
+ // oklab()/lab() — a and b are signed axes; chroma = sqrt(a² + b²).
498
+ // oklab a/b are ~-0.4..0.4, threshold 0.02. lab a/b are ~-128..127, threshold 3.
499
+ const oklab = color.match(/oklab\(\s*[\d.]+%?\s*([\d.-]+)\s+([\d.-]+)/i);
500
+ if (oklab) {
501
+ const a = parseFloat(oklab[1]), b = parseFloat(oklab[2]);
502
+ return Math.hypot(a, b) < 0.02;
503
+ }
504
+ const lab = color.match(/lab\(\s*[\d.]+%?\s*([\d.-]+)\s+([\d.-]+)/i);
505
+ if (lab) {
506
+ const a = parseFloat(lab[1]), b = parseFloat(lab[2]);
507
+ return Math.hypot(a, b) < 3;
508
+ }
509
+
510
+ // hsl/hsla — saturation is the second numeric component (percent).
511
+ // Modern jsdom usually converts hsl() to rgb, but handle it directly for
512
+ // safety across versions and for any engine that preserves the format.
513
+ const hsl = color.match(/hsla?\(\s*[\d.-]+\s*,?\s*([\d.]+)%/i);
514
+ if (hsl) return parseFloat(hsl[1]) < 10;
515
+
516
+ // hwb(hue whiteness% blackness%) — a pixel is fully gray when
517
+ // whiteness + blackness >= 100; chroma-like saturation = 1 - (w+b)/100.
518
+ const hwb = color.match(/hwb\(\s*[\d.-]+\s+([\d.]+)%\s+([\d.]+)%/i);
519
+ if (hwb) {
520
+ const w = parseFloat(hwb[1]), b = parseFloat(hwb[2]);
521
+ return (1 - Math.min(100, w + b) / 100) < 0.1;
522
+ }
523
+
524
+ // Unknown / unrecognized format — err on the side of DETECTING rather
525
+ // than silently skipping. This is the opposite of the previous default,
526
+ // which was the root cause of the oklch bug.
527
+ return false;
528
+ }
529
+
530
+ function oklchToSrgb(L, C, H, alpha) {
531
+ if (alpha === undefined) alpha = 1;
532
+ var hRad = (H * Math.PI) / 180;
533
+ var a_ = C * Math.cos(hRad), b_ = C * Math.sin(hRad);
534
+ var l_ = L + 0.3963377774 * a_ + 0.2158037573 * b_;
535
+ var m_ = L - 0.1055613458 * a_ - 0.0638541728 * b_;
536
+ var s_ = L - 0.0894841775 * a_ - 1.2914855480 * b_;
537
+ var lc = l_*l_*l_, mc = m_*m_*m_, sc = s_*s_*s_;
538
+ var rLin = 4.0767416621*lc - 3.3077115913*mc + 0.2309699292*sc;
539
+ var gLin = -1.2684380046*lc + 2.6097574011*mc - 0.3413193965*sc;
540
+ var bLin = -0.0041960863*lc - 0.7034186147*mc + 1.7076147010*sc;
541
+ function enc(x) { var c = Math.max(0, Math.min(1, x)); return c <= 0.0031308 ? 12.92*c : 1.055*Math.pow(c, 1/2.4) - 0.055; }
542
+ return { r: Math.round(enc(rLin)*255), g: Math.round(enc(gLin)*255), b: Math.round(enc(bLin)*255), a: alpha };
543
+ }
544
+
545
+ function parseRgb(color) {
546
+ if (!color || color === 'transparent') return null;
547
+ var m = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
548
+ if (m) return { r: +m[1], g: +m[2], b: +m[3], a: m[4] !== undefined ? +m[4] : 1 };
549
+ var ok = color.match(/oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+))?\s*\)/i);
550
+ if (ok) {
551
+ var L = ok[2] === '%' ? parseFloat(ok[1]) / 100 : parseFloat(ok[1]);
552
+ return oklchToSrgb(L, parseFloat(ok[3]), parseFloat(ok[4]), ok[5] !== undefined ? parseFloat(ok[5]) : 1);
553
+ }
554
+ return null;
555
+ }
556
+
557
+ function relativeLuminance({ r, g, b }) {
558
+ const [rs, gs, bs] = [r / 255, g / 255, b / 255].map(c =>
559
+ c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
560
+ );
561
+ return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
562
+ }
563
+
564
+ function contrastRatio(c1, c2) {
565
+ const l1 = relativeLuminance(c1);
566
+ const l2 = relativeLuminance(c2);
567
+ return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
568
+ }
569
+
570
+ function parseGradientColors(bgImage) {
571
+ if (!bgImage || !bgImage.includes('gradient')) return [];
572
+ const colors = [];
573
+ for (const m of bgImage.matchAll(/rgba?\([^)]+\)/g)) {
574
+ const c = parseRgb(m[0]);
575
+ if (c) colors.push(c);
576
+ }
577
+ for (const m of bgImage.matchAll(/oklch\([^)]+\)/gi)) {
578
+ const c = parseRgb(m[0]);
579
+ if (c) colors.push(c);
580
+ }
581
+ for (const m of bgImage.matchAll(/#([0-9a-f]{6}|[0-9a-f]{3})\b/gi)) {
582
+ const h = m[1];
583
+ if (h.length === 6) {
584
+ colors.push({ r: parseInt(h.slice(0,2),16), g: parseInt(h.slice(2,4),16), b: parseInt(h.slice(4,6),16), a: 1 });
585
+ } else {
586
+ colors.push({ r: parseInt(h[0]+h[0],16), g: parseInt(h[1]+h[1],16), b: parseInt(h[2]+h[2],16), a: 1 });
587
+ }
588
+ }
589
+ return colors;
590
+ }
591
+
592
+ function hasChroma(c, threshold = 30) {
593
+ if (!c) return false;
594
+ return (Math.max(c.r, c.g, c.b) - Math.min(c.r, c.g, c.b)) >= threshold;
595
+ }
596
+
597
+ function getHue(c) {
598
+ if (!c) return 0;
599
+ const r = c.r / 255, g = c.g / 255, b = c.b / 255;
600
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
601
+ if (max === min) return 0;
602
+ const d = max - min;
603
+ let h;
604
+ if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
605
+ else if (max === g) h = ((b - r) / d + 2) / 6;
606
+ else h = ((r - g) / d + 4) / 6;
607
+ return Math.round(h * 360);
608
+ }
609
+
610
+ function colorToHex(c) {
611
+ if (!c) return '?';
612
+ return '#' + [c.r, c.g, c.b].map(v => v.toString(16).padStart(2, '0')).join('');
613
+ }
614
+
615
+ // --- cli/engine/rules/checks.mjs ---
616
+ const DETECTOR_IS_BROWSER = typeof window !== 'undefined';
617
+
618
+ // ─── Section 3: Pure Detection ──────────────────────────────────────────────
619
+
620
+ function checkBorders(tag, widths, colors, radius) {
621
+ if (BORDER_SAFE_TAGS.has(tag)) return [];
622
+ const findings = [];
623
+ const sides = ['Top', 'Right', 'Bottom', 'Left'];
624
+
625
+ for (const side of sides) {
626
+ const w = widths[side];
627
+ if (w < 1 || isNeutralColor(colors[side])) continue;
628
+
629
+ const otherSides = sides.filter(s => s !== side);
630
+ const maxOther = Math.max(...otherSides.map(s => widths[s]));
631
+ if (!(w >= 2 && (maxOther <= 1 || w >= maxOther * 2))) continue;
632
+
633
+ const sn = side.toLowerCase();
634
+ const isSide = side === 'Left' || side === 'Right';
635
+
636
+ if (isSide) {
637
+ if (radius > 0) findings.push({ id: 'side-tab', snippet: `border-${sn}: ${w}px + border-radius: ${radius}px` });
638
+ else if (w >= 3) findings.push({ id: 'side-tab', snippet: `border-${sn}: ${w}px` });
639
+ } else {
640
+ if (radius > 0 && w >= 2) findings.push({ id: 'border-accent-on-rounded', snippet: `border-${sn}: ${w}px + border-radius: ${radius}px` });
641
+ }
642
+ }
643
+
644
+ return findings;
645
+ }
646
+
647
+ // Returns true if the given text is composed entirely of emoji characters
648
+ // (plus whitespace / variation selectors). Emojis render as multicolor glyphs
649
+ // regardless of CSS `color`, so contrast checks against the element's text
650
+ // color are meaningless for these nodes.
651
+ const EMOJI_CHAR_RE = /[\u{1F1E6}-\u{1F1FF}\u{1F300}-\u{1F9FF}\u{1FA00}-\u{1FAFF}\u{2600}-\u{27BF}\u{2300}-\u{23FF}\u{FE0F}\u{200D}\u{1F3FB}-\u{1F3FF}]/u;
652
+ const EMOJI_CHARS_GLOBAL = /[\u{1F1E6}-\u{1F1FF}\u{1F300}-\u{1F9FF}\u{1FA00}-\u{1FAFF}\u{2600}-\u{27BF}\u{2300}-\u{23FF}\u{FE0F}\u{200D}\u{1F3FB}-\u{1F3FF}]/gu;
653
+ function isEmojiOnlyText(text) {
654
+ if (!text) return false;
655
+ if (!EMOJI_CHAR_RE.test(text)) return false;
656
+ return text.replace(EMOJI_CHARS_GLOBAL, '').trim() === '';
657
+ }
658
+
659
+ function checkColors(opts) {
660
+ const { tag, textColor, bgColor, effectiveBg, effectiveBgStops, fontSize, fontWeight, hasDirectText, isEmojiOnly, bgClip, bgImage, classList } = opts;
661
+ if (SAFE_TAGS.has(tag)) {
662
+ // Exception for <a> and <button> elements styled as buttons. SAFE_TAGS
663
+ // exists to suppress contrast noise on inline links and unstyled controls,
664
+ // where the element has no own background and the contrast against the
665
+ // ancestor surface is already the intended visual. When the element has
666
+ // its own opaque background and direct text, it is a styled button — and
667
+ // contrast on its own surface is a real, frequent bug worth flagging.
668
+ const isStyledButton = (tag === 'a' || tag === 'button')
669
+ && hasDirectText
670
+ && bgColor && bgColor.a > 0.5;
671
+ if (!isStyledButton) return [];
672
+ }
673
+ const findings = [];
674
+
675
+ if (hasDirectText && textColor && !isEmojiOnly) {
676
+ // Run background-dependent checks against either a solid bg or, if the
677
+ // ancestor is a gradient, against every gradient stop (use the worst case).
678
+ const bgs = effectiveBg ? [effectiveBg] : (effectiveBgStops && effectiveBgStops.length ? effectiveBgStops : null);
679
+ if (bgs) {
680
+ // Gray on colored background — flag if every stop is chromatic
681
+ const textLum = relativeLuminance(textColor);
682
+ const isGray = !hasChroma(textColor, 20) && textLum > 0.05 && textLum < 0.85;
683
+ if (isGray && bgs.every(b => hasChroma(b, 40))) {
684
+ const bgLabel = effectiveBg ? colorToHex(effectiveBg) : `gradient(${bgs.map(colorToHex).join(', ')})`;
685
+ findings.push({ id: 'gray-on-color', snippet: `text ${colorToHex(textColor)} on bg ${bgLabel}` });
686
+ }
687
+
688
+ // Low contrast (WCAG AA) — worst case across all bg stops
689
+ const ratios = bgs.map(b => contrastRatio(textColor, b));
690
+ let worstIdx = 0;
691
+ for (let i = 1; i < ratios.length; i++) if (ratios[i] < ratios[worstIdx]) worstIdx = i;
692
+ const ratio = ratios[worstIdx];
693
+ const isLargeText = fontSize >= WCAG_LARGE_TEXT_PX || (fontSize >= WCAG_LARGE_BOLD_TEXT_PX && fontWeight >= 700);
694
+ const threshold = isLargeText ? 3.0 : 4.5;
695
+ if (ratio < threshold) {
696
+ // Skip the false-positive class where text has alpha < 1 AND we
697
+ // couldn't find an opaque ancestor (effectiveBg is null, we're
698
+ // comparing against gradient-stop fallback). In jsdom mode the
699
+ // detector can't resolve `var(--X)` color tokens, so a dark
700
+ // section sitting between the text and the body's decorative
701
+ // gradient is invisible to us — we end up measuring contrast
702
+ // against the body's paper-grain noise instead of the real
703
+ // local bg. Real low-contrast bugs use alpha=1 and have a
704
+ // resolvable opaque ancestor; semi-transparent Tailwind tokens
705
+ // like `text-paper/60` on `bg-ink` sections are the FP pattern.
706
+ const isAlphaFallbackFP = !DETECTOR_IS_BROWSER && !effectiveBg && (textColor.a != null && textColor.a < 1);
707
+ if (!isAlphaFallbackFP) {
708
+ findings.push({ id: 'low-contrast', snippet: `${ratio.toFixed(1)}:1 (need ${threshold}:1) — text ${colorToHex(textColor)} on ${colorToHex(bgs[worstIdx])}` });
709
+ }
710
+ }
711
+ }
712
+
713
+ // AI palette: purple/violet on headings
714
+ if (hasChroma(textColor, 50)) {
715
+ const hue = getHue(textColor);
716
+ if (hue >= 260 && hue <= 310 && (['h1', 'h2', 'h3'].includes(tag) || fontSize >= 20)) {
717
+ findings.push({ id: 'ai-color-palette', snippet: `Purple/violet text (${colorToHex(textColor)}) on heading` });
718
+ }
719
+ }
720
+ }
721
+
722
+ // Gradient text
723
+ if (bgClip === 'text' && bgImage && bgImage.includes('gradient')) {
724
+ findings.push({ id: 'gradient-text', snippet: 'background-clip: text + gradient' });
725
+ }
726
+
727
+ // Tailwind class checks
728
+ if (classList) {
729
+ const classStr = typeof classList === 'string' ? classList : Array.from(classList).join(' ');
730
+
731
+ const grayMatch = classStr.match(/\btext-(?:gray|slate|zinc|neutral|stone)-\d+\b/);
732
+ const colorBgMatch = classStr.match(/\bbg-(?:red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d+\b/);
733
+ if (grayMatch && colorBgMatch) {
734
+ findings.push({ id: 'gray-on-color', snippet: `${grayMatch[0]} on ${colorBgMatch[0]}` });
735
+ }
736
+
737
+ if (/\bbg-clip-text\b/.test(classStr) && /\bbg-gradient-to-/.test(classStr)) {
738
+ findings.push({ id: 'gradient-text', snippet: 'bg-clip-text + bg-gradient (Tailwind)' });
739
+ }
740
+
741
+ const purpleText = classStr.match(/\btext-(?:purple|violet|indigo)-\d+\b/);
742
+ if (purpleText && (['h1', 'h2', 'h3'].includes(tag) || /\btext-(?:[2-9]xl)\b/.test(classStr))) {
743
+ findings.push({ id: 'ai-color-palette', snippet: `${purpleText[0]} on heading` });
744
+ }
745
+
746
+ if (/\bfrom-(?:purple|violet|indigo)-\d+\b/.test(classStr) && /\bto-(?:purple|violet|indigo|blue|cyan|pink|fuchsia)-\d+\b/.test(classStr)) {
747
+ findings.push({ id: 'ai-color-palette', snippet: 'Purple/violet gradient (Tailwind)' });
748
+ }
749
+ }
750
+
751
+ return findings;
752
+ }
753
+
754
+ function isCardLikeFromProps(hasShadow, hasBorder, hasRadius, hasBg) {
755
+ if (!hasShadow && !hasBorder) return false;
756
+ return hasRadius || hasBg;
757
+ }
758
+
759
+ const HEADING_TAGS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']);
760
+
761
+ // Pure check: given a heading and metrics about its previousElementSibling,
762
+ // decide if the sibling is the canonical "icon-tile-stacked-above-heading" shape.
763
+ //
764
+ // Triggers when ALL of the following hold for the sibling:
765
+ // • size 32–128px on both axes (not too small, not a hero image)
766
+ // • aspect ratio 0.7–1.4 (squarish — excludes wide thumbnails / pill badges)
767
+ // • has a non-transparent background-color, background-image, OR a visible border
768
+ // (covers solid colors, white-with-border, gradients — anything that visually
769
+ // defines a tile)
770
+ // • border-radius < width/2 (excludes round avatars; rounded squares pass)
771
+ // • contains an <svg> or icon-class <i> element that's smaller than the tile
772
+ // • the tile sits above the heading (its bottom is above the heading's top)
773
+ function checkIconTile(opts) {
774
+ const { headingTag, headingText, headingTop,
775
+ siblingTag, siblingWidth, siblingHeight, siblingBottom,
776
+ siblingBgColor, siblingBgImage, siblingBorderWidth, siblingBorderRadius,
777
+ hasIconChild, iconChildWidth } = opts;
778
+ if (!HEADING_TAGS.has(headingTag)) return [];
779
+ if (!siblingTag) return [];
780
+ // Don't recurse into nested headings (e.g. h2 above h3 in a section header)
781
+ if (HEADING_TAGS.has(siblingTag)) return [];
782
+
783
+ // Size window: 32–128px on each axis
784
+ if (!(siblingWidth >= 32 && siblingWidth <= 128)) return [];
785
+ if (!(siblingHeight >= 32 && siblingHeight <= 128)) return [];
786
+
787
+ // Squarish aspect ratio
788
+ const ratio = siblingWidth / siblingHeight;
789
+ if (ratio < 0.7 || ratio > 1.4) return [];
790
+
791
+ // Must have something that visually defines the tile
792
+ const bgVisible = (siblingBgColor && siblingBgColor.a > 0.1)
793
+ || (siblingBgImage && siblingBgImage !== 'none' && siblingBgImage !== '');
794
+ const borderVisible = siblingBorderWidth > 0;
795
+ if (!bgVisible && !borderVisible) return [];
796
+
797
+ // Exclude circles (avatars). Rounded squares pass.
798
+ if (siblingBorderRadius >= siblingWidth / 2) return [];
799
+
800
+ // Must contain an icon element smaller than the tile
801
+ if (!hasIconChild) return [];
802
+ if (iconChildWidth && iconChildWidth >= siblingWidth * 0.95) return [];
803
+
804
+ // Vertical stacking: tile must end above where the heading starts.
805
+ // (Allow the check to skip when both top/bottom are 0 — jsdom layout case.)
806
+ if (headingTop && siblingBottom && siblingBottom > headingTop + 4) return [];
807
+
808
+ const text = (headingText || '').trim().slice(0, 60);
809
+ return [{
810
+ id: 'icon-tile-stack',
811
+ snippet: `${Math.round(siblingWidth)}x${Math.round(siblingHeight)}px icon tile above ${headingTag} "${text}"`,
812
+ }];
813
+ }
814
+
815
+ // Resolve the primary (non-generic) face from a font-family string and return
816
+ // whether the resolved primary is serif. Two paths:
817
+ // 1. Primary face is in KNOWN_SERIF_FONTS → serif.
818
+ // 2. Primary face is unknown but the stack ends in the generic `serif`
819
+ // token → treat as serif. Authors who declare `font-family: 'X', serif`
820
+ // almost always have a serif primary; a sans declared with a serif
821
+ // fallback is a code smell, not the common case.
822
+ // Returns { primary, isSerif } so the snippet can name the face.
823
+ function resolveSerif(fontFamily) {
824
+ if (!fontFamily) return { primary: null, isSerif: false };
825
+ const tokens = fontFamily.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
826
+ const primary = tokens.find(f => f && !GENERIC_FONTS.has(f)) || null;
827
+ if (!primary) return { primary: null, isSerif: false };
828
+ if (KNOWN_SERIF_FONTS.has(primary)) return { primary, isSerif: true };
829
+ if (tokens.includes('serif')) return { primary, isSerif: true };
830
+ return { primary, isSerif: false };
831
+ }
832
+
833
+ function checkItalicSerif(opts) {
834
+ const { tag, fontStyle, fontFamily, fontSize, headingText } = opts;
835
+ if (fontStyle !== 'italic') return [];
836
+ // Anchor the rule on hero-scale text. h1 is the canonical hero element;
837
+ // h2 ≥ 48px catches the cases where the design demotes the visual hero
838
+ // to an h2 but keeps the size.
839
+ if (tag !== 'h1' && !(tag === 'h2' && fontSize >= 48)) return [];
840
+ if (fontSize < 48) return [];
841
+ const { primary, isSerif } = resolveSerif(fontFamily);
842
+ if (!isSerif) return [];
843
+
844
+ const text = (headingText || '').trim().slice(0, 60);
845
+ return [{
846
+ id: 'italic-serif-display',
847
+ snippet: `italic serif ${tag} (${primary || 'serif'}) at ${Math.round(fontSize)}px "${text}"`,
848
+ }];
849
+ }
850
+
851
+ // Color saturation check. Returns true when the color has visible
852
+ // chroma — i.e., it's an "accent color" rather than near-neutral.
853
+ // Handles rgb()/rgba(), #hex, oklch(), and hsl(). var() refs are
854
+ // expected to be pre-resolved by the caller.
855
+ function isAccentColor(cssColor) {
856
+ if (!cssColor) return false;
857
+ const s = String(cssColor).trim();
858
+ // rgb / rgba — direct channel-distance check.
859
+ const rgbM = /rgba?\(\s*(\d+)\s*,?\s+|\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(s.replace(/rgba?\(\s*/, 'rgb(').replace(/,/g, ', '));
860
+ const rgbStrict = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(s);
861
+ if (rgbStrict) {
862
+ const r = +rgbStrict[1], g = +rgbStrict[2], b = +rgbStrict[3];
863
+ return (Math.max(r, g, b) - Math.min(r, g, b)) >= 40;
864
+ }
865
+ // #hex — 3, 4, 6, or 8 digit.
866
+ const hexM = /^#([0-9a-f]{3,8})\b/i.exec(s);
867
+ if (hexM) {
868
+ let h = hexM[1];
869
+ if (h.length === 3 || h.length === 4) h = h.split('').map((c) => c + c).join('').slice(0, 6);
870
+ else h = h.slice(0, 6);
871
+ if (h.length === 6) {
872
+ const r = parseInt(h.slice(0, 2), 16);
873
+ const g = parseInt(h.slice(2, 4), 16);
874
+ const b = parseInt(h.slice(4, 6), 16);
875
+ return (Math.max(r, g, b) - Math.min(r, g, b)) >= 40;
876
+ }
877
+ }
878
+ // oklch(L C H) — chroma C is what matters. Typical neutral grays
879
+ // have C < 0.02; visible accents are 0.05+. CSS minification can
880
+ // collapse spaces between L% and C ("oklch(43%.15 34)"), so we
881
+ // extract all numbers and take the second rather than matching a
882
+ // strict L-then-whitespace-then-C pattern.
883
+ if (/^oklch\(/i.test(s)) {
884
+ const nums = s.match(/\d*\.\d+|\d+/g);
885
+ if (nums && nums.length >= 2) {
886
+ const c = parseFloat(nums[1]);
887
+ return !Number.isNaN(c) && c >= 0.05;
888
+ }
889
+ }
890
+ // hsl(H, S%, L%) — saturation > 20% reads as accent.
891
+ const hslM = /hsla?\(\s*[\d.]+\s*,\s*([\d.]+)%/i.exec(s);
892
+ if (hslM) {
893
+ const sat = parseFloat(hslM[1]);
894
+ return !Number.isNaN(sat) && sat >= 20;
895
+ }
896
+ return false;
897
+ }
898
+
899
+ // Sibling-relationship rule. Anchor on a hero-scale h1, look at the
900
+ // previousElementSibling, and gate on EITHER the classic tracked-
901
+ // uppercase eyebrow OR the modern accent-colored bold eyebrow.
902
+ function checkHeroEyebrow(opts) {
903
+ const {
904
+ headingTag, headingText, headingFontSize,
905
+ siblingTag, siblingText, siblingTextTransform,
906
+ siblingFontSize, siblingLetterSpacing,
907
+ siblingFontWeight, siblingColor,
908
+ } = opts;
909
+ if (headingTag !== 'h1') return [];
910
+ // We previously gated on headingFontSize >= 48 to anchor "hero scale".
911
+ // But modern hero h1s use clamp() / vw / var(--text-*), none of which
912
+ // jsdom can resolve — the computed value comes back as "2em" or
913
+ // "var(--text-9xl)" and parseFloat returns 2 or NaN. The gate fails
914
+ // on virtually every Tailwind v4 / framework build. The other gates
915
+ // (sibling text 2-60 chars, font-size ≤ 14px, accent-bold OR
916
+ // tracked-caps) are tight enough to avoid false positives on non-
917
+ // hero h1s — a tiny tan label directly above any h1 is the
918
+ // antipattern regardless of how big the h1 ends up.
919
+ if (!siblingTag) return [];
920
+ // An h2 above an h1 is a different anti-pattern (heading hierarchy / dual
921
+ // headings) — never an eyebrow.
922
+ if (HEADING_TAGS.has(siblingTag)) return [];
923
+
924
+ const text = (siblingText || '').trim();
925
+ if (text.length < 2 || text.length > 60) return [];
926
+ if (!(siblingFontSize > 0 && siblingFontSize <= 14)) return [];
927
+
928
+ // Branch A: classic tracked-uppercase eyebrow.
929
+ const isUppercased = siblingTextTransform === 'uppercase'
930
+ || (/[A-Z]/.test(text) && !/[a-z]/.test(text));
931
+ const isClassicTracked = isUppercased && siblingLetterSpacing >= 1.6;
932
+
933
+ // Branch B: modern accent-bold eyebrow — sentence case, low
934
+ // tracking, but bold + accent-colored. The style choices changed;
935
+ // the pattern is the same kicker-above-headline anti-pattern.
936
+ const weight = Number(siblingFontWeight) || 400;
937
+ const isAccentBold = weight >= 700 && isAccentColor(siblingColor || '');
938
+
939
+ if (!isClassicTracked && !isAccentBold) return [];
940
+
941
+ const headingTextSnippet = (headingText || '').trim().slice(0, 60);
942
+ const eyebrowSnippet = text.slice(0, 40);
943
+ const style = isClassicTracked ? 'tracked-caps' : 'accent-bold';
944
+ return [{
945
+ id: 'hero-eyebrow-chip',
946
+ snippet: `eyebrow chip (${style}) "${eyebrowSnippet}" above ${headingTag} "${headingTextSnippet}"`,
947
+ }];
948
+ }
949
+
950
+ function checkRepeatedSectionKickers(opts) {
951
+ const { candidates, minCount = 3 } = opts;
952
+ if (!Array.isArray(candidates) || candidates.length < minCount) return [];
953
+ return candidates.map(candidate => ({
954
+ id: 'repeated-section-kickers',
955
+ snippet: `repeated section kicker "${candidate.kickerText}" before ${candidate.headingTag} "${candidate.headingText}" (${candidates.length} on page)`,
956
+ }));
957
+ }
958
+
959
+ const LAYOUT_TRANSITION_PROPS = new Set([
960
+ 'width', 'height', 'padding', 'margin',
961
+ 'max-height', 'max-width', 'min-height', 'min-width',
962
+ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
963
+ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
964
+ ]);
965
+
966
+ function checkMotion(opts) {
967
+ const { tag, transitionProperty, animationName, timingFunctions, classList } = opts;
968
+ if (SAFE_TAGS.has(tag)) return [];
969
+ const findings = [];
970
+
971
+ // --- Bounce/elastic easing ---
972
+ if (animationName && animationName !== 'none' && /bounce|elastic|wobble|jiggle|spring/i.test(animationName)) {
973
+ findings.push({ id: 'bounce-easing', snippet: `animation: ${animationName}` });
974
+ }
975
+ if (classList && /\banimate-bounce\b/.test(classList)) {
976
+ findings.push({ id: 'bounce-easing', snippet: 'animate-bounce (Tailwind)' });
977
+ }
978
+
979
+ // Check timing functions for overshoot cubic-bezier (y values outside [0, 1])
980
+ if (timingFunctions) {
981
+ const bezierRe = /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g;
982
+ let m;
983
+ while ((m = bezierRe.exec(timingFunctions)) !== null) {
984
+ const y1 = parseFloat(m[2]), y2 = parseFloat(m[4]);
985
+ if (y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1) {
986
+ findings.push({ id: 'bounce-easing', snippet: `cubic-bezier(${m[1]}, ${m[2]}, ${m[3]}, ${m[4]})` });
987
+ break;
988
+ }
989
+ }
990
+ }
991
+
992
+ // --- Layout property transition ---
993
+ if (transitionProperty && transitionProperty !== 'all' && transitionProperty !== 'none') {
994
+ const props = transitionProperty.split(',').map(p => p.trim().toLowerCase());
995
+ const layoutFound = props.filter(p => LAYOUT_TRANSITION_PROPS.has(p));
996
+ if (layoutFound.length > 0) {
997
+ findings.push({ id: 'layout-transition', snippet: `transition: ${layoutFound.join(', ')}` });
998
+ }
999
+ }
1000
+
1001
+ return findings;
1002
+ }
1003
+
1004
+ function checkGlow(opts) {
1005
+ const { boxShadow, effectiveBg } = opts;
1006
+ if (!boxShadow || boxShadow === 'none') return [];
1007
+ if (!effectiveBg) return [];
1008
+
1009
+ // Only flag on dark backgrounds (luminance < 0.1)
1010
+ const bgLum = relativeLuminance(effectiveBg);
1011
+ if (bgLum >= 0.1) return [];
1012
+
1013
+ // Split multiple shadows (commas not inside parentheses)
1014
+ const parts = boxShadow.split(/,(?![^(]*\))/);
1015
+ for (const shadow of parts) {
1016
+ const colorMatch = shadow.match(/rgba?\([^)]+\)/);
1017
+ if (!colorMatch) continue;
1018
+ const color = parseRgb(colorMatch[0]);
1019
+ if (!color || !hasChroma(color, 30)) continue;
1020
+
1021
+ // Extract px values — in computed style: "color Xpx Ypx BLURpx [SPREADpx]"
1022
+ const afterColor = shadow.substring(shadow.indexOf(colorMatch[0]) + colorMatch[0].length);
1023
+ const beforeColor = shadow.substring(0, shadow.indexOf(colorMatch[0]));
1024
+ const pxVals = [...beforeColor.matchAll(/([\d.]+)px/g), ...afterColor.matchAll(/([\d.]+)px/g)]
1025
+ .map(m => parseFloat(m[1]));
1026
+
1027
+ // Third value is blur (offset-x, offset-y, blur, [spread])
1028
+ if (pxVals.length >= 3 && pxVals[2] > 4) {
1029
+ return [{ id: 'dark-glow', snippet: `Colored glow (${colorToHex(color)}) on dark background` }];
1030
+ }
1031
+ }
1032
+
1033
+ return [];
1034
+ }
1035
+
1036
+ /**
1037
+ * Regex-on-HTML checks shared between browser and Node page-level detection.
1038
+ * These don't need DOM access, just the raw HTML string.
1039
+ */
1040
+ function checkHtmlPatterns(html) {
1041
+ const findings = [];
1042
+
1043
+ // --- Color ---
1044
+
1045
+ // AI color palette: purple/violet
1046
+ const purpleHexRe = /#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9|6366f1|764ba2|667eea)\b/gi;
1047
+ if (purpleHexRe.test(html)) {
1048
+ const purpleTextRe = /(?:(?:^|;)\s*color\s*:\s*(?:.*?)(?:#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9))|gradient.*?#(?:7c3aed|8b5cf6|a855f7|764ba2|667eea))/gi;
1049
+ if (purpleTextRe.test(html)) {
1050
+ findings.push({ id: 'ai-color-palette', snippet: 'Purple/violet accent colors detected' });
1051
+ }
1052
+ }
1053
+
1054
+ // Gradient text (background-clip: text + gradient)
1055
+ const gradientRe = /(?:-webkit-)?background-clip\s*:\s*text/gi;
1056
+ let gm;
1057
+ while ((gm = gradientRe.exec(html)) !== null) {
1058
+ const start = Math.max(0, gm.index - 200);
1059
+ const context = html.substring(start, gm.index + gm[0].length + 200);
1060
+ if (/gradient/i.test(context)) {
1061
+ findings.push({ id: 'gradient-text', snippet: 'background-clip: text + gradient' });
1062
+ break;
1063
+ }
1064
+ }
1065
+ if (/\bbg-clip-text\b/.test(html) && /\bbg-gradient-to-/.test(html)) {
1066
+ findings.push({ id: 'gradient-text', snippet: 'bg-clip-text + bg-gradient (Tailwind)' });
1067
+ }
1068
+
1069
+ // --- Layout ---
1070
+
1071
+ // Monotonous spacing
1072
+ const spacingValues = [];
1073
+ const spacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*(\d+)px/gi;
1074
+ let sm;
1075
+ while ((sm = spacingRe.exec(html)) !== null) {
1076
+ const v = parseInt(sm[1], 10);
1077
+ if (v > 0 && v < 200) spacingValues.push(v);
1078
+ }
1079
+ const gapRe = /gap\s*:\s*(\d+)px/gi;
1080
+ while ((sm = gapRe.exec(html)) !== null) {
1081
+ spacingValues.push(parseInt(sm[1], 10));
1082
+ }
1083
+ const twSpaceRe = /\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-(\d+)\b/g;
1084
+ while ((sm = twSpaceRe.exec(html)) !== null) {
1085
+ spacingValues.push(parseInt(sm[1], 10) * 4);
1086
+ }
1087
+ const remSpacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*([\d.]+)rem/gi;
1088
+ while ((sm = remSpacingRe.exec(html)) !== null) {
1089
+ const v = Math.round(parseFloat(sm[1]) * 16);
1090
+ if (v > 0 && v < 200) spacingValues.push(v);
1091
+ }
1092
+ const roundedSpacing = spacingValues.map(v => Math.round(v / 4) * 4);
1093
+ if (roundedSpacing.length >= 10) {
1094
+ const counts = {};
1095
+ for (const v of roundedSpacing) counts[v] = (counts[v] || 0) + 1;
1096
+ const maxCount = Math.max(...Object.values(counts));
1097
+ const dominantPct = maxCount / roundedSpacing.length;
1098
+ const unique = [...new Set(roundedSpacing)].filter(v => v > 0);
1099
+ if (dominantPct > 0.6 && unique.length <= 3) {
1100
+ const dominant = Object.entries(counts).sort((a, b) => b[1] - a[1])[0][0];
1101
+ findings.push({
1102
+ id: 'monotonous-spacing',
1103
+ snippet: `~${dominant}px used ${maxCount}/${roundedSpacing.length} times (${Math.round(dominantPct * 100)}%)`,
1104
+ });
1105
+ }
1106
+ }
1107
+
1108
+ // --- Motion ---
1109
+
1110
+ // Bounce/elastic animation names
1111
+ const bounceRe = /animation(?:-name)?\s*:\s*[^;]*\b(bounce|elastic|wobble|jiggle|spring)\b/gi;
1112
+ if (bounceRe.test(html)) {
1113
+ findings.push({ id: 'bounce-easing', snippet: 'Bounce/elastic animation in CSS' });
1114
+ }
1115
+
1116
+ // Overshoot cubic-bezier
1117
+ const bezierRe = /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g;
1118
+ let bm;
1119
+ while ((bm = bezierRe.exec(html)) !== null) {
1120
+ const y1 = parseFloat(bm[2]), y2 = parseFloat(bm[4]);
1121
+ if (y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1) {
1122
+ findings.push({ id: 'bounce-easing', snippet: `cubic-bezier(${bm[1]}, ${bm[2]}, ${bm[3]}, ${bm[4]})` });
1123
+ break;
1124
+ }
1125
+ }
1126
+
1127
+ // Layout property transitions
1128
+ const transRe = /transition(?:-property)?\s*:\s*([^;{}]+)/gi;
1129
+ let tm;
1130
+ while ((tm = transRe.exec(html)) !== null) {
1131
+ const val = tm[1].toLowerCase();
1132
+ if (/\ball\b/.test(val)) continue;
1133
+ const found = val.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
1134
+ if (found) {
1135
+ findings.push({ id: 'layout-transition', snippet: `transition: ${found.join(', ')}` });
1136
+ break;
1137
+ }
1138
+ }
1139
+
1140
+ // --- Dark glow ---
1141
+
1142
+ const darkBgRe = /background(?:-color)?\s*:\s*(?:#(?:0[0-9a-f]|1[0-9a-f]|2[0-3])[0-9a-f]{4}\b|#(?:0|1)[0-9a-f]{2}\b|rgb\(\s*(\d{1,2})\s*,\s*(\d{1,2})\s*,\s*(\d{1,2})\s*\))/gi;
1143
+ const twDarkBg = /\bbg-(?:gray|slate|zinc|neutral|stone)-(?:9\d{2}|800)\b/;
1144
+ if (darkBgRe.test(html) || twDarkBg.test(html)) {
1145
+ const shadowRe = /box-shadow\s*:\s*([^;{}]+)/gi;
1146
+ let shm;
1147
+ while ((shm = shadowRe.exec(html)) !== null) {
1148
+ const val = shm[1];
1149
+ const colorMatch = val.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
1150
+ if (!colorMatch) continue;
1151
+ const [r, g, b] = [+colorMatch[1], +colorMatch[2], +colorMatch[3]];
1152
+ if ((Math.max(r, g, b) - Math.min(r, g, b)) < 30) continue;
1153
+ const pxVals = [...val.matchAll(/(\d+)px|(?<![.\d])\b(0)\b(?![.\d])/g)].map(p => +(p[1] || p[2]));
1154
+ if (pxVals.length >= 3 && pxVals[2] > 4) {
1155
+ findings.push({ id: 'dark-glow', snippet: `Colored glow (rgb(${r},${g},${b})) on dark page` });
1156
+ break;
1157
+ }
1158
+ }
1159
+ }
1160
+
1161
+ // --- Provider tells (gated): repeating-gradient stripes (GPT) ---
1162
+ if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(html)) {
1163
+ findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
1164
+ }
1165
+
1166
+ // --- Provider tells (gated): "X theater" framing copy (GPT) ---
1167
+ // Lives here (regex-on-HTML) rather than in the text-content analyzers so it
1168
+ // runs in the bundled browser path too, not just the CLI/static path.
1169
+ {
1170
+ const bodyText = html
1171
+ .replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, ' ')
1172
+ .replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, ' ')
1173
+ .replace(/<[^>]+>/g, ' ');
1174
+ const tm = /\b(\w+)\s+theater\b/i.exec(bodyText);
1175
+ if (tm) findings.push({ id: 'theater-slop-phrase', snippet: `"${tm[0].trim()}"` });
1176
+ }
1177
+
1178
+ // --- Provider tells (gated): image hover transform (Gemini) ---
1179
+ // A CSS `img...:hover { transform: ... }` rule, or a Tailwind hover:scale /
1180
+ // hover:rotate / hover:translate utility on an <img>. Each distinct
1181
+ // mechanism is its own finding.
1182
+ const imgHoverCss = /\bimg\b[^,{}]*:hover\b[^{}]*\{[^}]*\btransform\s*:\s*(?:scale|rotate|translate|matrix|skew)/i;
1183
+ if (imgHoverCss.test(html)) {
1184
+ findings.push({ id: 'image-hover-transform', snippet: 'img:hover { transform } rule' });
1185
+ }
1186
+ const imgTagRe = /<img\b[^>]*\bclass\s*=\s*"([^"]*)"/gi;
1187
+ let im;
1188
+ while ((im = imgTagRe.exec(html)) !== null) {
1189
+ if (/\bhover:(?:scale|rotate|translate|skew)-/.test(im[1])) {
1190
+ findings.push({ id: 'image-hover-transform', snippet: 'Tailwind hover transform on <img>' });
1191
+ }
1192
+ }
1193
+
1194
+ return findings;
1195
+ }
1196
+
1197
+ // ─── Section 4: resolveBackground (unified) ─────────────────────────────────
1198
+
1199
+ // Read the element's own background color, computed-style first, with a
1200
+ // jsdom-friendly fallback that parses the inline `background:` shorthand
1201
+ // from the raw style attribute. jsdom (~v29) does not decompose the
1202
+ // shorthand into `backgroundColor`, so without this fallback the CLI silently
1203
+ // returns null for any element styled via `background: rgb(...)` or
1204
+ // `background: #abc`. Real browsers always decompose, so the fallback is
1205
+ // a no-op there.
1206
+ function readOwnBackgroundColor(el, computedStyle) {
1207
+ const bg = parseRgb(computedStyle.backgroundColor);
1208
+ if (DETECTOR_IS_BROWSER || (bg && bg.a >= 0.1)) return bg;
1209
+ const rawStyle = el.getAttribute?.('style') || '';
1210
+ const bgMatch = rawStyle.match(/background(?:-color)?\s*:\s*([^;]+)/i);
1211
+ const inlineBg = bgMatch ? bgMatch[1].trim() : '';
1212
+ if (!inlineBg) return bg;
1213
+ if (/gradient/i.test(inlineBg) || /url\s*\(/i.test(inlineBg)) return bg;
1214
+ const fromRgb = parseRgb(inlineBg);
1215
+ if (fromRgb) return fromRgb;
1216
+ const hexMatch = inlineBg.match(/#([0-9a-f]{6}|[0-9a-f]{3})\b/i);
1217
+ if (hexMatch) {
1218
+ const h = hexMatch[1];
1219
+ if (h.length === 6) {
1220
+ return { r: parseInt(h.slice(0, 2), 16), g: parseInt(h.slice(2, 4), 16), b: parseInt(h.slice(4, 6), 16), a: 1 };
1221
+ }
1222
+ return { r: parseInt(h[0] + h[0], 16), g: parseInt(h[1] + h[1], 16), b: parseInt(h[2] + h[2], 16), a: 1 };
1223
+ }
1224
+ return bg;
1225
+ }
1226
+
1227
+ function resolveBackground(el, win, customPropMap) {
1228
+ let current = el;
1229
+ while (current && current.nodeType === 1) {
1230
+ const style = DETECTOR_IS_BROWSER ? getComputedStyle(current) : win.getComputedStyle(current);
1231
+ const bgImage = style.backgroundImage || '';
1232
+ const hasGradientOrUrl = bgImage && bgImage !== 'none' && (/gradient/i.test(bgImage) || /url\s*\(/i.test(bgImage));
1233
+
1234
+ // Try the solid bg-color FIRST. If the element has both a solid color
1235
+ // and a gradient/url overlay (a common pattern: `background: var(--paper)
1236
+ // radial-gradient(...)` for paper-grain texture), the solid color is the
1237
+ // dominant visible surface for contrast purposes; the overlay is
1238
+ // decorative. The old behavior bailed on any gradient ancestor, which
1239
+ // caused massive false-positive contrast findings on grain-textured
1240
+ // body backgrounds.
1241
+ let bg = parseRgb(style.backgroundColor);
1242
+ if (!DETECTOR_IS_BROWSER && (!bg || bg.a < 0.1)) {
1243
+ // jsdom returns literal "var(--X)" / "oklch(...)" strings. Resolve
1244
+ // through customPropMap so Tailwind v4 color tokens become RGB.
1245
+ if (customPropMap) {
1246
+ bg = parseColorResolved(style.backgroundColor, customPropMap);
1247
+ }
1248
+ if (!bg || bg.a < 0.1) {
1249
+ // Inline-style fallback. jsdom doesn't decompose background
1250
+ // shorthand, so colors set via inline style are otherwise invisible.
1251
+ const rawStyle = current.getAttribute?.('style') || '';
1252
+ const bgMatch = rawStyle.match(/background(?:-color)?\s*:\s*([^;]+)/i);
1253
+ const inlineBg = bgMatch ? bgMatch[1].trim() : '';
1254
+ if (inlineBg && !/gradient/i.test(inlineBg) && !/url\s*\(/i.test(inlineBg)) {
1255
+ bg = parseColorResolved(inlineBg, customPropMap) || parseAnyColor(inlineBg);
1256
+ }
1257
+ }
1258
+ }
1259
+
1260
+ if (bg && bg.a > 0.1) {
1261
+ if (DETECTOR_IS_BROWSER || bg.a >= 0.5) return bg;
1262
+ }
1263
+ // No solid bg-color at this level. If THIS level has a gradient/url
1264
+ // with no underlying solid color we can read:
1265
+ // • on body/html: assume white. Body-level gradients are almost
1266
+ // always decorative texture (paper grain, noise) on top of a
1267
+ // solid bg-color the page set via `background: var(--paper)`
1268
+ // shorthand — which jsdom can't decompose into bg-color. The
1269
+ // downstream gradient-stops fallback path produces catastrophic
1270
+ // false positives in this case (gradient noise stops have
1271
+ // accidental browns/blacks that look like card backgrounds).
1272
+ // • on other elements: bail to null and let the caller fall back
1273
+ // to gradient stops (gradient buttons / hero sections are real
1274
+ // bgs worth checking against).
1275
+ if (hasGradientOrUrl) {
1276
+ if (current.tagName === 'BODY' || current.tagName === 'HTML') {
1277
+ return { r: 255, g: 255, b: 255, a: 1 };
1278
+ }
1279
+ return null;
1280
+ }
1281
+ current = current.parentElement;
1282
+ }
1283
+ return { r: 255, g: 255, b: 255 };
1284
+ }
1285
+
1286
+ // Walk parents looking for a gradient background and return its color stops.
1287
+ // Used as a fallback when resolveBackground() returns null because the
1288
+ // effective background is a gradient (no single solid color to compare against).
1289
+ function resolveGradientStops(el, win) {
1290
+ let current = el;
1291
+ while (current && current.nodeType === 1) {
1292
+ const style = DETECTOR_IS_BROWSER ? getComputedStyle(current) : win.getComputedStyle(current);
1293
+ const bgImage = style.backgroundImage || '';
1294
+ if (bgImage && bgImage !== 'none' && /gradient/i.test(bgImage)) {
1295
+ const stops = parseGradientColors(bgImage);
1296
+ if (stops.length > 0) return stops;
1297
+ }
1298
+ if (!DETECTOR_IS_BROWSER) {
1299
+ // jsdom doesn't decompose `background:` shorthand — peek at the raw inline style
1300
+ const rawStyle = current.getAttribute?.('style') || '';
1301
+ const bgMatch = rawStyle.match(/background(?:-image)?\s*:\s*([^;]+)/i);
1302
+ if (bgMatch && /gradient/i.test(bgMatch[1])) {
1303
+ const stops = parseGradientColors(bgMatch[1]);
1304
+ if (stops.length > 0) return stops;
1305
+ }
1306
+ }
1307
+ current = current.parentElement;
1308
+ }
1309
+ return null;
1310
+ }
1311
+
1312
+ // Parse a single CSS length token to pixels. Accepts "12px", "50%", a
1313
+ // shorthand like "12px 4px" (uses the first value), or empty / null.
1314
+ // Returns the pixel value, or null when the input is unparseable.
1315
+ // Percentages convert against `widthPx` when one is supplied. Without a
1316
+ // usable width (jsdom returns "auto" for many real-world elements,
1317
+ // which parseFloat collapses to 0), fall back to the raw percentage
1318
+ // number so callers gating on `> 0` (border-accent-on-rounded,
1319
+ // isCardLike's hasRadius) still see a positive value, matching the
1320
+ // original parseFloat("50%") === 50 behavior.
1321
+ function parseRadiusToPx(value, widthPx) {
1322
+ if (!value || typeof value !== 'string') return null;
1323
+ const trimmed = value.trim();
1324
+ if (!trimmed) return null;
1325
+ const first = trimmed.split(/\s+/)[0];
1326
+ const num = parseFloat(first);
1327
+ if (Number.isNaN(num)) return null;
1328
+ if (/%$/.test(first)) {
1329
+ if (widthPx && widthPx > 0) return (num / 100) * widthPx;
1330
+ return num;
1331
+ }
1332
+ return num;
1333
+ }
1334
+
1335
+ function resolveBorderRadiusPx(el, style, widthPx, win) {
1336
+ const fromComputed = parseRadiusToPx(style.borderRadius, widthPx);
1337
+ if (fromComputed !== null) return fromComputed;
1338
+ return 0;
1339
+ }
1340
+
1341
+ // ─── Section 5: Element Adapters ────────────────────────────────────────────
1342
+
1343
+ // Browser adapters — call getComputedStyle/getBoundingClientRect on live DOM
1344
+
1345
+ function checkElementBordersDOM(el) {
1346
+ const tag = el.tagName.toLowerCase();
1347
+ if (BORDER_SAFE_TAGS.has(tag)) return [];
1348
+ const rect = el.getBoundingClientRect();
1349
+ if (rect.width < 20 || rect.height < 20) return [];
1350
+ const style = getComputedStyle(el);
1351
+ const sides = ['Top', 'Right', 'Bottom', 'Left'];
1352
+ const widths = {}, colors = {};
1353
+ for (const s of sides) {
1354
+ widths[s] = parseFloat(style[`border${s}Width`]) || 0;
1355
+ colors[s] = style[`border${s}Color`] || '';
1356
+ }
1357
+ return checkBorders(tag, widths, colors, parseFloat(style.borderRadius) || 0);
1358
+ }
1359
+
1360
+ function checkElementColorsDOM(el) {
1361
+ const tag = el.tagName.toLowerCase();
1362
+ // No early SAFE_TAGS bail here — checkColors() does its own gating that
1363
+ // includes the styled-button exception for <a> / <button> with their own
1364
+ // opaque background. Bailing here would prevent that exception from firing.
1365
+ const rect = el.getBoundingClientRect();
1366
+ if (rect.width < 10 || rect.height < 10) return [];
1367
+ const style = getComputedStyle(el);
1368
+ const directText = [...el.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join('');
1369
+ const hasDirectText = directText.trim().length > 0;
1370
+ const effectiveBg = resolveBackground(el);
1371
+ return checkColors({
1372
+ tag,
1373
+ textColor: parseRgb(style.color),
1374
+ bgColor: readOwnBackgroundColor(el, style),
1375
+ effectiveBg,
1376
+ effectiveBgStops: effectiveBg ? null : resolveGradientStops(el),
1377
+ fontSize: parseFloat(style.fontSize) || 16,
1378
+ fontWeight: parseInt(style.fontWeight) || 400,
1379
+ hasDirectText,
1380
+ isEmojiOnly: isEmojiOnlyText(directText),
1381
+ bgClip: style.webkitBackgroundClip || style.backgroundClip || '',
1382
+ bgImage: style.backgroundImage || '',
1383
+ classList: el.getAttribute('class') || '',
1384
+ });
1385
+ }
1386
+
1387
+ function checkElementIconTileDOM(el) {
1388
+ const tag = el.tagName.toLowerCase();
1389
+ if (!HEADING_TAGS.has(tag)) return [];
1390
+ const sibling = el.previousElementSibling;
1391
+ if (!sibling) return [];
1392
+
1393
+ const sibRect = sibling.getBoundingClientRect();
1394
+ const headRect = el.getBoundingClientRect();
1395
+ const sibStyle = getComputedStyle(sibling);
1396
+
1397
+ // The tile may either contain an <svg>/<i> icon child, OR the tile itself
1398
+ // may contain an emoji/symbol character directly as its only text content
1399
+ // (the "card-icon" pattern from many AI-generated demos).
1400
+ const iconChild = sibling.querySelector('svg, i[data-lucide], i[class*="fa-"], i[class*="icon"]');
1401
+ const iconRect = iconChild?.getBoundingClientRect();
1402
+ const sibDirectText = [...sibling.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join('');
1403
+ const hasInlineEmojiIcon = sibling.children.length === 0 && isEmojiOnlyText(sibDirectText);
1404
+
1405
+ return checkIconTile({
1406
+ headingTag: tag,
1407
+ headingText: el.textContent || '',
1408
+ headingTop: headRect.top,
1409
+ siblingTag: sibling.tagName.toLowerCase(),
1410
+ siblingWidth: sibRect.width,
1411
+ siblingHeight: sibRect.height,
1412
+ siblingBottom: sibRect.bottom,
1413
+ siblingBgColor: parseRgb(sibStyle.backgroundColor),
1414
+ siblingBgImage: sibStyle.backgroundImage || '',
1415
+ siblingBorderWidth: parseFloat(sibStyle.borderTopWidth) || 0,
1416
+ siblingBorderRadius: parseFloat(sibStyle.borderRadius) || 0,
1417
+ hasIconChild: !!iconChild || hasInlineEmojiIcon,
1418
+ iconChildWidth: iconRect?.width || 0,
1419
+ });
1420
+ }
1421
+
1422
+ function checkElementItalicSerifDOM(el) {
1423
+ const tag = el.tagName.toLowerCase();
1424
+ if (tag !== 'h1' && tag !== 'h2') return [];
1425
+ const style = getComputedStyle(el);
1426
+ return checkItalicSerif({
1427
+ tag,
1428
+ fontStyle: style.fontStyle || '',
1429
+ fontFamily: style.fontFamily || '',
1430
+ fontSize: parseFloat(style.fontSize) || 0,
1431
+ headingText: el.textContent || '',
1432
+ });
1433
+ }
1434
+
1435
+ function checkElementHeroEyebrowDOM(el) {
1436
+ const tag = el.tagName.toLowerCase();
1437
+ if (tag !== 'h1') return [];
1438
+ const sibling = el.previousElementSibling;
1439
+ if (!sibling) return [];
1440
+ const headStyle = getComputedStyle(el);
1441
+ const sibStyle = getComputedStyle(sibling);
1442
+ return checkHeroEyebrow({
1443
+ headingTag: tag,
1444
+ headingText: el.textContent || '',
1445
+ headingFontSize: parseFloat(headStyle.fontSize) || 0,
1446
+ siblingTag: sibling.tagName.toLowerCase(),
1447
+ siblingText: sibling.textContent || '',
1448
+ siblingTextTransform: sibStyle.textTransform || '',
1449
+ siblingFontSize: parseFloat(sibStyle.fontSize) || 0,
1450
+ siblingLetterSpacing: parseFloat(sibStyle.letterSpacing) || 0,
1451
+ siblingFontWeight: sibStyle.fontWeight || '',
1452
+ siblingColor: sibStyle.color || '',
1453
+ });
1454
+ }
1455
+
1456
+ // Build a map of CSS custom properties declared on :root / :host / html.
1457
+ // Used to resolve var(--X) refs that jsdom returns verbatim in
1458
+ // getComputedStyle. Tailwind v4 routes every utility class through
1459
+ // CSS vars (font-weight: var(--font-weight-bold), font-size:
1460
+ // var(--text-xs), letter-spacing: var(--tracking-widest)), so without
1461
+ // resolution every style-based check silently fails on Tailwind v4
1462
+ // builds — the values come back as literal "var(--font-weight-bold)"
1463
+ // strings and parseFloat returns NaN.
1464
+ function buildCustomPropMap(document) {
1465
+ const map = new Map();
1466
+ let sheets;
1467
+ try { sheets = Array.from(document.styleSheets || []); }
1468
+ catch { return map; }
1469
+ for (const sheet of sheets) {
1470
+ let rules;
1471
+ try { rules = Array.from(sheet.cssRules || []); }
1472
+ catch { continue; }
1473
+ for (const rule of rules) {
1474
+ // Style rules only (type 1). Walk @media / @supports if present.
1475
+ if (rule.type === 4 /* MEDIA_RULE */ || rule.type === 12 /* SUPPORTS_RULE */) {
1476
+ try { rules.push(...Array.from(rule.cssRules || [])); } catch { /* ignore */ }
1477
+ continue;
1478
+ }
1479
+ if (rule.type !== 1 /* STYLE_RULE */) continue;
1480
+ const sel = rule.selectorText || '';
1481
+ if (!/(^|,\s*)(:root|html|:host)\b/i.test(sel)) continue;
1482
+ const style = rule.style;
1483
+ if (!style) continue;
1484
+ for (let i = 0; i < style.length; i++) {
1485
+ const prop = style[i];
1486
+ if (!prop || !prop.startsWith('--')) continue;
1487
+ const val = style.getPropertyValue(prop).trim();
1488
+ if (val) map.set(prop, val);
1489
+ }
1490
+ }
1491
+ }
1492
+ return map;
1493
+ }
1494
+
1495
+ // Resolve var(--X[, fallback]) refs in a computed-style value string.
1496
+ // Recurses up to 8 levels for chained refs (--a: var(--b)). Returns
1497
+ // the original string when no refs are present or the chain doesn't
1498
+ // resolve. Safe to call on already-resolved values.
1499
+ function resolveVarRefs(raw, customPropMap, depth = 0) {
1500
+ if (typeof raw !== 'string' || !raw.includes('var(')) return raw;
1501
+ if (depth > 8) return raw;
1502
+ return raw.replace(/var\(\s*(--[a-zA-Z0-9_-]+)\s*(?:,\s*([^)]+))?\)/g, (_m, name, fallback) => {
1503
+ const v = customPropMap.get(name);
1504
+ if (v != null) return resolveVarRefs(v, customPropMap, depth + 1);
1505
+ return fallback ? resolveVarRefs(fallback.trim(), customPropMap, depth + 1) : _m;
1506
+ });
1507
+ }
1508
+
1509
+ // OKLCH → sRGB conversion (Björn Ottosson's matrices). L in 0..1 (or %),
1510
+ // C in 0..~0.4 typical, H in degrees. Returns clamped {r,g,b,a:1} in 0..255.
1511
+ // Needed because jsdom doesn't compute oklch() values — getComputedStyle
1512
+ // returns the literal "oklch(...)" string. Without this, the entire
1513
+ // Tailwind v4 color palette (which is OKLCH-based) is invisible to the
1514
+ // detector's contrast / color checks.
1515
+ function oklchToRgb(L, C, H) {
1516
+ const hRad = (H * Math.PI) / 180;
1517
+ const a = C * Math.cos(hRad);
1518
+ const b = C * Math.sin(hRad);
1519
+ const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
1520
+ const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
1521
+ const s_ = L - 0.0894841775 * a - 1.2914855480 * b;
1522
+ const lc = l_ * l_ * l_, mc = m_ * m_ * m_, sc = s_ * s_ * s_;
1523
+ const rLin = 4.0767416621 * lc - 3.3077115913 * mc + 0.2309699292 * sc;
1524
+ const gLin = -1.2684380046 * lc + 2.6097574011 * mc - 0.3413193965 * sc;
1525
+ const bLin = -0.0041960863 * lc - 0.7034186147 * mc + 1.7076147010 * sc;
1526
+ const enc = (x) => {
1527
+ const c = Math.max(0, Math.min(1, x));
1528
+ return c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
1529
+ };
1530
+ return {
1531
+ r: Math.round(enc(rLin) * 255),
1532
+ g: Math.round(enc(gLin) * 255),
1533
+ b: Math.round(enc(bLin) * 255),
1534
+ a: 1,
1535
+ };
1536
+ }
1537
+
1538
+ // Extended color parser: rgb/rgba/hex/oklch. Returns null on no match.
1539
+ // Use this when the input might be any CSS color form; use plain parseRgb
1540
+ // when you only expect computed rgb() values from real browsers.
1541
+ function parseAnyColor(s) {
1542
+ if (!s || typeof s !== 'string') return null;
1543
+ const str = s.trim();
1544
+ if (str === 'transparent' || str === 'currentcolor' || str === 'inherit') return null;
1545
+ let m;
1546
+ m = str.match(/rgba?\(\s*(\d+(?:\.\d+)?)\s*,?\s*(\d+(?:\.\d+)?)\s*,?\s*(\d+(?:\.\d+)?)(?:\s*[,/]\s*([\d.]+))?\s*\)/);
1547
+ if (m) return { r: Math.round(+m[1]), g: Math.round(+m[2]), b: Math.round(+m[3]), a: m[4] !== undefined ? +m[4] : 1 };
1548
+ m = str.match(/^#([0-9a-f]{3,8})$/i);
1549
+ if (m) {
1550
+ const h = m[1];
1551
+ if (h.length === 3 || h.length === 4) {
1552
+ return {
1553
+ r: parseInt(h[0] + h[0], 16),
1554
+ g: parseInt(h[1] + h[1], 16),
1555
+ b: parseInt(h[2] + h[2], 16),
1556
+ a: h.length === 4 ? parseInt(h[3] + h[3], 16) / 255 : 1,
1557
+ };
1558
+ }
1559
+ if (h.length === 6 || h.length === 8) {
1560
+ return {
1561
+ r: parseInt(h.slice(0, 2), 16),
1562
+ g: parseInt(h.slice(2, 4), 16),
1563
+ b: parseInt(h.slice(4, 6), 16),
1564
+ a: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1,
1565
+ };
1566
+ }
1567
+ }
1568
+ // OKLCH parser. Tailwind v4's CSS minifier squishes the space after
1569
+ // `%` ("21.5%.02 50"), so the separator between L and C may be absent.
1570
+ // Match L (with optional %), then C and H separated permissively.
1571
+ m = str.match(/oklch\(\s*([\d.]+)(%?)\s*[\s,]*\s*([\d.]+)\s*[\s,]+\s*([-\d.]+)(?:deg)?\s*\)/i);
1572
+ if (m) {
1573
+ const Lnum = parseFloat(m[1]);
1574
+ const L = m[2] === '%' ? Lnum / 100 : Lnum;
1575
+ return oklchToRgb(L, parseFloat(m[3]), parseFloat(m[4]));
1576
+ }
1577
+ return null;
1578
+ }
1579
+
1580
+ // Resolve var() refs in a color string (via customPropMap), then parse.
1581
+ // Returns null on any failure. Used in jsdom-mode paths where
1582
+ // getComputedStyle returns literal "var(--X)" or "oklch(...)" strings.
1583
+ function parseColorResolved(str, customPropMap) {
1584
+ if (!str) return null;
1585
+ const resolved = customPropMap ? resolveVarRefs(str, customPropMap) : str;
1586
+ return parseAnyColor(resolved);
1587
+ }
1588
+
1589
+ const REPEATED_KICKER_SKIP_SELECTOR = [
1590
+ 'nav',
1591
+ 'form',
1592
+ 'table',
1593
+ 'thead',
1594
+ 'tbody',
1595
+ 'tfoot',
1596
+ 'figure',
1597
+ 'figcaption',
1598
+ 'ol',
1599
+ 'ul',
1600
+ 'li',
1601
+ '[role="navigation"]',
1602
+ '[aria-label*="breadcrumb" i]',
1603
+ '[class*="breadcrumb" i]',
1604
+ '[data-impeccable-allow-kickers]',
1605
+ ].join(',');
1606
+
1607
+ function cleanInlineText(el) {
1608
+ return [...el.childNodes]
1609
+ .filter(n => n.nodeType === 3)
1610
+ .map(n => n.textContent)
1611
+ .join(' ')
1612
+ .replace(/\s+/g, ' ')
1613
+ .trim();
1614
+ }
1615
+
1616
+ function isRepeatedKickerCandidate(opts) {
1617
+ const {
1618
+ headingTag,
1619
+ headingText,
1620
+ headingFontSize,
1621
+ kickerTag,
1622
+ kickerText,
1623
+ kickerTextTransform,
1624
+ kickerFontSize,
1625
+ kickerLetterSpacing,
1626
+ } = opts;
1627
+ if (!['h2', 'h3', 'h4'].includes(headingTag)) return false;
1628
+ if (!headingText || headingText.length < 3) return false;
1629
+ if (!(headingFontSize >= 20)) return false;
1630
+ if (!kickerTag || HEADING_TAGS.has(kickerTag)) return false;
1631
+ if (!['p', 'span', 'div', 'small'].includes(kickerTag)) return false;
1632
+ if (!kickerText || kickerText.length < 2 || kickerText.length > 34) return false;
1633
+ if (/^step\s*\d+/i.test(kickerText) || /^\d{1,2}$/.test(kickerText)) return false;
1634
+
1635
+ const isUppercased = kickerTextTransform === 'uppercase'
1636
+ || (/[A-Z]/.test(kickerText) && !/[a-z]/.test(kickerText));
1637
+ if (!isUppercased) return false;
1638
+ if (!(kickerFontSize > 0 && kickerFontSize <= 14)) return false;
1639
+ const minTrackedSpacing = Math.max(1, kickerFontSize * 0.08);
1640
+ if (!(kickerLetterSpacing >= minTrackedSpacing)) return false;
1641
+ return true;
1642
+ }
1643
+
1644
+ function collectRepeatedSectionKickerCandidates(doc, getStyle, resolveLetterSpacing) {
1645
+ const candidates = [];
1646
+ for (const heading of doc.querySelectorAll('h2, h3, h4')) {
1647
+ if (heading.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
1648
+ const kicker = heading.previousElementSibling;
1649
+ if (!kicker || kicker.closest?.(REPEATED_KICKER_SKIP_SELECTOR)) continue;
1650
+
1651
+ const headingStyle = getStyle(heading);
1652
+ const kickerStyle = getStyle(kicker);
1653
+ const headingText = (heading.textContent || '').replace(/\s+/g, ' ').trim();
1654
+ const kickerText = cleanInlineText(kicker) || (kicker.textContent || '').replace(/\s+/g, ' ').trim();
1655
+ const headingFontSize = resolveLetterSpacing(headingStyle.fontSize || '', 16) || parseFloat(headingStyle.fontSize) || 0;
1656
+ const kickerFontSize = resolveLetterSpacing(kickerStyle.fontSize || '', 16) || parseFloat(kickerStyle.fontSize) || 0;
1657
+ const kickerLetterSpacing = resolveLetterSpacing(kickerStyle.letterSpacing || '', kickerFontSize);
1658
+
1659
+ if (!isRepeatedKickerCandidate({
1660
+ headingTag: heading.tagName.toLowerCase(),
1661
+ headingText,
1662
+ headingFontSize,
1663
+ kickerTag: kicker.tagName.toLowerCase(),
1664
+ kickerText,
1665
+ kickerTextTransform: kickerStyle.textTransform || '',
1666
+ kickerFontSize,
1667
+ kickerLetterSpacing,
1668
+ })) {
1669
+ continue;
1670
+ }
1671
+
1672
+ candidates.push({
1673
+ headingTag: heading.tagName.toLowerCase(),
1674
+ headingText: headingText.replace(/^"|"$/g, '').slice(0, 60),
1675
+ kickerText: kickerText.slice(0, 40),
1676
+ });
1677
+ }
1678
+ return candidates;
1679
+ }
1680
+
1681
+ function checkRepeatedSectionKickersDOM() {
1682
+ const candidates = collectRepeatedSectionKickerCandidates(
1683
+ document,
1684
+ (el) => getComputedStyle(el),
1685
+ (value, fontSize) => resolveLengthPx(value, fontSize) || 0,
1686
+ );
1687
+ return checkRepeatedSectionKickers({ candidates });
1688
+ }
1689
+
1690
+ function checkElementMotionDOM(el) {
1691
+ const tag = el.tagName.toLowerCase();
1692
+ if (SAFE_TAGS.has(tag)) return [];
1693
+ const style = getComputedStyle(el);
1694
+ return checkMotion({
1695
+ tag,
1696
+ transitionProperty: style.transitionProperty || '',
1697
+ animationName: style.animationName || '',
1698
+ timingFunctions: [style.animationTimingFunction, style.transitionTimingFunction].filter(Boolean).join(' '),
1699
+ classList: el.getAttribute('class') || '',
1700
+ });
1701
+ }
1702
+
1703
+ function checkElementGlowDOM(el) {
1704
+ const tag = el.tagName.toLowerCase();
1705
+ const style = getComputedStyle(el);
1706
+ if (!style.boxShadow || style.boxShadow === 'none') return [];
1707
+ // Use parent's background — glow radiates outward, so the surrounding context matters
1708
+ // If resolveBackground returns null (gradient), try to infer from the gradient colors
1709
+ let parentBg = el.parentElement ? resolveBackground(el.parentElement) : resolveBackground(el);
1710
+ if (!parentBg) {
1711
+ // Gradient background — sample its colors to determine if it's dark
1712
+ let cur = el.parentElement;
1713
+ while (cur && cur.nodeType === 1) {
1714
+ const bgImage = getComputedStyle(cur).backgroundImage || '';
1715
+ const gradColors = parseGradientColors(bgImage);
1716
+ if (gradColors.length > 0) {
1717
+ // Average the gradient colors
1718
+ const avg = { r: 0, g: 0, b: 0 };
1719
+ for (const c of gradColors) { avg.r += c.r; avg.g += c.g; avg.b += c.b; }
1720
+ avg.r = Math.round(avg.r / gradColors.length);
1721
+ avg.g = Math.round(avg.g / gradColors.length);
1722
+ avg.b = Math.round(avg.b / gradColors.length);
1723
+ parentBg = avg;
1724
+ break;
1725
+ }
1726
+ cur = cur.parentElement;
1727
+ }
1728
+ }
1729
+ return checkGlow({ tag, boxShadow: style.boxShadow, effectiveBg: parentBg });
1730
+ }
1731
+
1732
+ function checkElementAIPaletteDOM(el) {
1733
+ const style = getComputedStyle(el);
1734
+ const findings = [];
1735
+
1736
+ // Check gradient backgrounds for purple/violet or cyan
1737
+ const bgImage = style.backgroundImage || '';
1738
+ const gradColors = parseGradientColors(bgImage);
1739
+ for (const c of gradColors) {
1740
+ if (hasChroma(c, 50)) {
1741
+ const hue = getHue(c);
1742
+ if (hue >= 260 && hue <= 310) {
1743
+ findings.push({ id: 'ai-color-palette', snippet: 'Purple/violet gradient background' });
1744
+ break;
1745
+ }
1746
+ if (hue >= 160 && hue <= 200) {
1747
+ findings.push({ id: 'ai-color-palette', snippet: 'Cyan gradient background' });
1748
+ break;
1749
+ }
1750
+ }
1751
+ }
1752
+
1753
+ // Check for neon text (vivid cyan/purple color on dark background)
1754
+ const textColor = parseRgb(style.color);
1755
+ if (textColor && hasChroma(textColor, 80)) {
1756
+ const hue = getHue(textColor);
1757
+ const isAIPalette = (hue >= 160 && hue <= 200) || (hue >= 260 && hue <= 310);
1758
+ if (isAIPalette) {
1759
+ const parentBg = el.parentElement ? resolveBackground(el.parentElement) : null;
1760
+ // Also check gradient parents
1761
+ let effectiveBg = parentBg;
1762
+ if (!effectiveBg) {
1763
+ let cur = el.parentElement;
1764
+ while (cur && cur.nodeType === 1) {
1765
+ const gi = getComputedStyle(cur).backgroundImage || '';
1766
+ const gc = parseGradientColors(gi);
1767
+ if (gc.length > 0) {
1768
+ const avg = { r: 0, g: 0, b: 0 };
1769
+ for (const c of gc) { avg.r += c.r; avg.g += c.g; avg.b += c.b; }
1770
+ avg.r = Math.round(avg.r / gc.length);
1771
+ avg.g = Math.round(avg.g / gc.length);
1772
+ avg.b = Math.round(avg.b / gc.length);
1773
+ effectiveBg = avg;
1774
+ break;
1775
+ }
1776
+ cur = cur.parentElement;
1777
+ }
1778
+ }
1779
+ if (effectiveBg && relativeLuminance(effectiveBg) < 0.1) {
1780
+ const label = hue >= 260 ? 'Purple/violet' : 'Cyan';
1781
+ findings.push({ id: 'ai-color-palette', snippet: `${label} neon text on dark background` });
1782
+ }
1783
+ }
1784
+ }
1785
+
1786
+ return findings;
1787
+ }
1788
+
1789
+ const QUALITY_TEXT_TAGS = new Set(['p', 'li', 'td', 'th', 'dd', 'blockquote', 'figcaption']);
1790
+
1791
+ // Resolve a CSS font-size value to pixels by walking up the parent chain.
1792
+ // Browsers resolve em/rem/% to px in getComputedStyle, but jsdom returns the
1793
+ // specified value verbatim — so for the Node path we walk parents ourselves.
1794
+ function resolveFontSizePx(el, win) {
1795
+ const chain = []; // raw font-size strings, leaf → root
1796
+ let cur = el;
1797
+ while (cur && cur.nodeType === 1) {
1798
+ const fs = (win ? win.getComputedStyle(cur) : getComputedStyle(cur)).fontSize;
1799
+ chain.push(fs || '');
1800
+ cur = cur.parentElement;
1801
+ }
1802
+ // Walk root → leaf, resolving each value relative to its parent context.
1803
+ let px = 16; // root default
1804
+ for (let i = chain.length - 1; i >= 0; i--) {
1805
+ const v = chain[i];
1806
+ if (!v || v === 'inherit') continue;
1807
+ const num = parseFloat(v);
1808
+ if (isNaN(num)) continue;
1809
+ if (v.endsWith('px')) px = num;
1810
+ else if (v.endsWith('rem')) px = num * 16;
1811
+ else if (v.endsWith('em')) px = num * px;
1812
+ else if (v.endsWith('%')) px = (num / 100) * px;
1813
+ else px = num; // unitless — already resolved
1814
+ }
1815
+ return px;
1816
+ }
1817
+
1818
+ // Resolve a CSS length value (line-height, letter-spacing, etc.) given a
1819
+ // known font-size context. Returns null for "normal" / unparseable values.
1820
+ function resolveLengthPx(value, fontSizePx) {
1821
+ if (!value || value === 'normal' || value === 'auto' || value === 'inherit') return null;
1822
+ const num = parseFloat(value);
1823
+ if (isNaN(num)) return null;
1824
+ if (value.endsWith('px')) return num;
1825
+ if (value.endsWith('rem')) return num * 16;
1826
+ if (value.endsWith('em')) return num * fontSizePx;
1827
+ if (value.endsWith('%')) return (num / 100) * fontSizePx;
1828
+ // Unitless line-height = multiplier, return px equivalent
1829
+ return num * fontSizePx;
1830
+ }
1831
+
1832
+ // Pure quality checks. Most run on computed CSS and DOM-only inputs (work in
1833
+ // jsdom and the browser). Two checks (line-length, cramped-padding) gate on
1834
+ // element rect dimensions, which jsdom can't compute — pass `rect: null` from
1835
+ // the Node adapter to skip those.
1836
+ //
1837
+ // Both adapters resolve font-size, line-height and letter-spacing to pixels
1838
+ // before calling this so the pure function only deals with numbers.
1839
+ function checkQuality(opts) {
1840
+ const { el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect, lineMax = 80, viewportWidth = 0, win = null } = opts;
1841
+ const findings = [];
1842
+ // Skip browser extension injected elements
1843
+ const elId = el.id || '';
1844
+ if (elId.startsWith('claude-') || elId.startsWith('cic-')) return findings;
1845
+
1846
+ // --- Line length too long --- (browser-only: needs rect.width)
1847
+ if (rect && hasDirectText && QUALITY_TEXT_TAGS.has(tag) && rect.width > 0 && textLen > lineMax) {
1848
+ const charsPerLine = rect.width / (fontSize * 0.5);
1849
+ if (charsPerLine > lineMax + 5) {
1850
+ findings.push({ id: 'line-length', snippet: `~${Math.round(charsPerLine)} chars/line (aim for <${lineMax})` });
1851
+ }
1852
+ }
1853
+
1854
+ // --- Cramped padding --- (browser-only: needs rect to skip small badges/labels)
1855
+ // Vertical and horizontal thresholds are independent because line-height
1856
+ // already provides built-in vertical breathing room (the line box is taller
1857
+ // than the cap height), but horizontal has no equivalent. Both scale with
1858
+ // font-size — bigger text demands proportionally more padding.
1859
+ // vertical: max(4px, fontSize × 0.3)
1860
+ // horizontal: max(8px, fontSize × 0.5)
1861
+ if (rect && hasDirectText && textLen > 20 && rect.width > 100 && rect.height > 30) {
1862
+ const borders = {
1863
+ top: parseFloat(style.borderTopWidth) || 0,
1864
+ right: parseFloat(style.borderRightWidth) || 0,
1865
+ bottom: parseFloat(style.borderBottomWidth) || 0,
1866
+ left: parseFloat(style.borderLeftWidth) || 0,
1867
+ };
1868
+ const borderCount = Object.values(borders).filter(w => w > 0).length;
1869
+ const hasBg = style.backgroundColor && style.backgroundColor !== 'rgba(0, 0, 0, 0)';
1870
+ if (borderCount >= 2 || hasBg) {
1871
+ const vPads = [], hPads = [];
1872
+ if (hasBg || borders.top > 0) vPads.push(parseFloat(style.paddingTop) || 0);
1873
+ if (hasBg || borders.bottom > 0) vPads.push(parseFloat(style.paddingBottom) || 0);
1874
+ if (hasBg || borders.left > 0) hPads.push(parseFloat(style.paddingLeft) || 0);
1875
+ if (hasBg || borders.right > 0) hPads.push(parseFloat(style.paddingRight) || 0);
1876
+
1877
+ const vMin = vPads.length ? Math.min(...vPads) : Infinity;
1878
+ const hMin = hPads.length ? Math.min(...hPads) : Infinity;
1879
+ const vThresh = Math.max(4, fontSize * 0.3);
1880
+ const hThresh = Math.max(8, fontSize * 0.5);
1881
+
1882
+ // Emit at most one finding per element — pick whichever axis is worse.
1883
+ if (vMin < vThresh) {
1884
+ findings.push({ id: 'cramped-padding', snippet: `${vMin}px vertical padding (need ≥${vThresh.toFixed(1)}px for ${fontSize}px text)` });
1885
+ } else if (hMin < hThresh) {
1886
+ findings.push({ id: 'cramped-padding', snippet: `${hMin}px horizontal padding (need ≥${hThresh.toFixed(1)}px for ${fontSize}px text)` });
1887
+ }
1888
+ }
1889
+ }
1890
+
1891
+ // --- Flush against a visible boundary ---
1892
+ // Fires when a container has a visible boundary (border, outline, OR a
1893
+ // non-transparent background) AND near-zero padding on the bounded
1894
+ // side(s) AND text-bearing children land flush against the boundary.
1895
+ //
1896
+ // Distinct from cramped-padding: that rule needs the element itself to
1897
+ // have direct text (hasDirectText). This rule targets the OPPOSITE
1898
+ // shape — a container with NO direct text, only children — which is
1899
+ // exactly what cramped-padding misses (a section wrapping a label +
1900
+ // list lands a free pass).
1901
+ //
1902
+ // The classic shape: agent writes `padding: 28px 0 0` shorthand on a
1903
+ // section that also has a border, zeroing horizontal padding so the
1904
+ // text-bearing children touch the side borders. Background and
1905
+ // outline count too: a colored card with zero padding has the same
1906
+ // visual failure mode.
1907
+ {
1908
+ const FLUSH_SKIP_TAGS = new Set(['HTML', 'BODY', 'MAIN', 'HEADER', 'FOOTER', 'NAV', 'ARTICLE', 'ASIDE', 'BUTTON', 'A', 'LABEL', 'SUMMARY', 'CODE', 'PRE', 'INPUT', 'TEXTAREA', 'SELECT', 'FORM', 'FIGURE', 'TABLE', 'TBODY', 'THEAD', 'TR', 'TD', 'TH']);
1909
+ const upperTag = tag ? tag.toUpperCase() : '';
1910
+ const elPosition = style.position || '';
1911
+ if (
1912
+ !FLUSH_SKIP_TAGS.has(upperTag) &&
1913
+ !hasDirectText &&
1914
+ !['fixed', 'absolute'].includes(elPosition) &&
1915
+ el.children && el.children.length > 0
1916
+ ) {
1917
+ const isTransparent = (c) =>
1918
+ !c || c === 'transparent' || c === 'rgba(0, 0, 0, 0)' ||
1919
+ /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0(?:\.0+)?\s*\)$/.test(c);
1920
+
1921
+ const borderW = {
1922
+ top: parseFloat(style.borderTopWidth) || 0,
1923
+ right: parseFloat(style.borderRightWidth) || 0,
1924
+ bottom: parseFloat(style.borderBottomWidth) || 0,
1925
+ left: parseFloat(style.borderLeftWidth) || 0,
1926
+ };
1927
+ const borderVisible = {
1928
+ top: borderW.top > 0 && !isTransparent(style.borderTopColor),
1929
+ right: borderW.right > 0 && !isTransparent(style.borderRightColor),
1930
+ bottom: borderW.bottom > 0 && !isTransparent(style.borderBottomColor),
1931
+ left: borderW.left > 0 && !isTransparent(style.borderLeftColor),
1932
+ };
1933
+ // Outline detection. jsdom decomposes `border` shorthand into
1934
+ // border{Top,…}Width/Color but does NOT decompose `outline` —
1935
+ // the longhands come back empty when the value was set via the
1936
+ // shorthand. Fall back to parsing `style.outline` ourselves.
1937
+ let outlineW = parseFloat(style.outlineWidth) || 0;
1938
+ let outlineStyleVal = style.outlineStyle || '';
1939
+ let outlineColorVal = style.outlineColor || '';
1940
+ if (!outlineW && style.outline) {
1941
+ const wMatch = style.outline.match(/(\d+(?:\.\d+)?)\s*px/);
1942
+ if (wMatch) outlineW = parseFloat(wMatch[1]) || 0;
1943
+ if (!outlineStyleVal) {
1944
+ outlineStyleVal = /\b(solid|dashed|dotted|double|groove|ridge|inset|outset)\b/.test(style.outline) ? 'solid' : '';
1945
+ }
1946
+ if (!outlineColorVal) {
1947
+ const cMatch = style.outline.match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-zA-Z]+)\s*$/);
1948
+ if (cMatch) outlineColorVal = cMatch[1];
1949
+ }
1950
+ }
1951
+ const outlineVisible = outlineW > 0 && !isTransparent(outlineColorVal) && outlineStyleVal && outlineStyleVal !== 'none';
1952
+ const bgVisible = !isTransparent(style.backgroundColor);
1953
+
1954
+ const anyVisible = borderVisible.top || borderVisible.right || borderVisible.bottom || borderVisible.left || outlineVisible || bgVisible;
1955
+ if (anyVisible) {
1956
+ // Resolve padding to px (jsdom returns raw "1.5rem" etc., not the
1957
+ // computed px value; parseFloat would strip the unit and treat
1958
+ // 1.5rem as 1.5px, false-flagging legitimate insets).
1959
+ const pad = {
1960
+ top: resolveLengthPx(style.paddingTop, fontSize) ?? 0,
1961
+ right: resolveLengthPx(style.paddingRight, fontSize) ?? 0,
1962
+ bottom: resolveLengthPx(style.paddingBottom, fontSize) ?? 0,
1963
+ left: resolveLengthPx(style.paddingLeft, fontSize) ?? 0,
1964
+ };
1965
+ const PAD_THRESHOLD = 2;
1966
+ // Children-insulate-this-side: a side is insulated if ANY direct
1967
+ // child has its own padding ≥ 4px on that side. Rationale: in
1968
+ // typical flow, only the first/last (or leftmost/rightmost)
1969
+ // children actually sit at the parent's edges. If even one of
1970
+ // them has its own padding, the visual flush is broken on that
1971
+ // side. Classic example: a column-flow card frame where the
1972
+ // top child (header) has padding-top:12 and the bottom child
1973
+ // (footer) has padding-bottom:8 — the parent's padding:0 doesn't
1974
+ // matter; nothing is actually flush. The `any-child-insulates`
1975
+ // heuristic accepts some false negatives (a card with one heavily
1976
+ // padded middle child won't flag) for far fewer false positives.
1977
+ const CHILD_INSULATE_THRESHOLD = 4;
1978
+ const childrenInsulate = { top: false, right: false, bottom: false, left: false };
1979
+ for (const child of el.children) {
1980
+ let childStyle = null;
1981
+ if (win && typeof win.getComputedStyle === 'function') {
1982
+ try { childStyle = win.getComputedStyle(child); } catch {}
1983
+ }
1984
+ if (!childStyle && typeof getComputedStyle === 'function') {
1985
+ try { childStyle = getComputedStyle(child); } catch {}
1986
+ }
1987
+ if (!childStyle) continue;
1988
+ const childPad = {
1989
+ top: resolveLengthPx(childStyle.paddingTop, fontSize) ?? 0,
1990
+ right: resolveLengthPx(childStyle.paddingRight, fontSize) ?? 0,
1991
+ bottom: resolveLengthPx(childStyle.paddingBottom, fontSize) ?? 0,
1992
+ left: resolveLengthPx(childStyle.paddingLeft, fontSize) ?? 0,
1993
+ };
1994
+ for (const s of ['top', 'right', 'bottom', 'left']) {
1995
+ if (childPad[s] >= CHILD_INSULATE_THRESHOLD) childrenInsulate[s] = true;
1996
+ }
1997
+ }
1998
+
1999
+ const flushSides = [];
2000
+ for (const side of ['top', 'right', 'bottom', 'left']) {
2001
+ const sideBounded = borderVisible[side] || outlineVisible || bgVisible;
2002
+ if (sideBounded && pad[side] <= PAD_THRESHOLD && !childrenInsulate[side]) {
2003
+ flushSides.push(side);
2004
+ }
2005
+ }
2006
+
2007
+ if (flushSides.length > 0) {
2008
+ // Confirm at least one direct child has substantial text content
2009
+ // (> 4 chars). Without this, the flush is harmless: e.g. an
2010
+ // image-only card.
2011
+ let hasTextChild = false;
2012
+ for (const child of el.children) {
2013
+ const childText = (child.textContent || '').trim();
2014
+ if (childText.length > 4) { hasTextChild = true; break; }
2015
+ }
2016
+ if (hasTextChild) {
2017
+ const cls = (typeof el.className === 'string' && el.className.trim())
2018
+ ? el.className.trim().split(/\s+/)[0]
2019
+ : '';
2020
+ const boundaryParts = [];
2021
+ const borderSidesVisible = ['top', 'right', 'bottom', 'left'].filter(s => borderVisible[s]);
2022
+ if (borderSidesVisible.length === 4) boundaryParts.push('border');
2023
+ else if (borderSidesVisible.length > 0) boundaryParts.push(`border-${borderSidesVisible.join('/')}`);
2024
+ if (outlineVisible) boundaryParts.push('outline');
2025
+ if (bgVisible) boundaryParts.push('bg');
2026
+ const sidesLabel = flushSides.length === 4 ? 'all sides' : flushSides.join('/');
2027
+ const ident = cls
2028
+ ? `<${tag.toLowerCase()}> "${cls}"`
2029
+ : `<${tag.toLowerCase()}>`;
2030
+ findings.push({
2031
+ id: 'cramped-padding',
2032
+ snippet: `${ident}: children flush against ${boundaryParts.join('+')} on ${sidesLabel} (no inset)`,
2033
+ });
2034
+ }
2035
+ }
2036
+ }
2037
+ }
2038
+ }
2039
+
2040
+ // --- Body text touching viewport edge --- (browser-only: needs rect)
2041
+ // Catches the failure mode where the agent ships body paragraphs
2042
+ // with NO container providing horizontal padding — text bleeds
2043
+ // directly to the viewport edge. Different from cramped-padding,
2044
+ // which requires a colored/bordered container. Here the failure
2045
+ // is the absence of the container entirely.
2046
+ //
2047
+ // Gate aggressively to avoid false positives:
2048
+ // - <p> or <li> only (body content; not headings, not nav, not
2049
+ // wrappers)
2050
+ // - text > 40 chars (paragraph-like, not a label)
2051
+ // - rect.width > 50% of viewport (real body, not a pull-quote)
2052
+ // - rect.left < 16 OR rect.right > viewport - 16 (actually
2053
+ // touching the edge)
2054
+ // - not inside <nav> or <header> (those legitimately bleed)
2055
+ // - element itself has no background-color (intentional full-bleed
2056
+ // sections set a bg-color and provide their own internal padding)
2057
+ if (rect && hasDirectText && textLen > 40 && ['P', 'LI'].includes(tag.toUpperCase()) && viewportWidth > 0) {
2058
+ const inNavHeader = el.closest && (el.closest('nav') || el.closest('header'));
2059
+ const hasOwnBg = style.backgroundColor && style.backgroundColor !== 'rgba(0, 0, 0, 0)' && style.backgroundColor !== 'transparent';
2060
+ const isPositioned = ['fixed', 'absolute'].includes(style.position || '');
2061
+ const widthRatio = rect.width / viewportWidth;
2062
+ const leftClose = rect.left < 16;
2063
+ const rightClose = rect.right > viewportWidth - 16;
2064
+ if (!inNavHeader && !hasOwnBg && !isPositioned && widthRatio > 0.5 && (leftClose || rightClose)) {
2065
+ const which = leftClose && rightClose
2066
+ ? `left ${Math.round(rect.left)}px / right ${Math.round(viewportWidth - rect.right)}px`
2067
+ : leftClose
2068
+ ? `left ${Math.round(rect.left)}px`
2069
+ : `right ${Math.round(viewportWidth - rect.right)}px`;
2070
+ findings.push({ id: 'body-text-viewport-edge', snippet: `<${tag.toLowerCase()}> with ${textLen}-char body bleeds to viewport edge (${which})` });
2071
+ }
2072
+ }
2073
+
2074
+ // --- Tight line height ---
2075
+ if (hasDirectText && textLen > 50 && !['h1','h2','h3','h4','h5','h6'].includes(tag)) {
2076
+ if (lineHeightPx != null && fontSize > 0) {
2077
+ const ratio = lineHeightPx / fontSize;
2078
+ if (ratio > 0 && ratio < 1.3) {
2079
+ findings.push({ id: 'tight-leading', snippet: `line-height ${ratio.toFixed(2)}x (need >=1.3)` });
2080
+ }
2081
+ }
2082
+ }
2083
+
2084
+ // --- Justified text (without hyphens) ---
2085
+ if (hasDirectText && style.textAlign === 'justify') {
2086
+ const hyphens = style.hyphens || style.webkitHyphens || '';
2087
+ if (hyphens !== 'auto') {
2088
+ findings.push({ id: 'justified-text', snippet: 'text-align: justify without hyphens: auto' });
2089
+ }
2090
+ }
2091
+
2092
+ // --- Tiny body text ---
2093
+ // Only flag actual body content, not UI labels (buttons, tabs, badges, captions, footer text, etc.)
2094
+ if (hasDirectText && textLen > 20 && fontSize < 12) {
2095
+ const skipTags = ['sub', 'sup', 'code', 'kbd', 'samp', 'var', 'caption', 'figcaption'];
2096
+ const inUIContext = el.closest && el.closest('button, a, label, summary, [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="option"], nav, footer, [class*="badge" i], [class*="chip" i], [class*="pill" i], [class*="tag" i], [class*="label" i], [class*="caption" i]');
2097
+ const isUppercase = style.textTransform === 'uppercase';
2098
+ if (!skipTags.includes(tag) && !inUIContext && !isUppercase) {
2099
+ findings.push({ id: 'tiny-text', snippet: `${fontSize}px body text` });
2100
+ }
2101
+ }
2102
+
2103
+ // --- All-caps body text ---
2104
+ if (hasDirectText && textLen > 30 && style.textTransform === 'uppercase') {
2105
+ if (!['h1','h2','h3','h4','h5','h6'].includes(tag)) {
2106
+ findings.push({ id: 'all-caps-body', snippet: `text-transform: uppercase on ${textLen} chars of body text` });
2107
+ }
2108
+ }
2109
+
2110
+ // --- Wide letter spacing on body text ---
2111
+ if (hasDirectText && textLen > 20 && style.textTransform !== 'uppercase') {
2112
+ if (letterSpacingPx != null && letterSpacingPx > 0 && fontSize > 0) {
2113
+ const trackingEm = letterSpacingPx / fontSize;
2114
+ if (trackingEm > 0.05) {
2115
+ findings.push({ id: 'wide-tracking', snippet: `letter-spacing: ${trackingEm.toFixed(2)}em on body text` });
2116
+ }
2117
+ }
2118
+ }
2119
+
2120
+ // --- Crushed letter spacing (mirror of wide-tracking) ---
2121
+ // Tracking pulled tighter than ~-0.05em crushes characters into each other.
2122
+ // Optical tightening that display type legitimately wants (around -0.02em)
2123
+ // stays well above this floor.
2124
+ if (hasDirectText && textLen > 20 && fontSize > 0) {
2125
+ if (letterSpacingPx != null && letterSpacingPx < 0) {
2126
+ const trackingEm = letterSpacingPx / fontSize;
2127
+ if (trackingEm <= -0.05) {
2128
+ const excerpt = (el.textContent || '').trim().replace(/\s+/g, ' ').slice(0, 40);
2129
+ findings.push({ id: 'extreme-negative-tracking', snippet: `letter-spacing: ${trackingEm.toFixed(2)}em — "${excerpt}"` });
2130
+ }
2131
+ }
2132
+ }
2133
+
2134
+ return findings;
2135
+ }
2136
+
2137
+ function checkElementQualityDOM(el) {
2138
+ const tag = el.tagName.toLowerCase();
2139
+ const style = getComputedStyle(el);
2140
+ const hasDirectText = [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 10);
2141
+ const textLen = el.textContent?.trim().length || 0;
2142
+ // Browser getComputedStyle resolves everything to px — direct parseFloat
2143
+ // works.
2144
+ const fontSize = parseFloat(style.fontSize) || 16;
2145
+ const lineHeightPx = resolveLengthPx(style.lineHeight, fontSize);
2146
+ const letterSpacingPx = resolveLengthPx(style.letterSpacing, fontSize);
2147
+ const rect = el.getBoundingClientRect();
2148
+ const lineMax = (typeof window !== 'undefined' && window.__IMPECCABLE_CONFIG__?.lineLengthMax) || 80;
2149
+ const viewportWidth = (typeof window !== 'undefined' ? window.innerWidth : 0) || 0;
2150
+ return checkQuality({ el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect, lineMax, viewportWidth, win: typeof window !== 'undefined' ? window : null });
2151
+ }
2152
+
2153
+ // Pure page-level skipped-heading walk. Takes a Document so it works in both
2154
+ // the browser and jsdom.
2155
+ function checkPageQualityFromDoc(doc) {
2156
+ const findings = [];
2157
+ const headings = doc.querySelectorAll('h1, h2, h3, h4, h5, h6');
2158
+ let prevLevel = 0;
2159
+ let prevText = '';
2160
+ for (const h of headings) {
2161
+ const level = parseInt(h.tagName[1]);
2162
+ const text = (h.textContent || '').trim().replace(/\s+/g, ' ').slice(0, 60);
2163
+ if (prevLevel > 0 && level > prevLevel + 1) {
2164
+ findings.push({
2165
+ id: 'skipped-heading',
2166
+ snippet: `<h${prevLevel}> "${prevText}" followed by <h${level}> "${text}" (missing h${prevLevel + 1})`,
2167
+ });
2168
+ }
2169
+ prevLevel = level;
2170
+ prevText = text;
2171
+ }
2172
+ return findings;
2173
+ }
2174
+
2175
+ // Browser adapter (returns the legacy { type, detail } shape used by the overlay loop)
2176
+ function checkPageQualityDOM() {
2177
+ return checkPageQualityFromDoc(document).map(f => ({ type: f.id, detail: f.snippet }));
2178
+ }
2179
+
2180
+ // Node adapters — take pre-extracted jsdom computed style
2181
+
2182
+ // jsdom doesn't lay out OR resolve em/rem/% to px — so we pre-resolve every
2183
+ // CSS length the rule needs ourselves (walking the parent chain for
2184
+ // font-size inheritance), and pass `rect: null` to skip the two rules that
2185
+ // genuinely need element rects (line-length, cramped-padding).
2186
+ function checkElementQuality(el, style, tag, window) {
2187
+ const hasDirectText = [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 10);
2188
+ const textLen = el.textContent?.trim().length || 0;
2189
+ const fontSize = resolveFontSizePx(el, window);
2190
+ const lineHeightPx = resolveLengthPx(style.lineHeight, fontSize);
2191
+ const letterSpacingPx = resolveLengthPx(style.letterSpacing, fontSize);
2192
+ return checkQuality({ el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect: null, win: window });
2193
+ }
2194
+
2195
+ function checkElementBorders(tag, style, overrides, resolvedRadius) {
2196
+ const sides = ['Top', 'Right', 'Bottom', 'Left'];
2197
+ const widths = {}, colors = {};
2198
+ for (const s of sides) {
2199
+ widths[s] = parseFloat(style[`border${s}Width`]) || 0;
2200
+ colors[s] = style[`border${s}Color`] || '';
2201
+ // jsdom silently drops any border shorthand containing var(), leaving
2202
+ // both width and color empty on the computed style. When the detectHtml
2203
+ // pre-pass pulled a resolved value off the rule, use it to fill in the
2204
+ // missing side so the side-tab check can run. Real browsers resolve
2205
+ // var() natively, so this fallback is a no-op in the browser path.
2206
+ if (widths[s] === 0 && overrides && overrides[s]) {
2207
+ widths[s] = overrides[s].width;
2208
+ colors[s] = overrides[s].color;
2209
+ } else if (colors[s] && colors[s].startsWith('var(') && overrides && overrides[s]) {
2210
+ // Longhand case: jsdom kept the width but left the color as the
2211
+ // literal `var(...)` string. Substitute the resolved color.
2212
+ colors[s] = overrides[s].color;
2213
+ }
2214
+ }
2215
+ // resolvedRadius lets the caller pre-resolve the radius via
2216
+ // resolveBorderRadiusPx so the value survives jsdom 29.1.0's broken
2217
+ // shorthand serialization. Falls back to the computed value for tests
2218
+ // and browser callers that don't pre-resolve.
2219
+ const radius = resolvedRadius != null
2220
+ ? resolvedRadius
2221
+ : (parseFloat(style.borderRadius) || 0);
2222
+ return checkBorders(tag, widths, colors, radius);
2223
+ }
2224
+
2225
+ function checkElementColors(el, style, tag, window, customPropMap, hasAnchorInheritRule) {
2226
+ const directText = [...el.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join('');
2227
+ const hasDirectText = directText.trim().length > 0;
2228
+
2229
+ const effectiveBg = resolveBackground(el, window, customPropMap);
2230
+ // jsdom returns literal "var(--X)" / "oklch(...)" for color, so plain
2231
+ // parseRgb misses Tailwind-tokenized text colors. Resolve through the
2232
+ // customPropMap first; fall back to parseRgb for vanilla rgb() pages.
2233
+ let textColor = customPropMap ? parseColorResolved(style.color, customPropMap) : null;
2234
+ if (!textColor) textColor = parseRgb(style.color);
2235
+
2236
+ // Anchor-inherit FP workaround: jsdom's UA stylesheet has `:link { color:
2237
+ // blue }` at high specificity. The page's `a { color: inherit }` rule
2238
+ // (Tailwind v4 preflight) loses to jsdom even though it WINS in real
2239
+ // browsers (Chrome's UA wraps :link in :where() — zero specificity).
2240
+ // When the page declares the inherit rule AND we see jsdom's default
2241
+ // link blue on an anchor, walk to the nearest non-anchor ancestor and
2242
+ // use its color instead.
2243
+ if (
2244
+ hasAnchorInheritRule &&
2245
+ textColor &&
2246
+ textColor.r === 0 && textColor.g === 0 && textColor.b === 238 &&
2247
+ (tag === 'a' || el.closest?.('a'))
2248
+ ) {
2249
+ let cur = el.parentElement;
2250
+ while (cur && cur.tagName !== 'HTML') {
2251
+ if (cur.tagName !== 'A') {
2252
+ const ps = window.getComputedStyle(cur);
2253
+ const inh = (customPropMap ? parseColorResolved(ps.color, customPropMap) : null) || parseRgb(ps.color);
2254
+ if (inh && !(inh.r === 0 && inh.g === 0 && inh.b === 238)) {
2255
+ textColor = inh;
2256
+ break;
2257
+ }
2258
+ }
2259
+ cur = cur.parentElement;
2260
+ }
2261
+ }
2262
+
2263
+ return checkColors({
2264
+ tag,
2265
+ textColor,
2266
+ bgColor: readOwnBackgroundColor(el, style),
2267
+ effectiveBg,
2268
+ effectiveBgStops: effectiveBg ? null : resolveGradientStops(el, window),
2269
+ fontSize: parseFloat(style.fontSize) || 16,
2270
+ fontWeight: parseInt(style.fontWeight) || 400,
2271
+ hasDirectText,
2272
+ isEmojiOnly: isEmojiOnlyText(directText),
2273
+ bgClip: style.webkitBackgroundClip || style.backgroundClip || '',
2274
+ bgImage: style.backgroundImage || '',
2275
+ classList: el.getAttribute?.('class') || el.className || '',
2276
+ });
2277
+ }
2278
+
2279
+ function checkElementIconTile(el, tag, window) {
2280
+ if (!HEADING_TAGS.has(tag)) return [];
2281
+ const sibling = el.previousElementSibling;
2282
+ if (!sibling) return [];
2283
+
2284
+ const sibStyle = window.getComputedStyle(sibling);
2285
+ // jsdom doesn't lay out — read explicit pixel dimensions from CSS instead.
2286
+ const sibWidth = parseFloat(sibStyle.width) || 0;
2287
+ const sibHeight = parseFloat(sibStyle.height) || 0;
2288
+
2289
+ const iconChild = sibling.querySelector('svg, i[data-lucide], i[class*="fa-"], i[class*="icon"]');
2290
+ let iconWidth = 0;
2291
+ if (iconChild) {
2292
+ const iconStyle = window.getComputedStyle(iconChild);
2293
+ iconWidth = parseFloat(iconStyle.width) || parseFloat(iconChild.getAttribute('width')) || 0;
2294
+ }
2295
+ // Or: tile contains an emoji/symbol character directly as its only content
2296
+ const sibDirectText = [...sibling.childNodes].filter(n => n.nodeType === 3).map(n => n.textContent).join('');
2297
+ const hasInlineEmojiIcon = sibling.children.length === 0 && isEmojiOnlyText(sibDirectText);
2298
+
2299
+ return checkIconTile({
2300
+ headingTag: tag,
2301
+ headingText: el.textContent || '',
2302
+ headingTop: 0, // jsdom: no layout, skip vertical-stacking gate
2303
+ siblingTag: sibling.tagName.toLowerCase(),
2304
+ siblingWidth: sibWidth,
2305
+ siblingHeight: sibHeight,
2306
+ siblingBottom: 0,
2307
+ siblingBgColor: parseRgb(sibStyle.backgroundColor),
2308
+ siblingBgImage: sibStyle.backgroundImage || '',
2309
+ siblingBorderWidth: parseFloat(sibStyle.borderTopWidth) || 0,
2310
+ siblingBorderRadius: resolveBorderRadiusPx(sibling, sibStyle, sibWidth, window),
2311
+ hasIconChild: !!iconChild || hasInlineEmojiIcon,
2312
+ iconChildWidth: iconWidth,
2313
+ });
2314
+ }
2315
+
2316
+ function checkElementItalicSerif(el, style, tag) {
2317
+ if (tag !== 'h1' && tag !== 'h2') return [];
2318
+ return checkItalicSerif({
2319
+ tag,
2320
+ fontStyle: style.fontStyle || '',
2321
+ fontFamily: style.fontFamily || '',
2322
+ fontSize: parseFloat(style.fontSize) || 0,
2323
+ headingText: el.textContent || '',
2324
+ });
2325
+ }
2326
+
2327
+ function checkElementHeroEyebrow(el, style, tag, window, customPropMap) {
2328
+ if (tag !== 'h1') return [];
2329
+ const sibling = el.previousElementSibling;
2330
+ if (!sibling) return [];
2331
+ const sibStyle = window.getComputedStyle(sibling);
2332
+ // Resolve Tailwind v4 CSS-variable wrappers (font-weight:var(--font-weight-bold)
2333
+ // etc.) before parsing. jsdom returns these verbatim from getComputedStyle;
2334
+ // without resolution every style-based gate fails silently on Tailwind v4 builds.
2335
+ const fontSizeRaw = customPropMap ? resolveVarRefs(sibStyle.fontSize, customPropMap) : sibStyle.fontSize;
2336
+ const fontWeightRaw = customPropMap ? resolveVarRefs(sibStyle.fontWeight, customPropMap) : sibStyle.fontWeight;
2337
+ const letterSpacingRaw = customPropMap ? resolveVarRefs(sibStyle.letterSpacing, customPropMap) : sibStyle.letterSpacing;
2338
+ const colorRaw = customPropMap ? resolveVarRefs(sibStyle.color, customPropMap) : sibStyle.color;
2339
+ const headingFontSizeRaw = customPropMap ? resolveVarRefs(style.fontSize, customPropMap) : style.fontSize;
2340
+ const siblingFontSize = parseFloat(fontSizeRaw) || 0;
2341
+ // resolveLengthPx returns null for 'normal' / 'auto'; coerce to 0 so the
2342
+ // gate falls through cleanly. jsdom returns letter-spacing verbatim
2343
+ // (e.g. '0.15em'), unlike real browsers, so this conversion is required.
2344
+ return checkHeroEyebrow({
2345
+ headingTag: tag,
2346
+ headingText: el.textContent || '',
2347
+ headingFontSize: parseFloat(headingFontSizeRaw) || 0,
2348
+ siblingTag: sibling.tagName.toLowerCase(),
2349
+ siblingText: sibling.textContent || '',
2350
+ siblingTextTransform: sibStyle.textTransform || '',
2351
+ siblingFontSize,
2352
+ siblingLetterSpacing: resolveLengthPx(letterSpacingRaw, siblingFontSize) || 0,
2353
+ siblingFontWeight: fontWeightRaw || '',
2354
+ siblingColor: colorRaw || '',
2355
+ });
2356
+ }
2357
+
2358
+ function checkRepeatedSectionKickersFromDoc(doc, win) {
2359
+ const candidates = collectRepeatedSectionKickerCandidates(
2360
+ doc,
2361
+ (el) => win.getComputedStyle(el),
2362
+ (value, fontSize) => resolveLengthPx(value, fontSize) || 0,
2363
+ );
2364
+ return checkRepeatedSectionKickers({ candidates });
2365
+ }
2366
+
2367
+ function checkElementMotion(tag, style) {
2368
+ return checkMotion({
2369
+ tag,
2370
+ transitionProperty: style.transitionProperty || '',
2371
+ animationName: style.animationName || '',
2372
+ timingFunctions: [style.animationTimingFunction, style.transitionTimingFunction].filter(Boolean).join(' '),
2373
+ classList: '',
2374
+ });
2375
+ }
2376
+
2377
+ function checkElementGlow(tag, style, effectiveBg) {
2378
+ if (!style.boxShadow || style.boxShadow === 'none') return [];
2379
+ return checkGlow({ tag, boxShadow: style.boxShadow, effectiveBg });
2380
+ }
2381
+
2382
+ // ─── Section 6: Page-Level Checks ───────────────────────────────────────────
2383
+
2384
+ // Browser page-level checks — use document/getComputedStyle globals
2385
+
2386
+ function checkTypography() {
2387
+ const findings = [];
2388
+
2389
+ // Walk actual text-bearing elements and tally font usage by *computed style*.
2390
+ // This is much more accurate than scanning CSS rules — it ignores rules that
2391
+ // exist in the stylesheet but apply to nothing (e.g. demo classes showing
2392
+ // anti-patterns), and counts what the user actually sees.
2393
+ const fontUsage = new Map(); // primary font name → count of elements
2394
+ let totalTextElements = 0;
2395
+ for (const el of document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, li, td, th, dd, blockquote, figcaption, a, button, label, span')) {
2396
+ // Skip impeccable's own elements
2397
+ if (el.closest && el.closest('.impeccable-overlay, .impeccable-label, .impeccable-banner, .impeccable-tooltip')) continue;
2398
+ // Only count elements that actually have visible direct text
2399
+ const hasText = [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
2400
+ if (!hasText) continue;
2401
+ const style = getComputedStyle(el);
2402
+ const ff = style.fontFamily;
2403
+ if (!ff) continue;
2404
+ const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
2405
+ const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
2406
+ if (!primary) continue;
2407
+ fontUsage.set(primary, (fontUsage.get(primary) || 0) + 1);
2408
+ totalTextElements++;
2409
+ }
2410
+
2411
+ if (totalTextElements >= 20) {
2412
+ // A font is "primary" if it's used by at least 15% of text elements
2413
+ const PRIMARY_THRESHOLD = 0.15;
2414
+ for (const [font, count] of fontUsage) {
2415
+ const share = count / totalTextElements;
2416
+ if (share < PRIMARY_THRESHOLD) continue;
2417
+ if (!OVERUSED_FONTS.has(font)) continue;
2418
+ if (isBrandFontOnOwnDomain(font)) continue;
2419
+ findings.push({ type: 'overused-font', detail: `Primary font: ${font} (${Math.round(share * 100)}% of text)` });
2420
+ }
2421
+
2422
+ // Single-font check: only one distinct primary font across all text
2423
+ if (fontUsage.size === 1) {
2424
+ const only = [...fontUsage.keys()][0];
2425
+ findings.push({ type: 'single-font', detail: `only font used is ${only}` });
2426
+ }
2427
+ }
2428
+
2429
+ const sizes = new Set();
2430
+ for (const el of document.querySelectorAll('h1,h2,h3,h4,h5,h6,p,span,a,li,td,th,label,button,div')) {
2431
+ const fs = parseFloat(getComputedStyle(el).fontSize);
2432
+ if (fs > 0 && fs < 200) sizes.add(Math.round(fs * 10) / 10);
2433
+ }
2434
+ if (sizes.size >= 3) {
2435
+ const sorted = [...sizes].sort((a, b) => a - b);
2436
+ const ratio = sorted[sorted.length - 1] / sorted[0];
2437
+ if (ratio < 2.0) {
2438
+ findings.push({ type: 'flat-type-hierarchy', detail: `Sizes: ${sorted.map(s => s + 'px').join(', ')} (ratio ${ratio.toFixed(1)}:1)` });
2439
+ }
2440
+ }
2441
+
2442
+ return findings;
2443
+ }
2444
+
2445
+ function isCardLikeDOM(el) {
2446
+ const tag = el.tagName.toLowerCase();
2447
+ if (SAFE_TAGS.has(tag) || ['input','select','textarea','img','video','canvas','picture'].includes(tag)) return false;
2448
+ const style = getComputedStyle(el);
2449
+ const cls = el.getAttribute('class') || '';
2450
+ const hasShadow = (style.boxShadow && style.boxShadow !== 'none') || /\bshadow(?:-sm|-md|-lg|-xl|-2xl)?\b/.test(cls);
2451
+ const hasBorder = /\bborder\b/.test(cls);
2452
+ const hasRadius = parseFloat(style.borderRadius) > 0 || /\brounded(?:-sm|-md|-lg|-xl|-2xl|-full)?\b/.test(cls);
2453
+ const hasBg = (style.backgroundColor && style.backgroundColor !== 'rgba(0, 0, 0, 0)') || /\bbg-(?:white|gray-\d+|slate-\d+)\b/.test(cls);
2454
+ return isCardLikeFromProps(hasShadow, hasBorder, hasRadius, hasBg);
2455
+ }
2456
+
2457
+ function checkLayout() {
2458
+ const findings = [];
2459
+ const flaggedEls = new Set();
2460
+
2461
+ for (const el of document.querySelectorAll('*')) {
2462
+ if (!isCardLikeDOM(el) || flaggedEls.has(el)) continue;
2463
+ const cls = el.getAttribute('class') || '';
2464
+ const style = getComputedStyle(el);
2465
+ if (style.position === 'absolute' || style.position === 'fixed') continue;
2466
+ if (/\b(?:dropdown|popover|tooltip|menu|modal|dialog)\b/i.test(cls)) continue;
2467
+ if ((el.textContent?.trim().length || 0) < 10) continue;
2468
+ const rect = el.getBoundingClientRect();
2469
+ if (rect.width < 50 || rect.height < 30) continue;
2470
+
2471
+ let parent = el.parentElement;
2472
+ while (parent) {
2473
+ if (isCardLikeDOM(parent)) { flaggedEls.add(el); break; }
2474
+ parent = parent.parentElement;
2475
+ }
2476
+ }
2477
+
2478
+ for (const el of flaggedEls) {
2479
+ let isAncestor = false;
2480
+ for (const other of flaggedEls) {
2481
+ if (other !== el && el.contains(other)) { isAncestor = true; break; }
2482
+ }
2483
+ if (!isAncestor) findings.push({ type: 'nested-cards', detail: 'Card inside card', el });
2484
+ }
2485
+
2486
+ return findings;
2487
+ }
2488
+
2489
+ // Node page-level checks — take document/window as parameters
2490
+
2491
+ function checkPageTypography(doc, win) {
2492
+ const findings = [];
2493
+
2494
+ const fonts = new Set();
2495
+ const overusedFound = new Set();
2496
+
2497
+ for (const sheet of doc.styleSheets) {
2498
+ let rules;
2499
+ try { rules = sheet.cssRules || sheet.rules; } catch { continue; }
2500
+ if (!rules) continue;
2501
+ for (const rule of rules) {
2502
+ if (rule.type !== 1) continue;
2503
+ const ff = rule.style?.fontFamily;
2504
+ if (!ff) continue;
2505
+ const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
2506
+ const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
2507
+ if (primary) {
2508
+ fonts.add(primary);
2509
+ if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
2510
+ }
2511
+ }
2512
+ }
2513
+
2514
+ // Check Google Fonts links in HTML
2515
+ const html = doc.documentElement?.outerHTML || '';
2516
+ const gfRe = /fonts\.googleapis\.com\/css2?\?family=([^&"'\s]+)/gi;
2517
+ let m;
2518
+ while ((m = gfRe.exec(html)) !== null) {
2519
+ const families = m[1].split('|').map(f => f.split(':')[0].replace(/\+/g, ' ').toLowerCase());
2520
+ for (const f of families) {
2521
+ fonts.add(f);
2522
+ if (OVERUSED_FONTS.has(f)) overusedFound.add(f);
2523
+ }
2524
+ }
2525
+
2526
+ // Also parse raw HTML/style content for font-family (jsdom may not expose all via CSSOM)
2527
+ const ffRe = /font-family\s*:\s*([^;}]+)/gi;
2528
+ let fm;
2529
+ while ((fm = ffRe.exec(html)) !== null) {
2530
+ for (const f of fm[1].split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())) {
2531
+ if (f && !GENERIC_FONTS.has(f)) {
2532
+ fonts.add(f);
2533
+ if (OVERUSED_FONTS.has(f)) overusedFound.add(f);
2534
+ }
2535
+ }
2536
+ }
2537
+
2538
+ for (const font of overusedFound) {
2539
+ findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
2540
+ }
2541
+
2542
+ // Single font
2543
+ if (fonts.size === 1) {
2544
+ const els = doc.querySelectorAll('*');
2545
+ if (els.length >= 20) {
2546
+ findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
2547
+ }
2548
+ }
2549
+
2550
+ // Flat type hierarchy
2551
+ const sizes = new Set();
2552
+ const textEls = doc.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div');
2553
+ for (const el of textEls) {
2554
+ const fontSize = parseFloat(win.getComputedStyle(el).fontSize);
2555
+ // Filter out sub-8px values (jsdom doesn't resolve relative units properly)
2556
+ if (fontSize >= 8 && fontSize < 200) sizes.add(Math.round(fontSize * 10) / 10);
2557
+ }
2558
+ if (sizes.size >= 3) {
2559
+ const sorted = [...sizes].sort((a, b) => a - b);
2560
+ const ratio = sorted[sorted.length - 1] / sorted[0];
2561
+ if (ratio < 2.0) {
2562
+ findings.push({ id: 'flat-type-hierarchy', snippet: `Sizes: ${sorted.map(s => s + 'px').join(', ')} (ratio ${ratio.toFixed(1)}:1)` });
2563
+ }
2564
+ }
2565
+
2566
+ return findings;
2567
+ }
2568
+
2569
+ function isCardLike(el, win) {
2570
+ const tag = el.tagName.toLowerCase();
2571
+ if (SAFE_TAGS.has(tag) || ['input', 'select', 'textarea', 'img', 'video', 'canvas', 'picture'].includes(tag)) return false;
2572
+
2573
+ const style = win.getComputedStyle(el);
2574
+ const rawStyle = el.getAttribute?.('style') || '';
2575
+ const cls = el.getAttribute?.('class') || '';
2576
+
2577
+ const hasShadow = (style.boxShadow && style.boxShadow !== 'none') ||
2578
+ /\bshadow(?:-sm|-md|-lg|-xl|-2xl)?\b/.test(cls) || /box-shadow/i.test(rawStyle);
2579
+ const hasBorder = /\bborder\b/.test(cls);
2580
+ const widthPx = parseFloat(style.width) || 0;
2581
+ const hasRadius = resolveBorderRadiusPx(el, style, widthPx, win) > 0 ||
2582
+ /\brounded(?:-sm|-md|-lg|-xl|-2xl|-full)?\b/.test(cls) || /border-radius/i.test(rawStyle);
2583
+ const hasBg = /\bbg-(?:white|gray-\d+|slate-\d+)\b/.test(cls) ||
2584
+ /background(?:-color)?\s*:\s*(?!transparent)/i.test(rawStyle);
2585
+
2586
+ return isCardLikeFromProps(hasShadow, hasBorder, hasRadius, hasBg);
2587
+ }
2588
+
2589
+ function checkPageLayout(doc, win) {
2590
+ const findings = [];
2591
+
2592
+ // Nested cards
2593
+ const allEls = doc.querySelectorAll('*');
2594
+ const flaggedEls = new Set();
2595
+ for (const el of allEls) {
2596
+ if (!isCardLike(el, win)) continue;
2597
+ if (flaggedEls.has(el)) continue;
2598
+
2599
+ const tag = el.tagName.toLowerCase();
2600
+ const cls = el.getAttribute?.('class') || '';
2601
+ const rawStyle = el.getAttribute?.('style') || '';
2602
+
2603
+ if (['pre', 'code'].includes(tag)) continue;
2604
+ if (/\b(?:absolute|fixed)\b/.test(cls) || /position\s*:\s*(?:absolute|fixed)/i.test(rawStyle)) continue;
2605
+ if ((el.textContent?.trim().length || 0) < 10) continue;
2606
+ if (/\b(?:dropdown|popover|tooltip|menu|modal|dialog)\b/i.test(cls)) continue;
2607
+
2608
+ // Walk up to find card-like ancestor
2609
+ let parent = el.parentElement;
2610
+ while (parent) {
2611
+ if (isCardLike(parent, win)) {
2612
+ flaggedEls.add(el);
2613
+ break;
2614
+ }
2615
+ parent = parent.parentElement;
2616
+ }
2617
+ }
2618
+
2619
+ // Only report innermost nested cards
2620
+ for (const el of flaggedEls) {
2621
+ let isAncestorOfFlagged = false;
2622
+ for (const other of flaggedEls) {
2623
+ if (other !== el && el.contains(other)) {
2624
+ isAncestorOfFlagged = true;
2625
+ break;
2626
+ }
2627
+ }
2628
+ if (!isAncestorOfFlagged) {
2629
+ findings.push({ id: 'nested-cards', snippet: `Card inside card (${el.tagName.toLowerCase()})` });
2630
+ }
2631
+ }
2632
+
2633
+ return findings;
2634
+ }
2635
+
2636
+ // ─── Cream / beige palette (the default "tasteful" AI surface) ────────────────
2637
+ // A warm, lightly-tinted off-white page background — light, with R≥G≥B and a
2638
+ // small warm tint (not white, not a strong color). The current reflex surface.
2639
+ function isCreamColor(rgb) {
2640
+ if (!rgb) return false;
2641
+ const { r, g, b } = rgb;
2642
+ if (Math.min(r, g, b) < 209) return false; // must be light
2643
+ if (!(r >= g && g >= b)) return false; // warm ordering
2644
+ const warmth = r - b;
2645
+ return warmth >= 6 && warmth <= 48; // tinted, not white, not strong
2646
+ }
2647
+
2648
+ // Tailwind background utilities that render as a warm off-white surface. The
2649
+ // static engine doesn't fetch Tailwind's CSS, so a `bg-amber-50` on <body>
2650
+ // resolves to nothing in computed style — catch it from the class list
2651
+ // instead. Candidate tokens map to their actual Tailwind hex and are still
2652
+ // filtered through isCreamColor, so neutral grays (stone) and over-saturated
2653
+ // shades drop out on their own.
2654
+ const TAILWIND_BG_HEX = {
2655
+ 'bg-amber-50': '#fffbeb', 'bg-amber-100': '#fef3c7',
2656
+ 'bg-orange-50': '#fff7ed', 'bg-orange-100': '#ffedd5',
2657
+ 'bg-yellow-50': '#fefce8',
2658
+ 'bg-stone-50': '#fafaf9', 'bg-stone-100': '#f5f5f4', 'bg-stone-200': '#e7e5e4',
2659
+ };
2660
+
2661
+ function creamFromClassList(cls) {
2662
+ if (!cls) return null;
2663
+ // Arbitrary value: bg-[#f5f0e6] / bg-[rgb(245_240_230)] (underscores = spaces).
2664
+ const arb = cls.match(/\bbg-\[([^\]]+)\]/);
2665
+ if (arb && isCreamColor(parseAnyColor(arb[1].replace(/_/g, ' ')))) return `bg-[${arb[1]}]`;
2666
+ // Named warm-light utilities.
2667
+ for (const [tok, hex] of Object.entries(TAILWIND_BG_HEX)) {
2668
+ if (new RegExp(`(^|\\s)${tok}($|\\s)`).test(cls) && isCreamColor(parseAnyColor(hex))) return tok;
2669
+ }
2670
+ return null;
2671
+ }
2672
+
2673
+ function checkCreamPalette(doc, win) {
2674
+ const findings = [];
2675
+ const body = doc.body || (doc.querySelector ? doc.querySelector('body') : null);
2676
+ if (!body) return findings;
2677
+ const html = doc.documentElement;
2678
+ const getCS = (el) => (win ? win.getComputedStyle(el) : getComputedStyle(el));
2679
+
2680
+ // 1. Computed background — covers inline / <style> / linked CSS, and Tailwind
2681
+ // once it's actually rendered (browser path).
2682
+ let bg = readOwnBackgroundColor(body, getCS(body));
2683
+ if (!bg || bg.a === 0) {
2684
+ if (html) bg = readOwnBackgroundColor(html, getCS(html));
2685
+ }
2686
+ if (isCreamColor(bg)) {
2687
+ findings.push({ id: 'cream-palette', snippet: `cream/beige page background rgb(${bg.r}, ${bg.g}, ${bg.b})` });
2688
+ return findings;
2689
+ }
2690
+
2691
+ // 2. Tailwind class fallback — for the static path, where utility classes
2692
+ // never resolve to computed CSS.
2693
+ for (const el of [body, html]) {
2694
+ const tok = creamFromClassList(el && el.getAttribute ? el.getAttribute('class') : '');
2695
+ if (tok) {
2696
+ findings.push({ id: 'cream-palette', snippet: `cream/beige page background (Tailwind ${tok})` });
2697
+ break;
2698
+ }
2699
+ }
2700
+ return findings;
2701
+ }
2702
+
2703
+ // ─── Oversized hero headline ────────────────────────────────────────────────
2704
+ // Fires when a *long* headline is set at display size, so a full sentence ends
2705
+ // up dominating the viewport. A punchy one- or two-word headline at the same
2706
+ // size is a legitimate stylistic choice and must pass — length, not size
2707
+ // alone, is the tell.
2708
+ const OVERSIZED_H1_FONT_PX = 72;
2709
+ const OVERSIZED_H1_MIN_CHARS = 40;
2710
+ function checkOversizedH1({ tag, fontSize, headingText }) {
2711
+ if (tag !== 'h1') return [];
2712
+ const textLen = headingText.length;
2713
+ if (fontSize >= OVERSIZED_H1_FONT_PX && textLen >= OVERSIZED_H1_MIN_CHARS) {
2714
+ return [{ id: 'oversized-h1', snippet: `${Math.round(fontSize)}px h1, ${textLen} chars "${headingText.slice(0, 60)}"` }];
2715
+ }
2716
+ return [];
2717
+ }
2718
+
2719
+ function checkElementOversizedH1(el, style, tag, window) {
2720
+ if (tag !== 'h1') return [];
2721
+ const fontSize = resolveFontSizePx(el, window);
2722
+ const headingText = (el.textContent || '').trim().replace(/\s+/g, ' ');
2723
+ return checkOversizedH1({ tag, fontSize, headingText });
2724
+ }
2725
+
2726
+ function checkElementOversizedH1DOM(el) {
2727
+ const tag = el.tagName.toLowerCase();
2728
+ if (tag !== 'h1') return [];
2729
+ const style = getComputedStyle(el);
2730
+ const fontSize = parseFloat(style.fontSize) || 0;
2731
+ const headingText = (el.textContent || '').trim().replace(/\s+/g, ' ');
2732
+ return checkOversizedH1({ tag, fontSize, headingText });
2733
+ }
2734
+
2735
+ // ─── GPT tell: hairline border + wide diffuse shadow (gated --gpt) ────────────
2736
+ function shadowMaxBlurPx(boxShadow) {
2737
+ if (!boxShadow || boxShadow === 'none') return 0;
2738
+ let maxBlur = 0;
2739
+ // Split into layers on commas not inside parentheses (rgba(...) etc.).
2740
+ for (const layer of boxShadow.split(/,(?![^()]*\))/)) {
2741
+ // Strip colors and keywords (rgba()/hsl()/hex/named/inset/px), leaving the
2742
+ // ordered length tokens: offsetX offsetY blur [spread]. Static jsdom keeps
2743
+ // unitless zeros ("0 0 24px"); browsers normalize to px ("0px 0px 24px") —
2744
+ // both reduce to the same numbers here.
2745
+ const cleaned = layer.replace(/rgba?\([^)]*\)|hsla?\([^)]*\)|#[0-9a-f]+|\b[a-z]+\b/gi, ' ');
2746
+ const nums = [...cleaned.matchAll(/-?\d*\.?\d+/g)].map(m => parseFloat(m[0]));
2747
+ if (nums.length >= 3) maxBlur = Math.max(maxBlur, nums[2]);
2748
+ }
2749
+ return maxBlur;
2750
+ }
2751
+
2752
+ function checkGptThinBorderWideShadow({ borderWidths, boxShadow }) {
2753
+ const maxBorder = Math.max(0, ...borderWidths);
2754
+ const hasThinBorder = maxBorder > 0 && maxBorder <= 1.5;
2755
+ const blur = shadowMaxBlurPx(boxShadow);
2756
+ if (hasThinBorder && blur >= 16) {
2757
+ return [{ id: 'gpt-thin-border-wide-shadow', snippet: `${maxBorder}px border + ${Math.round(blur)}px shadow blur` }];
2758
+ }
2759
+ return [];
2760
+ }
2761
+
2762
+ function borderWidthsFromStyle(style) {
2763
+ return [
2764
+ parseFloat(style.borderTopWidth) || 0,
2765
+ parseFloat(style.borderRightWidth) || 0,
2766
+ parseFloat(style.borderBottomWidth) || 0,
2767
+ parseFloat(style.borderLeftWidth) || 0,
2768
+ ];
2769
+ }
2770
+
2771
+ function checkElementGptBorderShadow(el, style) {
2772
+ return checkGptThinBorderWideShadow({ borderWidths: borderWidthsFromStyle(style), boxShadow: style.boxShadow || '' });
2773
+ }
2774
+
2775
+ function checkElementGptBorderShadowDOM(el) {
2776
+ const style = getComputedStyle(el);
2777
+ return checkGptThinBorderWideShadow({ borderWidths: borderWidthsFromStyle(style), boxShadow: style.boxShadow || '' });
2778
+ }
2779
+
2780
+ // ─── Clipped overflow container ───────────────────────────────────────────────
2781
+ // A clipping container (overflow hidden/clip, not a scroll region) wrapping an
2782
+ // absolutely/fixed-positioned descendant clips popovers/menus that must escape.
2783
+ function classSelector(el) {
2784
+ const cls = (el.getAttribute ? el.getAttribute('class') : el.className) || '';
2785
+ const tokens = String(cls).trim().split(/\s+/).filter(Boolean);
2786
+ const tag = el.tagName ? el.tagName.toLowerCase() : 'el';
2787
+ return tokens.length ? `${tag}.${tokens.join('.')}` : tag;
2788
+ }
2789
+
2790
+ function checkClippedOverflow(el, style, getStyle) {
2791
+ const clips = (v) => v === 'hidden' || v === 'clip';
2792
+ const scrolls = (v) => v === 'auto' || v === 'scroll';
2793
+ const ox = style.overflowX || '', oy = style.overflowY || '', ov = style.overflow || '';
2794
+ const anyClip = clips(ox) || clips(oy) || clips(ov);
2795
+ const anyScroll = scrolls(ox) || scrolls(oy) || scrolls(ov);
2796
+ if (!anyClip || anyScroll) return [];
2797
+ if (!el.querySelectorAll) return [];
2798
+ for (const child of el.querySelectorAll('*')) {
2799
+ const pos = (getStyle(child).position) || '';
2800
+ if (pos === 'absolute' || pos === 'fixed') {
2801
+ return [{ id: 'clipped-overflow-container', snippet: `${classSelector(el)} clips a positioned child` }];
2802
+ }
2803
+ }
2804
+ return [];
2805
+ }
2806
+
2807
+ function checkElementClippedOverflow(el, style, tag, window) {
2808
+ return checkClippedOverflow(el, style, (n) => window.getComputedStyle(n));
2809
+ }
2810
+
2811
+ function checkElementClippedOverflowDOM(el) {
2812
+ const style = getComputedStyle(el);
2813
+ return checkClippedOverflow(el, style, (n) => getComputedStyle(n));
2814
+ }
2815
+
2816
+ // ─── Text overflow (browser-only: needs scrollWidth/clientWidth) ──────────────
2817
+ const TEXT_OVERFLOW_SKIP_TAGS = new Set(['pre', 'code', 'textarea', 'svg', 'canvas', 'select', 'option', 'marquee']);
2818
+
2819
+ function checkElementTextOverflowDOM(el) {
2820
+ const tag = el.tagName.toLowerCase();
2821
+ if (TEXT_OVERFLOW_SKIP_TAGS.has(tag)) return [];
2822
+ // Only the element that actually owns overflowing text — not its ancestors,
2823
+ // which inherit a wider scrollWidth from the spilling descendant.
2824
+ const hasDirectText = [...el.childNodes].some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
2825
+ if (!hasDirectText) return [];
2826
+ const style = getComputedStyle(el);
2827
+ const isScrollRegion = (s) => /(auto|scroll)/.test(s.overflowX || '') || /(auto|scroll)/.test(s.overflow || '');
2828
+ if (isScrollRegion(style)) return [];
2829
+ // A scrollable ancestor means this overflow is intentional and scrollable.
2830
+ for (let p = el.parentElement; p; p = p.parentElement) {
2831
+ if (isScrollRegion(getComputedStyle(p))) return [];
2832
+ }
2833
+ const delta = el.scrollWidth - el.clientWidth;
2834
+ if (el.clientWidth > 0 && delta >= 16) {
2835
+ return [{ id: 'text-overflow', snippet: `${classSelector(el)} overflows its box by ${Math.round(delta)}px` }];
2836
+ }
2837
+ return [];
2838
+ }
2839
+
2840
+ // --- cli/engine/browser/injected/index.mjs ---
2841
+ const IS_BROWSER = typeof window !== 'undefined';
2842
+
2843
+ // ─── Section 7: Browser UI (IS_BROWSER only) ────────────────────────────────
2844
+
2845
+ if (IS_BROWSER) {
2846
+ // Detect extension mode via the script tag's data attribute or the document element fallback.
2847
+ // currentScript is reliable for synchronously-executing scripts (which our IIFE is).
2848
+ const _myScript = document.currentScript;
2849
+ const EXTENSION_MODE = (_myScript && _myScript.dataset.impeccableExtension === 'true')
2850
+ || document.documentElement.dataset.impeccableExtension === 'true';
2851
+
2852
+ // Kinpaku gold — pinned to the site's brand token (see
2853
+ // site/styles/kinpaku-tokens.css --ks-kinpaku). Keep this in sync with
2854
+ // the picker's C.brand in skill/scripts/live-browser.js and the kit's
2855
+ // picker section in site/styles/kinpaku-kit.css.
2856
+ //
2857
+ // One color across both light and dark host pages. The outline is a
2858
+ // 2px gesture pointing at an element + a labeled tag — it's a marker,
2859
+ // not body text, so it doesn't need WCAG AA against the page. The
2860
+ // label text inside the gold tag is dark (LABEL_INK) which has ~16:1
2861
+ // against the leaf gold, so reading the rule name is solid in both
2862
+ // modes. Hover deepens the gold (preserves chroma — never drops it,
2863
+ // dropping chroma washes the gold into a sand/olive tone).
2864
+ const BRAND_COLOR = 'oklch(84% 0.19 80.46)';
2865
+ const BRAND_COLOR_HOVER = 'oklch(74% 0.18 80)';
2866
+ const LABEL_INK = 'oklch(4% 0.004 95)';
2867
+ const LABEL_BG = BRAND_COLOR;
2868
+ const OUTLINE_COLOR = BRAND_COLOR;
2869
+
2870
+ // Inject hover styles via CSS (more reliable than JS event listeners)
2871
+ const styleEl = document.createElement('style');
2872
+ styleEl.textContent = `
2873
+ @keyframes impeccable-reveal {
2874
+ from { opacity: 0; }
2875
+ to { opacity: 1; }
2876
+ }
2877
+ .impeccable-overlay:not(.impeccable-banner) {
2878
+ pointer-events: none;
2879
+ outline: 2px solid ${OUTLINE_COLOR};
2880
+ border-radius: 4px;
2881
+ transition: outline-color 0.15s ease;
2882
+ animation: impeccable-reveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
2883
+ animation-play-state: paused;
2884
+ border-top-left-radius: 0;
2885
+ }
2886
+ .impeccable-overlay.impeccable-visible {
2887
+ animation-play-state: running;
2888
+ }
2889
+ .impeccable-overlay.impeccable-hover {
2890
+ outline-color: ${BRAND_COLOR_HOVER};
2891
+ z-index: 100001 !important;
2892
+ }
2893
+ .impeccable-overlay.impeccable-hover .impeccable-label {
2894
+ background: ${BRAND_COLOR_HOVER};
2895
+ }
2896
+ .impeccable-overlay.impeccable-spotlight {
2897
+ z-index: 100002 !important;
2898
+ }
2899
+ .impeccable-overlay.impeccable-spotlight-dimmed {
2900
+ opacity: 0.15 !important;
2901
+ animation: none !important;
2902
+ filter: blur(3px);
2903
+ }
2904
+ .impeccable-spotlight-backdrop {
2905
+ position: fixed;
2906
+ top: 0; left: 0; right: 0; bottom: 0;
2907
+ backdrop-filter: blur(3px) brightness(0.6);
2908
+ -webkit-backdrop-filter: blur(3px) brightness(0.6);
2909
+ pointer-events: none;
2910
+ z-index: 99998;
2911
+ opacity: 0;
2912
+ outline: none !important;
2913
+ animation: none !important;
2914
+ }
2915
+ .impeccable-spotlight-backdrop.impeccable-visible {
2916
+ opacity: 1;
2917
+ }
2918
+ .impeccable-hidden .impeccable-overlay${EXTENSION_MODE ? '' : ':not(.impeccable-banner)'} {
2919
+ display: none !important;
2920
+ }
2921
+ `;
2922
+ (document.head || document.documentElement).appendChild(styleEl);
2923
+
2924
+ // Spotlight backdrop element (created lazily on first use)
2925
+ let spotlightBackdrop = null;
2926
+ let spotlightTarget = null;
2927
+
2928
+ function getSpotlightBackdrop() {
2929
+ if (!spotlightBackdrop) {
2930
+ spotlightBackdrop = document.createElement('div');
2931
+ spotlightBackdrop.className = 'impeccable-spotlight-backdrop';
2932
+ document.body.appendChild(spotlightBackdrop);
2933
+ }
2934
+ return spotlightBackdrop;
2935
+ }
2936
+
2937
+ function updateSpotlightClipPath() {
2938
+ if (!spotlightBackdrop || !spotlightTarget) return;
2939
+ const r = spotlightTarget.getBoundingClientRect();
2940
+ // Match the overlay's outer edge: element rect + 4px (2px overlay offset + 2px outline width)
2941
+ const inset = 4;
2942
+ const radius = 6; // outline border-radius (4) + outline width (2)
2943
+ const x1 = r.left - inset;
2944
+ const y1 = r.top - inset;
2945
+ const x2 = r.right + inset;
2946
+ const y2 = r.bottom + inset;
2947
+ const vw = window.innerWidth;
2948
+ const vh = window.innerHeight;
2949
+ // Outer rect + rounded inner rect (evenodd creates a hole)
2950
+ const path = `M0 0H${vw}V${vh}H0Z M${x1 + radius} ${y1}H${x2 - radius}A${radius} ${radius} 0 0 1 ${x2} ${y1 + radius}V${y2 - radius}A${radius} ${radius} 0 0 1 ${x2 - radius} ${y2}H${x1 + radius}A${radius} ${radius} 0 0 1 ${x1} ${y2 - radius}V${y1 + radius}A${radius} ${radius} 0 0 1 ${x1 + radius} ${y1}Z`;
2951
+ spotlightBackdrop.style.clipPath = `path(evenodd, "${path}")`;
2952
+ }
2953
+
2954
+ function showSpotlight(target) {
2955
+ if (!target || !target.getBoundingClientRect) return;
2956
+ // Respect the spotlightBlur setting: if disabled, don't show the backdrop
2957
+ if (window.__IMPECCABLE_CONFIG__?.spotlightBlur === false) {
2958
+ spotlightTarget = target;
2959
+ return;
2960
+ }
2961
+ spotlightTarget = target;
2962
+ const bd = getSpotlightBackdrop();
2963
+ updateSpotlightClipPath();
2964
+ bd.classList.add('impeccable-visible');
2965
+ }
2966
+
2967
+ function hideSpotlight() {
2968
+ spotlightTarget = null;
2969
+ if (spotlightBackdrop) spotlightBackdrop.classList.remove('impeccable-visible');
2970
+ }
2971
+
2972
+ function isInViewport(el) {
2973
+ const r = el.getBoundingClientRect();
2974
+ return r.top >= 0 && r.left >= 0 && r.bottom <= window.innerHeight && r.right <= window.innerWidth;
2975
+ }
2976
+
2977
+ // Reposition spotlight on scroll/resize
2978
+ window.addEventListener('scroll', () => {
2979
+ if (spotlightTarget) updateSpotlightClipPath();
2980
+ }, { passive: true });
2981
+ window.addEventListener('resize', () => {
2982
+ if (spotlightTarget) updateSpotlightClipPath();
2983
+ });
2984
+
2985
+ const overlays = [];
2986
+ const TYPE_LABELS = {};
2987
+ const RULE_CATEGORY = {};
2988
+ for (const ap of ANTIPATTERNS) {
2989
+ TYPE_LABELS[ap.id] = ap.name.toLowerCase();
2990
+ RULE_CATEGORY[ap.id] = ap.category || 'quality';
2991
+ }
2992
+
2993
+ function isInFixedContext(el) {
2994
+ let p = el;
2995
+ while (p && p !== document.body) {
2996
+ if (getComputedStyle(p).position === 'fixed') return true;
2997
+ p = p.parentElement;
2998
+ }
2999
+ return false;
3000
+ }
3001
+
3002
+ function positionOverlay(overlay) {
3003
+ const el = overlay._targetEl;
3004
+ if (!el) return;
3005
+ const rect = el.getBoundingClientRect();
3006
+ if (overlay._isFixed) {
3007
+ // Viewport-relative coords for fixed targets
3008
+ overlay.style.top = `${rect.top - 2}px`;
3009
+ overlay.style.left = `${rect.left - 2}px`;
3010
+ } else {
3011
+ // Document-relative coords for normal targets
3012
+ overlay.style.top = `${rect.top + scrollY - 2}px`;
3013
+ overlay.style.left = `${rect.left + scrollX - 2}px`;
3014
+ }
3015
+ overlay.style.width = `${rect.width + 4}px`;
3016
+ overlay.style.height = `${rect.height + 4}px`;
3017
+ }
3018
+
3019
+ function repositionOverlays() {
3020
+ for (const o of overlays) {
3021
+ if (!o._targetEl || o.classList.contains('impeccable-banner')) continue;
3022
+ // Skip overlays whose target is currently hidden (display: none on the overlay)
3023
+ if (o.style.display === 'none') continue;
3024
+ positionOverlay(o);
3025
+ }
3026
+ }
3027
+
3028
+ let resizeRAF;
3029
+ const onResize = () => {
3030
+ cancelAnimationFrame(resizeRAF);
3031
+ resizeRAF = requestAnimationFrame(repositionOverlays);
3032
+ };
3033
+ window.addEventListener('resize', onResize);
3034
+ // Reposition on scroll too -- catches sticky/parallax shifts
3035
+ window.addEventListener('scroll', onResize, { passive: true });
3036
+ // Reposition when body resizes (lazy-loaded images, dynamic content, fonts loading)
3037
+ if (typeof ResizeObserver !== 'undefined') {
3038
+ const bodyResizeObserver = new ResizeObserver(onResize);
3039
+ bodyResizeObserver.observe(document.body);
3040
+ }
3041
+
3042
+ // Track target element visibility via IntersectionObserver.
3043
+ // Uses a huge rootMargin so all *rendered* elements count as intersecting,
3044
+ // while display:none / closed <details> / hidden modals etc. do not.
3045
+ // This is event-driven -- no polling needed.
3046
+ let overlayIndex = 0;
3047
+ const visibilityObserver = new IntersectionObserver((entries) => {
3048
+ for (const entry of entries) {
3049
+ const overlay = entry.target._impeccableOverlay;
3050
+ if (!overlay) continue;
3051
+ if (entry.isIntersecting) {
3052
+ overlay.style.display = '';
3053
+ positionOverlay(overlay);
3054
+ if (!overlay._revealed) {
3055
+ overlay._revealed = true;
3056
+ if (firstScanDone) {
3057
+ // Subsequent reveals (re-scans, scroll-into-view): instant, no animation
3058
+ overlay.style.animation = 'none';
3059
+ } else {
3060
+ // Initial scan: staggered cascade reveal
3061
+ overlay.style.animationDelay = `${Math.min((overlay._staggerIndex || 0) * 60, 600)}ms`;
3062
+ }
3063
+ requestAnimationFrame(() => {
3064
+ overlay.classList.add('impeccable-visible');
3065
+ if (overlay._checkLabel) overlay._checkLabel();
3066
+ });
3067
+ }
3068
+ } else {
3069
+ overlay.style.display = 'none';
3070
+ }
3071
+ }
3072
+ }, { rootMargin: '99999px' });
3073
+
3074
+ function detachOverlay(overlay) {
3075
+ if (!overlay) return;
3076
+ if (typeof overlay._cleanup === 'function') {
3077
+ try { overlay._cleanup(); } catch { /* best effort overlay teardown */ }
3078
+ }
3079
+ if (overlay._targetEl && overlay._targetEl._impeccableOverlay === overlay) {
3080
+ visibilityObserver.unobserve(overlay._targetEl);
3081
+ delete overlay._targetEl._impeccableOverlay;
3082
+ }
3083
+ const idx = overlays.indexOf(overlay);
3084
+ if (idx >= 0) overlays.splice(idx, 1);
3085
+ overlay.remove();
3086
+ }
3087
+
3088
+ // Reposition overlays after CSS transitions end (e.g. reveal animations).
3089
+ // Listens at document level so it catches transitions on ancestor elements
3090
+ // (the transform may be on a parent, not the flagged element itself).
3091
+ document.addEventListener('transitionend', (e) => {
3092
+ if (e.propertyName !== 'transform') return;
3093
+ for (const o of overlays) {
3094
+ if (!o._targetEl || o.classList.contains('impeccable-banner') || o.style.display === 'none') continue;
3095
+ if (e.target === o._targetEl || e.target.contains(o._targetEl)) {
3096
+ positionOverlay(o);
3097
+ }
3098
+ }
3099
+ });
3100
+
3101
+ const highlight = function(el, findings) {
3102
+ if (el._impeccableOverlay) detachOverlay(el._impeccableOverlay);
3103
+ const hasSlop = findings.some(f => RULE_CATEGORY[f.type || f.id] === 'slop');
3104
+
3105
+ const fixed = isInFixedContext(el);
3106
+ const rect = el.getBoundingClientRect();
3107
+ const outline = document.createElement('div');
3108
+ outline.className = 'impeccable-overlay';
3109
+ outline._targetEl = el;
3110
+ outline._isFixed = fixed;
3111
+ Object.assign(outline.style, {
3112
+ position: fixed ? 'fixed' : 'absolute',
3113
+ top: fixed ? `${rect.top - 2}px` : `${rect.top + scrollY - 2}px`,
3114
+ left: fixed ? `${rect.left - 2}px` : `${rect.left + scrollX - 2}px`,
3115
+ width: `${rect.width + 4}px`, height: `${rect.height + 4}px`,
3116
+ zIndex: '99999', boxSizing: 'border-box',
3117
+ });
3118
+
3119
+ // Build per-finding label entries: ✦ prefix for slop
3120
+ const entries = findings.map(f => {
3121
+ const name = TYPE_LABELS[f.type || f.id] || f.type || f.id;
3122
+ const prefix = RULE_CATEGORY[f.type || f.id] === 'slop' ? '\u2726 ' : '';
3123
+ return { name: prefix + name, detail: f.detail || f.snippet };
3124
+ });
3125
+ const allText = entries.map(e => e.name).join(', ');
3126
+
3127
+ const label = document.createElement('div');
3128
+ label.className = 'impeccable-label';
3129
+ Object.assign(label.style, {
3130
+ position: 'absolute', bottom: '100%', left: '-2px',
3131
+ display: 'flex', alignItems: 'center',
3132
+ whiteSpace: 'nowrap',
3133
+ fontSize: '11px', fontWeight: '600', letterSpacing: '0.02em',
3134
+ color: LABEL_INK, lineHeight: '14px',
3135
+ background: LABEL_BG,
3136
+ fontFamily: 'system-ui, sans-serif',
3137
+ borderRadius: '4px 4px 0 0',
3138
+ });
3139
+
3140
+ const textSpan = document.createElement('span');
3141
+ textSpan.style.padding = '3px 8px';
3142
+ textSpan.textContent = allText;
3143
+ label.appendChild(textSpan);
3144
+
3145
+ // State for cycling mode
3146
+ let cycleMode = false;
3147
+ let cycleIndex = 0;
3148
+ let isHovered = false;
3149
+ let prevBtn, nextBtn;
3150
+
3151
+ function updateCycleText() {
3152
+ const e = entries[cycleIndex];
3153
+ textSpan.textContent = isHovered ? e.detail : e.name;
3154
+ }
3155
+
3156
+ function enableCycleMode() {
3157
+ if (cycleMode || entries.length < 2) return;
3158
+ cycleMode = true;
3159
+
3160
+ const btnStyle = {
3161
+ background: 'none', border: 'none', color: 'rgba(255,255,255,0.7)',
3162
+ fontSize: '11px', cursor: 'pointer', padding: '3px 4px',
3163
+ fontFamily: 'system-ui, sans-serif', lineHeight: '14px',
3164
+ pointerEvents: 'auto',
3165
+ };
3166
+
3167
+ const navGroup = document.createElement('span');
3168
+ Object.assign(navGroup.style, {
3169
+ display: 'inline-flex', alignItems: 'center', flexShrink: '0',
3170
+ });
3171
+
3172
+ prevBtn = document.createElement('button');
3173
+ prevBtn.textContent = '\u2039';
3174
+ Object.assign(prevBtn.style, btnStyle);
3175
+ prevBtn.style.paddingLeft = '6px';
3176
+ prevBtn.addEventListener('click', (e) => {
3177
+ e.stopPropagation();
3178
+ cycleIndex = (cycleIndex - 1 + entries.length) % entries.length;
3179
+ updateCycleText();
3180
+ });
3181
+
3182
+ nextBtn = document.createElement('button');
3183
+ nextBtn.textContent = '\u203A';
3184
+ Object.assign(nextBtn.style, btnStyle);
3185
+ nextBtn.style.paddingRight = '2px';
3186
+ nextBtn.addEventListener('click', (e) => {
3187
+ e.stopPropagation();
3188
+ cycleIndex = (cycleIndex + 1) % entries.length;
3189
+ updateCycleText();
3190
+ });
3191
+
3192
+ navGroup.appendChild(prevBtn);
3193
+ navGroup.appendChild(nextBtn);
3194
+ label.insertBefore(navGroup, textSpan);
3195
+ textSpan.style.padding = '3px 8px 3px 4px';
3196
+ updateCycleText();
3197
+ }
3198
+
3199
+ outline.appendChild(label);
3200
+
3201
+ // Start hidden; the IntersectionObserver will show it once the target is rendered
3202
+ outline.style.display = 'none';
3203
+ outline._staggerIndex = overlayIndex++;
3204
+ el._impeccableOverlay = outline;
3205
+ visibilityObserver.observe(el);
3206
+
3207
+ // After first paint, check label width vs outline
3208
+ outline._checkLabel = () => {
3209
+ if (entries.length > 1 && label.offsetWidth > outline.offsetWidth) {
3210
+ enableCycleMode();
3211
+ }
3212
+ };
3213
+
3214
+ // Hover: show detail text, darken
3215
+ const onMouseEnter = () => {
3216
+ isHovered = true;
3217
+ outline.classList.add('impeccable-hover');
3218
+ outline.style.outlineColor = BRAND_COLOR_HOVER;
3219
+ label.style.background = BRAND_COLOR_HOVER;
3220
+ if (cycleMode) {
3221
+ updateCycleText();
3222
+ } else {
3223
+ textSpan.textContent = entries.map(e => e.detail).join(' | ');
3224
+ }
3225
+ };
3226
+ const onMouseLeave = () => {
3227
+ isHovered = false;
3228
+ outline.classList.remove('impeccable-hover');
3229
+ outline.style.outlineColor = '';
3230
+ label.style.background = LABEL_BG;
3231
+ if (cycleMode) {
3232
+ updateCycleText();
3233
+ } else {
3234
+ textSpan.textContent = allText;
3235
+ }
3236
+ };
3237
+ el.addEventListener('mouseenter', onMouseEnter);
3238
+ el.addEventListener('mouseleave', onMouseLeave);
3239
+ outline._cleanup = () => {
3240
+ el.removeEventListener('mouseenter', onMouseEnter);
3241
+ el.removeEventListener('mouseleave', onMouseLeave);
3242
+ };
3243
+
3244
+ document.body.appendChild(outline);
3245
+ overlays.push(outline);
3246
+ };
3247
+
3248
+ const showPageBanner = function(findings) {
3249
+ if (!findings.length) return;
3250
+ const banner = document.createElement('div');
3251
+ banner.className = 'impeccable-overlay impeccable-banner';
3252
+ Object.assign(banner.style, {
3253
+ position: 'fixed', top: '0', left: '0', right: '0', zIndex: '100000',
3254
+ background: LABEL_BG, color: LABEL_INK,
3255
+ fontFamily: 'system-ui, sans-serif', fontSize: '13px',
3256
+ display: 'flex', alignItems: 'center', pointerEvents: 'auto',
3257
+ height: '36px', overflow: 'hidden', maxWidth: '100vw',
3258
+ transform: 'translateY(-100%)',
3259
+ transition: 'transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
3260
+ });
3261
+ requestAnimationFrame(() => requestAnimationFrame(() => {
3262
+ banner.style.transform = 'translateY(0)';
3263
+ }));
3264
+
3265
+ // Scrollable findings area
3266
+ const scrollArea = document.createElement('div');
3267
+ Object.assign(scrollArea.style, {
3268
+ flex: '1', minWidth: '0', overflowX: 'auto', overflowY: 'hidden',
3269
+ display: 'flex', gap: '8px', alignItems: 'center',
3270
+ padding: '0 12px', scrollSnapType: 'x mandatory',
3271
+ scrollbarWidth: 'none',
3272
+ });
3273
+ for (const f of findings) {
3274
+ const prefix = RULE_CATEGORY[f.type] === 'slop' ? '\u2726 ' : '';
3275
+ const tag = document.createElement('span');
3276
+ tag.textContent = `${prefix}${TYPE_LABELS[f.type] || f.type}: ${f.detail}`;
3277
+ Object.assign(tag.style, {
3278
+ background: 'rgba(255,255,255,0.15)', padding: '2px 8px',
3279
+ borderRadius: '3px', fontSize: '12px', fontFamily: 'ui-monospace, monospace',
3280
+ whiteSpace: 'nowrap', flexShrink: '0', scrollSnapAlign: 'start',
3281
+ });
3282
+ scrollArea.appendChild(tag);
3283
+ }
3284
+ banner.appendChild(scrollArea);
3285
+
3286
+ // Controls area (only in standalone mode, not extension)
3287
+ if (!EXTENSION_MODE) {
3288
+ const controls = document.createElement('div');
3289
+ Object.assign(controls.style, {
3290
+ display: 'flex', alignItems: 'center', gap: '2px',
3291
+ padding: '0 8px', flexShrink: '0',
3292
+ });
3293
+
3294
+ // Toggle visibility button
3295
+ const toggle = document.createElement('button');
3296
+ toggle.textContent = '\u25C9'; // circle with dot (visible state)
3297
+ toggle.title = 'Toggle overlay visibility';
3298
+ Object.assign(toggle.style, {
3299
+ background: 'none', border: 'none',
3300
+ color: 'white', fontSize: '16px', cursor: 'pointer', padding: '0 4px',
3301
+ opacity: '0.85', transition: 'opacity 0.15s',
3302
+ });
3303
+ let overlaysVisible = true;
3304
+ toggle.addEventListener('click', () => {
3305
+ overlaysVisible = !overlaysVisible;
3306
+ document.body.classList.toggle('impeccable-hidden', !overlaysVisible);
3307
+ toggle.textContent = overlaysVisible ? '\u25C9' : '\u25CB'; // filled vs empty circle
3308
+ toggle.style.opacity = overlaysVisible ? '0.85' : '0.5';
3309
+ });
3310
+ controls.appendChild(toggle);
3311
+
3312
+ // Close button
3313
+ const close = document.createElement('button');
3314
+ close.textContent = '\u00d7';
3315
+ close.title = 'Dismiss banner';
3316
+ Object.assign(close.style, {
3317
+ background: 'none', border: 'none',
3318
+ color: 'white', fontSize: '18px', cursor: 'pointer', padding: '0 4px',
3319
+ });
3320
+ close.addEventListener('click', () => banner.remove());
3321
+ controls.appendChild(close);
3322
+
3323
+ banner.appendChild(controls);
3324
+ }
3325
+ document.body.appendChild(banner);
3326
+ overlays.push(banner);
3327
+ };
3328
+
3329
+ // Heuristic for skipping CSS-in-JS hashed class names like "css-1a2b3c" or "_2x4hG_".
3330
+ // These change between builds and produce brittle, ugly selectors.
3331
+ function isLikelyHashedClass(c) {
3332
+ if (!c) return true;
3333
+ if (/^(css|sc|emotion|jsx|module)-[\w-]{4,}$/i.test(c)) return true;
3334
+ if (/^_[\w-]{5,}$/.test(c)) return true;
3335
+ if (/^[a-z0-9]{6,}$/i.test(c) && /\d/.test(c)) return true;
3336
+ return false;
3337
+ }
3338
+
3339
+ function buildSelectorSegment(el) {
3340
+ const tag = el.tagName.toLowerCase();
3341
+ let sel = tag;
3342
+
3343
+ if (el.classList && el.classList.length > 0) {
3344
+ const classes = [...el.classList]
3345
+ .filter(c => !c.startsWith('impeccable-') && !isLikelyHashedClass(c))
3346
+ .slice(0, 2);
3347
+ if (classes.length > 0) {
3348
+ sel += '.' + classes.map(c => CSS.escape(c)).join('.');
3349
+ }
3350
+ }
3351
+
3352
+ // Disambiguate among siblings only if the parent has multiple matches
3353
+ const parent = el.parentElement;
3354
+ if (parent) {
3355
+ try {
3356
+ const matching = parent.querySelectorAll(':scope > ' + sel);
3357
+ if (matching.length > 1) {
3358
+ const sameType = [...parent.children].filter(c => c.tagName === el.tagName);
3359
+ const idx = sameType.indexOf(el) + 1;
3360
+ sel += `:nth-of-type(${idx})`;
3361
+ }
3362
+ } catch {
3363
+ const idx = [...parent.children].indexOf(el) + 1;
3364
+ sel = `${tag}:nth-child(${idx})`;
3365
+ }
3366
+ }
3367
+ return sel;
3368
+ }
3369
+
3370
+ function generateSelector(el) {
3371
+ if (el === document.body) return 'body';
3372
+ if (el === document.documentElement) return 'html';
3373
+ if (el.id) return '#' + CSS.escape(el.id);
3374
+
3375
+ const parts = [];
3376
+ let current = el;
3377
+ let depth = 0;
3378
+ const MAX_DEPTH = 10;
3379
+
3380
+ while (current && current !== document.body && current !== document.documentElement && depth < MAX_DEPTH) {
3381
+ parts.unshift(buildSelectorSegment(current));
3382
+
3383
+ // Anchor on an ancestor's ID and stop walking up
3384
+ if (current.id) {
3385
+ parts[0] = '#' + CSS.escape(current.id);
3386
+ break;
3387
+ }
3388
+
3389
+ // Stop as soon as the partial selector uniquely identifies the target
3390
+ const trySelector = parts.join(' > ');
3391
+ try {
3392
+ const matches = document.querySelectorAll(trySelector);
3393
+ if (matches.length === 1 && matches[0] === el) {
3394
+ return trySelector;
3395
+ }
3396
+ } catch { /* invalid selector — keep walking */ }
3397
+
3398
+ current = current.parentElement;
3399
+ depth++;
3400
+ }
3401
+
3402
+ return parts.join(' > ');
3403
+ }
3404
+
3405
+ function getDirectText(el) {
3406
+ return [...el.childNodes]
3407
+ .filter(n => n.nodeType === 3)
3408
+ .map(n => n.textContent || '')
3409
+ .join('');
3410
+ }
3411
+
3412
+ function getDirectTextRect(el) {
3413
+ const rects = [];
3414
+ for (const node of el.childNodes) {
3415
+ if (node.nodeType !== 3 || !(node.textContent || '').trim()) continue;
3416
+ const range = document.createRange();
3417
+ range.selectNodeContents(node);
3418
+ for (const rect of range.getClientRects()) {
3419
+ if (rect.width >= 1 && rect.height >= 1) rects.push(rect);
3420
+ }
3421
+ range.detach?.();
3422
+ }
3423
+ if (rects.length === 0) return null;
3424
+ const left = Math.min(...rects.map(r => r.left));
3425
+ const top = Math.min(...rects.map(r => r.top));
3426
+ const right = Math.max(...rects.map(r => r.right));
3427
+ const bottom = Math.max(...rects.map(r => r.bottom));
3428
+ return {
3429
+ left,
3430
+ top,
3431
+ right,
3432
+ bottom,
3433
+ width: right - left,
3434
+ height: bottom - top,
3435
+ x: left,
3436
+ y: top,
3437
+ };
3438
+ }
3439
+
3440
+ function collectVisualContrastReasons(el, style) {
3441
+ const reasons = new Set();
3442
+ const bgClip = style.webkitBackgroundClip || style.backgroundClip || '';
3443
+ const ownBgImage = style.backgroundImage || '';
3444
+ if (bgClip === 'text' && ownBgImage && ownBgImage !== 'none') {
3445
+ reasons.add('background-clip text');
3446
+ }
3447
+ if (style.textShadow && style.textShadow !== 'none') reasons.add('text shadow');
3448
+
3449
+ let current = el;
3450
+ while (current && current.nodeType === 1) {
3451
+ const tag = current.tagName?.toLowerCase();
3452
+ const currentStyle = getComputedStyle(current);
3453
+ const bgImage = currentStyle.backgroundImage || '';
3454
+ const isDocumentSurface = tag === 'body' || tag === 'html';
3455
+
3456
+ if (!isDocumentSurface && bgImage && bgImage !== 'none') {
3457
+ if (/url\s*\(/i.test(bgImage)) reasons.add('image background');
3458
+ if (/gradient/i.test(bgImage)) reasons.add('gradient background');
3459
+ }
3460
+ if (parseFloat(currentStyle.opacity) < 0.99) reasons.add('opacity stack');
3461
+ if (currentStyle.mixBlendMode && currentStyle.mixBlendMode !== 'normal') reasons.add('blend mode');
3462
+ if (currentStyle.filter && currentStyle.filter !== 'none') reasons.add('filter');
3463
+ if (currentStyle.backdropFilter && currentStyle.backdropFilter !== 'none') reasons.add('backdrop filter');
3464
+
3465
+ const solidBg = parseRgb(currentStyle.backgroundColor);
3466
+ if (solidBg && solidBg.a >= 0.95 && (!bgImage || bgImage === 'none')) break;
3467
+ current = current.parentElement;
3468
+ }
3469
+
3470
+ const sampleRect = getDirectTextRect(el) || el.getBoundingClientRect();
3471
+ if (sampleRect && document.elementsFromPoint) {
3472
+ const points = [
3473
+ [sampleRect.left + sampleRect.width / 2, sampleRect.top + sampleRect.height / 2],
3474
+ [sampleRect.left + Math.min(sampleRect.width - 1, Math.max(1, sampleRect.width * 0.25)), sampleRect.top + sampleRect.height / 2],
3475
+ [sampleRect.left + Math.min(sampleRect.width - 1, Math.max(1, sampleRect.width * 0.75)), sampleRect.top + sampleRect.height / 2],
3476
+ ];
3477
+ for (const [x, y] of points) {
3478
+ if (x < 0 || y < 0 || x > window.innerWidth || y > window.innerHeight) continue;
3479
+ const stack = document.elementsFromPoint(x, y);
3480
+ const selfIndex = stack.findIndex(node => node === el || el.contains(node) || node.contains?.(el));
3481
+ if (selfIndex < 0) continue;
3482
+ for (const node of stack.slice(selfIndex + 1)) {
3483
+ const nodeTag = node.tagName?.toLowerCase();
3484
+ if (nodeTag === 'img' || nodeTag === 'picture' || nodeTag === 'video' || nodeTag === 'canvas' || nodeTag === 'svg') {
3485
+ reasons.add(`${nodeTag} underlay`);
3486
+ break;
3487
+ }
3488
+ }
3489
+ }
3490
+ }
3491
+
3492
+ return [...reasons];
3493
+ }
3494
+
3495
+ function collectVisualContrastCandidates(options = {}) {
3496
+ const maxCandidates = Number.isFinite(options.maxCandidates) ? options.maxCandidates : 12;
3497
+ const candidates = [];
3498
+ for (const el of document.querySelectorAll('*')) {
3499
+ if (candidates.length >= maxCandidates) break;
3500
+ if (el.closest('.impeccable-overlay, .impeccable-label, .impeccable-banner, .impeccable-tooltip')) continue;
3501
+ if (el.closest('[id^="impeccable-live-"]')) continue;
3502
+ if (el === document.body || el === document.documentElement) continue;
3503
+
3504
+ const tag = el.tagName.toLowerCase();
3505
+ const style = getComputedStyle(el);
3506
+ if (style.display === 'none' || style.visibility === 'hidden') continue;
3507
+ const directText = getDirectText(el);
3508
+ const hasDirectText = directText.trim().length > 0;
3509
+ if (!hasDirectText || isEmojiOnlyText(directText)) continue;
3510
+
3511
+ const bgColor = readOwnBackgroundColor(el, style);
3512
+ const isStyledButton = (tag === 'a' || tag === 'button')
3513
+ && bgColor && bgColor.a > 0.5;
3514
+ if (SAFE_TAGS.has(tag) && !isStyledButton) continue;
3515
+
3516
+ const rect = getDirectTextRect(el) || el.getBoundingClientRect();
3517
+ if (!rect || rect.width < 4 || rect.height < 4) continue;
3518
+
3519
+ const reasons = collectVisualContrastReasons(el, style);
3520
+ if (reasons.length === 0) continue;
3521
+
3522
+ const textColor = parseRgb(style.color);
3523
+ const fontSize = parseFloat(style.fontSize) || 16;
3524
+ const fontWeight = parseInt(style.fontWeight) || 400;
3525
+ const isLargeText = fontSize >= WCAG_LARGE_TEXT_PX || (fontSize >= WCAG_LARGE_BOLD_TEXT_PX && fontWeight >= 700);
3526
+ const threshold = isLargeText ? 3.0 : 4.5;
3527
+ const clip = {
3528
+ x: Math.max(0, Math.floor(rect.left + window.scrollX - 2)),
3529
+ y: Math.max(0, Math.floor(rect.top + window.scrollY - 2)),
3530
+ width: Math.max(1, Math.ceil(rect.width + 4)),
3531
+ height: Math.max(1, Math.ceil(rect.height + 4)),
3532
+ };
3533
+
3534
+ candidates.push({
3535
+ selector: generateSelector(el),
3536
+ tagName: tag,
3537
+ text: directText.trim().replace(/\s+/g, ' ').slice(0, 80),
3538
+ threshold,
3539
+ reasons,
3540
+ clip,
3541
+ textColor,
3542
+ preferRenderedForeground: !textColor || textColor.a < 0.99 || reasons.some(reason =>
3543
+ reason === 'opacity stack' ||
3544
+ reason === 'blend mode' ||
3545
+ reason === 'filter' ||
3546
+ reason === 'backdrop filter' ||
3547
+ reason === 'background-clip text'
3548
+ ),
3549
+ backgroundClipText: reasons.includes('background-clip text'),
3550
+ });
3551
+ }
3552
+ return candidates;
3553
+ }
3554
+
3555
+ const visualContrastImageCache = new Map();
3556
+ const visualContrastRasterCache = new WeakMap();
3557
+
3558
+ function clampByte(value) {
3559
+ return Math.max(0, Math.min(255, Math.round(value)));
3560
+ }
3561
+
3562
+ function blendRgba(fg, bg) {
3563
+ if (!fg) return bg || null;
3564
+ if (!bg || fg.a == null || fg.a >= 0.999) {
3565
+ return { r: clampByte(fg.r), g: clampByte(fg.g), b: clampByte(fg.b), a: fg.a == null ? 1 : fg.a };
3566
+ }
3567
+ const alpha = Math.max(0, Math.min(1, fg.a));
3568
+ return {
3569
+ r: clampByte(fg.r * alpha + bg.r * (1 - alpha)),
3570
+ g: clampByte(fg.g * alpha + bg.g * (1 - alpha)),
3571
+ b: clampByte(fg.b * alpha + bg.b * (1 - alpha)),
3572
+ a: 1,
3573
+ };
3574
+ }
3575
+
3576
+ function pickWorstContrastColor(textColor, colors) {
3577
+ const usable = (colors || []).filter(Boolean);
3578
+ if (!usable.length) return null;
3579
+ let worst = usable[0];
3580
+ let worstRatio = contrastRatio(textColor, worst);
3581
+ for (const color of usable.slice(1)) {
3582
+ const ratio = contrastRatio(textColor, color);
3583
+ if (ratio < worstRatio) {
3584
+ worst = color;
3585
+ worstRatio = ratio;
3586
+ }
3587
+ }
3588
+ return worst;
3589
+ }
3590
+
3591
+ function firstCssUrl(value) {
3592
+ const match = String(value || '').match(/url\((?:"([^"]+)"|'([^']+)'|([^)]*))\)/i);
3593
+ if (!match) return '';
3594
+ return (match[1] || match[2] || match[3] || '').trim();
3595
+ }
3596
+
3597
+ function getLayerValue(value, index = 0) {
3598
+ return String(value || '').split(',')[index]?.trim() || '';
3599
+ }
3600
+
3601
+ function parsePositionToken(token, container, painted) {
3602
+ if (!token || token === 'center') return (container - painted) / 2;
3603
+ if (token === 'left' || token === 'top') return 0;
3604
+ if (token === 'right' || token === 'bottom') return container - painted;
3605
+ if (/%$/.test(token)) {
3606
+ const pct = parseFloat(token) / 100;
3607
+ return (container - painted) * pct;
3608
+ }
3609
+ if (/px$/.test(token)) return parseFloat(token) || 0;
3610
+ return (container - painted) / 2;
3611
+ }
3612
+
3613
+ function parsePositionPair(positionValue) {
3614
+ const tokens = String(positionValue || '50% 50%').trim().split(/\s+/).filter(Boolean);
3615
+ const first = tokens[0] || '50%';
3616
+ if (tokens.length < 2) {
3617
+ if (first === 'top' || first === 'bottom') return ['50%', first];
3618
+ return [first, '50%'];
3619
+ }
3620
+ return [first, tokens[1] || '50%'];
3621
+ }
3622
+
3623
+ function resolvePaintedImageRect(containerRect, image, sizeValue, positionValue) {
3624
+ const intrinsicWidth = image.naturalWidth || image.videoWidth || image.width || 1;
3625
+ const intrinsicHeight = image.naturalHeight || image.videoHeight || image.height || 1;
3626
+ let paintedWidth = intrinsicWidth;
3627
+ let paintedHeight = intrinsicHeight;
3628
+ const size = String(sizeValue || 'auto').trim();
3629
+
3630
+ if (size === 'cover' || size === 'contain') {
3631
+ const scale = size === 'cover'
3632
+ ? Math.max(containerRect.width / intrinsicWidth, containerRect.height / intrinsicHeight)
3633
+ : Math.min(containerRect.width / intrinsicWidth, containerRect.height / intrinsicHeight);
3634
+ paintedWidth = intrinsicWidth * scale;
3635
+ paintedHeight = intrinsicHeight * scale;
3636
+ } else if (size && size !== 'auto') {
3637
+ const parts = size.split(/\s+/);
3638
+ const widthToken = parts[0];
3639
+ const heightToken = parts[1] || 'auto';
3640
+ if (/%$/.test(widthToken)) paintedWidth = containerRect.width * (parseFloat(widthToken) / 100);
3641
+ else if (/px$/.test(widthToken)) paintedWidth = parseFloat(widthToken) || paintedWidth;
3642
+ if (heightToken === 'auto') paintedHeight = paintedWidth * (intrinsicHeight / intrinsicWidth);
3643
+ else if (/%$/.test(heightToken)) paintedHeight = containerRect.height * (parseFloat(heightToken) / 100);
3644
+ else if (/px$/.test(heightToken)) paintedHeight = parseFloat(heightToken) || paintedHeight;
3645
+ }
3646
+
3647
+ const [xToken, yToken] = parsePositionPair(positionValue);
3648
+ const positionX = parsePositionToken(xToken, containerRect.width, paintedWidth);
3649
+ const positionY = parsePositionToken(yToken, containerRect.height, paintedHeight);
3650
+ return {
3651
+ left: containerRect.left + positionX,
3652
+ top: containerRect.top + positionY,
3653
+ width: paintedWidth,
3654
+ height: paintedHeight,
3655
+ intrinsicWidth,
3656
+ intrinsicHeight,
3657
+ };
3658
+ }
3659
+
3660
+ function parseObjectPosition(positionValue) {
3661
+ return parsePositionPair(positionValue);
3662
+ }
3663
+
3664
+ function resolveObjectImageRect(containerRect, image, style) {
3665
+ const intrinsicWidth = image.naturalWidth || image.videoWidth || image.width || 1;
3666
+ const intrinsicHeight = image.naturalHeight || image.videoHeight || image.height || 1;
3667
+ const fit = style.objectFit || 'fill';
3668
+ let paintedWidth = containerRect.width;
3669
+ let paintedHeight = containerRect.height;
3670
+ if (fit === 'contain' || fit === 'cover') {
3671
+ const scale = fit === 'cover'
3672
+ ? Math.max(containerRect.width / intrinsicWidth, containerRect.height / intrinsicHeight)
3673
+ : Math.min(containerRect.width / intrinsicWidth, containerRect.height / intrinsicHeight);
3674
+ paintedWidth = intrinsicWidth * scale;
3675
+ paintedHeight = intrinsicHeight * scale;
3676
+ } else if (fit === 'none') {
3677
+ paintedWidth = intrinsicWidth;
3678
+ paintedHeight = intrinsicHeight;
3679
+ } else if (fit === 'scale-down') {
3680
+ const containScale = Math.min(containerRect.width / intrinsicWidth, containerRect.height / intrinsicHeight, 1);
3681
+ paintedWidth = intrinsicWidth * containScale;
3682
+ paintedHeight = intrinsicHeight * containScale;
3683
+ }
3684
+ const [xToken, yToken] = parseObjectPosition(style.objectPosition);
3685
+ return {
3686
+ left: containerRect.left + parsePositionToken(xToken, containerRect.width, paintedWidth),
3687
+ top: containerRect.top + parsePositionToken(yToken, containerRect.height, paintedHeight),
3688
+ width: paintedWidth,
3689
+ height: paintedHeight,
3690
+ intrinsicWidth,
3691
+ intrinsicHeight,
3692
+ };
3693
+ }
3694
+
3695
+ function pointToImageSource(point, paintedRect) {
3696
+ if (
3697
+ point.x < paintedRect.left ||
3698
+ point.y < paintedRect.top ||
3699
+ point.x > paintedRect.left + paintedRect.width ||
3700
+ point.y > paintedRect.top + paintedRect.height
3701
+ ) {
3702
+ return null;
3703
+ }
3704
+ return {
3705
+ x: Math.max(0, Math.min(paintedRect.intrinsicWidth - 1, ((point.x - paintedRect.left) / paintedRect.width) * paintedRect.intrinsicWidth)),
3706
+ y: Math.max(0, Math.min(paintedRect.intrinsicHeight - 1, ((point.y - paintedRect.top) / paintedRect.height) * paintedRect.intrinsicHeight)),
3707
+ };
3708
+ }
3709
+
3710
+ async function loadVisualContrastImage(src) {
3711
+ if (!src) return null;
3712
+ if (visualContrastImageCache.has(src)) return visualContrastImageCache.get(src);
3713
+ const promise = new Promise(resolve => {
3714
+ const img = new Image();
3715
+ let settled = false;
3716
+ const finish = value => {
3717
+ if (settled) return;
3718
+ settled = true;
3719
+ clearTimeout(timer);
3720
+ resolve(value);
3721
+ };
3722
+ const timer = setTimeout(() => finish(null), 800);
3723
+ try {
3724
+ const absolute = new URL(src, location.href);
3725
+ if (absolute.origin !== location.origin && absolute.protocol !== 'data:' && absolute.protocol !== 'blob:') {
3726
+ img.crossOrigin = 'anonymous';
3727
+ }
3728
+ } catch {
3729
+ // Let the browser resolve unusual URLs itself.
3730
+ }
3731
+ img.onload = () => finish(img);
3732
+ img.onerror = () => finish(null);
3733
+ img.src = src;
3734
+ });
3735
+ visualContrastImageCache.set(src, promise);
3736
+ return promise;
3737
+ }
3738
+
3739
+ function sampleDrawablePixel(drawable, sourcePoint) {
3740
+ if (visualContrastRasterCache.has(drawable)) {
3741
+ const cached = visualContrastRasterCache.get(drawable);
3742
+ if (!cached || !cached.ctx) return { status: 'unresolved', reason: cached?.reason || 'image sample failed' };
3743
+ try {
3744
+ const x = Math.max(0, Math.min(cached.width - 1, Math.floor(sourcePoint.x * cached.scaleX)));
3745
+ const y = Math.max(0, Math.min(cached.height - 1, Math.floor(sourcePoint.y * cached.scaleY)));
3746
+ const data = cached.ctx.getImageData(x, y, 1, 1).data;
3747
+ return {
3748
+ status: 'sampled',
3749
+ color: { r: data[0], g: data[1], b: data[2], a: data[3] / 255 },
3750
+ };
3751
+ } catch (err) {
3752
+ return {
3753
+ status: 'unresolved',
3754
+ reason: /taint|cross-origin|Security/i.test(err?.message || '') ? 'tainted image' : 'image sample failed',
3755
+ };
3756
+ }
3757
+ }
3758
+
3759
+ const canvas = document.createElement('canvas');
3760
+ const intrinsicWidth = drawable.naturalWidth || drawable.videoWidth || drawable.width || 1;
3761
+ const intrinsicHeight = drawable.naturalHeight || drawable.videoHeight || drawable.height || 1;
3762
+ const maxRasterSide = 640;
3763
+ const scale = Math.min(1, maxRasterSide / Math.max(intrinsicWidth, intrinsicHeight));
3764
+ canvas.width = Math.max(1, Math.round(intrinsicWidth * scale));
3765
+ canvas.height = Math.max(1, Math.round(intrinsicHeight * scale));
3766
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
3767
+ if (!ctx) return { status: 'unresolved', reason: 'canvas unavailable' };
3768
+ try {
3769
+ ctx.drawImage(drawable, 0, 0, canvas.width, canvas.height);
3770
+ const cached = {
3771
+ ctx,
3772
+ width: canvas.width,
3773
+ height: canvas.height,
3774
+ scaleX: canvas.width / intrinsicWidth,
3775
+ scaleY: canvas.height / intrinsicHeight,
3776
+ };
3777
+ visualContrastRasterCache.set(drawable, cached);
3778
+ const x = Math.max(0, Math.min(cached.width - 1, Math.floor(sourcePoint.x * cached.scaleX)));
3779
+ const y = Math.max(0, Math.min(cached.height - 1, Math.floor(sourcePoint.y * cached.scaleY)));
3780
+ const data = ctx.getImageData(x, y, 1, 1).data;
3781
+ return {
3782
+ status: 'sampled',
3783
+ color: { r: data[0], g: data[1], b: data[2], a: data[3] / 255 },
3784
+ };
3785
+ } catch (err) {
3786
+ const reason = /taint|cross-origin|Security/i.test(err?.message || '') ? 'tainted image' : 'image sample failed';
3787
+ visualContrastRasterCache.set(drawable, { ctx: null, reason });
3788
+ return {
3789
+ status: 'unresolved',
3790
+ reason,
3791
+ };
3792
+ }
3793
+ }
3794
+
3795
+ async function sampleCssBackground(el, style, point, textColor) {
3796
+ const rect = el.getBoundingClientRect();
3797
+ const bgImage = style.backgroundImage || '';
3798
+ if (bgImage && bgImage !== 'none') {
3799
+ if (/gradient/i.test(bgImage)) {
3800
+ const color = pickWorstContrastColor(textColor, parseGradientColors(bgImage));
3801
+ if (color) return { status: 'sampled', color, method: 'analytic-gradient' };
3802
+ }
3803
+ if (/url\s*\(/i.test(bgImage)) {
3804
+ const img = await loadVisualContrastImage(firstCssUrl(bgImage));
3805
+ if (!img) return { status: 'unresolved', reason: 'image unavailable' };
3806
+ const paintedRect = resolvePaintedImageRect(
3807
+ rect,
3808
+ img,
3809
+ getLayerValue(style.backgroundSize) || 'auto',
3810
+ getLayerValue(style.backgroundPosition) || '50% 50%',
3811
+ );
3812
+ const sourcePoint = pointToImageSource(point, paintedRect);
3813
+ if (!sourcePoint) return { status: 'unresolved', reason: 'point outside background image' };
3814
+ const sample = sampleDrawablePixel(img, sourcePoint);
3815
+ if (sample.status === 'sampled') return { ...sample, method: 'canvas-background-image' };
3816
+ return sample;
3817
+ }
3818
+ }
3819
+ const bg = parseRgb(style.backgroundColor);
3820
+ if (bg && bg.a > 0.05) return { status: 'sampled', color: bg, method: 'solid-background' };
3821
+ return { status: 'unresolved', reason: 'no readable background' };
3822
+ }
3823
+
3824
+ async function sampleImageElement(img, point) {
3825
+ const rect = img.getBoundingClientRect();
3826
+ const style = getComputedStyle(img);
3827
+ const paintedRect = resolveObjectImageRect(rect, img, style);
3828
+ const sourcePoint = pointToImageSource(point, paintedRect);
3829
+ if (!sourcePoint) return { status: 'unresolved', reason: 'point outside image' };
3830
+ const sample = sampleDrawablePixel(img, sourcePoint);
3831
+ if (sample.status === 'sampled') return { ...sample, method: 'canvas-img-underlay' };
3832
+
3833
+ if (img.currentSrc || img.src) {
3834
+ const loaded = await loadVisualContrastImage(img.currentSrc || img.src);
3835
+ if (loaded) {
3836
+ const loadedRect = { ...paintedRect, intrinsicWidth: loaded.naturalWidth || loaded.width || paintedRect.intrinsicWidth, intrinsicHeight: loaded.naturalHeight || loaded.height || paintedRect.intrinsicHeight };
3837
+ const loadedPoint = pointToImageSource(point, loadedRect);
3838
+ if (loadedPoint) {
3839
+ const loadedSample = sampleDrawablePixel(loaded, loadedPoint);
3840
+ if (loadedSample.status === 'sampled') return { ...loadedSample, method: 'canvas-img-underlay' };
3841
+ }
3842
+ }
3843
+ }
3844
+ return sample;
3845
+ }
3846
+
3847
+ function textSamplePoints(rect) {
3848
+ const insetX = Math.min(12, Math.max(1, rect.width * 0.12));
3849
+ const insetY = Math.min(8, Math.max(1, rect.height * 0.22));
3850
+ const xs = rect.width < 28
3851
+ ? [rect.left + rect.width / 2]
3852
+ : [rect.left + insetX, rect.left + rect.width / 2, rect.right - insetX];
3853
+ const ys = rect.height < 22
3854
+ ? [rect.top + rect.height / 2]
3855
+ : [rect.top + insetY, rect.top + rect.height / 2, rect.bottom - insetY];
3856
+ const points = [];
3857
+ for (const y of ys) {
3858
+ for (const x of xs) {
3859
+ if (x >= 0 && y >= 0 && x <= window.innerWidth && y <= window.innerHeight) points.push({ x, y });
3860
+ }
3861
+ }
3862
+ return points;
3863
+ }
3864
+
3865
+ async function sampleVisualBackgroundAtPoint(el, point, textColor, depth = 0) {
3866
+ if (depth > 8) {
3867
+ return { status: 'unresolved', reason: 'background stack too deep' };
3868
+ }
3869
+ const stack = typeof document.elementsFromPoint === 'function'
3870
+ ? document.elementsFromPoint(point.x, point.y)
3871
+ : [];
3872
+ const selfIndex = stack.findIndex(node => node === el || el.contains(node));
3873
+ const nodes = selfIndex >= 0 ? stack.slice(selfIndex) : [el, ...stack];
3874
+ const unresolved = [];
3875
+
3876
+ for (const node of nodes) {
3877
+ if (!node || node.nodeType !== 1) continue;
3878
+ if (node.closest?.('.impeccable-overlay, .impeccable-label, .impeccable-banner, .impeccable-tooltip')) continue;
3879
+ const tag = node.tagName?.toLowerCase();
3880
+ if (tag === 'img') {
3881
+ const sample = await sampleImageElement(node, point);
3882
+ if (sample.status === 'sampled') return sample;
3883
+ unresolved.push(sample.reason);
3884
+ continue;
3885
+ }
3886
+ if (tag === 'canvas' || tag === 'video') {
3887
+ const rect = node.getBoundingClientRect();
3888
+ const sourcePoint = pointToImageSource(point, {
3889
+ left: rect.left,
3890
+ top: rect.top,
3891
+ width: rect.width,
3892
+ height: rect.height,
3893
+ intrinsicWidth: node.width || node.videoWidth || rect.width,
3894
+ intrinsicHeight: node.height || node.videoHeight || rect.height,
3895
+ });
3896
+ if (sourcePoint) {
3897
+ const sample = sampleDrawablePixel(node, sourcePoint);
3898
+ if (sample.status === 'sampled') return { ...sample, method: `canvas-${tag}-underlay` };
3899
+ unresolved.push(sample.reason);
3900
+ }
3901
+ continue;
3902
+ }
3903
+ const style = getComputedStyle(node);
3904
+ const sample = await sampleCssBackground(node, style, point, textColor);
3905
+ if (sample.status === 'sampled') {
3906
+ if (!sample.color || sample.color.a == null || sample.color.a >= 0.95) return sample;
3907
+ const under = await sampleVisualBackgroundAtPoint(node.parentElement || document.body, point, textColor, depth + 1);
3908
+ if (under.status === 'sampled') {
3909
+ return {
3910
+ status: 'sampled',
3911
+ color: blendRgba(sample.color, under.color),
3912
+ method: `${sample.method}+alpha`,
3913
+ };
3914
+ }
3915
+ return sample;
3916
+ }
3917
+ unresolved.push(sample.reason);
3918
+ }
3919
+
3920
+ return {
3921
+ status: 'unresolved',
3922
+ reason: [...new Set(unresolved.filter(Boolean))].slice(0, 3).join(', ') || 'no readable visual background',
3923
+ };
3924
+ }
3925
+
3926
+ async function analyzeVisualContrastCandidate(candidate) {
3927
+ let el;
3928
+ try {
3929
+ el = document.querySelector(candidate.selector);
3930
+ } catch {
3931
+ return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'stale selector' };
3932
+ }
3933
+ if (!el) return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'missing element' };
3934
+
3935
+ const blockingReason = (candidate.reasons || []).find(reason =>
3936
+ reason === 'background-clip text' ||
3937
+ reason === 'blend mode' ||
3938
+ reason === 'filter' ||
3939
+ reason === 'backdrop filter' ||
3940
+ reason === 'opacity stack' ||
3941
+ reason === 'text shadow'
3942
+ );
3943
+ if (blockingReason) {
3944
+ return { ...candidate, status: 'unresolved', confidence: 'none', reason: `${blockingReason} needs screenshot pixels` };
3945
+ }
3946
+
3947
+ const style = getComputedStyle(el);
3948
+ const textColor = parseRgb(style.color) || candidate.textColor;
3949
+ if (!textColor) return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'unreadable text color' };
3950
+
3951
+ const rect = getDirectTextRect(el) || el.getBoundingClientRect();
3952
+ if (!rect || rect.width < 4 || rect.height < 4) {
3953
+ return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'missing text rect' };
3954
+ }
3955
+
3956
+ const points = textSamplePoints(rect);
3957
+ if (points.length === 0) {
3958
+ return { ...candidate, status: 'unresolved', confidence: 'none', reason: 'text outside viewport' };
3959
+ }
3960
+
3961
+ const ratios = [];
3962
+ const methods = new Set();
3963
+ const unresolved = [];
3964
+ for (const point of points) {
3965
+ const sample = await sampleVisualBackgroundAtPoint(el, point, textColor);
3966
+ if (sample.status !== 'sampled' || !sample.color) {
3967
+ unresolved.push(sample.reason);
3968
+ continue;
3969
+ }
3970
+ const fg = blendRgba(textColor, sample.color);
3971
+ ratios.push(contrastRatio(fg, sample.color));
3972
+ if (sample.method) methods.add(sample.method);
3973
+ }
3974
+
3975
+ if (ratios.length < Math.min(3, points.length)) {
3976
+ return {
3977
+ ...candidate,
3978
+ status: 'unresolved',
3979
+ confidence: 'none',
3980
+ samples: ratios.length,
3981
+ reason: [...new Set(unresolved.filter(Boolean))].slice(0, 3).join(', ') || 'not enough readable samples',
3982
+ };
3983
+ }
3984
+
3985
+ ratios.sort((a, b) => a - b);
3986
+ const pick = pct => ratios[Math.min(ratios.length - 1, Math.max(0, Math.floor((pct / 100) * ratios.length)))];
3987
+ const measuredRatio = pick(10);
3988
+ const medianRatio = pick(50);
3989
+ const status = measuredRatio < candidate.threshold ? 'fail' : 'pass';
3990
+ const method = [...methods].sort().join(', ') || 'browser-visual';
3991
+ const textLabel = candidate.text ? ` "${candidate.text}"` : '';
3992
+ const detail = `browser contrast ${measuredRatio.toFixed(1)}:1 median ${medianRatio.toFixed(1)}:1 (need ${candidate.threshold}:1) via ${method}${textLabel}`;
3993
+ return {
3994
+ ...candidate,
3995
+ status,
3996
+ confidence: method.includes('canvas-') ? 'high' : 'medium',
3997
+ method,
3998
+ ratio: measuredRatio,
3999
+ medianRatio,
4000
+ samples: ratios.length,
4001
+ finding: status === 'fail' ? { id: 'low-contrast', snippet: detail } : null,
4002
+ };
4003
+ }
4004
+
4005
+ function waitForVisualPaint() {
4006
+ return new Promise(resolve => {
4007
+ requestAnimationFrame(() => requestAnimationFrame(resolve));
4008
+ });
4009
+ }
4010
+
4011
+ async function analyzeVisualContrast(options = {}) {
4012
+ const candidates = collectVisualContrastCandidates(options);
4013
+ const results = [];
4014
+ const shouldScrollOffscreen = options.scrollOffscreen === true;
4015
+ const restoreScroll = { x: window.scrollX, y: window.scrollY };
4016
+ for (const candidate of candidates) {
4017
+ if (shouldScrollOffscreen && (window.scrollX !== restoreScroll.x || window.scrollY !== restoreScroll.y)) {
4018
+ window.scrollTo(restoreScroll.x, restoreScroll.y);
4019
+ await waitForVisualPaint();
4020
+ }
4021
+ let result = await analyzeVisualContrastCandidate(candidate);
4022
+ if (shouldScrollOffscreen && result.status === 'unresolved' && result.reason === 'text outside viewport') {
4023
+ let el = null;
4024
+ try {
4025
+ el = document.querySelector(candidate.selector);
4026
+ } catch {
4027
+ el = null;
4028
+ }
4029
+ if (el && typeof el.scrollIntoView === 'function') {
4030
+ el.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
4031
+ await waitForVisualPaint();
4032
+ result = await analyzeVisualContrastCandidate(candidate);
4033
+ }
4034
+ }
4035
+ results.push(result);
4036
+ }
4037
+ if (shouldScrollOffscreen && (window.scrollX !== restoreScroll.x || window.scrollY !== restoreScroll.y)) {
4038
+ window.scrollTo(restoreScroll.x, restoreScroll.y);
4039
+ }
4040
+ return results;
4041
+ }
4042
+
4043
+ function isElementHidden(el) {
4044
+ if (!el || el === document.body || el === document.documentElement) return false;
4045
+ if (typeof el.checkVisibility === 'function') return !el.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
4046
+ // Fallback: zero size or no offsetParent (covers display:none and detached subtrees)
4047
+ return el.offsetWidth === 0 && el.offsetHeight === 0;
4048
+ }
4049
+
4050
+ function serializeFindings(allFindings) {
4051
+ return allFindings.map(({ el, findings }) => ({
4052
+ selector: generateSelector(el),
4053
+ tagName: el.tagName?.toLowerCase() || 'unknown',
4054
+ rect: (el !== document.body && el !== document.documentElement && el.getBoundingClientRect)
4055
+ ? el.getBoundingClientRect().toJSON() : null,
4056
+ isPageLevel: el === document.body || el === document.documentElement,
4057
+ isHidden: isElementHidden(el),
4058
+ findings: findings.map(f => {
4059
+ const ap = ANTIPATTERNS.find(a => a.id === (f.type || f.id));
4060
+ return {
4061
+ type: f.type || f.id,
4062
+ category: ap ? ap.category : 'quality',
4063
+ severity: ap?.severity || 'warning',
4064
+ detail: f.detail || f.snippet,
4065
+ name: ap ? ap.name : (f.type || f.id),
4066
+ description: ap ? ap.description : '',
4067
+ };
4068
+ }),
4069
+ }));
4070
+ }
4071
+
4072
+ const printSummary = function(allFindings) {
4073
+ if (allFindings.length === 0) {
4074
+ console.log('%c[impeccable] No anti-patterns found.', 'color: #22c55e; font-weight: bold');
4075
+ return;
4076
+ }
4077
+ console.group(
4078
+ `%c[impeccable] ${allFindings.length} anti-pattern${allFindings.length === 1 ? '' : 's'} found`,
4079
+ 'color: oklch(84% 0.19 80.46); font-weight: bold'
4080
+ );
4081
+ for (const { el, findings } of allFindings) {
4082
+ for (const f of findings) {
4083
+ console.log(`%c${f.type || f.id}%c ${f.detail || f.snippet}`,
4084
+ 'color: oklch(84% 0.19 80.46); font-weight: bold', 'color: inherit', el);
4085
+ }
4086
+ }
4087
+ console.groupEnd();
4088
+ };
4089
+
4090
+ function addBrowserFindings(groupMap, el, findings) {
4091
+ if (!findings || findings.length === 0) return;
4092
+ const existing = groupMap.get(el);
4093
+ if (existing) existing.push(...findings);
4094
+ else groupMap.set(el, [...findings]);
4095
+ }
4096
+
4097
+ function browserFindingsFromMap(groupMap) {
4098
+ return [...groupMap.entries()].map(([el, findings]) => ({ el, findings }));
4099
+ }
4100
+
4101
+ function collectBrowserFindings() {
4102
+ const groupMap = new Map();
4103
+ const _disabled = EXTENSION_MODE ? (window.__IMPECCABLE_CONFIG__?.disabledRules || []) : [];
4104
+ const _ruleOk = (id) => !_disabled.length || !_disabled.includes(id);
4105
+ // Note: provider-gated rules (--gpt / --gemini) are NOT filtered here. In a
4106
+ // real browser env (detector page, live overlay, extension) running every
4107
+ // check is free, so we always surface them; the gating is purely a CLI
4108
+ // output concern, applied in the Node engines' detect* return paths.
4109
+
4110
+ for (const el of document.querySelectorAll('*')) {
4111
+ // Skip impeccable's own elements and any descendants (overlays, labels, banner, nav buttons)
4112
+ if (el.closest('.impeccable-overlay, .impeccable-label, .impeccable-banner, .impeccable-tooltip')) continue;
4113
+ // Skip browser extension elements (Claude, etc.)
4114
+ const elId = el.id || '';
4115
+ if (elId.startsWith('claude-') || elId.startsWith('cic-')) continue;
4116
+ // Skip the impeccable live-mode overlay (highlight, tooltip, bar, picker, toast).
4117
+ // These are inspector chrome, not part of the user's design.
4118
+ if (el.closest('[id^="impeccable-live-"]')) continue;
4119
+ // Skip html/body -- page-level findings go in the banner, not a full-page overlay
4120
+ if (el === document.body || el === document.documentElement) continue;
4121
+
4122
+ const findings = [
4123
+ ...checkElementBordersDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4124
+ ...checkElementColorsDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4125
+ ...checkElementMotionDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4126
+ ...checkElementGlowDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4127
+ ...checkElementAIPaletteDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4128
+ ...checkElementIconTileDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4129
+ ...checkElementItalicSerifDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4130
+ ...checkElementQualityDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4131
+ ...checkElementOversizedH1DOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4132
+ ...checkElementClippedOverflowDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4133
+ ...checkElementGptBorderShadowDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4134
+ ...checkElementTextOverflowDOM(el).map(f => ({ type: f.id, detail: f.snippet })),
4135
+ ].filter(f => _ruleOk(f.type));
4136
+
4137
+ addBrowserFindings(groupMap, el, findings);
4138
+
4139
+ // Hero eyebrow: the offending element is the eyebrow above the heading,
4140
+ // not the heading itself — highlight the previous sibling instead.
4141
+ const eyebrowFindings = checkElementHeroEyebrowDOM(el)
4142
+ .map(f => ({ type: f.id, detail: f.snippet }))
4143
+ .filter(f => _ruleOk(f.type));
4144
+ if (eyebrowFindings.length > 0 && el.previousElementSibling) {
4145
+ addBrowserFindings(groupMap, el.previousElementSibling, eyebrowFindings);
4146
+ }
4147
+ }
4148
+
4149
+ const pageLevelFindings = [];
4150
+
4151
+ const typoFindings = checkTypography().filter(f => _ruleOk(f.type));
4152
+ if (typoFindings.length > 0) {
4153
+ pageLevelFindings.push(...typoFindings);
4154
+ addBrowserFindings(groupMap, document.body, typoFindings);
4155
+ }
4156
+
4157
+ const sectionKickerFindings = checkRepeatedSectionKickersDOM()
4158
+ .map(f => ({ type: f.id, detail: f.snippet }))
4159
+ .filter(f => _ruleOk(f.type));
4160
+ if (sectionKickerFindings.length > 0) {
4161
+ pageLevelFindings.push(...sectionKickerFindings);
4162
+ addBrowserFindings(groupMap, document.body, sectionKickerFindings);
4163
+ }
4164
+
4165
+ const layoutFindings = checkLayout().filter(f => _ruleOk(f.type));
4166
+ for (const f of layoutFindings) {
4167
+ const el = f.el || document.body;
4168
+ addBrowserFindings(groupMap, el, [{ type: f.type, detail: f.detail || f.snippet }]);
4169
+ }
4170
+
4171
+ // Page-level quality checks (headings, etc.)
4172
+ const qualityFindings = checkPageQualityDOM().filter(f => _ruleOk(f.type));
4173
+ if (qualityFindings.length > 0) {
4174
+ pageLevelFindings.push(...qualityFindings);
4175
+ addBrowserFindings(groupMap, document.body, qualityFindings);
4176
+ }
4177
+
4178
+ const creamFindings = checkCreamPalette(document)
4179
+ .map(f => ({ type: f.id, detail: f.snippet }))
4180
+ .filter(f => _ruleOk(f.type));
4181
+ if (creamFindings.length > 0) {
4182
+ pageLevelFindings.push(...creamFindings);
4183
+ addBrowserFindings(groupMap, document.body, creamFindings);
4184
+ }
4185
+
4186
+ // Regex-on-HTML checks (shared with Node)
4187
+ // Clone the document and strip impeccable-live overlay nodes before the
4188
+ // regex scan, so the inspector's own inline styles (transitions on top/
4189
+ // left/width/height, etc.) don't register as page anti-patterns.
4190
+ const docClone = document.documentElement.cloneNode(true);
4191
+ for (const node of docClone.querySelectorAll('[id^="impeccable-live-"]')) {
4192
+ node.remove();
4193
+ }
4194
+ const htmlPatternFindings = checkHtmlPatterns(docClone.outerHTML);
4195
+ if (htmlPatternFindings.length > 0) {
4196
+ const mapped = htmlPatternFindings.map(f => ({ type: f.id, detail: f.snippet })).filter(f => _ruleOk(f.type));
4197
+ pageLevelFindings.push(...mapped);
4198
+ addBrowserFindings(groupMap, document.body, mapped);
4199
+ }
4200
+
4201
+ return {
4202
+ groupMap,
4203
+ allFindings: browserFindingsFromMap(groupMap),
4204
+ pageLevelFindings,
4205
+ };
4206
+ }
4207
+
4208
+ function shouldRunVisualContrast(options = {}) {
4209
+ return options.visualContrast === true || window.__IMPECCABLE_CONFIG__?.visualContrast === true;
4210
+ }
4211
+
4212
+ function visualContrastOptions(options = {}) {
4213
+ const config = window.__IMPECCABLE_CONFIG__ || {};
4214
+ const scrollOffscreen = typeof options.scrollOffscreen === 'boolean'
4215
+ ? options.scrollOffscreen
4216
+ : typeof options.visualContrastScrollOffscreen === 'boolean'
4217
+ ? options.visualContrastScrollOffscreen
4218
+ : typeof config.visualContrastScrollOffscreen === 'boolean'
4219
+ ? config.visualContrastScrollOffscreen
4220
+ : false;
4221
+ return {
4222
+ ...options,
4223
+ maxCandidates: Number.isFinite(options.visualContrastMaxCandidates)
4224
+ ? options.visualContrastMaxCandidates
4225
+ : Number.isFinite(options.maxCandidates)
4226
+ ? options.maxCandidates
4227
+ : Number.isFinite(config.visualContrastMaxCandidates)
4228
+ ? config.visualContrastMaxCandidates
4229
+ : undefined,
4230
+ scrollOffscreen,
4231
+ };
4232
+ }
4233
+
4234
+ let lastVisualContrastAnalyses = [];
4235
+ let lazyVisualContrastObserver = null;
4236
+ let lazyVisualContrastPending = new WeakMap();
4237
+ const lazyVisualContrastResolving = new WeakSet();
4238
+ let scanGeneration = 0;
4239
+
4240
+ function rememberVisualContrastAnalysis(result) {
4241
+ if (!result?.selector) {
4242
+ lastVisualContrastAnalyses.push(result);
4243
+ return;
4244
+ }
4245
+ const idx = lastVisualContrastAnalyses.findIndex(item => item.selector === result.selector);
4246
+ if (idx >= 0) lastVisualContrastAnalyses[idx] = result;
4247
+ else lastVisualContrastAnalyses.push(result);
4248
+ }
4249
+
4250
+ function disconnectLazyVisualContrastObserver() {
4251
+ if (lazyVisualContrastObserver) {
4252
+ lazyVisualContrastObserver.disconnect();
4253
+ lazyVisualContrastObserver = null;
4254
+ }
4255
+ lazyVisualContrastPending = new WeakMap();
4256
+ }
4257
+
4258
+ function addVisualContrastResult(groupMap, result, options = {}) {
4259
+ if (result.status !== 'fail' || !result.finding || !result.selector) return false;
4260
+ let el = null;
4261
+ try {
4262
+ el = document.querySelector(result.selector);
4263
+ } catch {
4264
+ el = null;
4265
+ }
4266
+ if (!el) return false;
4267
+ const findingType = result.finding.type || result.finding.id || 'low-contrast';
4268
+ const existing = groupMap.get(el) || [];
4269
+ if (existing.some(f => (f.type || f.id) === findingType)) return false;
4270
+ addBrowserFindings(groupMap, el, [{
4271
+ type: findingType,
4272
+ detail: result.finding.detail || result.finding.snippet,
4273
+ }]);
4274
+ if (options.decorate && el !== document.body && el !== document.documentElement) {
4275
+ highlight(el, groupMap.get(el) || []);
4276
+ }
4277
+ return true;
4278
+ }
4279
+
4280
+ function postSerializedFindings(groupMap) {
4281
+ if (!EXTENSION_MODE) return;
4282
+ const allFindings = browserFindingsFromMap(groupMap);
4283
+ window.postMessage({
4284
+ source: 'impeccable-results',
4285
+ findings: serializeFindings(allFindings),
4286
+ count: allFindings.length,
4287
+ }, '*');
4288
+ }
4289
+
4290
+ function postExtensionError(err) {
4291
+ if (!EXTENSION_MODE) return;
4292
+ window.postMessage({
4293
+ source: 'impeccable-error',
4294
+ message: err?.message || String(err),
4295
+ }, '*');
4296
+ }
4297
+
4298
+ function reportVisualContrastError(err, detail = {}) {
4299
+ window.dispatchEvent(new CustomEvent('impeccable-visual-contrast-error', {
4300
+ detail: {
4301
+ ...detail,
4302
+ message: err?.message || String(err),
4303
+ },
4304
+ }));
4305
+ if (EXTENSION_MODE) {
4306
+ postExtensionError(err);
4307
+ } else {
4308
+ console.warn('[impeccable] visual contrast scan failed', err);
4309
+ }
4310
+ }
4311
+
4312
+ function scheduleLazyVisualContrast(groupMap, analyses, options = {}, runtime = {}) {
4313
+ disconnectLazyVisualContrastObserver();
4314
+ if (options.visualContrastLazy === false || options.scrollOffscreen !== false) return;
4315
+ if (typeof IntersectionObserver === 'undefined') return;
4316
+ const unresolved = (analyses || []).filter(result =>
4317
+ result?.status === 'unresolved' &&
4318
+ result.reason === 'text outside viewport' &&
4319
+ result.selector
4320
+ );
4321
+ if (unresolved.length === 0) return;
4322
+ const generation = runtime.generation || scanGeneration;
4323
+
4324
+ lazyVisualContrastObserver = new IntersectionObserver((entries) => {
4325
+ for (const entry of entries) {
4326
+ if (!entry.isIntersecting) continue;
4327
+ const el = entry.target;
4328
+ const candidate = lazyVisualContrastPending.get(el);
4329
+ if (!candidate || lazyVisualContrastResolving.has(el)) continue;
4330
+ lazyVisualContrastObserver?.unobserve(el);
4331
+ lazyVisualContrastPending.delete(el);
4332
+ lazyVisualContrastResolving.add(el);
4333
+ waitForVisualPaint()
4334
+ .then(() => analyzeVisualContrastCandidate(candidate))
4335
+ .then(result => {
4336
+ if (generation !== scanGeneration) return;
4337
+ rememberVisualContrastAnalysis(result);
4338
+ const added = addVisualContrastResult(groupMap, result, { decorate: true });
4339
+ if (added) {
4340
+ postSerializedFindings(groupMap);
4341
+ window.dispatchEvent(new CustomEvent('impeccable-visual-contrast-resolved', {
4342
+ detail: {
4343
+ selector: result.selector,
4344
+ status: result.status,
4345
+ finding: result.finding || null,
4346
+ },
4347
+ }));
4348
+ }
4349
+ })
4350
+ .catch(err => {
4351
+ reportVisualContrastError(err, { selector: candidate.selector });
4352
+ })
4353
+ .finally(() => {
4354
+ lazyVisualContrastResolving.delete(el);
4355
+ });
4356
+ }
4357
+ }, { threshold: 0.5 });
4358
+
4359
+ for (const candidate of unresolved) {
4360
+ let el = null;
4361
+ try {
4362
+ el = document.querySelector(candidate.selector);
4363
+ } catch {
4364
+ el = null;
4365
+ }
4366
+ if (!el) continue;
4367
+ lazyVisualContrastPending.set(el, candidate);
4368
+ lazyVisualContrastObserver.observe(el);
4369
+ }
4370
+ }
4371
+
4372
+ async function addVisualContrastFindings(groupMap, options = {}, runtime = {}) {
4373
+ if (!shouldRunVisualContrast(options)) {
4374
+ lastVisualContrastAnalyses = [];
4375
+ disconnectLazyVisualContrastObserver();
4376
+ return [];
4377
+ }
4378
+ const resolvedOptions = visualContrastOptions(options);
4379
+ const analyses = await analyzeVisualContrast(resolvedOptions);
4380
+ if (runtime.generation && runtime.generation !== scanGeneration) return analyses;
4381
+ lastVisualContrastAnalyses = analyses;
4382
+ for (const result of analyses) {
4383
+ addVisualContrastResult(groupMap, result, { decorate: runtime.decorate });
4384
+ }
4385
+ if (runtime.decorate || runtime.scheduleLazy) scheduleLazyVisualContrast(groupMap, analyses, resolvedOptions, runtime);
4386
+ return analyses;
4387
+ }
4388
+
4389
+ async function collectBrowserFindingsAsync(options = {}, runtime = {}) {
4390
+ const collected = collectBrowserFindings();
4391
+ await addVisualContrastFindings(collected.groupMap, options, runtime);
4392
+ return {
4393
+ ...collected,
4394
+ allFindings: browserFindingsFromMap(collected.groupMap),
4395
+ visualContrastAnalyses: lastVisualContrastAnalyses,
4396
+ };
4397
+ }
4398
+
4399
+ function clearOverlays() {
4400
+ scanGeneration += 1;
4401
+ disconnectLazyVisualContrastObserver();
4402
+ for (const o of [...overlays]) detachOverlay(o);
4403
+ overlays.length = 0;
4404
+ visibilityObserver.disconnect();
4405
+ overlayIndex = 0;
4406
+ }
4407
+
4408
+ function renderBrowserFindings(collected) {
4409
+ const { allFindings, pageLevelFindings } = collected;
4410
+
4411
+ for (const { el, findings } of allFindings) {
4412
+ if (el === document.body || el === document.documentElement) continue;
4413
+ highlight(el, findings);
4414
+ }
4415
+
4416
+ if (pageLevelFindings.length > 0) {
4417
+ showPageBanner(pageLevelFindings);
4418
+ }
4419
+
4420
+ if (!EXTENSION_MODE) printSummary(allFindings);
4421
+
4422
+ // In extension mode, post serialized results for the DevTools panel
4423
+ if (EXTENSION_MODE) {
4424
+ window.postMessage({
4425
+ source: 'impeccable-results',
4426
+ findings: serializeFindings(allFindings),
4427
+ count: allFindings.length,
4428
+ }, '*');
4429
+ }
4430
+
4431
+ // After this scan completes, all subsequent reveals are instant (no stagger, no animation)
4432
+ setTimeout(() => { firstScanDone = true; }, 1000);
4433
+
4434
+ return allFindings;
4435
+ }
4436
+
4437
+ let firstScanDone = false;
4438
+ const scan = function(options = {}) {
4439
+ clearOverlays();
4440
+ const generation = scanGeneration;
4441
+ const collected = collectBrowserFindings();
4442
+ const allFindings = renderBrowserFindings(collected);
4443
+ if (shouldRunVisualContrast(options)) {
4444
+ addVisualContrastFindings(collected.groupMap, options, { decorate: true, generation })
4445
+ .then(() => {
4446
+ if (generation === scanGeneration) postSerializedFindings(collected.groupMap);
4447
+ })
4448
+ .catch(err => {
4449
+ reportVisualContrastError(err);
4450
+ });
4451
+ }
4452
+ return allFindings;
4453
+ };
4454
+
4455
+ const scanAsync = async function(options = {}) {
4456
+ clearOverlays();
4457
+ const generation = scanGeneration;
4458
+ if (shouldRunVisualContrast(options)) {
4459
+ const collected = await collectBrowserFindingsAsync(options, { generation, scheduleLazy: true });
4460
+ if (generation !== scanGeneration) return [];
4461
+ return renderBrowserFindings(collected);
4462
+ }
4463
+ lastVisualContrastAnalyses = [];
4464
+ return renderBrowserFindings(collectBrowserFindings());
4465
+ };
4466
+
4467
+ const detect = function(options = {}) {
4468
+ lastVisualContrastAnalyses = [];
4469
+ const { allFindings } = collectBrowserFindings();
4470
+ return options.serialize === false ? allFindings : serializeFindings(allFindings);
4471
+ };
4472
+
4473
+ const detectAsync = async function(options = {}) {
4474
+ if (shouldRunVisualContrast(options)) {
4475
+ const { allFindings } = await collectBrowserFindingsAsync(options);
4476
+ return options.serialize === false ? allFindings : serializeFindings(allFindings);
4477
+ }
4478
+ lastVisualContrastAnalyses = [];
4479
+ const { allFindings } = collectBrowserFindings();
4480
+ return options.serialize === false ? allFindings : serializeFindings(allFindings);
4481
+ };
4482
+
4483
+ if (EXTENSION_MODE) {
4484
+ // Extension mode: listen for commands, don't auto-scan
4485
+ window.addEventListener('message', (e) => {
4486
+ if (e.source !== window || !e.data || e.data.source !== 'impeccable-command') return;
4487
+ if (e.data.action === 'scan') {
4488
+ if (e.data.config) window.__IMPECCABLE_CONFIG__ = e.data.config;
4489
+ try {
4490
+ scan(e.data.config || {});
4491
+ } catch (err) {
4492
+ postExtensionError(err);
4493
+ }
4494
+ }
4495
+ if (e.data.action === 'toggle-overlays') {
4496
+ const visible = !document.body.classList.contains('impeccable-hidden');
4497
+ document.body.classList.toggle('impeccable-hidden', visible);
4498
+ window.postMessage({ source: 'impeccable-overlays-toggled', visible: !visible }, '*');
4499
+ }
4500
+ if (e.data.action === 'remove') {
4501
+ clearOverlays();
4502
+ styleEl.remove();
4503
+ if (spotlightBackdrop) { spotlightBackdrop.remove(); spotlightBackdrop = null; }
4504
+ document.body.classList.remove('impeccable-hidden');
4505
+ }
4506
+ if (e.data.action === 'highlight') {
4507
+ try {
4508
+ const target = e.data.selector ? document.querySelector(e.data.selector) : null;
4509
+ if (target) {
4510
+ // Scroll first so positionOverlay reads the post-scroll rect
4511
+ if (!isInViewport(target) && target.scrollIntoView) {
4512
+ target.scrollIntoView({ behavior: 'instant', block: 'center' });
4513
+ }
4514
+ for (const o of overlays) {
4515
+ if (o.classList.contains('impeccable-banner')) continue;
4516
+ const isMatch = o._targetEl === target;
4517
+ o.classList.toggle('impeccable-spotlight', isMatch);
4518
+ o.classList.toggle('impeccable-spotlight-dimmed', !isMatch);
4519
+ if (isMatch) {
4520
+ // Force the matching overlay visible immediately, don't wait for IntersectionObserver
4521
+ o.style.display = '';
4522
+ o.style.animation = 'none';
4523
+ o.classList.add('impeccable-visible');
4524
+ o._revealed = true;
4525
+ positionOverlay(o);
4526
+ }
4527
+ }
4528
+ showSpotlight(target);
4529
+ }
4530
+ } catch { /* invalid selector */ }
4531
+ }
4532
+ if (e.data.action === 'unhighlight') {
4533
+ hideSpotlight();
4534
+ for (const o of overlays) {
4535
+ o.classList.remove('impeccable-spotlight');
4536
+ o.classList.remove('impeccable-spotlight-dimmed');
4537
+ }
4538
+ }
4539
+ });
4540
+ window.postMessage({ source: 'impeccable-ready' }, '*');
4541
+ } else {
4542
+ if (window.__IMPECCABLE_CONFIG__?.autoScan !== false) {
4543
+ const runAutoScan = () => {
4544
+ try {
4545
+ scan();
4546
+ } catch (err) {
4547
+ console.warn('[impeccable] scan failed', err);
4548
+ }
4549
+ };
4550
+ if (document.readyState === 'loading') {
4551
+ document.addEventListener('DOMContentLoaded', () => setTimeout(runAutoScan, 100));
4552
+ } else {
4553
+ setTimeout(runAutoScan, 100);
4554
+ }
4555
+ }
4556
+ }
4557
+
4558
+ window.impeccableDetect = detect;
4559
+ window.impeccableDetectAsync = detectAsync;
4560
+ window.impeccableScan = scan;
4561
+ window.impeccableScanAsync = scanAsync;
4562
+ window.impeccableCollectVisualContrastCandidates = collectVisualContrastCandidates;
4563
+ window.impeccableAnalyzeVisualContrast = analyzeVisualContrast;
4564
+ window.impeccableGetLastVisualContrastAnalyses = () => lastVisualContrastAnalyses.slice();
4565
+ }
4566
+
4567
+ })();