@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69

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 (426) hide show
  1. package/README.md +64 -63
  2. package/api/build/_adapter.d.mts +51 -0
  3. package/api/build/_adapter.mjs +122 -6
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.mjs +23 -14
  6. package/api/build/build.type.d.mts +1 -1
  7. package/api/build/build.type.mjs +3 -3
  8. package/api/build/help/help.d.mts +15 -14
  9. package/api/build/help/help.mjs +62 -3
  10. package/api/build/kit/answer.mjs +2 -3
  11. package/api/build/kit/signals.d.mts +10 -0
  12. package/api/build/kit/signals.mjs +15 -2
  13. package/api/component/detail/blocks/blocks.mjs +2 -1
  14. package/api/discover/_adapter.d.mts +57 -6
  15. package/api/discover/_adapter.mjs +278 -49
  16. package/api/discover/_catalog-view.d.mts +7 -0
  17. package/api/discover/_catalog-view.mjs +10 -1
  18. package/api/discover/detail/detail.d.mts +3 -2
  19. package/api/discover/detail/detail.mjs +3 -2
  20. package/api/discover/detail/doc/doc.mjs +1 -1
  21. package/api/discover/discover.d.mts +24 -0
  22. package/api/discover/discover.doc.mjs +1 -1
  23. package/api/discover/discover.mjs +146 -25
  24. package/api/discover/discover.type.d.mts +6 -4
  25. package/api/discover/discover.type.mjs +6 -4
  26. package/api/discover/search/search.d.mts +22 -0
  27. package/api/discover/search/search.mjs +290 -70
  28. package/api/docs/_entry-names.mjs +4 -3
  29. package/api/doctor/_adapter.d.mts +43 -3
  30. package/api/doctor/_adapter.mjs +142 -18
  31. package/api/doctor/built-checks.d.mts +30 -3
  32. package/api/doctor/built-checks.mjs +132 -5
  33. package/api/doctor/doctor.d.mts +93 -6
  34. package/api/doctor/doctor.doc.mjs +2 -2
  35. package/api/doctor/doctor.mjs +524 -33
  36. package/api/doctor/doctor.type.d.mts +2 -1
  37. package/api/doctor/doctor.type.mjs +2 -1
  38. package/api/doctor/theme-checks.d.mts +19 -0
  39. package/api/doctor/theme-checks.mjs +74 -6
  40. package/api/hook/hook.type.d.mts +1 -1
  41. package/api/hook/hook.type.mjs +1 -1
  42. package/api/hook/list/list.mjs +11 -7
  43. package/api/icon/_adapter.d.mts +2 -1
  44. package/api/icon/_adapter.mjs +10 -15
  45. package/api/icon/_records.d.mts +3 -1
  46. package/api/icon/_records.mjs +30 -3
  47. package/api/icon/exportIconIndex.doc.mjs +1 -1
  48. package/api/icon/icon.doc.mjs +3 -3
  49. package/api/icon/icon.type.d.mts +32 -1
  50. package/api/icon/icon.type.mjs +19 -3
  51. package/api/icon/list/list.mjs +4 -1
  52. package/api/icon/rankIconIndex.doc.mjs +1 -1
  53. package/api/icon/search/icon-index.mjs +18 -8
  54. package/api/icon/search/search.d.mts +26 -3
  55. package/api/icon/search/search.mjs +155 -9
  56. package/api/init/_adapter.d.mts +14 -0
  57. package/api/init/_adapter.mjs +26 -4
  58. package/api/init/init.d.mts +1 -1
  59. package/api/init/init.doc.mjs +2 -2
  60. package/api/init/init.mjs +1 -1
  61. package/api/init/init.type.d.mts +29 -1
  62. package/api/init/init.type.mjs +14 -1
  63. package/api/init/run/run.d.mts +11 -1
  64. package/api/init/run/run.mjs +84 -5
  65. package/api/integration/_adapter.d.mts +5 -4
  66. package/api/integration/_adapter.mjs +7 -5
  67. package/api/integration/integrationCheck.doc.mjs +1 -1
  68. package/api/integration/pack-check.mjs +8 -9
  69. package/api/integration/validate-integration.d.mts +1 -1
  70. package/api/integration/validate-integration.mjs +26 -24
  71. package/api/integration/validate-integration.type.d.mts +5 -2
  72. package/api/integration/validate-integration.type.mjs +5 -2
  73. package/api/integration/validateIntegration.doc.mjs +1 -1
  74. package/api/render/_adapter.d.mts +4 -2
  75. package/api/render/_adapter.mjs +62 -21
  76. package/api/render/render.doc.mjs +8 -5
  77. package/api/render/render.mjs +1 -1
  78. package/api/render/render.type.d.mts +2 -0
  79. package/api/render/render.type.mjs +2 -0
  80. package/api/search/ORDERING.md +2 -2
  81. package/api/search/_candidate-score.d.mts +3 -0
  82. package/api/search/_candidate-score.mjs +36 -3
  83. package/api/search/_gather-docs.mjs +29 -2
  84. package/api/search/_gather-templates.mjs +2 -1
  85. package/api/search/_main-searcher.mjs +13 -0
  86. package/api/search/_named-keywords.d.mts +2 -1
  87. package/api/search/_named-keywords.mjs +48 -6
  88. package/api/search/_order.d.mts +36 -1
  89. package/api/search/_order.mjs +141 -3
  90. package/api/swizzle/list/list.mjs +8 -1
  91. package/api/swizzle/swizzle.type.d.mts +1 -1
  92. package/api/swizzle/swizzle.type.mjs +1 -1
  93. package/api/template/copy/copy.mjs +3 -4
  94. package/api/template/list/list.mjs +2 -1
  95. package/api/template/show/show.mjs +2 -1
  96. package/api/template/skeleton/skeleton.mjs +2 -1
  97. package/api/template/template.doc.mjs +1 -1
  98. package/api/template/template.mjs +19 -1
  99. package/api/template/template.type.d.mts +1 -0
  100. package/api/template/template.type.mjs +2 -1
  101. package/api/theme/_adapter.d.mts +1 -0
  102. package/api/theme/_adapter.mjs +3 -5
  103. package/api/theme/_app-provider.d.mts +42 -0
  104. package/api/theme/_app-provider.mjs +61 -27
  105. package/api/theme/build/build.d.mts +4 -10
  106. package/api/theme/build/build.mjs +165 -116
  107. package/api/theme/build/input-fields.d.mts +9 -0
  108. package/api/theme/build/input-fields.mjs +155 -16
  109. package/api/theme/build/radius-values.d.mts +18 -0
  110. package/api/theme/build/radius-values.mjs +76 -0
  111. package/api/theme/build/typography-values.mjs +7 -23
  112. package/api/theme/build/written-values.d.mts +18 -0
  113. package/api/theme/build/written-values.mjs +107 -31
  114. package/api/theme/eject/eject.mjs +6 -1
  115. package/api/theme/palette/generate/generator.mjs +24 -0
  116. package/api/theme/theme.type.d.mts +4 -2
  117. package/api/theme/theme.type.mjs +3 -2
  118. package/api/theme/themeBuild.doc.mjs +2 -2
  119. package/api/theme/themeEject.doc.mjs +1 -1
  120. package/api/theme-edit/_catalog.d.mts +40 -0
  121. package/api/theme-edit/_catalog.mjs +100 -22
  122. package/api/theme-edit/_check.mjs +213 -43
  123. package/api/theme-edit/_color.d.mts +14 -0
  124. package/api/theme-edit/_color.mjs +22 -0
  125. package/api/theme-edit/_compiler.mjs +52 -0
  126. package/api/theme-edit/_context.d.mts +20 -2
  127. package/api/theme-edit/_context.mjs +157 -29
  128. package/api/theme-edit/_edit.mjs +426 -58
  129. package/api/theme-edit/_how-question.d.mts +14 -0
  130. package/api/theme-edit/_how-question.mjs +1541 -127
  131. package/api/theme-edit/_how.mjs +43 -0
  132. package/api/theme-edit/_missed.mjs +107 -27
  133. package/api/theme-edit/_normal.d.mts +18 -4
  134. package/api/theme-edit/_normal.mjs +84 -3
  135. package/api/theme-edit/_palette.d.mts +9 -0
  136. package/api/theme-edit/_palette.mjs +158 -33
  137. package/api/theme-edit/_part-words.mjs +16 -3
  138. package/api/theme-edit/_parts.d.mts +8 -0
  139. package/api/theme-edit/_parts.mjs +120 -36
  140. package/api/theme-edit/_png.d.mts +24 -0
  141. package/api/theme-edit/_png.mjs +99 -0
  142. package/api/theme-edit/_preview-app.d.mts +16 -0
  143. package/api/theme-edit/_preview-app.mjs +52 -18
  144. package/api/theme-edit/_preview.d.mts +44 -26
  145. package/api/theme-edit/_preview.mjs +255 -67
  146. package/api/theme-edit/_project.d.mts +12 -1
  147. package/api/theme-edit/_project.mjs +16 -1
  148. package/api/theme-edit/_settings.d.mts +116 -0
  149. package/api/theme-edit/_settings.mjs +1197 -58
  150. package/api/theme-edit/_tables.d.mts +16 -0
  151. package/api/theme-edit/_tables.mjs +34 -4
  152. package/api/theme-edit/theme-edit.type.d.mts +15 -2
  153. package/api/theme-edit/theme-edit.type.mjs +8 -6
  154. package/api/upgrade/_adapter.d.mts +46 -7
  155. package/api/upgrade/_adapter.mjs +110 -15
  156. package/api/upgrade/registry/registry.d.mts +6 -3
  157. package/api/upgrade/registry/registry.mjs +21 -6
  158. package/api/upgrade/run/run.mjs +23 -11
  159. package/api/upgrade/upgrade.doc.mjs +4 -3
  160. package/assets/component-list.generated.json +1 -1
  161. package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
  162. package/assets/docs/tree/checks.doc.mjs +2 -2
  163. package/assets/docs/tree/host-entry.doc.mjs +4 -0
  164. package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
  165. package/assets/docs/tree/icon-sets.doc.mjs +6 -6
  166. package/assets/docs/tree/problems.doc.mjs +3 -3
  167. package/assets/docs/tree/render-pages.doc.mjs +17 -3
  168. package/assets/docs/tree/share-a-page.doc.mjs +5 -5
  169. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  170. package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
  171. package/assets/docs/tree/updates.doc.mjs +1 -1
  172. package/assets/docs/tree/versioning.doc.mjs +1 -1
  173. package/assets/docs/working-with-ai.doc.mjs +40 -5
  174. package/assets/docs-routes.generated.json +1 -1
  175. package/assets/docs.generated.json +2 -2
  176. package/assets/icons/installed-icon-set.doc.mjs +30 -0
  177. package/assets/search-catalog.generated.json +2 -2
  178. package/assets/self-audit.generated.json +1 -1
  179. package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
  180. package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
  181. package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
  182. package/assets/templates/components.generated.json +1 -1
  183. package/assets/templates/pages/ai-chat/page.tsx +6 -2
  184. package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
  185. package/assets/templates/pages/blank/page.tsx +4 -2
  186. package/assets/templates/pages/canvas-editor/page.tsx +3 -1
  187. package/assets/templates/pages/centered-hero/page.tsx +1 -1
  188. package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
  189. package/assets/templates/pages/classic-gallery/page.tsx +1 -1
  190. package/assets/templates/pages/contact-form/page.tsx +2 -2
  191. package/assets/templates/pages/course-detail/page.tsx +1 -1
  192. package/assets/templates/pages/dashboard/page.tsx +24 -8
  193. package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
  194. package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
  195. package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
  196. package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
  197. package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
  198. package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
  199. package/assets/templates/pages/detail-page/page.tsx +22 -5
  200. package/assets/templates/pages/documentation/page.tsx +4 -2
  201. package/assets/templates/pages/documentation-design/page.tsx +5 -2
  202. package/assets/templates/pages/documentation-technical/page.tsx +4 -2
  203. package/assets/templates/pages/editor/page.tsx +28 -9
  204. package/assets/templates/pages/file-explorer/page.tsx +3 -1
  205. package/assets/templates/pages/form-two-column/page.tsx +1 -1
  206. package/assets/templates/pages/form-wizard/page.tsx +1 -1
  207. package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
  208. package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
  209. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  210. package/assets/templates/pages/gallery-hero/page.tsx +1 -1
  211. package/assets/templates/pages/ide/page.tsx +7 -2
  212. package/assets/templates/pages/kanban-board/page.tsx +10 -4
  213. package/assets/templates/pages/library/page.tsx +31 -61
  214. package/assets/templates/pages/login/page.tsx +4 -2
  215. package/assets/templates/pages/login-card/page.tsx +4 -2
  216. package/assets/templates/pages/login-split/page.tsx +3 -2
  217. package/assets/templates/pages/login-sso/page.tsx +4 -4
  218. package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
  219. package/assets/templates/pages/payment-form/page.tsx +1 -1
  220. package/assets/templates/pages/product-detail/page.tsx +16 -4
  221. package/assets/templates/pages/product-gallery/page.tsx +1 -1
  222. package/assets/templates/pages/settings/page.tsx +10 -4
  223. package/assets/templates/pages/settings-dialog/page.tsx +5 -6
  224. package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
  225. package/assets/templates/pages/side-gallery/page.tsx +1 -1
  226. package/assets/templates/pages/table/page.tsx +2 -2
  227. package/assets/templates/pages/table-filter/page.tsx +21 -6
  228. package/assets/templates/pages/table-grouped/page.tsx +23 -2
  229. package/assets/templates/pages/table-inbox/page.tsx +82 -32
  230. package/assets/templates/pages/theme-showcase/page.tsx +3 -2
  231. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
  232. package/assets/templates/themes/butter/butterTheme.ts +197 -4
  233. package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
  234. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
  235. package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
  236. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
  237. package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
  238. package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
  239. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
  240. package/assets/templates/themes/stone/stoneTheme.ts +69 -0
  241. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
  242. package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
  243. package/authoring/codemod/parse.d.mts +0 -36
  244. package/authoring/codemod/parse.mjs +62 -41
  245. package/authoring/config/config.doc.mjs +1 -1
  246. package/authoring/config/parse.d.mts +0 -47
  247. package/authoring/config/parse.mjs +128 -103
  248. package/authoring/config/type.ts +4 -3
  249. package/authoring/debug/parse.d.mts +2 -2
  250. package/authoring/discover/parse.d.mts +2 -2
  251. package/authoring/discover/parse.mjs +52 -38
  252. package/authoring/discover/type.ts +2 -1
  253. package/authoring/doctypes/_schema.d.mts +834 -950
  254. package/authoring/doctypes/_schema.mjs +863 -825
  255. package/authoring/doctypes/command/parse.mjs +2 -2
  256. package/authoring/doctypes/component/parse.mjs +2 -2
  257. package/authoring/doctypes/enum/parse.mjs +2 -2
  258. package/authoring/doctypes/hook/parse.mjs +2 -2
  259. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
  260. package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
  261. package/authoring/doctypes/icon-definition/parse.mjs +59 -43
  262. package/authoring/doctypes/icon-set/parse.d.mts +0 -75
  263. package/authoring/doctypes/icon-set/parse.mjs +239 -210
  264. package/authoring/doctypes/legacy.mjs +3 -3
  265. package/authoring/doctypes/namespace/parse.mjs +2 -2
  266. package/authoring/doctypes/reference/parse.mjs +2 -2
  267. package/authoring/doctypes/schema/parse.mjs +2 -2
  268. package/authoring/doctypes/template/parse.d.mts +0 -101
  269. package/authoring/doctypes/template/parse.mjs +131 -106
  270. package/authoring/doctypes/theme/parse.d.mts +0 -23
  271. package/authoring/doctypes/theme/parse.mjs +52 -36
  272. package/authoring/gap-report/parse.d.mts +1 -1
  273. package/authoring/integration/integration.doc.mjs +8 -0
  274. package/authoring/integration/schema.d.mts +14 -3
  275. package/authoring/integration/schema.mjs +20 -2
  276. package/authoring/integration/type.ts +14 -0
  277. package/clients/cli/build-id.generated.json +1 -1
  278. package/clients/cli/commands/build.mjs +27 -13
  279. package/clients/cli/commands/component.mjs +14 -3
  280. package/clients/cli/commands/discover.doc.mjs +2 -2
  281. package/clients/cli/commands/discover.mjs +20 -3
  282. package/clients/cli/commands/docs.doc.mjs +11 -9
  283. package/clients/cli/commands/docs.mjs +50 -21
  284. package/clients/cli/commands/experimental/icon.mjs +330 -227
  285. package/clients/cli/commands/experimental/render.mjs +16 -1
  286. package/clients/cli/commands/experimental/theme.mjs +42 -17
  287. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  288. package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
  289. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
  290. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
  291. package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
  292. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  293. package/clients/cli/commands/experimental-render.doc.mjs +3 -3
  294. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  295. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  296. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  297. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  298. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  299. package/clients/cli/commands/init.doc.mjs +36 -24
  300. package/clients/cli/commands/integration-check.doc.mjs +1 -1
  301. package/clients/cli/commands/mcp.doc.mjs +53 -0
  302. package/clients/cli/commands/mcp.mjs +51 -0
  303. package/clients/cli/commands/search.mjs +46 -9
  304. package/clients/cli/commands/template.mjs +3 -2
  305. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  306. package/clients/cli/commands/theme.mjs +12 -2
  307. package/clients/cli/commands/upgrade.doc.mjs +3 -2
  308. package/clients/cli/commands.generated.json +1 -1
  309. package/clients/cli/formatters/index.mjs +52 -6
  310. package/clients/cli/index.mjs +23 -17
  311. package/clients/cli/lib/base-gate.mjs +37 -5
  312. package/clients/cli/lib/define-command.mjs +82 -4
  313. package/clients/cli/lib/json-shim.mjs +61 -4
  314. package/clients/cli/lib/manifest.mjs +9 -1
  315. package/clients/cli/lib/mcp-server.mjs +286 -0
  316. package/clients/cli/lib/mcp-tools.mjs +405 -0
  317. package/clients/cli/lib/other-cli-words.mjs +99 -0
  318. package/clients/cli/lib/stray-option.mjs +27 -1
  319. package/clients/cli/lib/unknown-command.mjs +326 -11
  320. package/clients/cli/manifest.generated.json +1 -1
  321. package/clients/cli/run.mjs +1 -1
  322. package/foundation/agent-docs/agent-docs.d.mts +49 -1
  323. package/foundation/agent-docs/agent-docs.mjs +108 -7
  324. package/foundation/agent-docs/computer-agent-text.mjs +1 -1
  325. package/foundation/bases/core.d.mts +1 -1
  326. package/foundation/bases/core.mjs +3 -3
  327. package/foundation/bases/resolve.d.mts +4 -8
  328. package/foundation/bases/resolve.mjs +15 -21
  329. package/foundation/bases/state.d.mts +15 -9
  330. package/foundation/bases/state.mjs +33 -6
  331. package/foundation/config/project.d.mts +5 -4
  332. package/foundation/config/project.mjs +33 -17
  333. package/foundation/discovery/component-discovery.mjs +15 -28
  334. package/foundation/discovery/icon-imports.d.mts +66 -0
  335. package/foundation/discovery/icon-imports.mjs +225 -0
  336. package/foundation/discovery/icon-ranking.d.mts +12 -2
  337. package/foundation/discovery/icon-ranking.mjs +197 -10
  338. package/foundation/discovery/icon-set-checks.mjs +2 -1
  339. package/foundation/discovery/icon-set-discovery.d.mts +28 -0
  340. package/foundation/discovery/icon-set-discovery.mjs +42 -0
  341. package/foundation/discovery/icon-set-writer.d.mts +2 -11
  342. package/foundation/discovery/icon-set-writer.mjs +3 -29
  343. package/foundation/discovery/module-exports.d.mts +1 -1
  344. package/foundation/discovery/module-exports.mjs +136 -33
  345. package/foundation/discovery/name-roots.d.mts +5 -0
  346. package/foundation/discovery/name-roots.mjs +11 -0
  347. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  348. package/foundation/discovery/runner-allowlist.mjs +2 -0
  349. package/foundation/discovery/runner-commands.mjs +1 -0
  350. package/foundation/discovery/template-adapter.d.mts +1 -1
  351. package/foundation/discovery/template-destination.d.mts +14 -6
  352. package/foundation/discovery/template-destination.mjs +42 -8
  353. package/foundation/discovery/template-icons.d.mts +45 -2
  354. package/foundation/discovery/template-icons.mjs +26 -54
  355. package/foundation/discovery/template-needs.d.mts +28 -2
  356. package/foundation/discovery/template-needs.mjs +92 -11
  357. package/foundation/discovery/theme-discovery.d.mts +8 -0
  358. package/foundation/discovery/theme-discovery.mjs +23 -6
  359. package/foundation/discovery/theme-imports.mjs +2 -4
  360. package/foundation/doc-compiler/parse-readable.mjs +4 -3
  361. package/foundation/doc-compiler/stored-docs.d.mts +13 -0
  362. package/foundation/doc-compiler/stored-docs.mjs +74 -3
  363. package/foundation/env/cli-command.d.mts +68 -10
  364. package/foundation/env/cli-command.mjs +116 -22
  365. package/foundation/env/project-scope.d.mts +9 -0
  366. package/foundation/env/project-scope.mjs +28 -2
  367. package/foundation/fs/gather-cache.d.mts +23 -0
  368. package/foundation/fs/gather-cache.mjs +94 -2
  369. package/foundation/fs/module-loader.d.mts +3 -1
  370. package/foundation/fs/module-loader.mjs +85 -5
  371. package/foundation/fs/read-record.mjs +9 -5
  372. package/foundation/identity/package-names.d.mts +18 -0
  373. package/foundation/identity/package-names.mjs +19 -0
  374. package/foundation/identity/providers.mjs +3 -2
  375. package/foundation/integrations/icon-features.d.mts +63 -0
  376. package/foundation/integrations/icon-features.mjs +54 -0
  377. package/foundation/integrations/integrations.d.mts +13 -1
  378. package/foundation/integrations/integrations.mjs +47 -6
  379. package/foundation/integrations/pack-state.d.mts +21 -0
  380. package/foundation/integrations/pack-state.mjs +42 -19
  381. package/foundation/integrations/validate-contributions.d.mts +11 -3
  382. package/foundation/integrations/validate-contributions.mjs +51 -13
  383. package/foundation/release/cache.d.mts +13 -1
  384. package/foundation/release/cache.mjs +94 -14
  385. package/foundation/release/notices.d.mts +15 -0
  386. package/foundation/release/notices.mjs +111 -7
  387. package/foundation/release/project.d.mts +3 -4
  388. package/foundation/release/project.mjs +5 -6
  389. package/foundation/render/client-bundle.d.mts +126 -0
  390. package/foundation/render/client-bundle.mjs +565 -0
  391. package/foundation/render/cut-short.d.mts +7 -1
  392. package/foundation/render/cut-short.mjs +46 -6
  393. package/foundation/render/embedded-imports.d.mts +4 -3
  394. package/foundation/render/embedded-imports.mjs +13 -8
  395. package/foundation/render/esbuild-dependency.d.mts +14 -0
  396. package/foundation/render/esbuild-dependency.mjs +41 -0
  397. package/foundation/render/file-header.mjs +5 -4
  398. package/foundation/render/page-worker.mjs +562 -86
  399. package/foundation/render/picture-chrome.mjs +54 -29
  400. package/foundation/render/picture-playwright.mjs +78 -42
  401. package/foundation/render/picture-window.d.mts +33 -0
  402. package/foundation/render/picture-window.mjs +78 -0
  403. package/foundation/render/render-page.d.mts +55 -4
  404. package/foundation/render/render-page.mjs +199 -28
  405. package/foundation/render/restore-folder.d.mts +13 -0
  406. package/foundation/render/restore-folder.mjs +30 -0
  407. package/foundation/render/served-packages.d.mts +2 -1
  408. package/foundation/render/served-packages.mjs +5 -3
  409. package/foundation/render/ts-paths.d.mts +11 -0
  410. package/foundation/render/ts-paths.mjs +27 -2
  411. package/foundation/render/value-uses.d.mts +43 -0
  412. package/foundation/render/value-uses.mjs +110 -0
  413. package/foundation/response/error-codes.d.mts +2 -1
  414. package/foundation/response/error-codes.doc.mjs +7 -1
  415. package/foundation/response/error-codes.mjs +10 -2
  416. package/foundation/response/response-types.doc.mjs +12 -12
  417. package/foundation/runtime/package-root.d.mts +8 -0
  418. package/foundation/runtime/package-root.mjs +20 -0
  419. package/foundation/suggest/other-command.d.mts +11 -0
  420. package/foundation/suggest/other-command.mjs +1 -1
  421. package/foundation/text/icon-id.d.mts +20 -0
  422. package/foundation/text/icon-id.mjs +40 -0
  423. package/foundation/text/icon-set-next.d.mts +25 -0
  424. package/foundation/text/icon-set-next.mjs +29 -0
  425. package/foundation/xle/browser.d.mts +2 -2
  426. package/package.json +7 -6
@@ -59,6 +59,9 @@ import {
59
59
  positionalCornerToken,
60
60
  radiusAt,
61
61
  partState,
62
+ baseBlocksFor,
63
+ partsOf,
64
+ MOMENT_STATES,
62
65
  } from './_settings.mjs';
63
66
  import {
64
67
  borderlessSurfaces,
@@ -73,10 +76,11 @@ import {
73
76
  stateSynonym,
74
77
  } from './_check.mjs';
75
78
  import {coreKeyframes} from './_parts.mjs';
76
- import {NUMBER_WORDS, commaNumbers, modeNear} from './_normal.mjs';
79
+ import {NUMBER_WORDS, commaNumbers, modeNear, pluralOf} from './_normal.mjs';
77
80
  import {levenshteinDistance} from '../../foundation/text/levenshtein.mjs';
78
81
  import {cssProperties, keywordsOf, matchValue, splitTop} from './_css.mjs';
79
82
 
83
+ import {render as renderStep} from './_how-commands.mjs';
80
84
  /** @typedef {import('./_how-commands.mjs').Step} Step */
81
85
  /** @typedef {import('./_how-commands.mjs').MeasureIntent} MeasureIntent */
82
86
 
@@ -625,7 +629,7 @@ function colorsFound(c) {
625
629
  c.slice((m.index ?? 0) + m[0].length);
626
630
  }
627
631
  const re =
628
- /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color-mix)\([^)]*\)|\b(?:(lighter|light|pale|darker|dark|deep|rich|subtle|soft)\s+)?([a-z]+)\b/g;
632
+ /#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color-mix)\([^)]*\)|\b(?:(lighter|light|pale|pastel|darker|dark|deeper|deep|rich|subtle|soft)\s+)?([a-z]+)\b/g;
629
633
  for (const m of c
630
634
  .replace(GRAY_STOP, s => ' '.repeat(s.length))
631
635
  .matchAll(re)) {
@@ -650,6 +654,7 @@ function colorsFound(c) {
650
654
  lighter: 'light',
651
655
  darker: 'dark',
652
656
  deep: 'dark',
657
+ deeper: 'dark',
653
658
  rich: 'dark',
654
659
  })[m[1] ?? ''] ?? m[1];
655
660
  const word = m[2];
@@ -665,10 +670,19 @@ function colorsFound(c) {
665
670
  base &&
666
671
  (shade === 'light' ||
667
672
  shade === 'pale' ||
673
+ shade === 'pastel' ||
668
674
  (shade === 'dark' && Math.max(...base.slice(0, 3)) > 150))
669
675
  ) {
670
676
  const to = shade === 'dark' ? 0 : 255;
671
- const k = shade === 'dark' ? 0.4 : shade === 'light' ? 0.75 : 0.88;
677
+ // (A pastel is a hue well toward white, keeping some of its color.)
678
+ const k =
679
+ shade === 'dark'
680
+ ? 0.4
681
+ : shade === 'pastel'
682
+ ? 0.6
683
+ : shade === 'light'
684
+ ? 0.75
685
+ : 0.88;
672
686
  found.push([
673
687
  m.index ?? 0,
674
688
  hex(base.slice(0, 3).map(v => Math.round(v + (to - v) * k))),
@@ -1197,7 +1211,20 @@ function sharedAsk(q, partWords) {
1197
1211
  const m2 = new RegExp(
1198
1212
  `^\\s*([a-z]+)\\s+(?:${re2.source})`,
1199
1213
  ).exec(right);
1200
- return m2 && stateWord(m2[1]) != null ? m2 : null;
1214
+ // (A word that describes the part, "the draft badge", "the
1215
+ // hovered card", goes with it, as on the left; a word that
1216
+ // is an ask of its own, a color, an aspect or a verb, never.)
1217
+ const w = m2 ? m2[1].toLowerCase() : '';
1218
+ const describes =
1219
+ m2 != null &&
1220
+ (stateWord(w) != null ||
1221
+ (!colorsIn(w).length &&
1222
+ !aspectsOf(w).length &&
1223
+ !partWords.some(([p]) => p.test(` ${w} `)) &&
1224
+ !/^(?:make|set|give|turn|change|add|remove|keep|use|put|round|square|no|not|without|except|than)$/.test(
1225
+ w,
1226
+ )));
1227
+ return describes ? m2 : null;
1201
1228
  })();
1202
1229
  if (!r) continue;
1203
1230
  const lead = left.slice(0, l.index);
@@ -1600,13 +1627,54 @@ function shadowWay(text) {
1600
1627
  return null;
1601
1628
  }
1602
1629
 
1630
+ /**
1631
+ * A clause's colors without one said as what something is now, which is
1632
+ * the color the ask moves away from, never the one it asks for: "too
1633
+ * bright blue" (the way, "too bright", stays an ask).
1634
+ * @param {string} text
1635
+ */
1636
+ function withoutColorNow(text) {
1637
+ return String(text).replace(
1638
+ /\btoo\s+(?:[a-z]+\s+)?(?=[a-z#])((?:[a-z]+|#[0-9a-f]{3,8})\b)/gi,
1639
+ (m, w) => (colorsIn(w).length ? m.replace(w, ' ') : m),
1640
+ );
1641
+ }
1642
+
1643
+ /**
1644
+ * A question without a report of how something looks now ("is still
1645
+ * gray", "it's blue now"): what it is now is no value to write, so the rest
1646
+ * reads as the ask it is (the part, and what to look at).
1647
+ * @param {string} text
1648
+ */
1649
+ function withoutLooksNow(text) {
1650
+ return (
1651
+ String(text)
1652
+ .replace(
1653
+ /\b(?:(?:is|are|it'?s|looks?|stays?)\s+)?(?:still|currently|right now)\s+((?:[a-z]+|#[0-9a-f]{3,8})\b)/gi,
1654
+ (m, w) => (colorsIn(w).length ? ' ' : m),
1655
+ )
1656
+ .replace(
1657
+ /\b(?:is|are|it'?s)\s+((?:[a-z]+|#[0-9a-f]{3,8}))\s+now\b/gi,
1658
+ (m, w) => (colorsIn(w).length ? ' ' : m),
1659
+ )
1660
+ // (Spaces only: a line break between asks stays a break.)
1661
+ .replace(/[ \t]{2,}/g, ' ')
1662
+ );
1663
+ }
1664
+
1603
1665
  /**
1604
1666
  * The near color a "never use pure <color>" ask moves a color to: a
1605
- * near-black for a dark color, a near-white for a light one.
1667
+ * near-black for a dark color, a near-white for a light one, tinted with
1668
+ * the theme's own neutral in that mode (a purple theme's off-white is a
1669
+ * pale lavender), so it reads as the theme's and is visibly off the color.
1606
1670
  * @param {number[]} avoid the RGB to stay off
1671
+ * @param {number[] | null} [tint] the theme's neutral there, as RGB
1607
1672
  */
1608
- function nearOff(avoid) {
1609
- return avoid.reduce((x, y) => x + y, 0) < 384 ? '#1f2937' : '#f9fafb';
1673
+ function nearOff(avoid, tint) {
1674
+ const dark = avoid.reduce((x, y) => x + y, 0) < 384;
1675
+ if (!tint) return dark ? '#1f2937' : '#f9fafb';
1676
+ const share = dark ? 0.25 : 0.1;
1677
+ return hex(avoid.map((x, i) => Math.round(x + (tint[i] - x) * share)));
1610
1678
  }
1611
1679
 
1612
1680
  /**
@@ -1683,7 +1751,9 @@ function keepsAsExcept(question) {
1683
1751
  // up to the ask's own verb, is a keep too.
1684
1752
  .replace(
1685
1753
  new RegExp(
1686
- String.raw`^\s*(?:please\s+)?(?:keep|leave)\s+(?:the\s+|my\s+)?([a-z0-9][a-z0-9 -]*?)\s*(?:,\s*)?(?:and\s+|then\s+)?(?=(?:please\s+)?(?:make|set|give|turn|change|round|add|remove)\b)`,
1754
+ // (The ask's verb is a whole word: the "round" inside "background"
1755
+ // is no verb, so the keep never ends mid-word.)
1756
+ String.raw`^\s*(?:please\s+)?(?:keep|leave)\s+(?:the\s+|my\s+)?([a-z0-9][a-z0-9 -]*?)\s*(?:,\s*)?(?:and\s+|then\s+)?(?=(?:please\s+)?\b(?:make|set|give|turn|change|round|add|remove)\b)`,
1687
1757
  'i',
1688
1758
  ),
1689
1759
  (_m, x) => {
@@ -1736,6 +1806,20 @@ function stateWord(t) {
1736
1806
  return null;
1737
1807
  }
1738
1808
 
1809
+ /**
1810
+ * Whether states said together are the part in all of them at once: a
1811
+ * list with a condition in it (checked, selected, disabled); never moment
1812
+ * states alone (hovered and pressed are each one).
1813
+ * @param {string[]} words
1814
+ */
1815
+ function atOnce(words) {
1816
+ const states = words.map(stateWord);
1817
+ return (
1818
+ states.every(st => st != null) &&
1819
+ states.some(st => !MOMENT_STATES.includes(String(st)))
1820
+ );
1821
+ }
1822
+
1739
1823
  /**
1740
1824
  * A clause's words with its mode phrases taken out ("in light mode", "dark
1741
1825
  * theme", "in light"), so "darker … in light mode" reads as darker.
@@ -1777,6 +1861,55 @@ const BY_SCREEN = /** @type {const} */ ('by-screen');
1777
1861
  */
1778
1862
  const compared = new WeakMap();
1779
1863
 
1864
+ /**
1865
+ * How visible an ask makes a line or a tint: `stronger` (more of it) or
1866
+ * fainter, by the factor said when one is (`half as visible` 0.5 of its
1867
+ * strength). Words of transparency count the other way: more transparent
1868
+ * or see-through is fainter, and `half as transparent` is twice as strong.
1869
+ * Null when the ask says nothing of visibility. The one reader the border
1870
+ * answers share.
1871
+ * @param {string} text
1872
+ * @returns {{stronger: boolean, by: number | null} | null}
1873
+ */
1874
+ export function visibilityAsk(text) {
1875
+ const t = text.toLowerCase();
1876
+ const SEE = '(?:transparent|translucent|see-through|see through)';
1877
+ const SHOW = '(?:visible|noticeable|prominent|obvious|pronounced|strong)';
1878
+ const by = exactFactor(t);
1879
+ if (new RegExp(`\\b${SEE}\\b`).test(t)) {
1880
+ // "less transparent", "half as transparent": stronger; "more
1881
+ // transparent", "twice as transparent": fainter.
1882
+ const less = new RegExp(
1883
+ `\\bless ${SEE}\\b|\\bhalf as ${SEE}\\b|\\bnot as ${SEE}\\b`,
1884
+ ).test(t);
1885
+ const factor =
1886
+ by != null && by > 0
1887
+ ? less
1888
+ ? by < 1
1889
+ ? 1 / by
1890
+ : by
1891
+ : by > 1
1892
+ ? 1 / by
1893
+ : by
1894
+ : null;
1895
+ return {stronger: less, by: factor};
1896
+ }
1897
+ if (/\bmore opaque\b|\bopaquer\b/.test(t)) return {stronger: true, by};
1898
+ if (/\bless opaque\b/.test(t)) return {stronger: false, by};
1899
+ if (
1900
+ new RegExp(
1901
+ `\\b${SHOW}\\b|\\binvisible\\b|\\bfaint(?:er)?\\b|\\bsubtler\\b|\\bweaker\\b`,
1902
+ ).test(t)
1903
+ ) {
1904
+ const fainter =
1905
+ new RegExp(
1906
+ `\\b(?:less|half as|barely|hardly|not as|a lot less|much less) ${SHOW}\\b|\\binvisible\\b|\\bfaint(?:er)?\\b|\\bsubtler\\b|\\bweaker\\b`,
1907
+ ).test(t) && !new RegExp(`\\b(?:twice|\\d+ times) as ${SHOW}\\b`).test(t);
1908
+ return {stronger: !fainter, by};
1909
+ }
1910
+ return null;
1911
+ }
1912
+
1780
1913
  /**
1781
1914
  * An exact relative amount the words give ("half", "double", "twice",
1782
1915
  * "triple", "a third", "a quarter", "50%", "x0.8"), as a factor of the
@@ -2010,7 +2143,7 @@ export function partLexicon(ctx) {
2010
2143
  ...Object.keys(HUES).filter(w => w.length >= 5 && !PALETTE_NAMES.has(w)),
2011
2144
  ...[...project.target.keys()]
2012
2145
  .filter(key => !key.includes('-'))
2013
- .flatMap(key => [key, `${key}s`]),
2146
+ .flatMap(key => [key, pluralOf(key)]),
2014
2147
  ]),
2015
2148
  ];
2016
2149
  // Every group the editor knows, by its own name ("checks", "inputs"),
@@ -2210,7 +2343,11 @@ const STATE_WORDS = /** @type {Array<[RegExp, string]>} */ ([
2210
2343
  [/\b(hover(ed|ing)?|mouse ?over)\b/, 'hover'],
2211
2344
  [/\b(focus(ed|ing)?|on focus)\b/, 'focus'],
2212
2345
  [/\b(disabled|inactive)\b/, 'disabled'],
2213
- [/\b(checked|ticked|when on|turned on|toggled on|is on)\b/, 'checked'],
2346
+ // (A switch's "on color", "on state": its checked look.)
2347
+ [
2348
+ /\b(checked|ticked|when on|turned on|toggled on|is on|on[- ](?:colou?r|state|look))\b/,
2349
+ 'checked',
2350
+ ],
2214
2351
  [
2215
2352
  /\b(selected|active (tab|nav|item|link|page))\b|\bactive\b(?=.*\b(nav|tab|item)\b)/,
2216
2353
  'selected',
@@ -2247,6 +2384,7 @@ const STATE_WORDS = /** @type {Array<[RegExp, string]>} */ ([
2247
2384
  /\b(unchecked|not checked|unticked|when off|turned off|toggled off|switched off|is off)\b/,
2248
2385
  'unchecked',
2249
2386
  ],
2387
+ [/\b(unselected|not selected|non-selected)\b/, 'unselected'],
2250
2388
  ]);
2251
2389
 
2252
2390
  /**
@@ -2365,7 +2503,11 @@ function aspectsOf(text) {
2365
2503
  add('case');
2366
2504
  if (/\bitalics?\b/.test(c)) add('italic');
2367
2505
  if (
2368
- /\b(bold(er)?|unbold\w*|weight|heav(y|ier)|semibold)\b/.test(c) ||
2506
+ // ("heavy shadows", "a heavy border": how strong a shadow or line
2507
+ // is, never a font weight.)
2508
+ /\b(bold(er)?|unbold\w*|weight|heav(y|ier)(?!\s+(?:drop\s+|box\s+)?(?:shadows?|borders?|lines?|outlines?))|semibold)\b/.test(
2509
+ c,
2510
+ ) ||
2369
2511
  // "body 16px regular": a weight word after a size.
2370
2512
  /\b\d+(\.\d+)?(px|rem|em|pt) (regular|normal|medium)\b|\b(body|text|headings?) (regular|normal)$/.test(
2371
2513
  c,
@@ -2627,10 +2769,9 @@ function namedLists(q, partWords, isVariant) {
2627
2769
  // ("the checked and disabled checkbox": two states said of one
2628
2770
  // part, both at once, never each.)
2629
2771
  (items.length === 2 &&
2630
- items.every(w => stateWord(w) != null) &&
2772
+ atOnce(items) &&
2631
2773
  /\sand\s/i.test(String(list)) &&
2632
- !/,|\bor\b/i.test(String(list)) &&
2633
- !/s$/i.test(String(noun)))
2774
+ !/,|\bor\b/i.test(String(list)))
2634
2775
  )
2635
2776
  continue;
2636
2777
  // The asks said of the list: up to a full stop or semicolon, an
@@ -2706,11 +2847,10 @@ function namedLists(q, partWords, isVariant) {
2706
2847
  // part, both at once, never each.)
2707
2848
  const bothAtOnce =
2708
2849
  items.length === 2 &&
2709
- items.every(w => stateWord(w) != null) &&
2850
+ atOnce(items) &&
2710
2851
  !/,|\bor\b/i.test(String(list)) &&
2711
2852
  !ones &&
2712
- nounPart != null &&
2713
- !/s$/i.test(next);
2853
+ nounPart != null;
2714
2854
  if (bothAtOnce) return m;
2715
2855
  if (items.every(modifies))
2716
2856
  // (The noun said after the list stays after its last item.)
@@ -2806,9 +2946,7 @@ function clausesOf(q, partWords) {
2806
2946
  const bothStates = tokenLists.replace(
2807
2947
  /\b([a-z]+)\s+and\s+([a-z]+)\s+([a-z][a-z-]*)\b/gi,
2808
2948
  (m, a, b, noun) =>
2809
- stateWord(String(a).toLowerCase()) != null &&
2810
- stateWord(String(b).toLowerCase()) != null &&
2811
- !/s$/i.test(String(noun)) &&
2949
+ atOnce([String(a).toLowerCase(), String(b).toLowerCase()]) &&
2812
2950
  partWords.some(([re]) => re.test(` ${String(noun).toLowerCase()} `))
2813
2951
  ? `${a} & ${b} ${noun}`
2814
2952
  : m,
@@ -2818,14 +2956,22 @@ function clausesOf(q, partWords) {
2818
2956
  /** @type {Array<{text: string, joint: string}>} */
2819
2957
  const pieces = [];
2820
2958
  {
2959
+ // (A generic family after a color, "on black, monospace", starts an
2960
+ // ask of its own: a font stack starts with a family's name, never a
2961
+ // color.)
2821
2962
  const split = (
2822
2963
  /\bswap\b/.test(bothStates)
2823
2964
  ? bothStates.replace(/\band\b/g, '&')
2824
2965
  : sharedAsk(bothStates, partWords)
2825
- ).split(
2826
- // A font stack ("Georgia, serif") is one value, not two asks.
2827
- /(;|\.(?=\s|$)|,(?![^(]*\))(?!\s*(?:serif|sans-serif|monospace|system-ui|cursive|fantasy|ui-[a-z-]+)\b)|\b(?:and|but|then|plus|also|y|et|und|и)\b|(?<!\b(?:tint(?:ed|s)?|paint(?:ed|s)?|wash(?:ed|es)?)(?:\s+[a-z-]+){0,3}\s+)\bwith\b(?!\s+(?:an?\s+)?\d{1,3}(?:\.\d+)?\s?%\s+(?:alpha|opacity|transparency)\b)|\bwhile\b|(?=\bexcept\b))/,
2828
- );
2966
+ )
2967
+ .replace(
2968
+ /([a-z#0-9]+)(\s*),(?=\s*(?:serif|sans-serif|monospace|system-ui|cursive|fantasy)\b)/gi,
2969
+ (m, prev, sp) => (colorsIn(String(prev)).length ? `${prev}${sp};` : m),
2970
+ )
2971
+ .split(
2972
+ // A font stack ("Georgia, serif") is one value, not two asks.
2973
+ /(;|\.(?=\s|$)|,(?![^(]*\))(?!\s*(?:serif|sans-serif|monospace|system-ui|cursive|fantasy|ui-[a-z-]+)\b)|\b(?:and|but|then|plus|also|y|et|und|и)\b|(?<!\b(?:tint(?:ed|s)?|paint(?:ed|s)?|wash(?:ed|es)?)(?:\s+[a-z-]+){0,3}\s+)\bwith\b(?!\s+(?:an?\s+)?\d{1,3}(?:\.\d+)?\s?%\s+(?:alpha|opacity|transparency)\b)|\bwhile\b|(?=\bexcept\b))/,
2974
+ );
2829
2975
  let joint = '';
2830
2976
  for (let k = 0; k < split.length; k++) {
2831
2977
  const piece = split[k] ?? '';
@@ -2862,7 +3008,26 @@ function clausesOf(q, partWords) {
2862
3008
  );
2863
3009
  const cornerWords = /\b(round|corner|radius|shape|circular)/.test(text);
2864
3010
  for (const [re, part] of partWords) {
2865
- const m = re.exec(rest);
3011
+ // (A part word is a word of its own, never one half of a hyphenated
3012
+ // compound, "field-service", "card-like": a match with a letter
3013
+ // joined to it by a hyphen names no part. A part's own name written
3014
+ // with a hyphen, "date-picker", is one match and counts whole.)
3015
+ const all = new RegExp(
3016
+ re.source,
3017
+ re.flags.includes('g') ? re.flags : `${re.flags}g`,
3018
+ );
3019
+ /** @type {RegExpExecArray | null} */
3020
+ let m = null;
3021
+ for (const x of rest.matchAll(all)) {
3022
+ const at = /** @type {number} */ (x.index);
3023
+ if (
3024
+ /[a-z]-$/i.test(rest.slice(0, at)) ||
3025
+ /^-[a-z]/i.test(rest.slice(at + x[0].length))
3026
+ )
3027
+ continue;
3028
+ m = x;
3029
+ break;
3030
+ }
2866
3031
  if (!m) continue;
2867
3032
  const p = {...part};
2868
3033
  if (p.on === 'heading' && /^h[1-6]$/.test(m[0])) p.level = m[1];
@@ -2874,7 +3039,7 @@ function clausesOf(q, partWords) {
2874
3039
  if (p.on === 'banner' && status)
2875
3040
  p.when = `status:${status === 'danger' ? 'error' : status}`;
2876
3041
  parts.push(p);
2877
- rest = rest.replace(re, ' ');
3042
+ rest = `${rest.slice(0, m.index)} ${rest.slice(/** @type {number} */ (m.index) + m[0].length)}`;
2878
3043
  }
2879
3044
  // "the sidebar the page color", "the header the card color", "cards
2880
3045
  // the color of the page": a part named as its color after another part
@@ -3112,6 +3277,12 @@ function clausesOf(q, partWords) {
3112
3277
  // "transparent" inside color-mix() asks for no see-through fill.
3113
3278
  const aspects0 = aspectsOf(
3114
3279
  (groundSaid ? text.replace(groundSaid, ' ') : text)
3280
+ // ("the text on the gradient": where the text sits, never what
3281
+ // changes.)
3282
+ .replace(
3283
+ /\b(text|labels?|writing|words)\s+on\s+(?:the\s+|a\s+|an\s+)?[a-z-]+\b/g,
3284
+ '$1',
3285
+ )
3115
3286
  .replace(
3116
3287
  refSaid ? new RegExp(`\\b${refSaid}\\b(?=\\S*\\s+colou?r)`) : /$^/,
3117
3288
  ' ',
@@ -3358,7 +3529,7 @@ function clausesOf(q, partWords) {
3358
3529
  named: namedProperty(text),
3359
3530
  neg,
3360
3531
  dir,
3361
- colors: colorsIn(text),
3532
+ colors: colorsIn(withoutColorNow(text)),
3362
3533
  bad: badHex(text),
3363
3534
  // A typed clamp() or calc() is a length, kept whole.
3364
3535
  lengths: [
@@ -3391,13 +3562,26 @@ export function namedProperty(text) {
3391
3562
  for (const m of flat.matchAll(
3392
3563
  /\b((?:border|outline)(?: (?:top|right|bottom|left))? (?:colou?r|width|style)|(?:min|max) (?:height|width)|line height|letter spacing|font (?:size|weight)|radius|[a-z]+(?:-[a-z]+)+|[a-z]+)(\s*:)?\s*/g,
3393
3564
  )) {
3394
- const prop =
3565
+ const prop0 =
3395
3566
  PROPERTY_WORDS[m[1]] ??
3396
3567
  (/^(border|outline)( (top|right|bottom|left))? (colou?r|width|style)$/.test(
3397
3568
  m[1],
3398
3569
  )
3399
3570
  ? m[1].replace(/colour/, 'color').replace(/ /g, '-')
3400
3571
  : m[1]);
3572
+ // ("bottom border 1px #49454f": the side said before it is the side's.)
3573
+ const sideBefore = /\b(top|right|bottom|left)\s+$/.exec(
3574
+ flat.slice(0, m.index ?? 0),
3575
+ )?.[1];
3576
+ const prop =
3577
+ sideBefore && /^(border|outline)$/.test(prop0)
3578
+ ? `${prop0}-${sideBefore}`
3579
+ : prop0;
3580
+ // ("1px border rgba(0 0 0 / 0.2)": a width said before it is its own.)
3581
+ const lenBefore =
3582
+ /(?:^|\s)(\d*\.?\d+(?:px|rem|em))\s+(?:(?:top|right|bottom|left)\s+)?$/.exec(
3583
+ flat.slice(0, m.index ?? 0),
3584
+ )?.[1];
3401
3585
  // A property word right after another one ("border width") is part of
3402
3586
  // it, never a property of its own.
3403
3587
  if (
@@ -3467,7 +3651,16 @@ export function namedProperty(text) {
3467
3651
  // A value that drops typed words is not the one asked for: "border
3468
3652
  // 0 0 2px" is not "border 0".
3469
3653
  if (n < tokens.length && /^[-.\d#]/.test(tokens[n] ?? '')) break;
3470
- return completeShorthand(prop, value);
3654
+ const done = completeShorthand(prop, value);
3655
+ if (
3656
+ lenBefore &&
3657
+ /^(border|outline)(-(top|right|bottom|left))?-color$/.test(done.prop)
3658
+ )
3659
+ return {
3660
+ prop: done.prop.replace(/-color$/, ''),
3661
+ value: `${lenBefore} solid ${done.value}`,
3662
+ };
3663
+ return done;
3471
3664
  }
3472
3665
  }
3473
3666
  return null;
@@ -3735,6 +3928,17 @@ function oneModeLine(C, TARGET, part, width, color, mode, state) {
3735
3928
  * @returns {{parts: string[], aspects: string[], drafts: Draft[]}}
3736
3929
  */
3737
3930
  export function draftAnswer(ctx, env, question) {
3931
+ // The theme's own neutral, as its seed is set: what a near color off a
3932
+ // pure one is tinted with, so it reads as the theme's (none: a plain
3933
+ // near-black or near-white).
3934
+ const themeNeutral = parseColor(
3935
+ String(
3936
+ (env.data?.settings ?? []).find(
3937
+ (/** @type {any} */ x) =>
3938
+ x.source === 'dial' && x.thing === 'neutral' && !x.on && !x.mode,
3939
+ )?.value ?? '',
3940
+ ),
3941
+ );
3738
3942
  // (The words as asked, for the readers that hold the whole question.)
3739
3943
  const asked0 = String(question).toLowerCase();
3740
3944
  // "darkmode", "dark-mode": one spelling of a mode before any clause is
@@ -3780,6 +3984,17 @@ export function draftAnswer(ctx, env, question) {
3780
3984
  // color the answer writes is held to (after the answers are made), never
3781
3985
  // the color asked for nor a clause of its own, so it is read out of the
3782
3986
  // words here.
3987
+ // "navy, not bright blue": a color said against the one it replaces is
3988
+ // the first color alone, never a prohibition of its own.
3989
+ question = question.replace(
3990
+ /(\S+)\s*,?\s*(?:and\s+|but\s+)?not\s+((?:[a-z]+\s+)?(?:[a-z]+|#[0-9a-f]{3,8}))(?=\s*(?:[,;.!?]|$))/gi,
3991
+ (m, first, second) =>
3992
+ colorsIn(first).length &&
3993
+ colorsIn(String(second).split(/\s+/).pop() ?? '').length
3994
+ ? first
3995
+ : m,
3996
+ );
3997
+ question = withoutLooksNow(question);
3783
3998
  const colorBound = colorBoundOf(question);
3784
3999
  if (colorBound)
3785
4000
  question = question
@@ -3892,6 +4107,107 @@ export function draftAnswer(ctx, env, question) {
3892
4107
  /\b(?:that\s+|which\s+)?(?:works|looks good|holds up|also works|is usable|works well)\s+in\s+(?:both\s+)?(?:dark|light)(?:\s+(?:and|&)\s+(?:dark|light))?\s+modes?\b/gi,
3893
4108
  ' ',
3894
4109
  )
4110
+ // ("green text on a black page": the text's color and the page's, each
4111
+ // its own, as "a black page with green text" says it. "green text on
4112
+ // black", with the ground's noun left out at the end of its clause, is
4113
+ // the same: the color under text is the page's.)
4114
+ .replace(
4115
+ /\b((?:[a-z]+\s+)?(?:[a-z]+|#[0-9a-f]{3,8}))\s+(text|writing|type)\s+on\s+(?:(?:a|an|the)\s+((?:[a-z]+\s+)?(?:[a-z]+|#[0-9a-f]{3,8}))\s+(page|background|surface)\b|((?:[a-z]+|#[0-9a-f]{3,8}))(?=\s*(?:[,;.!?]|$)))/gi,
4116
+ (m, ink, _t, under, ground, bare) =>
4117
+ colorsIn(String(ink).toLowerCase()).length &&
4118
+ colorsIn(String(under ?? bare).toLowerCase()).length
4119
+ ? `${under ?? bare} ${ground ?? 'page'} background, ${ink} text`
4120
+ : m,
4121
+ )
4122
+ // ("a frosted glass look", "glass cards", "translucent with a blur":
4123
+ // the glass rung of the surfaces dial.)
4124
+ .replace(
4125
+ /\b(?:frosted(?:\s+glass)?|glassy|glass(?:morphism)?)(?:\s+(?:look|effect|style|surfaces?|cards?|panels?))?\b|\btranslucent\s+with\s+(?:a\s+)?blur\b/gi,
4126
+ 'make the surfaces glass',
4127
+ )
4128
+ .replace(
4129
+ /\b(?:make\s+)?(?:the\s+)?(?:cards?|panels?|surfaces?)\s+make the surfaces glass\b/gi,
4130
+ 'make the surfaces glass',
4131
+ )
4132
+ // ("tight dense spacing": the rung said wins over the way.)
4133
+ .replace(
4134
+ /\b(tight|compact|roomy|spacious)\s+(?:and\s+)?(?:dense|denser|airy|airier|loose|looser)\b|\b(?:dense|denser|airy|airier|loose|looser)\s+(?:and\s+)?(tight|compact|roomy|spacious)\b/gi,
4135
+ (_m, a, b) => a ?? b,
4136
+ )
4137
+ // ("gridlines": a table's cell borders.)
4138
+ .replace(
4139
+ /\b(?:show\s+)?grid\s?lines?(?:\s+(?:between|on|in)\s+(?:the\s+)?table\s+cells)?\b/gi,
4140
+ '1px border on table cells',
4141
+ )
4142
+ // ("big buttons" said alone: bigger; "the large buttons 4px taller"
4143
+ // names their size.)
4144
+ .replace(
4145
+ /(^|[,;:]\s*|\band\s+)(?:make\s+(?:the\s+)?)?(big|large|huge)\s+(buttons?|inputs?|controls?)\s*(?=$|[,;.]|\band\b)/gi,
4146
+ '$1bigger $3',
4147
+ )
4148
+ // ("luxury fashion brand: black and ivory": a lead naming what the
4149
+ // theme is for, never the brand color itself.)
4150
+ .replace(/\b(?:brand|company|startup|business)\s*:/gi, 'theme:')
4151
+ // ("headings semibold, not bold": the rung said, and the one it is
4152
+ // set against; never a second ask.)
4153
+ .replace(
4154
+ /\b(thin|light|regular|normal|medium|semibold|semi-bold|bold|heavy|black|extra-?bold)\b([^,;.]*?)[,;]?\s*(?:but\s+)?not\s+(?:too\s+)?(?:thin|light|regular|normal|medium|semibold|semi-bold|bold|heavy|black|extra-?bold)\b/gi,
4155
+ '$1$2',
4156
+ )
4157
+ // ("lots of data on screen", "information-dense": the theme denser.)
4158
+ .replace(
4159
+ /\b(?:lots|a lot|plenty) of (?:data|information|info|content|rows|things) (?:on|per) (?:the )?(?:screen|page)\b|\binformation[- ]dense\b|\bdata[- ]dense\b|\bfit more (?:on|per) (?:the )?(?:screen|page)\b/gi,
4160
+ 'more compact',
4161
+ )
4162
+ // ("red only for alerts", "red reserved for errors": the danger color,
4163
+ // every error, alert and destructive look; never every banner.)
4164
+ .replace(
4165
+ /\b((?:[a-z]+\s+)?[a-z]+|#[0-9a-f]{3,8})\s+(?:only|just|reserved)\s+for\s+(?:the\s+)?(?:alerts?|errors?|danger|destructive(?:\s+actions?)?|warnings? and errors?)\b/gi,
4166
+ (m, color) =>
4167
+ colorsIn(String(color).toLowerCase()).length
4168
+ ? `danger color ${color}`
4169
+ : m,
4170
+ )
4171
+ // ("bigger, bolder headings": ways listed before one part are all its.)
4172
+ .replace(
4173
+ /\b(bigger|larger|smaller|bolder|lighter|darker|rounder|wider|taller|softer|brighter)\s*,\s*(?:and\s+)?(bigger|larger|smaller|bolder|lighter|darker|rounder|wider|taller|softer|brighter)\s+(?=[a-z])/gi,
4174
+ '$1 $2 ',
4175
+ )
4176
+ // ("dark purple theme", "moody dark purple": dark said of a whole look
4177
+ // with a hue is the dark mode and that hue as the accent; "dark purple
4178
+ // buttons" stays a shade.)
4179
+ .replace(
4180
+ /\b(dark|light)\s+([a-z]+)(?=\s+(?:theme|look|vibe|aesthetic|palette)\b|\s*(?:[,;:]|$))/gi,
4181
+ (m, mode, hue, at, whole) =>
4182
+ Object.hasOwn(HUES, String(hue).toLowerCase()) &&
4183
+ // (A whole look: no part named anywhere in the ask.)
4184
+ !partLexicon(ctx).parts.some(([re]) =>
4185
+ re.test(` ${String(whole).toLowerCase()} `),
4186
+ ) &&
4187
+ !/\b(?:text|backgrounds?|borders?|fills?|colou?r of)\b/i.test(
4188
+ String(whole),
4189
+ )
4190
+ ? `${mode} theme with ${hue} accent`
4191
+ : m,
4192
+ )
4193
+ // ("deeper blue": a dark shade of the hue.)
4194
+ .replace(/\b(?:deeper|richer)\s+(?=([a-z]+)\b)/gi, (m, hue) =>
4195
+ Object.hasOwn(HUES, String(hue).toLowerCase()) ? 'dark ' : m,
4196
+ )
4197
+ // ("easy to read at night", "for reading at night": a dark mode by
4198
+ // default, and larger text for "easy to read".)
4199
+ .replace(
4200
+ /\b(?:at|for|during the)\s+night(?:time)?\b/gi,
4201
+ ', dark by default',
4202
+ )
4203
+ .replace(/\b(?:easy|easier|comfortable)\s+to\s+read\b/gi, 'larger text')
4204
+ // ("use the system font": the font named, never a part called so.)
4205
+ .replace(
4206
+ /\b(?:use|using|with|switch to|go with)\s+(?:the|a)\s+(system|serif|sans-serif|sans|monospace|mono|rounded|display)\s+(font|typeface|type)\b/gi,
4207
+ '$1 $2',
4208
+ )
4209
+ // ("dark mode first", "dark first": the mode the app opens in.)
4210
+ .replace(/\b(dark|light)(?:\s+mode)?\s+first\b/gi, '$1 mode by default')
3895
4211
  // ("almost square", "nearly square": a rung short of square, the
3896
4212
  // small corners.)
3897
4213
  .replace(
@@ -3936,9 +4252,90 @@ export function draftAnswer(ctx, env, question) {
3936
4252
  const {C} = ctx;
3937
4253
  const TARGET = ctx.project.target;
3938
4254
  const TOKENS = ctx.project.core.tokenDefaults;
4255
+ // "--brand-primary: #4f46e5; --brand-bg: #f9fafb": a custom property of
4256
+ // the app's own (no token of the editor's) is read by its last word, the
4257
+ // role it names, never by every word of its name.
4258
+ question = question.replace(
4259
+ /--([a-z][a-z0-9]*(?:-[a-z0-9]+)*?)-(primary|accent|brand|bg|background|surface|page|text|fg|foreground|radius|border|muted|secondary)(?![\w-])\s*:?\s*/gi,
4260
+ (m, pre, role) => {
4261
+ if (Object.hasOwn(TOKENS, `--${pre}-${role}`.toLowerCase())) return m;
4262
+ const said = /** @type {Record<string, string>} */ ({
4263
+ primary: 'accent ',
4264
+ accent: 'accent ',
4265
+ brand: 'accent ',
4266
+ bg: 'page background ',
4267
+ background: 'page background ',
4268
+ page: 'page background ',
4269
+ surface: 'card background ',
4270
+ text: 'text ',
4271
+ fg: 'text ',
4272
+ foreground: 'text ',
4273
+ radius: 'corners ',
4274
+ border: 'border color ',
4275
+ muted: 'secondary text ',
4276
+ secondary: 'secondary text ',
4277
+ })[String(role).toLowerCase()];
4278
+ return said ?? m;
4279
+ },
4280
+ );
3939
4281
  /** A part's rest color read, with the project's tokens. @param {Array<{token: string, when: string[]}>} reads @param {string} [when] */
3940
4282
  const restRead = (reads, when) => restColorRead(reads, when, TOKENS);
3941
4283
  const lex = partLexicon(ctx);
4284
+ // "make the blue a bit darker": a color named as the theme's own, with a
4285
+ // way, is the theme color whose hue it is (the accent when the accent is
4286
+ // blue), never a part.
4287
+ {
4288
+ /** @param {string} tok @returns {string} */
4289
+ const roleNow = tok => {
4290
+ let v = String(
4291
+ env.own?.light?.[tok] ?? env.base.light?.[tok] ?? TOKENS[tok] ?? '',
4292
+ );
4293
+ for (let i = 0; i < 4; i++) {
4294
+ const ref = /^var\(\s*(--[a-z0-9-]+)\s*\)$/i.exec(v.trim())?.[1];
4295
+ if (!ref) break;
4296
+ v = String(
4297
+ env.own?.light?.[ref] ?? env.base.light?.[ref] ?? TOKENS[ref] ?? '',
4298
+ );
4299
+ }
4300
+ return v;
4301
+ };
4302
+ const ROLES = /** @type {Array<[string, string]>} */ ([
4303
+ ['--color-accent', 'accent color'],
4304
+ ['--color-error', 'danger color'],
4305
+ ['--color-success', 'success color'],
4306
+ ['--color-warning', 'warning color'],
4307
+ ['--color-info', 'info color'],
4308
+ ]);
4309
+ question = question.replace(
4310
+ /\bthe\s+([a-z]+)\b(?=\s+(?:color\s+)?(?:a\s+(?:bit|little|touch)\s+|slightly\s+|much\s+|way\s+)?(?:darker|lighter|brighter|deeper|softer|warmer|cooler|calmer|duller|bolder|more\s+[a-z]+|less\s+[a-z]+)\b)/gi,
4311
+ (m, name) => {
4312
+ const word = String(name).toLowerCase();
4313
+ if (lex.parts.some(([re]) => re.test(` ${word} `))) return m;
4314
+ const said = colorsIn(word)[0];
4315
+ const h = said ? hueOf(said) : null;
4316
+ if (h == null) return m;
4317
+ const near = ROLES.map(([tok, label]) => {
4318
+ const hr = hueOf(roleNow(tok));
4319
+ const d =
4320
+ hr == null
4321
+ ? 999
4322
+ : Math.min(Math.abs(hr - h), 360 - Math.abs(hr - h));
4323
+ return {label, d};
4324
+ }).sort((a, b) => a.d - b.d)[0];
4325
+ return near && near.d <= 30 ? `the ${near.label}` : m;
4326
+ },
4327
+ );
4328
+ }
4329
+ // "17px like iOS": a value said with where it comes from; a name after
4330
+ // "like" that is no part of the editor's is the source, never words to
4331
+ // read.
4332
+ question = question.replace(
4333
+ /(\d(?:px|rem|em|pt)?)\s+(?:just\s+)?like\s+(?:on\s+|in\s+)?([a-z][a-z0-9.]*)\b/gi,
4334
+ (m, v, name) =>
4335
+ lex.parts.some(([re]) => re.test(` ${String(name).toLowerCase()} `))
4336
+ ? m
4337
+ : v,
4338
+ );
3942
4339
 
3943
4340
  // "focus-ring", "table_row": a word of the editor's vocabulary written
3944
4341
  // with hyphens or underscores reads as the same words with spaces, for
@@ -4446,6 +4843,61 @@ export function draftAnswer(ctx, env, question) {
4446
4843
  : `${level} font size calc(${Number(f.toFixed(3))} * var(${tok}))`;
4447
4844
  },
4448
4845
  )
4846
+ // "the hovered item of menus blue and the disabled one gray": "the
4847
+ // disabled one" is the element named, in its place, never the place.
4848
+ .replace(
4849
+ /\b([a-z]+)\s+((?:of|in|inside|within)\s+(?:the\s+)?[a-z]+)\b([^,;.\n]*?)\band the (active|selected|current|disabled|hovered|focused|checked|open) ones?\b/gi,
4850
+ (m, noun, place, mid, st) => {
4851
+ const w = String(noun).toLowerCase().replace(/s$/, '');
4852
+ // (A part's own word, or the last word of a part's name: a menu's
4853
+ // item.)
4854
+ const isPart =
4855
+ lex.parts.some(([re]) => re.test(` ${w} `)) ||
4856
+ [...ctx.project.target.keys()].some(k => k.endsWith(`-${w}`));
4857
+ return isPart
4858
+ ? `${noun} ${place}${mid}and the ${st} ${noun} ${place}`
4859
+ : m;
4860
+ },
4861
+ )
4862
+ // "the selected tab text white and the others gray", "primary buttons
4863
+ // blue and the others gray": the others are the same parts but that
4864
+ // state or variant, read as an except, its own ask.
4865
+ .replace(
4866
+ /^(.*?)\band\s+(?:all\s+)?the\s+(?:others?|rest)\b([^,;.\n]*)/gim,
4867
+ (m, before, after) => {
4868
+ const pairs = [
4869
+ ...String(before).matchAll(
4870
+ /(?=\b([a-z]+)\s+([a-z]+?)(s?)((?:\s+(?:text|background|border|fill|icons?|labels?))?)\b)/gi,
4871
+ ),
4872
+ ].reverse();
4873
+ for (const [, qual, noun, , aspect] of pairs) {
4874
+ const q = String(qual).toLowerCase();
4875
+ const part = lex.parts.find(([re]) =>
4876
+ re.test(` ${String(noun).toLowerCase()} `),
4877
+ )?.[1];
4878
+ if (!part || part.missing) continue;
4879
+ const base = FAMILIES[part.on] ? FAMILIES[part.on][0] : part.on;
4880
+ // (A variant: the part's other values on that axis, each named,
4881
+ // as a list of variants is. A state: the part not in it.)
4882
+ const axis = Object.values(ctx.C.variantValues(base) ?? {}).find(
4883
+ vals => /** @type {string[]} */ (vals).map(String).includes(q),
4884
+ );
4885
+ if (axis) {
4886
+ const rest = /** @type {string[]} */ (axis)
4887
+ .map(String)
4888
+ .filter(v => v !== q && !/^(?:default|md)$/.test(v));
4889
+ if (!rest.length) continue;
4890
+ return [
4891
+ String(before).replace(/[\s,]+$/, ''),
4892
+ ...rest.map(v => `the ${v} ${noun}s${aspect}${after}`),
4893
+ ].join('; ');
4894
+ }
4895
+ if (stateWord(q) == null) continue;
4896
+ return `${String(before).replace(/[\s,]+$/, '')}; the un${q} ${noun}s${aspect}${after}`;
4897
+ }
4898
+ return m;
4899
+ },
4900
+ )
4449
4901
  // "the nav links bolder and the active one blue": "the active one" is
4450
4902
  // the same parts in that state.
4451
4903
  .replace(
@@ -4942,7 +5394,16 @@ export function draftAnswer(ctx, env, question) {
4942
5394
  // "muted ones", "the muted card", "the muted background": the muted
4943
5395
  // variant or token it names, not a color ask.
4944
5396
  /(?<![-\w])(?:more )?(?:muted|pastel|duller|subdued|desaturated)(?![-\w])(?! (?:ones?|cards?|buttons?|badges?|variant|backgrounds?|surfaces?|bg|text)\b)/gi,
4945
- 'less saturated',
5397
+ // ("pastel pink": a shade of the hue named, read by the color reader.)
5398
+ (m, at, whole) =>
5399
+ /^pastel$/i.test(m) &&
5400
+ colorsIn(
5401
+ (
5402
+ /^\s+([a-z]+)/i.exec(String(whole).slice(at + m.length))?.[1] ?? ''
5403
+ ).toLowerCase(),
5404
+ ).length
5405
+ ? m
5406
+ : 'less saturated',
4946
5407
  )
4947
5408
  // "less sharp", "less thick", "less round": the opposite word.
4948
5409
  .replace(/\bless (?:sharp|square|angular|boxy)\b/gi, 'rounder')
@@ -5222,10 +5683,12 @@ export function draftAnswer(ctx, env, question) {
5222
5683
  /\b(\d+(?:\.\d+)?)pt\b/gi,
5223
5684
  (_, n) => `${Math.round((Number(n) * 4) / 3)}px`,
5224
5685
  )
5225
- // "a 1px border instead of a shadow": no shadow, and the border.
5686
+ // "a 1px border instead of a shadow": the border, and no shadow (on
5687
+ // the part the ask names: "inputs filled gray instead of outlined"
5688
+ // takes the inputs' outline away, never every border).
5226
5689
  .replace(
5227
5690
  /^(.*?)\binstead of (?:a |an |the )?([a-z]+(?: [a-z]+)?)\b/gim,
5228
- (m, a, b) => (a.trim() ? `no ${b} ; ${a}` : m),
5691
+ (m, a, b) => (a.trim() ? `${a.trim()} ; no ${b}` : m),
5229
5692
  )
5230
5693
  // "why are my headings not bold": the complaint asks for bold.
5231
5694
  .replace(/\bwhy (?:is|are|isn'?t|aren'?t)\b(.*?)\bnot\s+/gi, 'make$1 ')
@@ -5671,6 +6134,29 @@ export function draftAnswer(ctx, env, question) {
5671
6134
  );
5672
6135
  const media = MEDIA_RE.test(q);
5673
6136
  if (media) q = q.replace(MEDIA_RE, ' ').replace(/\s+/g, ' ').trim();
6137
+ // Two colors of the whole theme joined by "and" before one way ("the
6138
+ // accent and danger darker", "--color-accent and --color-danger
6139
+ // darker"): each takes that way, as two parts joined by "and" do.
6140
+ {
6141
+ const COLOR = `(?:--[a-z][a-z0-9-]*|${PALETTE_DIALS.join('|')})`;
6142
+ q = q.replace(
6143
+ new RegExp(
6144
+ `\\b(?:the\\s+)?(${COLOR})((?:\\s*,\\s*(?:the\\s+)?${COLOR})*)\\s*,?\\s+and\\s+(?:the\\s+)?(${COLOR})\\s+(?!and\\b)([^,;.]+)`,
6145
+ 'g',
6146
+ ),
6147
+ (all, first, more, last, ask) =>
6148
+ [
6149
+ first,
6150
+ ...String(more)
6151
+ .split(',')
6152
+ .map(x => x.replace(/^\s*(?:the\s+)?/, '').trim())
6153
+ .filter(Boolean),
6154
+ last,
6155
+ ]
6156
+ .map(x => `${x} ${ask.trim()}`)
6157
+ .join(' and '),
6158
+ );
6159
+ }
5674
6160
  const clauses0 = clausesOf(q, lex.parts);
5675
6161
  // "cream background, terracotta accent, serif headings": a list whose
5676
6162
  // items each ask their own thing is each of them, never the first one's
@@ -5869,7 +6355,12 @@ export function draftAnswer(ctx, env, question) {
5869
6355
  // A look taken away from the part before ("rounded buttons, no
5870
6356
  // shadow"; never "serif headings, no shadows": a text part's look is
5871
6357
  // its type).
5872
- if (c.neg && own.length && !before.parts.every(p => textOnlyPart(p.on)))
6358
+ if (
6359
+ c.neg &&
6360
+ own.length &&
6361
+ !own.includes('text') &&
6362
+ !before.parts.every(p => textOnlyPart(p.on))
6363
+ )
5873
6364
  return 'inherit';
5874
6365
  // A CSS property named with its value ("card padding-block 20px,
5875
6366
  // padding-inline 16px"): a declaration list, the part's.
@@ -5889,8 +6380,18 @@ export function draftAnswer(ctx, env, question) {
5889
6380
  if (own.length && own.every(a => a === 'text') && pageBefore)
5890
6381
  return 'theme';
5891
6382
  if (j.sep === 'with' || j.list === 'colon') return 'inherit';
5892
- // Only a way, a value or a color: the same part.
5893
- if (!own.length) return 'inherit';
6383
+ // (The part's text in its with-list: "badges with a subtle background
6384
+ // and dark text".)
6385
+ if (j.list === 'with' && own.length && own.every(a => a === 'text'))
6386
+ return 'inherit';
6387
+ // Only a way, a value or a color, said with "and" or as a bare
6388
+ // fragment ("rounder and darker", ", red"): the same part. A comma
6389
+ // item with words of its own ("magenta #ff00e6 for highlights") is not
6390
+ // the part before's.
6391
+ if (!own.length)
6392
+ return j.sep === 'and' || c.text.trim().split(/\s+/).length <= 2
6393
+ ? 'inherit'
6394
+ : 'theme';
5894
6395
  // (The theme's spacing said as a dial, never a part's padding or gap.)
5895
6396
  if (
5896
6397
  own.some(a => THEME_ASPECTS.includes(a)) ||
@@ -5898,6 +6399,15 @@ export function draftAnswer(ctx, env, question) {
5898
6399
  !/\b(?:padding|gaps?|margins?|inset)\b|\bpadding-/.test(c.text))
5899
6400
  )
5900
6401
  return 'theme';
6402
+ // A list item said subject first, "text #111827", "border #e5e7eb",
6403
+ // in a comma list of tokens: its own item, the theme's.
6404
+ if (
6405
+ j.sep === 'comma' &&
6406
+ /^(?:text|muted text|secondary text|borders?|background|links?|accent)\s+(?:#|rgb|hsl|oklch|var\()/.test(
6407
+ c.text.trim(),
6408
+ )
6409
+ )
6410
+ return 'theme';
5901
6411
  // A text color: the part's, when it holds text.
5902
6412
  if (own.every(a => a === 'text'))
5903
6413
  return c.colors.length && !before.parts.every(p => textOnlyPart(p.on))
@@ -5948,8 +6458,14 @@ export function draftAnswer(ctx, env, question) {
5948
6458
  // (Only for a look said as a look, "a theme in navy", or a color said
5949
6459
  // alone; never a statement, "I set the accent to red by mistake", nor a
5950
6460
  // color another dial names, "a more muted success green".)
6461
+ // (Or a look said as a list, "clean and trustworthy like a bank: blue
6462
+ // and gray, lots of data": several pieces and no part named.)
6463
+ const lookList =
6464
+ !clauses.some(c => c.parts.length > 0) &&
6465
+ q.split(/[,;:]|\band\b/).filter(x => x.trim()).length >= 3;
5951
6466
  const lookSaid =
5952
- /\b(?:theme|look|feel|vibe|style|palette|brand|branding)\b/.test(q);
6467
+ /\b(?:theme|look|feel|vibe|style|palette|brand|branding)\b/.test(q) ||
6468
+ lookList;
5953
6469
  const namesAPart = clauses.some(c => c.parts.length > 0);
5954
6470
  for (let i = clauses.length - 1; i >= 0 && !paintsAPart && !namesAPart; i--) {
5955
6471
  const c = clauses[i];
@@ -6080,7 +6596,10 @@ export function draftAnswer(ctx, env, question) {
6080
6596
  for (const [ci, c] of [...clauses.entries()].reverse())
6081
6597
  if (
6082
6598
  c.lengths.some(l => /^\d*\.?\d+(?:px|rem|em)$/.test(l)) &&
6083
- /\b(?:text|labels?|font|type|letters)\b/.test(c.text) &&
6599
+ // (Uppercase or italic is the text's look whatever the words: "table
6600
+ // headers uppercase 11px".)
6601
+ (/\b(?:text|labels?|font|type|letters)\b/.test(c.text) ||
6602
+ c.aspects.some(a => a === 'case' || a === 'italic')) &&
6084
6603
  c.aspects.some(a =>
6085
6604
  ['case', 'weight', 'italic', 'tracking', 'family'].includes(a),
6086
6605
  ) &&
@@ -6105,6 +6624,46 @@ export function draftAnswer(ctx, env, question) {
6105
6624
  });
6106
6625
  c.lengths = [];
6107
6626
  }
6627
+ // ("badges uppercase bold": two looks of a part's text said together are
6628
+ // each an ask of their own, run in turn.)
6629
+ const TEXT_LOOKS = ['case', 'weight', 'italic', 'tracking', 'fontsize'];
6630
+ for (const [ci, c] of [...clauses.entries()].reverse()) {
6631
+ // ("large bold headings", "bigger, bolder headings": a heading's size
6632
+ // word beside its weight is its text size.)
6633
+ if (
6634
+ c.parts.length &&
6635
+ c.parts.every(p =>
6636
+ /(?:^|-)(?:heading|title)s?$/.test(String(p.on).split('|')[0]),
6637
+ ) &&
6638
+ c.aspects.some(
6639
+ a => a === 'size' || (TEXT_LOOKS.includes(a) && a !== 'fontsize'),
6640
+ ) &&
6641
+ !c.aspects.includes('fontsize') &&
6642
+ /\b(?:large|larger|big|bigger|huge|giant|small|smaller|tiny)\b(?![\s-]*caps\b)/.test(
6643
+ c.text,
6644
+ )
6645
+ )
6646
+ c.aspects = [...c.aspects.filter(a => a !== 'size'), 'fontsize'];
6647
+ const looks = c.aspects.filter(a => TEXT_LOOKS.includes(a));
6648
+ if (
6649
+ !c.parts.length ||
6650
+ looks.length < 2 ||
6651
+ looks.length !== c.aspects.length ||
6652
+ c.except ||
6653
+ c.neg
6654
+ )
6655
+ continue;
6656
+ c.aspects = [looks[0]];
6657
+ clauses.splice(
6658
+ ci + 1,
6659
+ 0,
6660
+ ...looks.slice(1).map(a => ({
6661
+ ...c,
6662
+ parts: c.parts.map(x => ({...x})),
6663
+ aspects: [a],
6664
+ })),
6665
+ );
6666
+ }
6108
6667
  // ("make it calmer", "the error toast calmer": its color, the fill it
6109
6668
  // shows.)
6110
6669
  for (const c of clauses)
@@ -6162,6 +6721,7 @@ export function draftAnswer(ctx, env, question) {
6162
6721
  !a.except &&
6163
6722
  b.state &&
6164
6723
  b.state !== a.state &&
6724
+ [a.state, b.state].some(st => !MOMENT_STATES.includes(String(st))) &&
6165
6725
  !b.alsoState &&
6166
6726
  (!b.parts.length ||
6167
6727
  b.parts.every(x => a.parts.some(y => y.on === x.on))) &&
@@ -6282,6 +6842,8 @@ export function draftAnswer(ctx, env, question) {
6282
6842
  const symDone = new Set();
6283
6843
  /** Places the question names that the editor cannot keep apart. @type {Array<{c: any, text: string}>} */
6284
6844
  const placeNotes = [];
6845
+ /** The other reading of two states said together, as a line. @type {Draft[]} */
6846
+ const otherReadings = [];
6285
6847
  /** Clauses whose every step was kept to their container. @type {Set<any>} */
6286
6848
  const keptInPlace = new Set();
6287
6849
  // "checkboxes green": the color a checked box fills with (the checks
@@ -7047,6 +7609,30 @@ export function draftAnswer(ctx, env, question) {
7047
7609
  if (/-label$/.test(k) && stems.has(k.split('-')[0]))
7048
7610
  found.push({k, score: 60 - k.split('-').length});
7049
7611
  }
7612
+ // A group part holds the parts it is the group of (a toggle button
7613
+ // group's buttons are its toggle buttons): the part named by the
7614
+ // group's name without its last word, by that part's last word.
7615
+ for (const h of members)
7616
+ if (/-group$/.test(h)) {
7617
+ const stem = h.replace(/-group$/, '');
7618
+ if (
7619
+ keys.includes(stem) &&
7620
+ words(stem.split('-').at(-1) ?? '').test(nameText)
7621
+ )
7622
+ found.push({k: stem, score: 45});
7623
+ }
7624
+ // A thing the place does not draw itself whose name only one part of
7625
+ // the catalog ends with ("the date picker's days": the calendar's
7626
+ // day, the one day there is), said as that part.
7627
+ if (!found.length && by === 'possessive') {
7628
+ const last = String(said).trim().split(/\s+/).at(-1) ?? '';
7629
+ const ending = keys.filter(
7630
+ k =>
7631
+ k.split('-').length > 1 &&
7632
+ words(k.split('-').at(-1) ?? '').test(last),
7633
+ );
7634
+ if (ending.length === 1) found.push({k: ending[0], score: 5});
7635
+ }
7050
7636
  // A group of parts the place holds, named ("the buttons' icons").
7051
7637
  const group = Object.keys(FAMILIES).find(
7052
7638
  g =>
@@ -7175,9 +7761,17 @@ export function draftAnswer(ctx, env, question) {
7175
7761
  : (ctx.project.target.get(k)?.states ?? [])
7176
7762
  .filter(
7177
7763
  (/** @type {string} */ st) =>
7178
- !/^(hover|active|focus|focus-visible|focus-within|disabled|selected|checked|open|expanded|pressed|current)$/.test(
7764
+ !/^(hover|active|focus|focus-visible|focus-within|disabled)$/.test(
7765
+ st,
7766
+ ) &&
7767
+ words(st).test(elementText) &&
7768
+ // (A state many parts take, selected or checked,
7769
+ // only with the part's own word said: "the
7770
+ // selected day" is a calendar's day.)
7771
+ (!/^(selected|checked|open|expanded|pressed|current)$/.test(
7179
7772
  st,
7180
- ) && words(st).test(elementText),
7773
+ ) ||
7774
+ words(String(k.split('-').at(-1))).test(elementText)),
7181
7775
  )
7182
7776
  .map((/** @type {string} */ st) => ({k, st})),
7183
7777
  )
@@ -8104,6 +8698,24 @@ export function draftAnswer(ctx, env, question) {
8104
8698
  ?.find(t => /title/.test(t) && t !== ts0(owner.on));
8105
8699
  if (title && C.MAP[title]) c.parts = [{on: title}];
8106
8700
  }
8701
+ // "selected tab text white, unselected tabs gray": a clause naming the
8702
+ // same part in another state, with only its color, says the same thing
8703
+ // of it as the clause before.
8704
+ for (let i = 1; i < clauses.length; i++) {
8705
+ const [b, c] = [clauses[i - 1], clauses[i]];
8706
+ if (
8707
+ c.except ||
8708
+ b.except ||
8709
+ !c.parts.length ||
8710
+ (ownAspects.get(c) ?? c.aspects).length ||
8711
+ !c.colors.length ||
8712
+ !b.aspects.length ||
8713
+ (b.state ?? '') === (c.state ?? '') ||
8714
+ !c.parts.every(p => b.parts.some(x => x.on === p.on))
8715
+ )
8716
+ continue;
8717
+ c.aspects = [...b.aspects];
8718
+ }
8107
8719
  fillAspect();
8108
8720
  for (let i = 0; i < clauses.length; i++) {
8109
8721
  const c = clauses[i];
@@ -8234,12 +8846,18 @@ export function draftAnswer(ctx, env, question) {
8234
8846
  // "on focus, inputs get a 2px outline": a clause that only names a state
8235
8847
  // gives it to the clause after it.
8236
8848
  // (Never an except's state: "except when focused, and rounder".)
8849
+ // (Only from a clause that names nothing but the state: "primary hover
8850
+ // #4338ca" asks for a value of its own, and gives the next clause
8851
+ // nothing.)
8237
8852
  if (
8238
8853
  !c.state &&
8239
8854
  prev?.state &&
8240
8855
  !prev.except &&
8241
8856
  !prev.parts.length &&
8242
8857
  !prev.aspects.length &&
8858
+ !prev.colors.length &&
8859
+ !prev.lengths.length &&
8860
+ !prev.dir &&
8243
8861
  c.parts.length
8244
8862
  )
8245
8863
  c.state = prev.state;
@@ -8258,6 +8876,8 @@ export function draftAnswer(ctx, env, question) {
8258
8876
  !c.state &&
8259
8877
  // (An except's mode is what it keeps: "except primary in dark mode".)
8260
8878
  !c.except &&
8879
+ // (The mode the app opens in is the theme's, scoping nothing.)
8880
+ !/\bby default\b|\bopens? in\b|\bstarts? in\b/.test(c.text) &&
8261
8881
  !prev.mode &&
8262
8882
  (prev.parts.length || prev.aspects.length)
8263
8883
  ) {
@@ -8393,7 +9013,10 @@ export function draftAnswer(ctx, env, question) {
8393
9013
  !modal ||
8394
9014
  /\b(?:(?:in\s+)?(?:both|all)\s+modes|every\s+mode|everywhere|light\s+and\s+dark|dark\s+and\s+light)\b/i.test(
8395
9015
  `${c.text} ${question}`,
8396
- )
9016
+ ) ||
9017
+ // (Said with a one-mode theme, "dark only … page #x", the theme
9018
+ // has one mode: its page needs none.)
9019
+ /\b(?:dark|light)[- ](?:mode[- ])?only\b/.test(q)
8397
9020
  )
8398
9021
  return null;
8399
9022
  const rgb = parseColor(String(color));
@@ -8405,6 +9028,55 @@ export function draftAnswer(ctx, env, question) {
8405
9028
  ? 'dark'
8406
9029
  : null;
8407
9030
  };
9031
+ /**
9032
+ * A color at another color's lightness: the amount toward white or black
9033
+ * whose luminance is that color's (a color word's tone for a mode's page
9034
+ * or surface).
9035
+ * @param {string} color
9036
+ * @param {string} like
9037
+ */
9038
+ const toneLike = (color, like) => {
9039
+ const target = parseColor(like);
9040
+ if (!target || !parseColor(color)) return null;
9041
+ const want = ratio(target, [0, 0, 0]);
9042
+ let lo = -1;
9043
+ let hi = 1;
9044
+ for (let k = 0; k < 24; k++) {
9045
+ const mid = (lo + hi) / 2;
9046
+ const v = parseColor(shift(color, mid) ?? '');
9047
+ if (!v) return null;
9048
+ if (ratio(v, [0, 0, 0]) < want) lo = mid;
9049
+ else hi = mid;
9050
+ }
9051
+ return shift(color, (lo + hi) / 2);
9052
+ };
9053
+ /**
9054
+ * A page color said as a word ("make it gray") that is neither clearly
9055
+ * light nor clearly dark, on a theme that draws both modes: each mode's
9056
+ * page takes the word's color at that page's own lightness, so neither
9057
+ * mode gets a mid-tone page under its text. Null when the color was
9058
+ * typed, a mode or both modes were said, or the theme draws one mode.
9059
+ * @param {Clause} c
9060
+ * @param {string} color
9061
+ * @returns {{light: string, dark: string} | null}
9062
+ */
9063
+ const pageTones = (c, color) => {
9064
+ if (!modal || c.mode || pageModeOf(c, color)) return null;
9065
+ if (
9066
+ /\b(?:(?:in\s+)?(?:both|all)\s+modes|every\s+mode|everywhere|light\s+and\s+dark|dark\s+and\s+light)\b/i.test(
9067
+ `${c.text} ${question}`,
9068
+ ) ||
9069
+ question.toLowerCase().includes(String(color).toLowerCase())
9070
+ )
9071
+ return null;
9072
+ if (!parseColor(color)) return null;
9073
+ /** @param {'light' | 'dark'} m */
9074
+ const tone = m =>
9075
+ toneLike(color, String(current('--color-background-body', m) ?? ''));
9076
+ const light = tone('light');
9077
+ const dark = tone('dark');
9078
+ return light && dark ? {light, dark} : null;
9079
+ };
8408
9080
  /** How a page color's mode reads. @param {Clause} c @param {'light' | 'dark' | null} m */
8409
9081
  const pageModeSaid = (c, m) => {
8410
9082
  if (!m || !modal) return '';
@@ -8792,8 +9464,12 @@ export function draftAnswer(ctx, env, question) {
8792
9464
  // on inputs", "large padding on buttons", it is the amount.)
8793
9465
  const besidePart = (/** @type {string} */ w) =>
8794
9466
  !new RegExp(
8795
- String.raw`\b(?:${w})\s+(?:shadows?|padding|radius|corners?|borders?|gaps?|spacing|text|fonts?|type|outlines?|rings?|margins?)\b`,
8796
- ).test(c.text);
9467
+ String.raw`\b(?:${w})\s+(?:shadows?|padding|radius|corners?|borders?|gaps?|spacing|text|fonts?|type|outlines?|rings?|margins?|weight|bold|letters?|headings?)\b`,
9468
+ ).test(c.text) &&
9469
+ // ("buttons medium weight": a weight, never a size.)
9470
+ !new RegExp(String.raw`\b(?:${w})\s*(?:-\s*)?(?:weight|bold)\b`).test(
9471
+ c.text,
9472
+ );
8797
9473
  const size =
8798
9474
  /\b(small|sm)\b/.test(c.text) && besidePart('small|sm')
8799
9475
  ? ['sm', 'small']
@@ -9119,7 +9795,8 @@ export function draftAnswer(ctx, env, question) {
9119
9795
  // that mode (its width and style are the part's own).
9120
9796
  const color =
9121
9797
  new RegExp(COLOR_IN_VALUE.source, 'i').exec(value)?.[0] ??
9122
- colorsIn(value)[0];
9798
+ colorsIn(value)[0] ??
9799
+ /var\(--color-[a-z0-9-]+\)/.exec(value)?.[0];
9123
9800
  // (A state's look keeps the border the part draws at rest: a focused
9124
9801
  // input's line is its resting one, recolored.)
9125
9802
  const shows =
@@ -9157,6 +9834,15 @@ export function draftAnswer(ctx, env, question) {
9157
9834
  value: ring.value,
9158
9835
  ...(ring.when ? {when: ring.when} : {}),
9159
9836
  });
9837
+ // (No ring where the part draws its own shadow: the border itself,
9838
+ // its color see-through in the other mode, so that mode keeps the
9839
+ // look with an edge of the same width it cannot see.)
9840
+ if (!st.state)
9841
+ return held({
9842
+ ...st,
9843
+ mode: undefined,
9844
+ value: `${w} solid light-dark(${c.mode === 'light' ? `${color}, transparent` : `transparent, ${color}`})`,
9845
+ });
9160
9846
  shadowWhy = `${one(st.on)} draws no border now, so a border in ${c.mode} mode would take its width in the other mode too, and it draws a shadow of its own, so a ring in its box-shadow would take that away`;
9161
9847
  }
9162
9848
  return st;
@@ -9953,7 +10639,7 @@ export function draftAnswer(ctx, env, question) {
9953
10639
  * @param {Clause} c @param {string} chosen
9954
10640
  * @returns {string}
9955
10641
  */
9956
- const themeShade = (c, chosen) => {
10642
+ const themeShade = (c, chosen, mirror = false) => {
9957
10643
  for (const m of c.text.matchAll(/\b([a-z]+)\b/g)) {
9958
10644
  const word = m[1];
9959
10645
  if (!Object.hasOwn(HUES, word) || HUES[word] !== chosen) continue;
@@ -9984,13 +10670,32 @@ export function draftAnswer(ctx, env, question) {
9984
10670
  const light = nearestShade(ramp.light, chosen);
9985
10671
  const dark = nearestShade(ramp.dark, chosen);
9986
10672
  if (light == null || dark == null) return chosen;
9987
- const [l, d] = [ramp.light[light], ramp.dark[dark]];
10673
+ // (A gray on a surface: the light mode's step and its mirror in the
10674
+ // dark mode, so the surface stays as far from its page, and its text
10675
+ // as readable, in both.)
10676
+ const mirrored =
10677
+ mirror && family === 'neutral'
10678
+ ? ramp.dark[String(100 - Number(light))]
10679
+ : undefined;
10680
+ const [l, d] = [ramp.light[light], mirrored ?? ramp.dark[dark]];
9988
10681
  return String(l).toLowerCase() === String(d).toLowerCase()
9989
10682
  ? l
9990
10683
  : `light-dark(${l}, ${d})`;
9991
10684
  }
9992
10685
  return chosen;
9993
10686
  };
10687
+ /**
10688
+ * Whether every part a clause names is a surface: its resting fill a
10689
+ * background token, or no fill of its own (a header cell, an input).
10690
+ * @param {Clause} c
10691
+ */
10692
+ const onSurfaces = c =>
10693
+ c.parts.length > 0 &&
10694
+ c.parts.every(p => {
10695
+ const reads = C.partReads(one(p.on), 'background') ?? [];
10696
+ const tok = restRead(reads, '');
10697
+ return !reads.length || (!!tok && /^--color-background-/.test(tok));
10698
+ });
9994
10699
  /** A color for the clause, for a fill, a text or a border color. @param {Clause} c @param {'fill' | 'text' | 'border'} use */
9995
10700
  const colorFor = (c, use) => {
9996
10701
  // (A border's color is read as a fill's, but takes its own palette
@@ -10053,7 +10758,8 @@ export function draftAnswer(ctx, env, question) {
10053
10758
  c.text,
10054
10759
  );
10055
10760
  const said = fillWord ? colorsIn(fillWord[0]) : [];
10056
- if (said.length) return themeShade(c, said[0]);
10761
+ if (said.length)
10762
+ return themeShade(c, said[0], use === 'fill' && onSurfaces(c));
10057
10763
  // (Else never the color said before "text".)
10058
10764
  const textWord =
10059
10765
  /(?:(?:light|dark|pale|deep)\s+)?(?:#[0-9a-f]{3,8}|[a-z]+)\s+(?:text|labels?|writing|words|letters)\b/i.exec(
@@ -10061,14 +10767,15 @@ export function draftAnswer(ctx, env, question) {
10061
10767
  );
10062
10768
  const ink = textWord ? colorsIn(textWord[0])[0] : undefined;
10063
10769
  const other = c.colors.find(x => x !== ink);
10064
- if (ink && other) return themeShade(c, other);
10770
+ if (ink && other)
10771
+ return themeShade(c, other, use === 'fill' && onSurfaces(c));
10065
10772
  }
10066
10773
  if (
10067
10774
  kind === 'fill' &&
10068
10775
  c.colors.length &&
10069
10776
  !THEME_COLOR_WORDS.some(([re]) => re.test(c.text))
10070
10777
  )
10071
- return themeShade(c, c.colors[0]);
10778
+ return themeShade(c, c.colors[0], use === 'fill' && onSurfaces(c));
10072
10779
  for (const [re, fill, text] of THEME_COLOR_WORDS)
10073
10780
  if (re.test(ownText)) return kind === 'fill' ? fill : text;
10074
10781
  // "the color of the text", "the same color as the danger": a theme
@@ -10169,40 +10876,87 @@ export function draftAnswer(ctx, env, question) {
10169
10876
  if (steps.length) tops.push({clause: c, steps});
10170
10877
  };
10171
10878
 
10879
+ // "the pink page background is a bit much, make the page a warm cream":
10880
+ // a clause that says how a part looks now (its color before it, a
10881
+ // complaint after) is the reason for the ask after it on the same part,
10882
+ // never a value: it writes nothing of its own.
10883
+ for (let i = 0; i < clauses.length - 1; i++) {
10884
+ const c = clauses[i];
10885
+ const verb =
10886
+ /\b(?:is|are|looks?|feels?|seems?)\s+(?:a\s+bit\s+|a\s+little\s+|way\s+|kind\s+of\s+|far\s+|just\s+)?(?:too\s+\w+|much|too\s+much|overwhelming|loud|harsh|garish)\b/.exec(
10887
+ c.text,
10888
+ );
10889
+ if (!verb || c.except || !c.parts.length || !c.colors.length) continue;
10890
+ // (Its color said before the complaint: what the part is now.)
10891
+ if (!colorsIn(c.text.slice(0, verb.index)).length) continue;
10892
+ const later = clauses
10893
+ .slice(i + 1)
10894
+ .find(
10895
+ o =>
10896
+ !o.except &&
10897
+ (o.colors.length || o.dir) &&
10898
+ (!o.parts.length ||
10899
+ o.parts.some(p => c.parts.some(x => x.on === p.on))),
10900
+ );
10901
+ if (!later) continue;
10902
+ if (!later.parts.length) later.parts = c.parts.map(p => ({...p}));
10903
+ c.parts = [];
10904
+ c.colors = [];
10905
+ c.dir = null;
10906
+ c.text = '';
10907
+ }
10172
10908
  // "switches: track #e5e7eb when off": a part whose only selection
10173
10909
  // state is checked draws its unchecked look at rest, so the clause is
10174
10910
  // its resting look with the checked one kept, never every state.
10175
10911
  for (let i = clauses.length - 1; i >= 0; i--) {
10176
10912
  const c = clauses[i];
10913
+ // (The same for "unselected": the resting look, selected kept.)
10914
+ const on = /** @type {Record<string, string>} */ ({
10915
+ unchecked: 'checked',
10916
+ unselected: 'selected',
10917
+ })[c.state ?? ''];
10177
10918
  if (
10178
- c.state !== 'unchecked' ||
10919
+ !on ||
10179
10920
  c.except ||
10180
10921
  !c.parts.length ||
10181
10922
  !c.parts.every(
10182
10923
  p =>
10183
- statesOf(p.on).includes('checked') &&
10184
- !statesOf(p.on).includes('unchecked'),
10924
+ statesOf(p.on).includes(on) &&
10925
+ !statesOf(p.on).includes(String(c.state)),
10185
10926
  )
10186
10927
  )
10187
10928
  continue;
10188
10929
  c.state = null;
10930
+ // (When the ask says the kept state's own look too, "selected tab text
10931
+ // white, unselected tabs gray", that clause writes it: nothing more to
10932
+ // keep.)
10933
+ const said = clauses.some(
10934
+ o =>
10935
+ o !== c &&
10936
+ !o.except &&
10937
+ o.state === on &&
10938
+ o.parts.some(p => c.parts.some(x => x.on === p.on)),
10939
+ );
10189
10940
  // (Its state words are read: the resting look, checked kept.)
10941
+ // (The whole state phrase goes, the "when it is" before it included,
10942
+ // so the words the answer repeats never end on a bare "when".)
10190
10943
  c.text = c.text
10191
10944
  .replace(
10192
- /\b(?:unchecked|not checked|unticked|when off|turned off|toggled off|switched off|is off)\b/g,
10945
+ /(?:\bwhen\s+(?:(?:it|they)\s+(?:is|are)\s+|it'?s\s+|they'?re\s+)?|\b(?:is|are)\s+)?\b(?:unchecked|not checked|unticked|off|turned off|toggled off|switched off|unselected|not selected|non-selected)\b/g,
10193
10946
  ' ',
10194
10947
  )
10195
10948
  .replace(/\s+/g, ' ')
10196
10949
  .trim();
10950
+ if (said) continue;
10197
10951
  clauses.splice(i + 1, 0, {
10198
10952
  ...c,
10199
- text: `except checked ${c.parts.map(p => p.on).join(' and ')}`,
10953
+ text: `except ${on} ${c.parts.map(p => p.on).join(' and ')}`,
10200
10954
  aspects: [],
10201
10955
  colors: [],
10202
10956
  lengths: [],
10203
10957
  dir: null,
10204
10958
  decl: {},
10205
- state: 'checked',
10959
+ state: on,
10206
10960
  except: true,
10207
10961
  });
10208
10962
  }
@@ -11601,7 +12355,7 @@ export function draftAnswer(ctx, env, question) {
11601
12355
  now => {
11602
12356
  const n = parseColor(now);
11603
12357
  return n && n.every((x, i) => Math.abs(x - avoid[i]) <= 2)
11604
- ? nearOff(avoid)
12358
+ ? nearOff(avoid, themeNeutral)
11605
12359
  : null;
11606
12360
  },
11607
12361
  c,
@@ -13555,6 +14309,43 @@ export function draftAnswer(ctx, env, question) {
13555
14309
  for (const p of targets.slice(0, 3)) {
13556
14310
  for (const a of c.aspects.slice(0, 3)) {
13557
14311
  let d = answerFor(c, p, a);
14312
+ // The other reading of two states said together, as a second line:
14313
+ // each one alone for a condition list read at once ("the checked
14314
+ // and disabled checkboxes"), both at once for moment states read
14315
+ // as each ("hovered and pressed buttons").
14316
+ if (d?.options[0]?.length && p) {
14317
+ /** @param {Partial<Clause>} over */
14318
+ const reread = over => {
14319
+ const r = answerFor({...c, ...over}, p, a);
14320
+ const o = r?.options[0] ?? [];
14321
+ return o.length && env.check(o).ok ? o : null;
14322
+ };
14323
+ const prev = clauses[clauses.indexOf(c) - 1];
14324
+ /** @param {string} what @param {Step[]} steps */
14325
+ const other = (what, steps) =>
14326
+ otherReadings.push({
14327
+ text: `or ${what}: ${steps.map(st => renderStep(st, env.slug)).join(' && ')}`,
14328
+ options: [],
14329
+ });
14330
+ if (c.alsoState) {
14331
+ const one1 = reread({alsoState: null});
14332
+ const one2 = reread({state: c.alsoState, alsoState: null});
14333
+ if (one1 && one2) other('each state alone', [...one2, ...one1]);
14334
+ } else if (
14335
+ c.state &&
14336
+ prev?.state &&
14337
+ prev.state !== c.state &&
14338
+ !prev.alsoState &&
14339
+ MOMENT_STATES.includes(String(c.state)) &&
14340
+ MOMENT_STATES.includes(String(prev.state)) &&
14341
+ JSON.stringify(prev.parts) === JSON.stringify(c.parts) &&
14342
+ JSON.stringify(prev.colors) === JSON.stringify(c.colors) &&
14343
+ JSON.stringify(prev.aspects) === JSON.stringify(c.aspects)
14344
+ ) {
14345
+ const both = reread({state: prev.state, alsoState: c.state});
14346
+ if (both) other(`${prev.state} and ${c.state} at once`, both);
14347
+ }
14348
+ }
13558
14349
  // A part kept to its container ("buttons inside cards", "headings
13559
14350
  // in cards"): only a token the part reads, set on the container
13560
14351
  // (which the parts inside it read, and the container's own element
@@ -14520,12 +15311,21 @@ export function draftAnswer(ctx, env, question) {
14520
15311
  : ['background-color', 'background'];
14521
15312
  // (The variant's or status's own read in that state first: an error
14522
15313
  // input keeps its red when focused.)
15314
+ // (A state the part data records by its attribute, "checked=checked",
15315
+ // is that state too, as the pseudo-class ":checked" is.)
14523
15316
  const stateRead = (/** @type {string | null} */ need) =>
14524
15317
  C.partReads(one(p.on), group).find(
14525
15318
  r =>
14526
15319
  r.when.some(
14527
15320
  w =>
14528
- w.includes(`:${p.state}`) &&
15321
+ (w.includes(`:${p.state}`) ||
15322
+ w
15323
+ .split(/[ ,]/)
15324
+ .some(
15325
+ x =>
15326
+ x === `${p.state}=${p.state}` ||
15327
+ x === `${p.state}=true`,
15328
+ )) &&
14529
15329
  !/::before/.test(w) &&
14530
15330
  (!need || w.split(/[ ,]/).includes(need)),
14531
15331
  ) &&
@@ -14708,6 +15508,25 @@ export function draftAnswer(ctx, env, question) {
14708
15508
  const on = p?.on;
14709
15509
  const {noState, ...f} = p ? flagsFor(c, p) : {};
14710
15510
  if (noState && on) {
15511
+ // (The state is another part's, named by its own word in the ask,
15512
+ // "the date picker's selected day": the calendar day's, a part of the
15513
+ // plain component the place draws. Said, with its line, never
15514
+ // written: it reaches every one.)
15515
+ const other = [...ctx.project.target.keys()].filter(
15516
+ k =>
15517
+ k !== one(on) &&
15518
+ (ctx.project.target.get(k)?.states ?? []).includes(noState) &&
15519
+ new RegExp(`\\b${String(k.split('-').at(-1))}s?\\b`).test(c.text),
15520
+ );
15521
+ if (other.length === 1) {
15522
+ const k = other[0];
15523
+ const comp = ctx.project.target.get(k)?.component ?? k;
15524
+ return {
15525
+ text: `${on} has no ${noState} state: the ${noState} ${k.split('-').at(-1)} is ${k}'s, a part of the plain ${comp}, so a change there reaches every ${comp.toLowerCase()}; nothing is written. To change every ${comp.toLowerCase()}'s ${noState} ${k.split('-').at(-1)} instead, set it --on ${k} --state ${noState}`,
15526
+ options: [],
15527
+ lookup: `${HOW} ${k}`,
15528
+ };
15529
+ }
14711
15530
  return {
14712
15531
  text: `${on} has no ${noState} state that set can name (its states: ${statesOf(on).join(', ') || 'none'}), so a change would reach every ${on}`,
14713
15532
  options: [],
@@ -14727,14 +15546,29 @@ export function draftAnswer(ctx, env, question) {
14727
15546
  ? ['box-shadow']
14728
15547
  : ['border', 'border-color', 'border-width', 'border-style'];
14729
15548
  const rec = C.MAP[one(on)];
15549
+ // (Only a part its component draws inside the overlay, never one
15550
+ // that stands alone, a divider, nor one that draws a line of its
15551
+ // own.)
15552
+ const comp = ctx.project.target.get(one(on))?.component;
15553
+ const standalone =
15554
+ !comp ||
15555
+ ctx.project.components[String(comp)]?.targets?.[0]?.className ===
15556
+ `astryx-${one(on)}`;
14730
15557
  const holder =
14731
- rec && !props.some(x => rec.own?.[x] || rec.at?.[x])
15558
+ rec &&
15559
+ !standalone &&
15560
+ !(rec.line ?? []).length &&
15561
+ !props.some(x => rec.own?.[x] || rec.at?.[x])
14732
15562
  ? Object.keys(C.MAP)
14733
15563
  .filter(
14734
15564
  k =>
14735
15565
  k !== one(on) &&
14736
15566
  (C.MAP[k].contains ?? []).includes(one(on)) &&
14737
- props.some(x => C.MAP[k].own?.[x]) &&
15567
+ // (Its edge: the overlay's own shadow; for a border, the
15568
+ // surface it paints, whose edge the list sits inside.)
15569
+ (a === 'shadow'
15570
+ ? props.some(x => C.MAP[k].own?.[x])
15571
+ : Boolean(C.MAP[k].own?.['background-color'])) &&
14738
15572
  ctx.project.components[
14739
15573
  String(ctx.project.target.get(k)?.component ?? '')
14740
15574
  ]?.category === 'Overlay',
@@ -14747,7 +15581,7 @@ export function draftAnswer(ctx, env, question) {
14747
15581
  : undefined;
14748
15582
  if (holder)
14749
15583
  return {
14750
- text: `${on} draws no ${a} of its own: the ${holder} it opens in draws it, and a change on ${holder} reaches every ${holder}; nothing is written. To change every ${holder}'s ${a}, set it --on ${holder}`,
15584
+ text: `${on} draws no ${a} of its own: the ${holder} it opens in ${a === 'shadow' ? 'draws it' : 'is the surface whose edge it is'}, and a change on ${holder} reaches every ${holder}; nothing is written. To change every ${holder}'s ${a}, set it --on ${holder}`,
14751
15585
  options: [],
14752
15586
  lookup: `${HOW} ${holder}`,
14753
15587
  };
@@ -15360,6 +16194,20 @@ export function draftAnswer(ctx, env, question) {
15360
16194
  ],
15361
16195
  sequence: true,
15362
16196
  };
16197
+ // (A color word in neither mode's lightness, with no text said with
16198
+ // it: each mode's page takes it at its own.)
16199
+ const tones = pageTones(c, String(color));
16200
+ if (tones)
16201
+ return {
16202
+ text: `the page background: --color-background-body, ${color}'s color at each mode's own page lightness (${tones.light} in light mode, ${tones.dark} in dark mode), so both pages keep their text readable`,
16203
+ options: [
16204
+ [
16205
+ set('--color-background-body', tones.light, {mode: 'light'}),
16206
+ set('--color-background-body', tones.dark, {mode: 'dark'}),
16207
+ ],
16208
+ ],
16209
+ sequence: true,
16210
+ };
15363
16211
  return {
15364
16212
  text: `the page background: --color-background-body${pageModeSaid(c, pageMode)}${panel ? `; the main panel (layout-content) draws ${panel} over it, so the second line paints the frame and the main panel too` : ''}`,
15365
16213
  options: [
@@ -16884,28 +17732,25 @@ export function draftAnswer(ctx, env, question) {
16884
17732
  sequence: steps.length > 1,
16885
17733
  };
16886
17734
  }
16887
- // Darker, lighter, subtler or more contrast asks for the color.
17735
+ // Darker, lighter, subtler, more contrast or how visible (or
17736
+ // transparent) asks for the color.
17737
+ const seen = visibilityAsk(c.text);
16888
17738
  if (
16889
- /\b(darker|lighter|subtle\w*|contrast|stronger|fainter|softer|visible|invisible|too (dark|light|faint|strong|harsh|heavy))\b/.test(
17739
+ seen ||
17740
+ /\b(darker|lighter|subtle\w*|contrast|stronger|fainter|softer|too (dark|light|faint|strong|harsh|heavy))\b/.test(
16890
17741
  c.text,
16891
17742
  )
16892
17743
  ) {
16893
17744
  // "too light" asks for stronger borders, "too dark" for fainter.
16894
17745
  // Visibility is the border's strength: "less visible", "half as
16895
- // visible", "barely visible" are fainter, by the share named.
16896
- const lessVisible =
16897
- /\b(?:less|half as|barely|hardly|not as|a lot less|much less)\s+visible\b|\binvisible\b/.test(
16898
- c.text,
16899
- );
16900
- const more =
16901
- (/\b(darker|stronger|more contrast|visible|too (light|faint|subtle))\b/.test(
16902
- c.text,
16903
- ) &&
16904
- !lessVisible) ||
16905
- false;
16906
- const visibleBy = /\bvisible\b/.test(c.text)
16907
- ? exactFactor(c.text)
16908
- : null;
17746
+ // visible", "more transparent" are fainter, "half as
17747
+ // transparent" stronger, by the share named (visibilityAsk).
17748
+ const more = seen
17749
+ ? seen.stronger
17750
+ : /\b(darker|stronger|more contrast|too (light|faint|subtle))\b/.test(
17751
+ c.text,
17752
+ );
17753
+ const visibleBy = seen?.by ?? null;
16909
17754
  // A named mode with darker or lighter moves the border that way
16910
17755
  // as it paints on that mode's page ("lighter in dark mode" is
16911
17756
  // more of a light ink); otherwise darker is more contrast.
@@ -16988,6 +17833,59 @@ export function draftAnswer(ctx, env, question) {
16988
17833
  return null;
16989
17834
  const color = colorFor(c, 'border');
16990
17835
  const w = c.lengths[0];
17836
+ // A ring said with no focus ("cards: 1px ring #e5e7eb", as a
17837
+ // ring is written in CSS utilities) is a ring at rest: a
17838
+ // box-shadow of that width and color; the focus ring only when
17839
+ // focus is said.
17840
+ const focusSaid =
17841
+ Boolean(f.state && /focus/.test(f.state)) ||
17842
+ /\bfocus(?:ed|ing|-visible|-within)?\b/.test(c.text);
17843
+ if (on && !focusSaid && !c.neg && color) {
17844
+ // The ring goes in front of the shadow the part shows now (the
17845
+ // theme's own, else the shadow token Core draws it with), so
17846
+ // its own shadow stays, as an input's ring sits beside its
17847
+ // bevel.
17848
+ const ring = `0 0 0 ${w ?? '1px'} ${color}`;
17849
+ const rests = C.partReads(one(on), 'shadow') ?? [];
17850
+ const coreShadow = (
17851
+ rests.find(
17852
+ r =>
17853
+ r.props.includes('box-shadow') &&
17854
+ r.when.includes(f.when ?? '') &&
17855
+ /^--shadow-/.test(r.token),
17856
+ ) ??
17857
+ rests.find(
17858
+ r =>
17859
+ r.props.includes('box-shadow') &&
17860
+ r.when.includes('') &&
17861
+ /^--shadow-/.test(r.token),
17862
+ )
17863
+ )?.token;
17864
+ // (What Core draws there at rest, as the census read it: the
17865
+ // render asked for, else its first render with no state; a
17866
+ // card's ring and elevation layers stay in it.)
17867
+ const drawn = Object.entries(
17868
+ C.MAP[one(on)]?.at?.['box-shadow'] ?? {},
17869
+ ).filter(([k]) => !/:/.test(k));
17870
+ const coreDrawn = ((f.when
17871
+ ? drawn.find(([k]) =>
17872
+ k.split(',').includes(String(f.when).replace(':', '=')),
17873
+ )
17874
+ : undefined) ?? drawn[0])?.[1];
17875
+ const shows =
17876
+ (f.state || c.mode || f.when
17877
+ ? null
17878
+ : partValue(on, 'box-shadow')) ??
17879
+ coreDrawn ??
17880
+ (coreShadow ? `var(${coreShadow})` : null);
17881
+ const keep = shows && !/^\s*none\s*$/i.test(shows) ? shows : null;
17882
+ return {
17883
+ text: `a ring at rest${where}: box-shadow ${ring}${keep ? `, in front of the shadow it shows now (${keep})` : ''}, shown always (for the ring shown while focused, say "focus ring")`,
17884
+ options: [
17885
+ [set('box-shadow', keep ? `${ring}, ${keep}` : ring, f)],
17886
+ ],
17887
+ };
17888
+ }
16991
17889
  const fl = {...f, state: f.state ?? 'focus-visible'};
16992
17890
  /** @type {Step[]} */
16993
17891
  const steps = [
@@ -17169,9 +18067,7 @@ export function draftAnswer(ctx, env, question) {
17169
18067
  // at a lower alpha, on the part (the looks that draw no border
17170
18068
  // stay without one); a part that draws none has none to fade.
17171
18069
  if (
17172
- /\b(?:less (?:visible|noticeable|prominent|obvious)|half as (?:visible|noticeable|strong)|fainter|subtler|more (?:transparent|see-through)|weaker)\b/.test(
17173
- c.text,
17174
- ) &&
18070
+ visibilityAsk(c.text)?.stronger === false &&
17175
18071
  !/\b(?:thin|thick|width|wide|px)\w*/.test(c.text)
17176
18072
  ) {
17177
18073
  const read = restRead(C.partReads(one(on), 'border'), f.when);
@@ -17404,7 +18300,9 @@ export function draftAnswer(ctx, env, question) {
17404
18300
  };
17405
18301
  }
17406
18302
  }
17407
- if (!hasBorder && color && !style && !side) {
18303
+ // ("dialogs with a 1px border #23252a": a width said asks for the
18304
+ // part's own edge, never only its inner lines' color.)
18305
+ if (!hasBorder && color && !style && !side && !c.lengths.length) {
17408
18306
  const lineRead = (/** @type {{props: string[]}} */ r) =>
17409
18307
  r.props.some(x =>
17410
18308
  /^border(-(top|bottom|left|right))?(-color)?$/.test(x),
@@ -17566,8 +18464,20 @@ export function draftAnswer(ctx, env, question) {
17566
18464
  })(),
17567
18465
  }
17568
18466
  : {
17569
- text: `${on} draws no border now: a border in ${c.mode} mode only would take its width in the other mode too, and ${on} draws a shadow of its own, so a ring in its box-shadow would take that away`,
17570
- options: [],
18467
+ // (No ring where the part draws its own shadow: the border
18468
+ // itself, its color see-through in the other mode, where it
18469
+ // keeps an edge of that width it does not show.)
18470
+ text: `a border${where}, in ${c.mode} mode only: ${on} draws a shadow of its own, so no ring inside its edge; the border's color is see-through in the ${c.mode === 'light' ? 'dark' : 'light'} mode, which keeps an unseen ${width ?? '1px'} edge`,
18471
+ options: [
18472
+ [
18473
+ set(
18474
+ prop,
18475
+ `${width ?? '1px'} solid light-dark(${c.mode === 'light' ? `${lineColor}, transparent` : `transparent, ${lineColor}`})`,
18476
+ f,
18477
+ ),
18478
+ ],
18479
+ ],
18480
+ ...(c.mode ? {modeInValue: true} : {}),
17571
18481
  };
17572
18482
  }
17573
18483
  return {
@@ -17898,6 +18808,69 @@ export function draftAnswer(ctx, env, question) {
17898
18808
  options: [[set(gap ? 'gap' : 'padding', stepped, f)]],
17899
18809
  };
17900
18810
  }
18811
+ // A part whose rows are as tall as the parts inside it pad them (a
18812
+ // table row, its cells): tighter is those parts' block padding one
18813
+ // spacing step down, which shows; the spacing dial's step scales
18814
+ // everything inside and barely moves a row.
18815
+ const rowPad =
18816
+ value === 'less' && on && !FAMILIES[on] && !f.state && !f.when
18817
+ ? (() => {
18818
+ const own = ctx.project.target.get(one(on))?.component;
18819
+ const inner = [one(on), ...(C.MAP[one(on)]?.contains ?? [])]
18820
+ .filter(
18821
+ k =>
18822
+ ctx.project.target.get(k)?.component === own &&
18823
+ C.MAP[k]?.at?.['padding-block'],
18824
+ )
18825
+ .map(k => {
18826
+ const v = Object.values(
18827
+ C.MAP[k]?.at?.['padding-block'] ?? {},
18828
+ )[0];
18829
+ return {
18830
+ k,
18831
+ tok: /var\((--spacing-[\w-]+)\)/.exec(String(v))?.[1],
18832
+ };
18833
+ })
18834
+ .filter(x => x.tok);
18835
+ if (!inner.length || inner.some(x => x.tok !== inner[0].tok))
18836
+ return null;
18837
+ const px = (/** @type {string} */ t) =>
18838
+ lengthPx(String(resolvedValue(t) || current(t) || ''));
18839
+ const now = px(/** @type {string} */ (inner[0].tok));
18840
+ if (now == null) return null;
18841
+ const down = Object.keys(TOKENS)
18842
+ .filter(t => /^--spacing-[\d-]+$/.test(t))
18843
+ .map(t => ({t, v: px(t)}))
18844
+ .filter(x => x.v != null && x.v < now && x.v > 0)
18845
+ .sort((a, b) => Number(b.v) - Number(a.v))[0];
18846
+ return down
18847
+ ? {
18848
+ parts: inner.map(x => x.k),
18849
+ from: inner[0].tok,
18850
+ to: down.t,
18851
+ by: 2 * (now - Number(down.v)),
18852
+ }
18853
+ : null;
18854
+ })()
18855
+ : null;
18856
+ // (The spacing dial's step on the part leads: it reaches every row.
18857
+ // The block padding of the cells that set a row's height, one
18858
+ // spacing step down, is the second line: it shows more, the body
18859
+ // cells first, never the header alone.)
18860
+ if (rowPad) {
18861
+ const cells = [...rowPad.parts].sort(
18862
+ (x, y) => Number(/header/.test(x)) - Number(/header/.test(y)),
18863
+ );
18864
+ return {
18865
+ text: `${on} tighter: spacing ${value} on ${on} (one step of the room inside it); for more, the second line sets the block padding of ${cells.join(' and ')}, which set its height, one spacing step down (${rowPad.from} to ${rowPad.to}), ${rowPad.by}px less per row`,
18866
+ options: [
18867
+ [set('spacing', value, stepOk ? stepFlags : {on})],
18868
+ cells.map(k =>
18869
+ set('padding-block', `var(${rowPad.to})`, {on: k}),
18870
+ ),
18871
+ ],
18872
+ };
18873
+ }
17901
18874
  return {
17902
18875
  text: `room inside ${on}: spacing ${value} (padding, gaps and heights inside it; one step${padFactor ? ', not an exact amount: give a value, such as 24px, for one' : ''})`,
17903
18876
  options: [[set('spacing', value, stepOk ? stepFlags : {on})]],
@@ -18945,28 +19918,38 @@ export function draftAnswer(ctx, env, question) {
18945
19918
  };
18946
19919
  }
18947
19920
  }
18948
- if (tall)
18949
- return {
18950
- text: `the height${where}: min-height ${tall}${rowsSized && FAMILIES[on] ? ` (never one fixed height: ${(FAMILIES[on] ?? []).filter(m => !(C.partReads(m, 'size') ?? []).some(r => /^--size-/.test(r.token))).join(', ')} take their height from their content or rows)` : ''}`,
18951
- options: [
18952
- [set('min-height', tall, f)],
18953
- ...(rowsSized && FAMILIES[on] ? [] : [[set('height', tall, f)]]),
18954
- ],
18955
- };
18956
- if (on === 'progress-bar-fill' || on === 'progress-bar-track')
19921
+ // A progress bar's height is its track's, a height said in px or a
19922
+ // way ("4px tall", "thinner"): the fill runs the track's height, so
19923
+ // a height on the fill draws a strip over the unchanged track. Only
19924
+ // the fill named as the fill ("the progress fill 4px") is the fill.
19925
+ if (
19926
+ (on === 'progress-bar-track' ||
19927
+ (on === 'progress-bar-fill' &&
19928
+ !/\b(fill|filled|indicator)\b/.test(c.text))) &&
19929
+ !f.state
19930
+ )
18957
19931
  return {
18958
19932
  text: 'the progress bar thickness: the height of its track',
18959
19933
  options: [
18960
19934
  [
18961
19935
  set(
18962
19936
  'height',
18963
- c.lengths[0] ??
19937
+ tall ??
19938
+ c.lengths[0] ??
18964
19939
  (c.dir === 'less' || /\bthin/.test(c.text) ? '2px' : '8px'),
18965
19940
  {on: 'progress-bar-track'},
18966
19941
  ),
18967
19942
  ],
18968
19943
  ],
18969
19944
  };
19945
+ if (tall)
19946
+ return {
19947
+ text: `the height${where}: min-height ${tall}${rowsSized && FAMILIES[on] ? ` (never one fixed height: ${(FAMILIES[on] ?? []).filter(m => !(C.partReads(m, 'size') ?? []).some(r => /^--size-/.test(r.token))).join(', ')} take their height from their content or rows)` : ''}`,
19948
+ options: [
19949
+ [set('min-height', tall, f)],
19950
+ ...(rowsSized && FAMILIES[on] ? [] : [[set('height', tall, f)]]),
19951
+ ],
19952
+ };
18970
19953
  if (
18971
19954
  /\b(wider|narrower|width|wide)\b/.test(c.text) &&
18972
19955
  !/\bborder[- ]width\b/.test(c.text)
@@ -19302,7 +20285,7 @@ export function draftAnswer(ctx, env, question) {
19302
20285
  const n = parseColor(now);
19303
20286
  if (!avoid || !n || n.some((x, i) => Math.abs(x - avoid[i]) > 2))
19304
20287
  return null;
19305
- return nearOff(avoid);
20288
+ return nearOff(avoid, themeNeutral);
19306
20289
  };
19307
20290
  const own = restRead(C.partReads(one(on), 'text'), f.when);
19308
20291
  const steps =
@@ -19337,7 +20320,7 @@ export function draftAnswer(ctx, env, question) {
19337
20320
  n.some((x, i) => Math.abs(x - avoid[i]) > 2)
19338
20321
  )
19339
20322
  return null;
19340
- return nearOff(avoid);
20323
+ return nearOff(avoid, themeNeutral);
19341
20324
  },
19342
20325
  c,
19343
20326
  );
@@ -19457,7 +20440,7 @@ export function draftAnswer(ctx, env, question) {
19457
20440
  };
19458
20441
  if (on === 'link' && color) {
19459
20442
  // (A link color one mode's page would make unreadable, a dark
19460
- // blue on the dark page under 2:1, is set for the other mode
20443
+ // blue on the dark page under 2.5:1, is set for the other mode
19461
20444
  // only, as the text color is; said.)
19462
20445
  const rgb = parseColor(color);
19463
20446
  const readable = /** @type {Array<'light' | 'dark'>} */ ([
@@ -19465,7 +20448,7 @@ export function draftAnswer(ctx, env, question) {
19465
20448
  'dark',
19466
20449
  ]).filter(m => {
19467
20450
  const page = parseColor(current('--color-background-body', m));
19468
- return !rgb || !page || ratio(rgb, page) >= 2;
20451
+ return !rgb || !page || ratio(rgb, page) >= 2.5;
19469
20452
  });
19470
20453
  const oneMode =
19471
20454
  !c.mode &&
@@ -19635,8 +20618,15 @@ export function draftAnswer(ctx, env, question) {
19635
20618
  };
19636
20619
  }
19637
20620
  // A part that takes its color from a prop (a heading): the text
19638
- // token, on that part only.
19639
- if (!env.check([set('color', color, f)]).ok)
20621
+ // token, on that part only. (A color it already has is said so,
20622
+ // never read as a prop.)
20623
+ const colorCheck = env.check([set('color', color, f)]);
20624
+ if (!colorCheck.ok && /^it changes nothing/.test(colorCheck.why ?? ''))
20625
+ return {
20626
+ text: `the text color${where} is ${color} already, so nothing changes`,
20627
+ options: [],
20628
+ };
20629
+ if (!colorCheck.ok)
19640
20630
  return {
19641
20631
  text: `the text color${where}: --color-text-primary on ${on} only (${on} takes its color from a prop, so a color property never shows)`,
19642
20632
  options: [
@@ -19674,11 +20664,39 @@ export function draftAnswer(ctx, env, question) {
19674
20664
  // A state Core paints with an inline style from a token (a selected
19675
20665
  // table row's wash): that token, on the part in that state.
19676
20666
  const inlinePart = on ? one(on) : null;
20667
+ // (In two states at once where one is the inline one, a selected
20668
+ // row hovered: that token, in the other state; the wash is the
20669
+ // token's value there, so only the rows in the inline state show
20670
+ // it.)
20671
+ const pieces = String(f.state ?? '').split('+');
20672
+ const inlineState =
20673
+ inlinePart && pieces.length === 2
20674
+ ? pieces.find(
20675
+ p => C.MAP[inlinePart]?.inline?.[p]?.['background-color'],
20676
+ )
20677
+ : undefined;
19677
20678
  const inlineToken =
19678
20679
  inlinePart && f.state
19679
- ? C.MAP[inlinePart]?.inline?.[f.state]?.['background-color']
20680
+ ? (C.MAP[inlinePart]?.inline?.[inlineState ?? f.state]?.[
20681
+ 'background-color'
20682
+ ] ?? null)
19680
20683
  : null;
19681
20684
  const inlineColor = inlineToken ? colorFor(c, 'fill') : null;
20685
+ if (inlinePart && inlineToken && inlineColor && inlineState) {
20686
+ const other = pieces.find(p => p !== inlineState);
20687
+ return {
20688
+ text: `the background${where}: ${inlineToken}, which Core paints ${inlinePart} with when ${inlineState}, set for ${other}, so a ${inlineState} ${inlinePart} shows it when ${other}`,
20689
+ options: [
20690
+ [
20691
+ set(inlineToken, inlineColor, {
20692
+ on: inlinePart,
20693
+ state: other,
20694
+ ...modeOf(c),
20695
+ }),
20696
+ ],
20697
+ ],
20698
+ };
20699
+ }
19682
20700
  if (inlinePart && inlineToken && inlineColor)
19683
20701
  return {
19684
20702
  text: `the background${where}: ${inlineToken}, which Core paints ${inlinePart} with when ${f.state}`,
@@ -19931,6 +20949,20 @@ export function draftAnswer(ctx, env, question) {
19931
20949
  const color = colorFor(c, 'fill');
19932
20950
  if (color) {
19933
20951
  const pageMode = pageModeOf(c, color);
20952
+ const tones = pageTones(c, color);
20953
+ if (tones)
20954
+ return {
20955
+ text: `the page background: --color-background-body, ${color}'s color at each mode's own page lightness (${tones.light} in light mode, ${tones.dark} in dark mode), so both pages keep their text readable`,
20956
+ options: [
20957
+ [
20958
+ set('--color-background-body', tones.light, {
20959
+ mode: 'light',
20960
+ }),
20961
+ set('--color-background-body', tones.dark, {mode: 'dark'}),
20962
+ ],
20963
+ ],
20964
+ sequence: true,
20965
+ };
19934
20966
  return {
19935
20967
  text: `the page background: --color-background-body${pageModeSaid(c, pageMode)}`,
19936
20968
  options: [
@@ -20965,6 +21997,23 @@ export function draftAnswer(ctx, env, question) {
20965
21997
  : {text: 'no setting is a second brand color', options: []};
20966
21998
  /** @type {Step | null} */
20967
21999
  let darkStep = null;
22000
+ /**
22001
+ * Whether a fill stands out on the dark page (3:1) with text that reads
22002
+ * on it (4.5:1, white or black).
22003
+ * @param {string} x
22004
+ */
22005
+ const standsInDark = x => {
22006
+ const rgb = parseColor(x);
22007
+ const page = parseColor(
22008
+ String(current('--color-background-body', 'dark') ?? ''),
22009
+ );
22010
+ return Boolean(
22011
+ rgb &&
22012
+ page &&
22013
+ ratio(rgb, page) >= 3 &&
22014
+ Math.max(ratio(rgb, [255, 255, 255]), ratio(rgb, [0, 0, 0])) >= 4.5,
22015
+ );
22016
+ };
20968
22017
  // A theme whose modes show this color in different hues (butter's blue
20969
22018
  // light accent, yellow dark one), or that shows only its dark mode: the
20970
22019
  // editor's one seed would make every mode's shades from one hue. A step
@@ -21202,8 +22251,39 @@ export function draftAnswer(ctx, env, question) {
21202
22251
  tokenAlpha,
21203
22252
  )
21204
22253
  : color;
22254
+ let nearDark = false;
22255
+ // A deeper or darker role color asked for, too dark to stand out on
22256
+ // the dark page: the editor's dark half falls back to its paler
22257
+ // official shade, so the dark token is set in the same answer to the
22258
+ // color nearest it that stands out there (3:1) with text that reads on
22259
+ // it (4.5:1): dark mode goes the way the ask goes, not paler.
22260
+ if (
22261
+ modal &&
22262
+ !darkStep &&
22263
+ // ("deeper blue" reads as "dark blue" here.)
22264
+ /\b(?:darker|darken|deeper|dark)\b(?!\s+(?:mode|theme|scheme)\b)/i.test(
22265
+ c.text,
22266
+ ) &&
22267
+ color &&
22268
+ dial !== 'neutral' &&
22269
+ dial !== 'secondary' &&
22270
+ parseColor(color) &&
22271
+ alphaOf(color) >= 1
22272
+ ) {
22273
+ if (!standsInDark(color)) {
22274
+ let near = null;
22275
+ for (let k = 0.02; k <= 0.6 && !near; k += 0.02) {
22276
+ const next = shift(color, k);
22277
+ if (next && standsInDark(next)) near = next;
22278
+ }
22279
+ if (near) {
22280
+ darkStep = set(token, near, {mode: 'dark'});
22281
+ nearDark = true;
22282
+ }
22283
+ }
22284
+ }
21205
22285
  return {
21206
- text: `${dial}: the editor makes its light and dark shades from ${color}${darkStep ? `, and the dark ${token} steps from its own value the same way` : `; or, the second line, only ${token} itself${tokenAlpha < 1 ? `, kept at its own ${Math.round(tokenAlpha * 100)}% strength (a wash)` : ''}, leaving the other ${dial} shades as they are`}`,
22286
+ text: `${dial}: the editor makes its light and dark shades from ${color}${darkStep ? `, and the dark ${token} ${nearDark ? 'is the color nearest it that stands out on the dark page, so dark mode follows it instead of turning paler' : 'steps from its own value the same way'}` : `; or, the second line, only ${token} itself${tokenAlpha < 1 ? `, kept at its own ${Math.round(tokenAlpha * 100)}% strength (a wash)` : ''}, leaving the other ${dial} shades as they are`}`,
21207
22287
  options: darkStep
21208
22288
  ? [[set(dial, color), darkStep]]
21209
22289
  : [[set(dial, color)], [set(token, exactToken)]],
@@ -21274,9 +22354,48 @@ export function draftAnswer(ctx, env, question) {
21274
22354
  ? m[1]
21275
22355
  : undefined;
21276
22356
  })();
22357
+ // (Right before a part, "the zorp card rounder", or between a part's
22358
+ // possessive and its element, "the button's foo icon": a word there
22359
+ // that is no part's own word names nothing the part has.)
22360
+ // (A word some part's own name holds, "the close button", names a
22361
+ // piece of a part, which the place reader reads: never unknown.)
22362
+ const inPartName = (/** @type {string} */ w) =>
22363
+ [...TARGET.keys()].some(k => k.split('-').includes(singular(w)));
22364
+ const beforePartWord = (() => {
22365
+ const m = new RegExp(String.raw`\b${DET}([a-z]{3,})\s+([a-z]+)\b`).exec(
22366
+ text,
22367
+ );
22368
+ return m &&
22369
+ !inPartName(m[1]) &&
22370
+ lex.parts.some(([re]) => re.test(` ${m[2]} `)) &&
22371
+ !lex.parts.some(([re]) => {
22372
+ const x = re.exec(` ${m[1]} ${m[2]} `);
22373
+ return x != null && x[0].includes(m[1]);
22374
+ })
22375
+ ? m[1]
22376
+ : undefined;
22377
+ })();
22378
+ const possessiveWord = (() => {
22379
+ const m = /\b([a-z]+)(?:'s|s'|’s|s’)\s+([a-z]{3,})\s+([a-z]+)\b/.exec(
22380
+ text,
22381
+ );
22382
+ return m &&
22383
+ !inPartName(m[2]) &&
22384
+ lex.parts.some(([re]) => re.test(` ${m[1]} `)) &&
22385
+ (lex.parts.some(([re]) => re.test(` ${m[3]} `)) ||
22386
+ new RegExp(String.raw`^${THING}$|^icons?$`).test(m[3])) &&
22387
+ !lex.parts.some(([re]) => {
22388
+ const x = re.exec(` ${m[2]} ${m[3]} `);
22389
+ return x != null && x[0].includes(m[2]);
22390
+ })
22391
+ ? m[2]
22392
+ : undefined;
22393
+ })();
21277
22394
  const slots = between
21278
- ? [betweenWord, placedWord]
22395
+ ? [betweenWord, placedWord, beforePartWord, possessiveWord]
21279
22396
  : [
22397
+ beforePartWord,
22398
+ possessiveWord,
21280
22399
  new RegExp(
21281
22400
  String.raw`\b(?:from|on)\s+${DET}([a-z]{3,})\b(?!\s+(?:mode|theme)\b)`,
21282
22401
  ).exec(text)?.[1],
@@ -21334,7 +22453,7 @@ export function draftAnswer(ctx, env, question) {
21334
22453
  ),
21335
22454
  ))) ||
21336
22455
  parseColor(w) ||
21337
- /^(?:dark|light|darker|lighter|bigger|smaller|more|less|least|most|much|very|bit|lot|whole|entire|whole|entire|overall|main|page|app|site|everything|everywhere|default|global|general|base|theme|themes|screen|screens|current|other|same|top|bottom|left|right|inner|outer|side|sides|plus|thus|always|sometimes|its|this|that|these|those|them|they|was|has|does|yes|minus|options|things|thing|ones|one|edges|tokens|settings|variables|parts|part|modes|mode|pixels|steps|step|levels|level|times|default|normal|regular|primary|secondary|small|large|medium|subtle|strong|soft|hard|new|old|nice|good|bad|ugly|pretty|heavy|thin|thick|bold|round|rounded|square|flat|clean|modern|fancy|simple|minimal|same|their|your|mine|ours|any|some|every|each|first|last|second|third|letter|letters|word|words|line|lines|link|links|title|titles|label|labels|heading|headings|body|copy|content|everything)$/.test(
22456
+ /^(?:dark|light|darker|lighter|bigger|smaller|more|less|least|most|much|very|bit|lot|whole|entire|whole|entire|overall|main|page|app|site|everything|everywhere|default|global|general|base|theme|themes|screen|screens|current|other|same|top|bottom|left|right|inner|outer|side|sides|plus|thus|always|sometimes|its|this|that|these|those|them|they|was|has|does|yes|minus|options|things|thing|ones|one|edges|tokens|settings|variables|parts|part|modes|mode|pixels|steps|step|levels|level|times|default|normal|regular|primary|secondary|small|large|medium|big|tiny|huge|little|subtle|strong|soft|hard|new|old|nice|good|bad|ugly|pretty|heavy|thin|thick|bold|round|rounded|square|flat|clean|modern|fancy|simple|minimal|same|their|your|mine|ours|any|some|every|each|first|last|second|third|letter|letters|word|words|line|lines|link|links|title|titles|label|labels|heading|headings|body|copy|content|everything)$/.test(
21338
22457
  w,
21339
22458
  )
21340
22459
  )
@@ -21449,10 +22568,16 @@ export function draftAnswer(ctx, env, question) {
21449
22568
  // (A rung by name; a length said beside a step is an example. The
21450
22569
  // step goes the rung's way: "sharper … almost square", never
21451
22570
  // "rounder but square", which contradicts.)
21452
- const rung = (/** @type {Step} */ x) => /^[a-z]+$/.test(String(x.value));
22571
+ // (A size said beside the way, "bigger, 17px", is how much: it wins
22572
+ // as a rung does.)
22573
+ const sized = (/** @type {Step} */ x) =>
22574
+ /^\d*\.?\d+(?:px|rem|em)?$/.test(String(x.value));
22575
+ const rung = (/** @type {Step} */ x) =>
22576
+ /^[a-z]+$/.test(String(x.value)) || sized(x);
21453
22577
  const LOW = /^(?:square|small|tight|compact|light|thin|regular)$/;
21454
22578
  const HIGH = /^(?:large|round|pill|roomy|spacious|bold|heavy)$/;
21455
22579
  const sameWay = (/** @type {Step} */ r, /** @type {Step} */ a) =>
22580
+ sized(a) ||
21456
22581
  (r.value === 'less' && LOW.test(String(a.value))) ||
21457
22582
  (r.value === 'more' && HIGH.test(String(a.value)));
21458
22583
  if (
@@ -21465,6 +22590,24 @@ export function draftAnswer(ctx, env, question) {
21465
22590
  (rel(st) ? sameWay(st, prior.step) : sameWay(prior.step, st)) &&
21466
22591
  (prior.clause.mode ?? '') === (clause.mode ?? '')
21467
22592
  ) {
22593
+ // ("like 1 or 2 px": a size given as an example keeps the way.)
22594
+ const sizedStep = rel(st) ? prior.step : st;
22595
+ const sizedClause = rel(st) ? prior.clause : clause;
22596
+ if (
22597
+ sized(sizedStep) &&
22598
+ /^\s*(?:like|say|e\.?g\.?|about|around|maybe|roughly)\b/.test(
22599
+ sizedClause.text,
22600
+ )
22601
+ ) {
22602
+ relDropped.push(sizedStep);
22603
+ if (!rel(st)) {
22604
+ steps.splice(k, 1, prior.step);
22605
+ continue;
22606
+ }
22607
+ last.delete(key);
22608
+ last.set(key, {step: st, clause});
22609
+ continue;
22610
+ }
21468
22611
  relDropped.push(rel(st) ? st : prior.step);
21469
22612
  if (rel(st)) {
21470
22613
  steps.splice(k, 1, prior.step);
@@ -22283,7 +23426,19 @@ export function draftAnswer(ctx, env, question) {
22283
23426
  (state ? state.test(cond) && !/:hover|:not\(/.test(cond) : !cond)
22284
23427
  );
22285
23428
  });
22286
- const value = keys.map(k => at[k])[0];
23429
+ // The base theme's own rule for the part draws the property where it
23430
+ // sets one (neutral's neutral badge fills with its gray), over what
23431
+ // Core reads there.
23432
+ const key = keys[0];
23433
+ const camel = prop.replace(/-([a-z])/g, (_m, x) => x.toUpperCase());
23434
+ const baseRule =
23435
+ key && !key.split(' ')[1]
23436
+ ? baseBlocksFor(
23437
+ /** @type {any} */ (env.base).components?.[one(named)],
23438
+ key.split(' ')[0],
23439
+ ).find(({block}) => typeof block[camel] === 'string')
23440
+ : null;
23441
+ const value = baseRule ? baseRule.block[camel] : keys.map(k => at[k])[0];
22287
23442
  if (value == null) return null;
22288
23443
  const mode = inMode ?? readMode ?? 'light';
22289
23444
  const read = String(value)
@@ -22466,7 +23621,36 @@ export function draftAnswer(ctx, env, question) {
22466
23621
  const tok = /var\(\s*(--[a-z0-9-]+)\s*\)/.exec(v)?.[1];
22467
23622
  return tok ? `${partNow(tok, mode)}${named ? ` (${tok})` : ''}` : v;
22468
23623
  };
22469
- const rest = at['background-color'][base];
23624
+ // (A fill the theme sets on the part there, for the mode asked, wins;
23625
+ // else the base theme's own rule for the part draws its fill where it
23626
+ // sets one: neutral's neutral badge fills with its gray.)
23627
+ const set = [...env.data.settings]
23628
+ .reverse()
23629
+ .find(
23630
+ x =>
23631
+ x.source === 'property' &&
23632
+ /^background(?:-color)?$/.test(x.thing) &&
23633
+ !x.state &&
23634
+ (!x.mode || x.mode === mode) &&
23635
+ (!x.when || (vWord && x.when === `${vAxis}:${vWord}`)) &&
23636
+ partsOf(ctx, x).includes(one(named)),
23637
+ );
23638
+ const setValue = set
23639
+ ? (() => {
23640
+ const pair = /^light-dark\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(
23641
+ String(set.value).trim(),
23642
+ );
23643
+ return pair ? pair[mode === 'dark' ? 2 : 1] : String(set.value);
23644
+ })()
23645
+ : null;
23646
+ const rest =
23647
+ setValue ??
23648
+ baseBlocksFor(
23649
+ /** @type {any} */ (env.base).components?.[one(named)],
23650
+ base,
23651
+ ).find(({block}) => typeof block.backgroundColor === 'string')?.block
23652
+ .backgroundColor ??
23653
+ at['background-color'][base];
22470
23654
  const suffix = `${qMode ? ` in ${qMode} mode` : ''}${vWord ? ` (${vWord})` : ''}`;
22471
23655
  // (At rest, the reading the value answer gives: the value now.)
22472
23656
  if (!sel) return `${shown(rest, false)}${suffix}`;
@@ -22953,7 +24137,13 @@ export function draftAnswer(ctx, env, question) {
22953
24137
  st.on &&
22954
24138
  st.mode === 'dark' &&
22955
24139
  kind === 'light' &&
22956
- !typed(v)
24140
+ !typed(v) &&
24141
+ // (A color word the ask says, never a color a direction made:
24142
+ // "the card background darker" keeps each card's own dark
24143
+ // tone, whatever text it draws.)
24144
+ colorsIn(question).some(
24145
+ x => String(x).toLowerCase() === v.toLowerCase(),
24146
+ )
22957
24147
  ) {
22958
24148
  const ink = inkOf(st.on, st.when, 'dark');
22959
24149
  const rgb = parseColor(v);
@@ -22971,14 +24161,19 @@ export function draftAnswer(ctx, env, question) {
22971
24161
  if (kind !== 'light' || /light-dark\(/.test(String(st.value)))
22972
24162
  continue;
22973
24163
  // (A border shorthand keeps its width in both modes: only its
22974
- // color is the light mode's, the dark mode keeping the theme's
22975
- // border color.)
22976
- if (st.thing === 'border')
24164
+ // color is the light mode's, the dark mode keeping the border
24165
+ // color the part draws now, an input's emphasized one, else the
24166
+ // theme's.)
24167
+ if (st.thing === 'border') {
24168
+ const own =
24169
+ st.on && restRead(C.partReads(one(st.on), 'border') ?? [], '');
24170
+ const keep =
24171
+ own && /^--color-/.test(own) ? own : '--color-border';
22977
24172
  st.value = String(st.value).replace(
22978
24173
  v,
22979
- `light-dark(${v}, var(--color-border))`,
24174
+ `light-dark(${v}, var(${keep}))`,
22980
24175
  );
22981
- else st.mode = 'light';
24176
+ } else st.mode = 'light';
22982
24177
  notes.add(
22983
24178
  `(a light ${st.on ? 'border' : 'border color'}, in light mode only: on the dark page it would be a glaring edge, so the dark mode keeps its own; for the dark mode too, set a dark color with --mode dark, or say "in both modes")`,
22984
24179
  );
@@ -23015,6 +24210,75 @@ export function draftAnswer(ctx, env, question) {
23015
24210
  for (const n of notes) if (!d.text.includes(n)) d.text += ` ${n}`;
23016
24211
  }
23017
24212
  }
24213
+ // A plain fill on a part whose variants are colors or statuses besides
24214
+ // its neutral ones ("white cards": default, muted, transparent beside
24215
+ // blue, green …; "blue tags": neutral beside success, error …): the
24216
+ // neutral variants take it; each colored or status variant keeps its
24217
+ // own, named, with a line for each to change it too.
24218
+ /** @type {Draft[]} */
24219
+ const keptLines = [];
24220
+ for (const d of result)
24221
+ for (const o of /contradict/.test(d.text) ? [] : d.options) {
24222
+ // (Parts the answer keeps a variant or state of apart, as asked.)
24223
+ const apart = new Set(
24224
+ o
24225
+ .filter(x => /^background/.test(x.thing) && (x.when || x.state))
24226
+ .map(x => String(x.on)),
24227
+ );
24228
+ for (let i = o.length - 1; i >= 0; i--) {
24229
+ const st = o[i];
24230
+ if (
24231
+ !st.on ||
24232
+ st.when ||
24233
+ st.state ||
24234
+ st.only ||
24235
+ !/^background(?:-color)?$/.test(st.thing) ||
24236
+ FAMILIES[st.on]
24237
+ )
24238
+ continue;
24239
+ // (A plain color only: a token, a gradient, a see-through or a
24240
+ // removed fill is what each variant does with it as asked.)
24241
+ const v0 = String(st.value ?? '').trim();
24242
+ if (!/^#[0-9a-f]{3,8}$/i.test(v0) || !parseColor(v0) || alphaOf(v0) < 1)
24243
+ continue;
24244
+ // (A color the ask says, typed or as a word: never one worked out
24245
+ // from another, "the accent but lighter"; nor an answer that
24246
+ // already keeps a variant or state apart, an except.)
24247
+ const said = new Set(
24248
+ clauses.flatMap(x => x.colors).map(x => String(x).toLowerCase()),
24249
+ );
24250
+ if (
24251
+ !said.has(v0.toLowerCase()) &&
24252
+ !question.toLowerCase().includes(v0.toLowerCase())
24253
+ )
24254
+ continue;
24255
+ if (apart.has(String(st.on))) continue;
24256
+ const variants = C.variantValues(one(st.on)).variant ?? [];
24257
+ // (A part with a main variant, a button's primary, is read by the
24258
+ // pass below: its variants are roles, not colors.)
24259
+ if (variants.includes('primary')) continue;
24260
+
24261
+ const colored = variants.filter(
24262
+ v =>
24263
+ Object.hasOwn(HUES, v) ||
24264
+ /^(?:success|warning|error|danger|info|destructive|critical|positive|negative|caution|attention)$/.test(
24265
+ v,
24266
+ ),
24267
+ );
24268
+ const plain = variants.filter(v => !colored.includes(v));
24269
+ if (!colored.length || !plain.length) continue;
24270
+ o.splice(i, 1, ...plain.map(v => ({...st, when: `variant:${v}`})));
24271
+ const name = one(st.on);
24272
+ if (!/keeps? (?:their|its) own color/.test(d.text))
24273
+ d.text += ` (the ${colored.join(', ')} ${name} ${colored.length > 1 ? 'variants keep their' : 'variant keeps its'} own color; the next lines change ${colored.length > 1 ? 'them' : 'it'} too)`;
24274
+ if (!keptLines.some(k => k.text.includes(`${name} variants`)))
24275
+ keptLines.push({
24276
+ text: `to change the ${colored.join(', ')} ${name} variants too: one line for each`,
24277
+ options: colored.map(v => [{...st, when: `variant:${v}`}]),
24278
+ });
24279
+ }
24280
+ }
24281
+ result.push(...keptLines);
23018
24282
  // A fill given to every variant of a part ("navy buttons"): a variant
23019
24283
  // whose own text would barely show on it (a secondary button's dark
23020
24284
  // label on navy, under 3:1) keeps its fill; the others take it, each by
@@ -23034,21 +24298,21 @@ export function draftAnswer(ctx, env, question) {
23034
24298
  continue;
23035
24299
  const fill = parseColor(String(st.value ?? ''));
23036
24300
  if (!fill || alphaOf(String(st.value)) < 1) continue;
23037
- // (Its text given in the same answer: the ask's own look.)
23038
- if (
23039
- o.some(
23040
- x =>
23041
- x !== st &&
23042
- x.on === st.on &&
23043
- (x.thing === 'color' || /^--color-(?:text|on)-/.test(x.thing)),
23044
- )
23045
- )
23046
- continue;
23047
24301
  const variants = C.variantValues(one(st.on)).variant ?? [];
23048
24302
  // (Role variants only, a part with a main variant, a button's
23049
24303
  // primary: a tone family, a badge's statuses, each pairs its text
23050
24304
  // with its own fill and is recolored as a whole.)
23051
24305
  if (variants.length < 2 || !variants.includes('primary')) continue;
24306
+ // (Its text given in the same answer: the ask's own look, so no
24307
+ // variant loses its text.)
24308
+ const ownInk = o.some(
24309
+ x =>
24310
+ x !== st &&
24311
+ x.on === st.on &&
24312
+ !x.when &&
24313
+ !x.state &&
24314
+ (x.thing === 'color' || /^--color-(?:text|on)-/.test(x.thing)),
24315
+ );
23052
24316
  /** @type {Map<string, string>} */
23053
24317
  const ink = new Map();
23054
24318
  for (const r of C.partReads(one(st.on), 'text') ?? []) {
@@ -23059,10 +24323,88 @@ export function draftAnswer(ctx, env, question) {
23059
24323
  }
23060
24324
  }
23061
24325
  const mode = /** @type {'light' | 'dark'} */ (st.mode ?? 'light');
24326
+ const lost = ownInk
24327
+ ? []
24328
+ : variants.filter(v => {
24329
+ const t = ink.get(v);
24330
+ const rgb = t ? parseColor(String(current(t, mode) ?? '')) : null;
24331
+ return rgb != null && ratio(fill, rgb) < 3;
24332
+ });
24333
+ if (lost.length === variants.length) continue;
24334
+ // (Once the color goes to some variants only, a variant drawn in a
24335
+ // status color, the destructive button's red, keeps its meaning
24336
+ // too, unless the color asked is that status color already.)
24337
+ const fills = C.partReads(one(String(st.on)), 'background') ?? [];
24338
+ const status = variants.filter(v => {
24339
+ if (lost.includes(v)) return false;
24340
+ const r = fills.find(
24341
+ x =>
24342
+ x.when.some(w => w.trim() === `variant=${v}`) &&
24343
+ /^--color-(?:error|danger|warning|success)\b/.test(x.token),
24344
+ );
24345
+ if (!r) return false;
24346
+ const now = parseColor(String(current(r.token, mode) ?? ''));
24347
+ const near =
24348
+ !!now && Math.hypot(...now.map((x, k) => x - (fill[k] ?? 0))) < 80;
24349
+ return !near;
24350
+ });
24351
+ // (Only once the color goes to some variants anyway, or when the
24352
+ // ask gives the whole look, its fill and its text ("gold buttons
24353
+ // with black text"): a bare color every button's text reads on
24354
+ // stays every button's.)
24355
+ if (!lost.length && !(ownInk && status.length)) continue;
24356
+ const kept = variants.filter(
24357
+ v => !lost.includes(v) && !status.includes(v),
24358
+ );
24359
+ if (!kept.length) continue;
24360
+ o.splice(i, 1, ...kept.map(v => ({...st, when: `variant:${v}`})));
24361
+ if (
24362
+ !/keep their own fill|keeps its own fill|status color/.test(d.text)
24363
+ ) {
24364
+ if (lost.length)
24365
+ d.text += ` (${lost.join(', ')} ${lost.length > 1 ? 'keep their own fill' : 'keeps its own fill'}: ${lost.length > 1 ? 'their' : 'its'} text would barely show on ${st.value}; give ${lost.length > 1 ? 'them' : 'it'} a text color too to change ${lost.length > 1 ? 'them' : 'it'})`;
24366
+ if (status.length)
24367
+ d.text += ` (${status.join(', ')} ${status.length > 1 ? 'keep their' : 'keeps its'} status color; name ${status.length > 1 ? 'them' : 'it'} to change ${status.length > 1 ? 'them' : 'it'} too)`;
24368
+ }
24369
+ }
24370
+ }
24371
+ // A text color given to every variant of a part ("buttons with white
24372
+ // text"), with no fill of its own in the answer: a variant whose own
24373
+ // fill would hide it (a ghost button's page, a secondary button's light
24374
+ // fill, under 3:1) keeps its text; said.
24375
+ for (const d of result)
24376
+ for (const o of d.options) {
24377
+ for (let i = o.length - 1; i >= 0; i--) {
24378
+ const st = o[i];
24379
+ if (
24380
+ !st.on ||
24381
+ st.when ||
24382
+ st.state ||
24383
+ st.only ||
24384
+ st.thing !== 'color' ||
24385
+ FAMILIES[st.on]
24386
+ )
24387
+ continue;
24388
+ const ink = parseColor(String(st.value ?? ''));
24389
+ if (!ink || alphaOf(String(st.value)) < 1) continue;
24390
+ if (
24391
+ o.some(x => x !== st && x.on === st.on && /^background/.test(x.thing))
24392
+ )
24393
+ continue;
24394
+ const variants = C.variantValues(one(st.on)).variant ?? [];
24395
+ if (variants.length < 2 || !variants.includes('primary')) continue;
24396
+ const fills = (C.partReads(one(st.on), 'background') ?? []).filter(
24397
+ r => /^--color-/.test(r.token) && !/overlay|tint/.test(r.token),
24398
+ );
24399
+ const mode = /** @type {'light' | 'dark'} */ (st.mode ?? 'light');
23062
24400
  const lost = variants.filter(v => {
23063
- const t = ink.get(v);
23064
- const rgb = t ? parseColor(String(current(t, mode) ?? '')) : null;
23065
- return rgb != null && ratio(fill, rgb) < 3;
24401
+ const r = fills.find(x =>
24402
+ x.when.some(w => w.trim() === `variant=${v}`),
24403
+ );
24404
+ const f = parseColor(
24405
+ String(current(r?.token ?? '--color-background-body', mode) ?? ''),
24406
+ );
24407
+ return !!f && ratio(ink, f) < 3;
23066
24408
  });
23067
24409
  if (!lost.length || lost.length === variants.length) continue;
23068
24410
  o.splice(
@@ -23072,8 +24414,8 @@ export function draftAnswer(ctx, env, question) {
23072
24414
  .filter(v => !lost.includes(v))
23073
24415
  .map(v => ({...st, when: `variant:${v}`})),
23074
24416
  );
23075
- if (!/keep their own fill|keeps its own fill/.test(d.text))
23076
- d.text += ` (${lost.join(', ')} ${lost.length > 1 ? 'keep their own fill' : 'keeps its own fill'}: ${lost.length > 1 ? 'their' : 'its'} text would barely show on ${st.value}; give ${lost.length > 1 ? 'them' : 'it'} a text color too to change ${lost.length > 1 ? 'them' : 'it'})`;
24417
+ if (!/keep their own text|keeps its own text/.test(d.text))
24418
+ d.text += ` (${lost.join(', ')} ${lost.length > 1 ? 'keep their own text' : 'keeps its own text'}: ${st.value} would barely show on ${lost.length > 1 ? 'their' : 'its'} fill; give ${lost.length > 1 ? 'them' : 'it'} a fill too to change ${lost.length > 1 ? 'them' : 'it'})`;
23077
24419
  }
23078
24420
  }
23079
24421
  // A fill given to a part that holds others ("a navy header"): a part
@@ -23122,6 +24464,8 @@ export function draftAnswer(ctx, env, question) {
23122
24464
  }
23123
24465
  for (const n of placeNotes)
23124
24466
  if (!keptInPlace.has(n.c)) result.push({text: n.text, options: []});
24467
+ // (The other reading of states said together, said last.)
24468
+ result.push(...otherReadings);
23125
24469
  // A panel's look written for every one (a card's) reaches the panels an
23126
24470
  // app places in a layout too (cards in a carousel, a grid or a stack, as
23127
24471
  // tiles): said once, with the place to ask for to keep them apart.
@@ -23211,6 +24555,75 @@ export function draftAnswer(ctx, env, question) {
23211
24555
  ),
23212
24556
  ),
23213
24557
  );
24558
+ // "make the primary button #0064E0", "pumpkin orange buttons": a fill
24559
+ // typed on a part is measured against the text each of its looks draws
24560
+ // on it, as set measures it after; a look whose text would not read
24561
+ // (under 4.5:1) in a mode takes a text color that does there, white or
24562
+ // black, beside the fill. A text that reads keeps the fill line alone.
24563
+ for (const [di, d] of [...result.entries()].reverse()) {
24564
+ const o = d.options[0];
24565
+ if (!o || o.length !== 1) continue;
24566
+ const st = o[0];
24567
+ const fill = parseColor(String(st.value ?? ''));
24568
+ if (
24569
+ !st.on ||
24570
+ !/^background(?:-color)?$/.test(st.thing) ||
24571
+ !fill ||
24572
+ alphaOf(String(st.value)) < 1 ||
24573
+ !C.MAP[one(st.on)] ||
24574
+ textOnlyPart(one(st.on)) ||
24575
+ FAMILIES[st.on]
24576
+ )
24577
+ continue;
24578
+ const textReads = C.partReads(one(st.on), 'text') ?? [];
24579
+ // (Each look the fill reaches: the one named, else each variant.)
24580
+ const variants = st.when
24581
+ ? [String(st.when)]
24582
+ : (C.variantValues(one(st.on))?.variant ?? []).map(v => `variant:${v}`);
24583
+ const looks = variants.length ? variants : [''];
24584
+ const modes = /** @type {Array<'light' | 'dark'>} */ (
24585
+ st.mode
24586
+ ? [st.mode]
24587
+ : modal
24588
+ ? ['light', 'dark']
24589
+ : [env.data.mode === 'dark-only' ? 'dark' : 'light']
24590
+ );
24591
+ /** @type {Step[]} */
24592
+ const fixes = [];
24593
+ for (const look of looks) {
24594
+ const tok = restRead(textReads, look);
24595
+ if (!tok) continue;
24596
+ for (const m of modes) {
24597
+ const ink = parseColor(String(current(tok, m) ?? ''));
24598
+ if (!ink || alphaOf(String(current(tok, m))) < 1) continue;
24599
+ if (ratio(ink, fill) >= 4.5) continue;
24600
+ const white = ratio([255, 255, 255], fill);
24601
+ const black = ratio([0, 0, 0], fill);
24602
+ fixes.push(
24603
+ set('color', white >= black ? '#ffffff' : '#000000', {
24604
+ on: st.on,
24605
+ ...(look ? {when: look} : {}),
24606
+ ...(st.state ? {state: st.state} : {}),
24607
+ ...(modes.length > 1 || st.mode ? {mode: m} : {}),
24608
+ }),
24609
+ );
24610
+ }
24611
+ }
24612
+ if (!fixes.length || !env.check([st, ...fixes]).ok) continue;
24613
+ // (Its own line beside the fill's, so the fill reads as asked and the
24614
+ // text as measured.)
24615
+ const where = fixes
24616
+ .map(x =>
24617
+ `${x.when ? `${x.when.replace(':', ' ')} ` : ''}${x.mode ? `in ${x.mode} mode` : ''}`.trim(),
24618
+ )
24619
+ .join(', ');
24620
+ d.text = `${d.text}; its text would not read on that fill (${where}): the next line keeps it readable`;
24621
+ result.splice(di + 1, 0, {
24622
+ text: `readable text on that fill: ${st.on}'s text measures under 4.5:1 on ${st.value} (${where}), so ${[...new Set(fixes.map(x => x.value))].join(' or ')} there`,
24623
+ options: [fixes],
24624
+ ...(fixes.length > 1 ? {sequence: true} : {}),
24625
+ });
24626
+ }
23214
24627
  // "make the info banner navy": one status's fill on one part, or that
23215
24628
  // status's color for the whole theme (its banners, badges and toasts
23216
24629
  // together), the dial; both are offered, the part's first.
@@ -23245,8 +24658,9 @@ export function draftAnswer(ctx, env, question) {
23245
24658
  // are named, never dropped without a word.
23246
24659
  if (
23247
24660
  !gateAll &&
23248
- /\b(?:theme|vibe|palette|aesthetic|branding)\b/.test(q) &&
23249
- result.some(d => d.options.some(o => o.length))
24661
+ (/\b(?:theme|vibe|palette|aesthetic|branding|feel)\b/.test(q) ||
24662
+ (!partsSeen.length &&
24663
+ q.split(/[,;:]|\band\b/).filter(x => x.trim()).length >= 3))
23250
24664
  ) {
23251
24665
  const STOP =
23252
24666
  /^(?:theme|themes|look|looks|feel|vibe|style|palette|with|give|make|want|need|have|this|that|those|these|their|ours?|your|for|and|but|the|very|really|quite|some|more|less|less|like|into|from|only|both|mode|modes|site|sites|apps?|page|pages|product|website|please|also|plus|something|kind|sort|ish|using|uses|feeling|overall|while|keep|kept|just|still|then|than|colou?rs?|them|they|those|these|what|when|where|which|lighten|darken|soften|brighten|sharpen|tone|default|brand|color|deep|rich)$/;