@litfamily/litgravity 0.1.7 → 0.1.9

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 (1070) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +79 -11
  3. package/README_ko-KR.md +80 -12
  4. package/bin/litgravity.mjs +3 -7
  5. package/lib/doctor.mjs +22 -18
  6. package/lib/host-tools.mjs +9 -36
  7. package/lib/install.mjs +18 -5
  8. package/lib/list.mjs +8 -16
  9. package/lib/paths.mjs +0 -1
  10. package/package.json +2 -2
  11. package/plugin/hooks/lib/extensions.mjs +53 -0
  12. package/plugin/hooks/lib/reentry.mjs +6 -5
  13. package/plugin/hooks/lib/rewind/board.mjs +295 -0
  14. package/plugin/hooks/lib/rewind/brief.mjs +26 -18
  15. package/plugin/hooks/lib/rewind/collect.mjs +42 -4
  16. package/plugin/hooks/lib/routes.mjs +36 -11
  17. package/plugin/hooks/post-tool-use.mjs +0 -2
  18. package/plugin/hooks/pre-invocation.mjs +0 -2
  19. package/plugin/hooks/session-start.mjs +7 -0
  20. package/plugin/hooks/stop.mjs +2 -8
  21. package/plugin/plugin.json +1 -1
  22. package/plugin/skills/autoconference/SKILL.md +1 -1
  23. package/plugin/skills/autoconference/modes/core.md +1 -1
  24. package/plugin/skills/autoconference/references/visualization-guide.md +6 -6
  25. package/plugin/skills/autoconference/scripts/style_presets.py +6 -6
  26. package/plugin/skills/autoresearch/references/type-checklists.md +1 -1
  27. package/plugin/skills/autoresearch/references/visualization-guide.md +11 -5
  28. package/plugin/skills/frontend-ui-ux/SKILL.md +18 -147
  29. package/plugin/skills/lit-adhd/SKILL.md +45 -20
  30. package/plugin/skills/lit-adhd/references/card-examples.md +99 -1
  31. package/plugin/skills/lit-adhd/references/status-taxonomy.md +17 -8
  32. package/plugin/skills/lit-code/references/core/agy-surfaces-and-verification.md +1 -1
  33. package/plugin/skills/lit-code/references/engineering-risk-signals.md +2 -2
  34. package/plugin/skills/lit-diagram-drawer/SKILL.md +20 -164
  35. package/plugin/skills/lit-docx/SKILL.md +20 -122
  36. package/plugin/skills/lit-loop/SKILL.md +1 -1
  37. package/plugin/skills/lit-pptx/SKILL.md +18 -130
  38. package/plugin/skills/lit-schematic/SKILL.md +19 -98
  39. package/plugin/skills/lit-scientific-visualization/SKILL.md +19 -160
  40. package/plugin/skills/lit-typographic-motion/SKILL.md +19 -188
  41. package/plugin/skills/readme-studio/SKILL.md +20 -98
  42. package/plugin/skills/visual-qa/SKILL.md +20 -121
  43. package/lib/runtime.mjs +0 -81
  44. package/plugin/hooks/lib/motion.mjs +0 -171
  45. package/plugin/lib/python-pick.mjs +0 -63
  46. package/plugin/skills/frontend-ui-ux/ATTRIBUTION.md +0 -23
  47. package/plugin/skills/frontend-ui-ux/LICENSE +0 -21
  48. package/plugin/skills/frontend-ui-ux/PROVENANCE.json +0 -38
  49. package/plugin/skills/frontend-ui-ux/SOURCE-MANIFEST.json +0 -1060
  50. package/plugin/skills/frontend-ui-ux/THIRD-PARTY-NOTICE.txt +0 -14
  51. package/plugin/skills/frontend-ui-ux/data/design-intelligence.json +0 -1
  52. package/plugin/skills/frontend-ui-ux/examples/design-contract.example.json +0 -186
  53. package/plugin/skills/frontend-ui-ux/examples/phase-3-readme-ab/README.md +0 -9
  54. package/plugin/skills/frontend-ui-ux/kit/components.css +0 -417
  55. package/plugin/skills/frontend-ui-ux/kit/fonts.json +0 -22
  56. package/plugin/skills/frontend-ui-ux/kit/layouts/landing.html +0 -164
  57. package/plugin/skills/frontend-ui-ux/kit/layouts/settings.html +0 -114
  58. package/plugin/skills/frontend-ui-ux/kit/layouts/workspace.html +0 -115
  59. package/plugin/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +0 -227
  60. package/plugin/skills/frontend-ui-ux/kit/styles/field-notes.json +0 -205
  61. package/plugin/skills/frontend-ui-ux/kit/styles/graphite.json +0 -200
  62. package/plugin/skills/frontend-ui-ux/kit/styles/meadow.json +0 -199
  63. package/plugin/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +0 -222
  64. package/plugin/skills/frontend-ui-ux/kit/ui.js +0 -226
  65. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-ATTRIBUTION.md +0 -217
  66. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-LICENSE-Apache-2.0.txt +0 -201
  67. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/legal/root-LICENSE +0 -21
  68. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/manifest.json +0 -873
  69. package/plugin/skills/frontend-ui-ux/references/adaptive-layout.md +0 -103
  70. package/plugin/skills/frontend-ui-ux/references/brand-and-imagery.md +0 -96
  71. package/plugin/skills/frontend-ui-ux/references/complete-contract.md +0 -415
  72. package/plugin/skills/frontend-ui-ux/references/composition.md +0 -93
  73. package/plugin/skills/frontend-ui-ux/references/craft-floor.md +0 -203
  74. package/plugin/skills/frontend-ui-ux/references/creative-directions.md +0 -96
  75. package/plugin/skills/frontend-ui-ux/references/default-editorial-pixel.json +0 -27
  76. package/plugin/skills/frontend-ui-ux/references/design/README.md +0 -248
  77. package/plugin/skills/frontend-ui-ux/references/design/_INDEX.md +0 -191
  78. package/plugin/skills/frontend-ui-ux/references/design/airbnb.md +0 -393
  79. package/plugin/skills/frontend-ui-ux/references/design/airtable.md +0 -92
  80. package/plugin/skills/frontend-ui-ux/references/design/apple.md +0 -250
  81. package/plugin/skills/frontend-ui-ux/references/design/aside.md +0 -209
  82. package/plugin/skills/frontend-ui-ux/references/design/binance.md +0 -348
  83. package/plugin/skills/frontend-ui-ux/references/design/bmw.md +0 -183
  84. package/plugin/skills/frontend-ui-ux/references/design/brutalist-skill.md +0 -92
  85. package/plugin/skills/frontend-ui-ux/references/design/bugatti.md +0 -271
  86. package/plugin/skills/frontend-ui-ux/references/design/cal.md +0 -262
  87. package/plugin/skills/frontend-ui-ux/references/design/claude.md +0 -315
  88. package/plugin/skills/frontend-ui-ux/references/design/clay.md +0 -307
  89. package/plugin/skills/frontend-ui-ux/references/design/clickhouse.md +0 -284
  90. package/plugin/skills/frontend-ui-ux/references/design/clone-from-url.md +0 -65
  91. package/plugin/skills/frontend-ui-ux/references/design/cohere.md +0 -269
  92. package/plugin/skills/frontend-ui-ux/references/design/coinbase.md +0 -132
  93. package/plugin/skills/frontend-ui-ux/references/design/composio.md +0 -310
  94. package/plugin/skills/frontend-ui-ux/references/design/cursor.md +0 -312
  95. package/plugin/skills/frontend-ui-ux/references/design/design-system-architecture.md +0 -244
  96. package/plugin/skills/frontend-ui-ux/references/design/elevenlabs.md +0 -268
  97. package/plugin/skills/frontend-ui-ux/references/design/expo.md +0 -284
  98. package/plugin/skills/frontend-ui-ux/references/design/ferrari.md +0 -317
  99. package/plugin/skills/frontend-ui-ux/references/design/figma.md +0 -223
  100. package/plugin/skills/frontend-ui-ux/references/design/framer.md +0 -249
  101. package/plugin/skills/frontend-ui-ux/references/design/gpt-tasteskill.md +0 -74
  102. package/plugin/skills/frontend-ui-ux/references/design/hashicorp.md +0 -281
  103. package/plugin/skills/frontend-ui-ux/references/design/ibm.md +0 -335
  104. package/plugin/skills/frontend-ui-ux/references/design/image-to-code-skill.md +0 -1228
  105. package/plugin/skills/frontend-ui-ux/references/design/imagegen-brandkit.md +0 -798
  106. package/plugin/skills/frontend-ui-ux/references/design/imagegen-frontend-mobile.md +0 -1465
  107. package/plugin/skills/frontend-ui-ux/references/design/imagegen-frontend-web.md +0 -987
  108. package/plugin/skills/frontend-ui-ux/references/design/intercom.md +0 -149
  109. package/plugin/skills/frontend-ui-ux/references/design/kraken.md +0 -128
  110. package/plugin/skills/frontend-ui-ux/references/design/lamborghini.md +0 -291
  111. package/plugin/skills/frontend-ui-ux/references/design/layout-skill.md +0 -107
  112. package/plugin/skills/frontend-ui-ux/references/design/lazyweb.md +0 -77
  113. package/plugin/skills/frontend-ui-ux/references/design/linear.app.md +0 -370
  114. package/plugin/skills/frontend-ui-ux/references/design/lovable.md +0 -301
  115. package/plugin/skills/frontend-ui-ux/references/design/mastercard.md +0 -368
  116. package/plugin/skills/frontend-ui-ux/references/design/meta.md +0 -369
  117. package/plugin/skills/frontend-ui-ux/references/design/minimalist-skill.md +0 -85
  118. package/plugin/skills/frontend-ui-ux/references/design/minimax.md +0 -260
  119. package/plugin/skills/frontend-ui-ux/references/design/mintlify.md +0 -329
  120. package/plugin/skills/frontend-ui-ux/references/design/miro.md +0 -111
  121. package/plugin/skills/frontend-ui-ux/references/design/mistral.ai.md +0 -264
  122. package/plugin/skills/frontend-ui-ux/references/design/mongodb.md +0 -269
  123. package/plugin/skills/frontend-ui-ux/references/design/nike.md +0 -366
  124. package/plugin/skills/frontend-ui-ux/references/design/notion.md +0 -312
  125. package/plugin/skills/frontend-ui-ux/references/design/nvidia.md +0 -296
  126. package/plugin/skills/frontend-ui-ux/references/design/ollama.md +0 -270
  127. package/plugin/skills/frontend-ui-ux/references/design/opencode.ai.md +0 -284
  128. package/plugin/skills/frontend-ui-ux/references/design/output-skill.md +0 -49
  129. package/plugin/skills/frontend-ui-ux/references/design/pinterest.md +0 -233
  130. package/plugin/skills/frontend-ui-ux/references/design/playstation.md +0 -367
  131. package/plugin/skills/frontend-ui-ux/references/design/posthog.md +0 -259
  132. package/plugin/skills/frontend-ui-ux/references/design/raycast.md +0 -271
  133. package/plugin/skills/frontend-ui-ux/references/design/react-dev-tooling-skill.md +0 -230
  134. package/plugin/skills/frontend-ui-ux/references/design/redesign-skill.md +0 -178
  135. package/plugin/skills/frontend-ui-ux/references/design/renault.md +0 -314
  136. package/plugin/skills/frontend-ui-ux/references/design/replicate.md +0 -264
  137. package/plugin/skills/frontend-ui-ux/references/design/resend.md +0 -306
  138. package/plugin/skills/frontend-ui-ux/references/design/revolut.md +0 -188
  139. package/plugin/skills/frontend-ui-ux/references/design/runwayml.md +0 -247
  140. package/plugin/skills/frontend-ui-ux/references/design/sanity.md +0 -360
  141. package/plugin/skills/frontend-ui-ux/references/design/sentry.md +0 -265
  142. package/plugin/skills/frontend-ui-ux/references/design/shopify.md +0 -353
  143. package/plugin/skills/frontend-ui-ux/references/design/soft-skill.md +0 -98
  144. package/plugin/skills/frontend-ui-ux/references/design/spacex.md +0 -197
  145. package/plugin/skills/frontend-ui-ux/references/design/spotify.md +0 -249
  146. package/plugin/skills/frontend-ui-ux/references/design/starbucks.md +0 -583
  147. package/plugin/skills/frontend-ui-ux/references/design/stitch-design-example.md +0 -121
  148. package/plugin/skills/frontend-ui-ux/references/design/stitch-skill.md +0 -184
  149. package/plugin/skills/frontend-ui-ux/references/design/stripe.md +0 -325
  150. package/plugin/skills/frontend-ui-ux/references/design/supabase.md +0 -258
  151. package/plugin/skills/frontend-ui-ux/references/design/superhuman.md +0 -255
  152. package/plugin/skills/frontend-ui-ux/references/design/taste-skill.md +0 -1206
  153. package/plugin/skills/frontend-ui-ux/references/design/tesla.md +0 -289
  154. package/plugin/skills/frontend-ui-ux/references/design/theverge.md +0 -342
  155. package/plugin/skills/frontend-ui-ux/references/design/together.ai.md +0 -266
  156. package/plugin/skills/frontend-ui-ux/references/design/uber.md +0 -298
  157. package/plugin/skills/frontend-ui-ux/references/design/vercel.md +0 -313
  158. package/plugin/skills/frontend-ui-ux/references/design/vodafone.md +0 -426
  159. package/plugin/skills/frontend-ui-ux/references/design/voltagent.md +0 -326
  160. package/plugin/skills/frontend-ui-ux/references/design/warp.md +0 -256
  161. package/plugin/skills/frontend-ui-ux/references/design/webflow.md +0 -95
  162. package/plugin/skills/frontend-ui-ux/references/design/wired.md +0 -281
  163. package/plugin/skills/frontend-ui-ux/references/design/wise.md +0 -176
  164. package/plugin/skills/frontend-ui-ux/references/design/x.ai.md +0 -260
  165. package/plugin/skills/frontend-ui-ux/references/design/zapier.md +0 -331
  166. package/plugin/skills/frontend-ui-ux/references/designpowers/EVIDENCE.md +0 -97
  167. package/plugin/skills/frontend-ui-ux/references/designpowers/README.md +0 -48
  168. package/plugin/skills/frontend-ui-ux/references/designpowers/UPSTREAM.md +0 -80
  169. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-a-direction.md +0 -64
  170. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-b-execution.md +0 -65
  171. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-c-review.md +0 -65
  172. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-d-memory.md +0 -83
  173. package/plugin/skills/frontend-ui-ux/references/designpowers/orchestration.md +0 -80
  174. package/plugin/skills/frontend-ui-ux/references/designpowers/routing.md +0 -79
  175. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/LICENSE +0 -21
  176. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/accessibility-reviewer.md +0 -83
  177. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/content-writer.md +0 -132
  178. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-builder.md +0 -109
  179. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-critic.md +0 -89
  180. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-lead.md +0 -113
  181. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-scout.md +0 -78
  182. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-strategist.md +0 -121
  183. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/heuristic-evaluator.md +0 -268
  184. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/inspiration-scout.md +0 -107
  185. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/motion-designer.md +0 -120
  186. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/accessible-content/reference.md +0 -101
  187. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/adaptive-interfaces/reference.md +0 -109
  188. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/cognitive-accessibility/reference.md +0 -107
  189. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debate/reference.md +0 -199
  190. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debt-tracker/reference.md +0 -174
  191. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-handoff/reference.md +0 -125
  192. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-md/reference.md +0 -106
  193. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-retrospective/reference.md +0 -266
  194. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-review/reference.md +0 -123
  195. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-system-alignment/reference.md +0 -120
  196. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/designpowers-critique/reference.md +0 -164
  197. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/heuristic-evaluation/reference.md +0 -85
  198. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/inclusive-personas/reference.md +0 -98
  199. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/inspiration-scouting/reference.md +0 -165
  200. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/interaction-design/reference.md +0 -122
  201. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/motion-choreography/reference.md +0 -81
  202. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/research-planning/reference.md +0 -96
  203. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/responsive-patterns/reference.md +0 -77
  204. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/synthetic-user-testing/reference.md +0 -192
  205. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-feedback/reference.md +0 -165
  206. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-report/reference.md +0 -78
  207. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/token-architecture/reference.md +0 -75
  208. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/ui-composition/reference.md +0 -117
  209. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/usability-testing/reference.md +0 -78
  210. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/verification-before-shipping/reference.md +0 -125
  211. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/voice-and-tone/reference.md +0 -79
  212. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/writing-design-plans/reference.md +0 -119
  213. package/plugin/skills/frontend-ui-ux/references/evidence-review.md +0 -119
  214. package/plugin/skills/frontend-ui-ux/references/house-styles.md +0 -234
  215. package/plugin/skills/frontend-ui-ux/references/implementation-platforms.md +0 -115
  216. package/plugin/skills/frontend-ui-ux/references/inclusive-interface.md +0 -98
  217. package/plugin/skills/frontend-ui-ux/references/interaction-motion.md +0 -48
  218. package/plugin/skills/frontend-ui-ux/references/motion-guide.md +0 -153
  219. package/plugin/skills/frontend-ui-ux/references/operating-lanes.md +0 -101
  220. package/plugin/skills/frontend-ui-ux/references/perfection/README.md +0 -160
  221. package/plugin/skills/frontend-ui-ux/references/perfection/react-perf-tooling.md +0 -127
  222. package/plugin/skills/frontend-ui-ux/references/performance-delivery.md +0 -91
  223. package/plugin/skills/frontend-ui-ux/references/product-direction.md +0 -92
  224. package/plugin/skills/frontend-ui-ux/references/production-interview.md +0 -71
  225. package/plugin/skills/frontend-ui-ux/references/redesign-playbook.md +0 -103
  226. package/plugin/skills/frontend-ui-ux/references/slop-register.md +0 -139
  227. package/plugin/skills/frontend-ui-ux/references/system-foundations.md +0 -90
  228. package/plugin/skills/frontend-ui-ux/references/taste-direction.md +0 -79
  229. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/README.md +0 -659
  230. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/charts.csv +0 -26
  231. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/colors.csv +0 -162
  232. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/icons.csv +0 -106
  233. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/landing.csv +0 -35
  234. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/products.csv +0 -162
  235. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/react-performance.csv +0 -45
  236. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/astro.csv +0 -54
  237. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/flutter.csv +0 -53
  238. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/html-tailwind.csv +0 -56
  239. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/jetpack-compose.csv +0 -53
  240. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nextjs.csv +0 -53
  241. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxt-ui.csv +0 -51
  242. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxtjs.csv +0 -59
  243. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react-native.csv +0 -52
  244. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react.csv +0 -54
  245. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/shadcn.csv +0 -61
  246. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/svelte.csv +0 -54
  247. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/swiftui.csv +0 -51
  248. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/vue.csv +0 -50
  249. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/styles.csv +0 -85
  250. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/typography.csv +0 -74
  251. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/ui-reasoning.csv +0 -162
  252. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/ux-guidelines.csv +0 -100
  253. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/web-interface.csv +0 -31
  254. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/scripts/core.py +0 -262
  255. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/scripts/design_system.py +0 -1148
  256. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/scripts/search.py +0 -114
  257. package/plugin/skills/frontend-ui-ux/references/visual-language.md +0 -90
  258. package/plugin/skills/frontend-ui-ux/references/visual-reconstruction.md +0 -55
  259. package/plugin/skills/frontend-ui-ux/schemas/design-contract-v1alpha1.schema.json +0 -306
  260. package/plugin/skills/frontend-ui-ux/schemas/design-contract-v1beta1.schema.json +0 -291
  261. package/plugin/skills/frontend-ui-ux/schemas/design-contract-v1beta2.schema.json +0 -311
  262. package/plugin/skills/frontend-ui-ux/scripts/chrome-driver.mjs +0 -217
  263. package/plugin/skills/frontend-ui-ux/scripts/design-contract-format.mjs +0 -286
  264. package/plugin/skills/frontend-ui-ux/scripts/design-contract-inventory-rules.mjs +0 -354
  265. package/plugin/skills/frontend-ui-ux/scripts/design-contract-rules.mjs +0 -361
  266. package/plugin/skills/frontend-ui-ux/scripts/design-contract-surface-rules.mjs +0 -313
  267. package/plugin/skills/frontend-ui-ux/scripts/design-data.mjs +0 -68
  268. package/plugin/skills/frontend-ui-ux/scripts/design-lock.mjs +0 -400
  269. package/plugin/skills/frontend-ui-ux/scripts/errors.mjs +0 -12
  270. package/plugin/skills/frontend-ui-ux/scripts/import-design-intelligence.mjs +0 -124
  271. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +0 -196
  272. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +0 -1555
  273. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +0 -153
  274. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-server.mjs +0 -57
  275. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-static.mjs +0 -129
  276. package/plugin/skills/frontend-ui-ux/scripts/interface-probe.mjs +0 -322
  277. package/plugin/skills/frontend-ui-ux/scripts/json-boundary.mjs +0 -63
  278. package/plugin/skills/frontend-ui-ux/scripts/pixel-art.mjs +0 -60
  279. package/plugin/skills/frontend-ui-ux/scripts/query-design-intelligence.mjs +0 -106
  280. package/plugin/skills/frontend-ui-ux/scripts/search.mjs +0 -43
  281. package/plugin/skills/frontend-ui-ux/scripts/source-replay.mjs +0 -153
  282. package/plugin/skills/frontend-ui-ux/scripts/strict-json.mjs +0 -143
  283. package/plugin/skills/frontend-ui-ux/scripts/validate-design-contract.mjs +0 -52
  284. package/plugin/skills/frontend-ui-ux/scripts/verify-corpus.mjs +0 -90
  285. package/plugin/skills/lit-diagram-drawer/NOTICE +0 -33
  286. package/plugin/skills/lit-diagram-drawer/assets/examples/type-architecture-dark.html +0 -1
  287. package/plugin/skills/lit-diagram-drawer/assets/examples/type-architecture-full.html +0 -1
  288. package/plugin/skills/lit-diagram-drawer/assets/examples/type-architecture-light.html +0 -1
  289. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bar-dark.html +0 -1
  290. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bar-full.html +0 -1
  291. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bar-light.html +0 -1
  292. package/plugin/skills/lit-diagram-drawer/assets/examples/type-beeswarm-dark.html +0 -1
  293. package/plugin/skills/lit-diagram-drawer/assets/examples/type-beeswarm-full.html +0 -1
  294. package/plugin/skills/lit-diagram-drawer/assets/examples/type-beeswarm-light.html +0 -1
  295. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bubble-dark.html +0 -1
  296. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bubble-full.html +0 -1
  297. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bubble-light.html +0 -1
  298. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bump-dark.html +0 -1
  299. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bump-full.html +0 -1
  300. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bump-light.html +0 -1
  301. package/plugin/skills/lit-diagram-drawer/assets/examples/type-data-flow-dark.html +0 -1
  302. package/plugin/skills/lit-diagram-drawer/assets/examples/type-data-flow-full.html +0 -1
  303. package/plugin/skills/lit-diagram-drawer/assets/examples/type-data-flow-light.html +0 -1
  304. package/plugin/skills/lit-diagram-drawer/assets/examples/type-datalake-dark.html +0 -1
  305. package/plugin/skills/lit-diagram-drawer/assets/examples/type-datalake-full.html +0 -1
  306. package/plugin/skills/lit-diagram-drawer/assets/examples/type-datalake-light.html +0 -1
  307. package/plugin/skills/lit-diagram-drawer/assets/examples/type-db-schema-dark.html +0 -1
  308. package/plugin/skills/lit-diagram-drawer/assets/examples/type-db-schema-full.html +0 -1
  309. package/plugin/skills/lit-diagram-drawer/assets/examples/type-db-schema-light.html +0 -1
  310. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dependency-dark.html +0 -1
  311. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dependency-full.html +0 -1
  312. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dependency-light.html +0 -1
  313. package/plugin/skills/lit-diagram-drawer/assets/examples/type-deployment-dark.html +0 -1
  314. package/plugin/skills/lit-diagram-drawer/assets/examples/type-deployment-full.html +0 -1
  315. package/plugin/skills/lit-diagram-drawer/assets/examples/type-deployment-light.html +0 -1
  316. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-integration-dark.html +0 -1
  317. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-integration-full.html +0 -1
  318. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-integration-light.html +0 -1
  319. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-security-matrix-dark.html +0 -1
  320. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-security-matrix-full.html +0 -1
  321. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-security-matrix-light.html +0 -1
  322. package/plugin/skills/lit-diagram-drawer/assets/examples/type-er-dark.html +0 -1
  323. package/plugin/skills/lit-diagram-drawer/assets/examples/type-er-full.html +0 -1
  324. package/plugin/skills/lit-diagram-drawer/assets/examples/type-er-light.html +0 -1
  325. package/plugin/skills/lit-diagram-drawer/assets/examples/type-fishbone-dark.html +0 -1
  326. package/plugin/skills/lit-diagram-drawer/assets/examples/type-fishbone-full.html +0 -1
  327. package/plugin/skills/lit-diagram-drawer/assets/examples/type-fishbone-light.html +0 -1
  328. package/plugin/skills/lit-diagram-drawer/assets/examples/type-flowchart-dark.html +0 -1
  329. package/plugin/skills/lit-diagram-drawer/assets/examples/type-flowchart-full.html +0 -1
  330. package/plugin/skills/lit-diagram-drawer/assets/examples/type-flowchart-light.html +0 -1
  331. package/plugin/skills/lit-diagram-drawer/assets/examples/type-gantt-dark.html +0 -1
  332. package/plugin/skills/lit-diagram-drawer/assets/examples/type-gantt-full.html +0 -1
  333. package/plugin/skills/lit-diagram-drawer/assets/examples/type-gantt-light.html +0 -1
  334. package/plugin/skills/lit-diagram-drawer/assets/examples/type-heatmap-dark.html +0 -1
  335. package/plugin/skills/lit-diagram-drawer/assets/examples/type-heatmap-full.html +0 -1
  336. package/plugin/skills/lit-diagram-drawer/assets/examples/type-heatmap-light.html +0 -1
  337. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-dark.html +0 -1
  338. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-full.html +0 -1
  339. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-light.html +0 -1
  340. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-vertical-dark.html +0 -1
  341. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-vertical-full.html +0 -1
  342. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-vertical-light.html +0 -1
  343. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-drawio-dark.html +0 -1
  344. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-drawio-full.html +0 -1
  345. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-drawio-light.html +0 -1
  346. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-excalidraw-dark.html +0 -1
  347. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-excalidraw-full.html +0 -1
  348. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-excalidraw-light.html +0 -1
  349. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-mermaid-dark.html +0 -1
  350. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-mermaid-full.html +0 -1
  351. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-mermaid-light.html +0 -1
  352. package/plugin/skills/lit-diagram-drawer/assets/examples/type-it-state-dark.html +0 -1
  353. package/plugin/skills/lit-diagram-drawer/assets/examples/type-it-state-full.html +0 -1
  354. package/plugin/skills/lit-diagram-drawer/assets/examples/type-it-state-light.html +0 -1
  355. package/plugin/skills/lit-diagram-drawer/assets/examples/type-journey-dark.html +0 -1
  356. package/plugin/skills/lit-diagram-drawer/assets/examples/type-journey-full.html +0 -1
  357. package/plugin/skills/lit-diagram-drawer/assets/examples/type-journey-light.html +0 -1
  358. package/plugin/skills/lit-diagram-drawer/assets/examples/type-kanban-dark.html +0 -1
  359. package/plugin/skills/lit-diagram-drawer/assets/examples/type-kanban-full.html +0 -1
  360. package/plugin/skills/lit-diagram-drawer/assets/examples/type-kanban-light.html +0 -1
  361. package/plugin/skills/lit-diagram-drawer/assets/examples/type-layers-dark.html +0 -1
  362. package/plugin/skills/lit-diagram-drawer/assets/examples/type-layers-full.html +0 -1
  363. package/plugin/skills/lit-diagram-drawer/assets/examples/type-layers-light.html +0 -1
  364. package/plugin/skills/lit-diagram-drawer/assets/examples/type-line-dark.html +0 -1
  365. package/plugin/skills/lit-diagram-drawer/assets/examples/type-line-full.html +0 -1
  366. package/plugin/skills/lit-diagram-drawer/assets/examples/type-line-light.html +0 -1
  367. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-dark.html +0 -1
  368. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-full.html +0 -1
  369. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-light.html +0 -1
  370. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-terminal-dark.html +0 -1
  371. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-terminal-full.html +0 -1
  372. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-terminal-light.html +0 -1
  373. package/plugin/skills/lit-diagram-drawer/assets/examples/type-marimekko-dark.html +0 -1
  374. package/plugin/skills/lit-diagram-drawer/assets/examples/type-marimekko-full.html +0 -1
  375. package/plugin/skills/lit-diagram-drawer/assets/examples/type-marimekko-light.html +0 -1
  376. package/plugin/skills/lit-diagram-drawer/assets/examples/type-medallion-dark.html +0 -1
  377. package/plugin/skills/lit-diagram-drawer/assets/examples/type-medallion-full.html +0 -1
  378. package/plugin/skills/lit-diagram-drawer/assets/examples/type-medallion-light.html +0 -1
  379. package/plugin/skills/lit-diagram-drawer/assets/examples/type-nested-dark.html +0 -1
  380. package/plugin/skills/lit-diagram-drawer/assets/examples/type-nested-full.html +0 -1
  381. package/plugin/skills/lit-diagram-drawer/assets/examples/type-nested-light.html +0 -1
  382. package/plugin/skills/lit-diagram-drawer/assets/examples/type-org-chart-dark.html +0 -1
  383. package/plugin/skills/lit-diagram-drawer/assets/examples/type-org-chart-full.html +0 -1
  384. package/plugin/skills/lit-diagram-drawer/assets/examples/type-org-chart-light.html +0 -1
  385. package/plugin/skills/lit-diagram-drawer/assets/examples/type-paved-road-animated-dark.html +0 -1
  386. package/plugin/skills/lit-diagram-drawer/assets/examples/type-paved-road-animated-full.html +0 -1
  387. package/plugin/skills/lit-diagram-drawer/assets/examples/type-paved-road-animated-light.html +0 -1
  388. package/plugin/skills/lit-diagram-drawer/assets/examples/type-polar-dark.html +0 -1
  389. package/plugin/skills/lit-diagram-drawer/assets/examples/type-polar-full.html +0 -1
  390. package/plugin/skills/lit-diagram-drawer/assets/examples/type-polar-light.html +0 -1
  391. package/plugin/skills/lit-diagram-drawer/assets/examples/type-policy-trace-animated-dark.html +0 -1
  392. package/plugin/skills/lit-diagram-drawer/assets/examples/type-policy-trace-animated-full.html +0 -1
  393. package/plugin/skills/lit-diagram-drawer/assets/examples/type-policy-trace-animated-light.html +0 -1
  394. package/plugin/skills/lit-diagram-drawer/assets/examples/type-process-dark.html +0 -1
  395. package/plugin/skills/lit-diagram-drawer/assets/examples/type-process-full.html +0 -1
  396. package/plugin/skills/lit-diagram-drawer/assets/examples/type-process-light.html +0 -1
  397. package/plugin/skills/lit-diagram-drawer/assets/examples/type-pyramid-dark.html +0 -1
  398. package/plugin/skills/lit-diagram-drawer/assets/examples/type-pyramid-full.html +0 -1
  399. package/plugin/skills/lit-diagram-drawer/assets/examples/type-pyramid-light.html +0 -1
  400. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-consultant-dark.html +0 -1
  401. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-consultant-full.html +0 -1
  402. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-consultant-light.html +0 -1
  403. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-dark.html +0 -1
  404. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-full.html +0 -1
  405. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-light.html +0 -1
  406. package/plugin/skills/lit-diagram-drawer/assets/examples/type-queue-animated-dark.html +0 -1
  407. package/plugin/skills/lit-diagram-drawer/assets/examples/type-queue-animated-full.html +0 -1
  408. package/plugin/skills/lit-diagram-drawer/assets/examples/type-queue-animated-light.html +0 -1
  409. package/plugin/skills/lit-diagram-drawer/assets/examples/type-radar-dark.html +0 -1
  410. package/plugin/skills/lit-diagram-drawer/assets/examples/type-radar-full.html +0 -1
  411. package/plugin/skills/lit-diagram-drawer/assets/examples/type-radar-light.html +0 -1
  412. package/plugin/skills/lit-diagram-drawer/assets/examples/type-ridgeline-dark.html +0 -1
  413. package/plugin/skills/lit-diagram-drawer/assets/examples/type-ridgeline-full.html +0 -1
  414. package/plugin/skills/lit-diagram-drawer/assets/examples/type-ridgeline-light.html +0 -1
  415. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sankey-dark.html +0 -1
  416. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sankey-full.html +0 -1
  417. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sankey-light.html +0 -1
  418. package/plugin/skills/lit-diagram-drawer/assets/examples/type-scatter-dark.html +0 -1
  419. package/plugin/skills/lit-diagram-drawer/assets/examples/type-scatter-full.html +0 -1
  420. package/plugin/skills/lit-diagram-drawer/assets/examples/type-scatter-light.html +0 -1
  421. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-dark.html +0 -1
  422. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-full.html +0 -1
  423. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-light.html +0 -1
  424. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-oauth-dark.html +0 -1
  425. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-oauth-full.html +0 -1
  426. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-oauth-light.html +0 -1
  427. package/plugin/skills/lit-diagram-drawer/assets/examples/type-slopegraph-dark.html +0 -1
  428. package/plugin/skills/lit-diagram-drawer/assets/examples/type-slopegraph-full.html +0 -1
  429. package/plugin/skills/lit-diagram-drawer/assets/examples/type-slopegraph-light.html +0 -1
  430. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-dark.html +0 -1
  431. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-full.html +0 -1
  432. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-lifecycle-dark.html +0 -1
  433. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-lifecycle-full.html +0 -1
  434. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-lifecycle-light.html +0 -1
  435. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-light.html +0 -1
  436. package/plugin/skills/lit-diagram-drawer/assets/examples/type-story-map-dark.html +0 -1
  437. package/plugin/skills/lit-diagram-drawer/assets/examples/type-story-map-full.html +0 -1
  438. package/plugin/skills/lit-diagram-drawer/assets/examples/type-story-map-light.html +0 -1
  439. package/plugin/skills/lit-diagram-drawer/assets/examples/type-streamgraph-dark.html +0 -1
  440. package/plugin/skills/lit-diagram-drawer/assets/examples/type-streamgraph-full.html +0 -1
  441. package/plugin/skills/lit-diagram-drawer/assets/examples/type-streamgraph-light.html +0 -1
  442. package/plugin/skills/lit-diagram-drawer/assets/examples/type-swimlane-dark.html +0 -1
  443. package/plugin/skills/lit-diagram-drawer/assets/examples/type-swimlane-full.html +0 -1
  444. package/plugin/skills/lit-diagram-drawer/assets/examples/type-swimlane-light.html +0 -1
  445. package/plugin/skills/lit-diagram-drawer/assets/examples/type-timeline-dark.html +0 -1
  446. package/plugin/skills/lit-diagram-drawer/assets/examples/type-timeline-full.html +0 -1
  447. package/plugin/skills/lit-diagram-drawer/assets/examples/type-timeline-light.html +0 -1
  448. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-block-decomposition-dark.html +0 -1
  449. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-block-decomposition-full.html +0 -1
  450. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-block-decomposition-light.html +0 -1
  451. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-dark.html +0 -1
  452. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-full.html +0 -1
  453. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-light.html +0 -1
  454. package/plugin/skills/lit-diagram-drawer/assets/examples/type-treemap-dark.html +0 -1
  455. package/plugin/skills/lit-diagram-drawer/assets/examples/type-treemap-full.html +0 -1
  456. package/plugin/skills/lit-diagram-drawer/assets/examples/type-treemap-light.html +0 -1
  457. package/plugin/skills/lit-diagram-drawer/assets/examples/type-uml-class-dark.html +0 -1
  458. package/plugin/skills/lit-diagram-drawer/assets/examples/type-uml-class-full.html +0 -1
  459. package/plugin/skills/lit-diagram-drawer/assets/examples/type-uml-class-light.html +0 -1
  460. package/plugin/skills/lit-diagram-drawer/assets/examples/type-venn-dark.html +0 -1
  461. package/plugin/skills/lit-diagram-drawer/assets/examples/type-venn-full.html +0 -1
  462. package/plugin/skills/lit-diagram-drawer/assets/examples/type-venn-light.html +0 -1
  463. package/plugin/skills/lit-diagram-drawer/assets/examples/type-wardley-dark.html +0 -1
  464. package/plugin/skills/lit-diagram-drawer/assets/examples/type-wardley-full.html +0 -1
  465. package/plugin/skills/lit-diagram-drawer/assets/examples/type-wardley-light.html +0 -1
  466. package/plugin/skills/lit-diagram-drawer/assets/examples/type-waterfall-dark.html +0 -1
  467. package/plugin/skills/lit-diagram-drawer/assets/examples/type-waterfall-full.html +0 -1
  468. package/plugin/skills/lit-diagram-drawer/assets/examples/type-waterfall-light.html +0 -1
  469. package/plugin/skills/lit-diagram-drawer/assets/fonts/OFL.txt +0 -94
  470. package/plugin/skills/lit-diagram-drawer/assets/fonts/PretendardVariable.woff2 +0 -0
  471. package/plugin/skills/lit-diagram-drawer/assets/fonts/provenance.json +0 -22
  472. package/plugin/skills/lit-diagram-drawer/assets/icons.html +0 -231
  473. package/plugin/skills/lit-diagram-drawer/assets/index.html +0 -1
  474. package/plugin/skills/lit-diagram-drawer/assets/licenses/devicon-MIT.txt +0 -20
  475. package/plugin/skills/lit-diagram-drawer/assets/licenses/diagram-design-MIT.txt +0 -21
  476. package/plugin/skills/lit-diagram-drawer/assets/licenses/log-z-MIT.txt +0 -21
  477. package/plugin/skills/lit-diagram-drawer/assets/licenses/simple-icons-CC0.md +0 -30
  478. package/plugin/skills/lit-diagram-drawer/assets/licenses/tabler-MIT.txt +0 -21
  479. package/plugin/skills/lit-diagram-drawer/examples/01-service-architecture/after.html +0 -1
  480. package/plugin/skills/lit-diagram-drawer/examples/01-service-architecture/brief.md +0 -33
  481. package/plugin/skills/lit-diagram-drawer/examples/01-service-architecture/constructed-naive-foil.html +0 -1
  482. package/plugin/skills/lit-diagram-drawer/examples/02-release-decision/after.html +0 -1
  483. package/plugin/skills/lit-diagram-drawer/examples/02-release-decision/brief.md +0 -18
  484. package/plugin/skills/lit-diagram-drawer/examples/02-release-decision/constructed-naive-foil.html +0 -1
  485. package/plugin/skills/lit-diagram-drawer/examples/03-data-retention/after.html +0 -1
  486. package/plugin/skills/lit-diagram-drawer/examples/03-data-retention/brief.md +0 -19
  487. package/plugin/skills/lit-diagram-drawer/examples/03-data-retention/constructed-naive-foil.html +0 -1
  488. package/plugin/skills/lit-diagram-drawer/examples/04-oauth-sequence/after.html +0 -1
  489. package/plugin/skills/lit-diagram-drawer/examples/04-oauth-sequence/brief.md +0 -17
  490. package/plugin/skills/lit-diagram-drawer/examples/04-oauth-sequence/constructed-naive-foil.html +0 -1
  491. package/plugin/skills/lit-diagram-drawer/examples/05-review-lanes/after.html +0 -1
  492. package/plugin/skills/lit-diagram-drawer/examples/05-review-lanes/brief.md +0 -17
  493. package/plugin/skills/lit-diagram-drawer/examples/05-review-lanes/constructed-naive-foil.html +0 -1
  494. package/plugin/skills/lit-diagram-drawer/examples/06-rollout-gates/after.html +0 -1
  495. package/plugin/skills/lit-diagram-drawer/examples/06-rollout-gates/brief.md +0 -17
  496. package/plugin/skills/lit-diagram-drawer/examples/06-rollout-gates/constructed-naive-foil.html +0 -1
  497. package/plugin/skills/lit-diagram-drawer/examples/07-deployment-boundary/after.html +0 -1
  498. package/plugin/skills/lit-diagram-drawer/examples/07-deployment-boundary/brief.md +0 -19
  499. package/plugin/skills/lit-diagram-drawer/examples/07-deployment-boundary/constructed-naive-foil.html +0 -1
  500. package/plugin/skills/lit-diagram-drawer/examples/08-policy-traces/after.html +0 -1
  501. package/plugin/skills/lit-diagram-drawer/examples/08-policy-traces/brief.md +0 -20
  502. package/plugin/skills/lit-diagram-drawer/examples/08-policy-traces/constructed-naive-foil.html +0 -1
  503. package/plugin/skills/lit-diagram-drawer/references/accessibility.md +0 -37
  504. package/plugin/skills/lit-diagram-drawer/references/drawing-rules.md +0 -86
  505. package/plugin/skills/lit-diagram-drawer/references/export.md +0 -34
  506. package/plugin/skills/lit-diagram-drawer/references/failure-codes.md +0 -66
  507. package/plugin/skills/lit-diagram-drawer/references/import-drawio.md +0 -21
  508. package/plugin/skills/lit-diagram-drawer/references/import-excalidraw.md +0 -14
  509. package/plugin/skills/lit-diagram-drawer/references/import-mermaid.md +0 -18
  510. package/plugin/skills/lit-diagram-drawer/references/import-schema.md +0 -28
  511. package/plugin/skills/lit-diagram-drawer/references/korean-typography.md +0 -34
  512. package/plugin/skills/lit-diagram-drawer/references/motion.md +0 -29
  513. package/plugin/skills/lit-diagram-drawer/references/office-pptx-docx.md +0 -42
  514. package/plugin/skills/lit-diagram-drawer/references/output-spec.md +0 -48
  515. package/plugin/skills/lit-diagram-drawer/references/playbooks.md +0 -67
  516. package/plugin/skills/lit-diagram-drawer/references/primitive-annotation.md +0 -12
  517. package/plugin/skills/lit-diagram-drawer/references/primitive-icons.md +0 -21
  518. package/plugin/skills/lit-diagram-drawer/references/primitive-sketchy.md +0 -11
  519. package/plugin/skills/lit-diagram-drawer/references/primitive-terminal.md +0 -11
  520. package/plugin/skills/lit-diagram-drawer/references/profiles.md +0 -24
  521. package/plugin/skills/lit-diagram-drawer/references/semantic-patterns.md +0 -27
  522. package/plugin/skills/lit-diagram-drawer/references/style-guide.md +0 -76
  523. package/plugin/skills/lit-diagram-drawer/references/type-architecture.md +0 -51
  524. package/plugin/skills/lit-diagram-drawer/references/type-bar.md +0 -51
  525. package/plugin/skills/lit-diagram-drawer/references/type-beeswarm.md +0 -49
  526. package/plugin/skills/lit-diagram-drawer/references/type-bubble.md +0 -49
  527. package/plugin/skills/lit-diagram-drawer/references/type-bump.md +0 -49
  528. package/plugin/skills/lit-diagram-drawer/references/type-catalog.json +0 -1433
  529. package/plugin/skills/lit-diagram-drawer/references/type-data-flow.md +0 -51
  530. package/plugin/skills/lit-diagram-drawer/references/type-datalake.md +0 -49
  531. package/plugin/skills/lit-diagram-drawer/references/type-db-schema.md +0 -49
  532. package/plugin/skills/lit-diagram-drawer/references/type-dependency.md +0 -49
  533. package/plugin/skills/lit-diagram-drawer/references/type-deployment.md +0 -49
  534. package/plugin/skills/lit-diagram-drawer/references/type-dp-integration.md +0 -49
  535. package/plugin/skills/lit-diagram-drawer/references/type-dp-security-matrix.md +0 -49
  536. package/plugin/skills/lit-diagram-drawer/references/type-er.md +0 -49
  537. package/plugin/skills/lit-diagram-drawer/references/type-fishbone.md +0 -49
  538. package/plugin/skills/lit-diagram-drawer/references/type-flowchart.md +0 -49
  539. package/plugin/skills/lit-diagram-drawer/references/type-gantt.md +0 -49
  540. package/plugin/skills/lit-diagram-drawer/references/type-heatmap.md +0 -53
  541. package/plugin/skills/lit-diagram-drawer/references/type-high-level-vertical.md +0 -53
  542. package/plugin/skills/lit-diagram-drawer/references/type-high-level.md +0 -53
  543. package/plugin/skills/lit-diagram-drawer/references/type-import-drawio.md +0 -53
  544. package/plugin/skills/lit-diagram-drawer/references/type-import-excalidraw.md +0 -53
  545. package/plugin/skills/lit-diagram-drawer/references/type-import-mermaid.md +0 -53
  546. package/plugin/skills/lit-diagram-drawer/references/type-it-state.md +0 -54
  547. package/plugin/skills/lit-diagram-drawer/references/type-journey.md +0 -54
  548. package/plugin/skills/lit-diagram-drawer/references/type-kanban.md +0 -54
  549. package/plugin/skills/lit-diagram-drawer/references/type-layers.md +0 -54
  550. package/plugin/skills/lit-diagram-drawer/references/type-line.md +0 -54
  551. package/plugin/skills/lit-diagram-drawer/references/type-loop-terminal.md +0 -53
  552. package/plugin/skills/lit-diagram-drawer/references/type-loop.md +0 -54
  553. package/plugin/skills/lit-diagram-drawer/references/type-marimekko.md +0 -54
  554. package/plugin/skills/lit-diagram-drawer/references/type-medallion.md +0 -54
  555. package/plugin/skills/lit-diagram-drawer/references/type-nested.md +0 -59
  556. package/plugin/skills/lit-diagram-drawer/references/type-org-chart.md +0 -58
  557. package/plugin/skills/lit-diagram-drawer/references/type-paved-road-animated.md +0 -72
  558. package/plugin/skills/lit-diagram-drawer/references/type-polar.md +0 -67
  559. package/plugin/skills/lit-diagram-drawer/references/type-policy-trace-animated.md +0 -69
  560. package/plugin/skills/lit-diagram-drawer/references/type-process.md +0 -58
  561. package/plugin/skills/lit-diagram-drawer/references/type-pyramid.md +0 -59
  562. package/plugin/skills/lit-diagram-drawer/references/type-quadrant-consultant.md +0 -60
  563. package/plugin/skills/lit-diagram-drawer/references/type-quadrant.md +0 -57
  564. package/plugin/skills/lit-diagram-drawer/references/type-queue-animated.md +0 -63
  565. package/plugin/skills/lit-diagram-drawer/references/type-radar.md +0 -57
  566. package/plugin/skills/lit-diagram-drawer/references/type-ridgeline.md +0 -63
  567. package/plugin/skills/lit-diagram-drawer/references/type-sankey.md +0 -68
  568. package/plugin/skills/lit-diagram-drawer/references/type-scatter.md +0 -60
  569. package/plugin/skills/lit-diagram-drawer/references/type-sequence-oauth.md +0 -66
  570. package/plugin/skills/lit-diagram-drawer/references/type-sequence.md +0 -63
  571. package/plugin/skills/lit-diagram-drawer/references/type-slopegraph.md +0 -65
  572. package/plugin/skills/lit-diagram-drawer/references/type-state-lifecycle.md +0 -53
  573. package/plugin/skills/lit-diagram-drawer/references/type-state.md +0 -59
  574. package/plugin/skills/lit-diagram-drawer/references/type-story-map.md +0 -52
  575. package/plugin/skills/lit-diagram-drawer/references/type-streamgraph.md +0 -53
  576. package/plugin/skills/lit-diagram-drawer/references/type-swimlane.md +0 -52
  577. package/plugin/skills/lit-diagram-drawer/references/type-timeline.md +0 -52
  578. package/plugin/skills/lit-diagram-drawer/references/type-tree-block-decomposition.md +0 -57
  579. package/plugin/skills/lit-diagram-drawer/references/type-tree.md +0 -54
  580. package/plugin/skills/lit-diagram-drawer/references/type-treemap.md +0 -54
  581. package/plugin/skills/lit-diagram-drawer/references/type-uml-class.md +0 -52
  582. package/plugin/skills/lit-diagram-drawer/references/type-venn.md +0 -51
  583. package/plugin/skills/lit-diagram-drawer/references/type-wardley.md +0 -52
  584. package/plugin/skills/lit-diagram-drawer/references/type-waterfall.md +0 -54
  585. package/plugin/skills/lit-diagram-drawer/references/verifier-guide.md +0 -76
  586. package/plugin/skills/lit-diagram-drawer/scripts/block-registry.mjs +0 -43
  587. package/plugin/skills/lit-diagram-drawer/scripts/brief-contract.mjs +0 -94
  588. package/plugin/skills/lit-diagram-drawer/scripts/check-visible-text.mjs +0 -15
  589. package/plugin/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +0 -13
  590. package/plugin/skills/lit-diagram-drawer/scripts/diagram-metrics.mjs +0 -219
  591. package/plugin/skills/lit-diagram-drawer/scripts/diagram-runtime-lock/package.json +0 -9
  592. package/plugin/skills/lit-diagram-drawer/scripts/diagram-runtime.mjs +0 -277
  593. package/plugin/skills/lit-diagram-drawer/scripts/doctor.mjs +0 -25
  594. package/plugin/skills/lit-diagram-drawer/scripts/drawio-model.mjs +0 -162
  595. package/plugin/skills/lit-diagram-drawer/scripts/drawio-source.mjs +0 -147
  596. package/plugin/skills/lit-diagram-drawer/scripts/drawio-xml.mjs +0 -148
  597. package/plugin/skills/lit-diagram-drawer/scripts/export.mjs +0 -119
  598. package/plugin/skills/lit-diagram-drawer/scripts/import-common.mjs +0 -85
  599. package/plugin/skills/lit-diagram-drawer/scripts/import-drawio.mjs +0 -48
  600. package/plugin/skills/lit-diagram-drawer/scripts/import-excalidraw.mjs +0 -234
  601. package/plugin/skills/lit-diagram-drawer/scripts/import-mermaid.mjs +0 -104
  602. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-common.mjs +0 -115
  603. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-er.mjs +0 -70
  604. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-flowchart.mjs +0 -178
  605. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-sequence.mjs +0 -137
  606. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-state.mjs +0 -80
  607. package/plugin/skills/lit-diagram-drawer/scripts/office-safety.mjs +0 -54
  608. package/plugin/skills/lit-diagram-drawer/scripts/runtime-probes.mjs +0 -11
  609. package/plugin/skills/lit-diagram-drawer/scripts/verify-all.mjs +0 -85
  610. package/plugin/skills/lit-diagram-drawer/scripts/verify-brief.mjs +0 -16
  611. package/plugin/skills/lit-diagram-drawer/scripts/verify-diagram.mjs +0 -27
  612. package/plugin/skills/lit-diagram-drawer/scripts/verify-motion.mjs +0 -12
  613. package/plugin/skills/lit-diagram-drawer/scripts/verify-type.mjs +0 -48
  614. package/plugin/skills/lit-diagram-drawer/scripts/visual-quality-geometry.mjs +0 -226
  615. package/plugin/skills/lit-diagram-drawer/scripts/visual-quality.mjs +0 -146
  616. package/plugin/skills/lit-docx/NOTICE +0 -35
  617. package/plugin/skills/lit-docx/references/build-loop.md +0 -96
  618. package/plugin/skills/lit-docx/references/components.md +0 -287
  619. package/plugin/skills/lit-docx/references/direction-step.md +0 -339
  620. package/plugin/skills/lit-docx/references/examples/01-report-ko.md +0 -166
  621. package/plugin/skills/lit-docx/references/examples/02-brief-ko.md +0 -96
  622. package/plugin/skills/lit-docx/references/examples/03-manual-ko.md +0 -170
  623. package/plugin/skills/lit-docx/references/examples/04-proposal-ko.md +0 -141
  624. package/plugin/skills/lit-docx/references/examples/05-memo-en.md +0 -56
  625. package/plugin/skills/lit-docx/references/examples/06-journal-en.md +0 -129
  626. package/plugin/skills/lit-docx/references/examples/07-report-en.md +0 -123
  627. package/plugin/skills/lit-docx/references/examples/08-proposal-en.md +0 -122
  628. package/plugin/skills/lit-docx/references/examples/09-memo-ko.md +0 -40
  629. package/plugin/skills/lit-docx/references/frontmatter_schema.md +0 -94
  630. package/plugin/skills/lit-docx/references/journal_style_spec.md +0 -89
  631. package/plugin/skills/lit-docx/references/markdown_quality_checklist.md +0 -43
  632. package/plugin/skills/lit-docx/references/page-composition.md +0 -319
  633. package/plugin/skills/lit-docx/references/slop_phrase_list.yaml +0 -58
  634. package/plugin/skills/lit-docx/references/slop_rules.md +0 -88
  635. package/plugin/skills/lit-docx/references/tonalities/brief.md +0 -170
  636. package/plugin/skills/lit-docx/references/tonalities/journal.md +0 -173
  637. package/plugin/skills/lit-docx/references/tonalities/manual.md +0 -182
  638. package/plugin/skills/lit-docx/references/tonalities/memo.md +0 -171
  639. package/plugin/skills/lit-docx/references/tonalities/proposal.md +0 -181
  640. package/plugin/skills/lit-docx/references/tonalities/report.md +0 -199
  641. package/plugin/skills/lit-docx/scripts/clean_markdown.py +0 -95
  642. package/plugin/skills/lit-docx/scripts/convert_md_to_docx.py +0 -1395
  643. package/plugin/skills/lit-docx/scripts/convert_md_to_pdf.py +0 -301
  644. package/plugin/skills/lit-docx/scripts/convert_pdf.py +0 -139
  645. package/plugin/skills/lit-docx/scripts/docx_design.py +0 -2449
  646. package/plugin/skills/lit-docx/scripts/docx_layout.py +0 -959
  647. package/plugin/skills/lit-docx/scripts/edit_docx.py +0 -306
  648. package/plugin/skills/lit-docx/scripts/embed_images.py +0 -78
  649. package/plugin/skills/lit-docx/scripts/generate_docx_templates.py +0 -500
  650. package/plugin/skills/lit-docx/scripts/pdf_fonts.py +0 -83
  651. package/plugin/skills/lit-docx/scripts/qa_docx.py +0 -234
  652. package/plugin/skills/lit-docx/scripts/slop_lint.py +0 -573
  653. package/plugin/skills/lit-docx/scripts/visual_audit.py +0 -48
  654. package/plugin/skills/lit-docx/templates/docx/acs.docx +0 -0
  655. package/plugin/skills/lit-docx/templates/docx/elsevier.docx +0 -0
  656. package/plugin/skills/lit-docx/templates/docx/ieee.docx +0 -0
  657. package/plugin/skills/lit-docx/templates/docx/korean-generic.docx +0 -0
  658. package/plugin/skills/lit-docx/templates/docx/nature.docx +0 -0
  659. package/plugin/skills/lit-docx/templates/latex/acs/README.md +0 -5
  660. package/plugin/skills/lit-docx/templates/latex/acs/template.tex +0 -41
  661. package/plugin/skills/lit-docx/templates/latex/elsevier/README.md +0 -5
  662. package/plugin/skills/lit-docx/templates/latex/elsevier/template.tex +0 -42
  663. package/plugin/skills/lit-docx/templates/latex/ieee/README.md +0 -5
  664. package/plugin/skills/lit-docx/templates/latex/ieee/template.tex +0 -41
  665. package/plugin/skills/lit-docx/templates/latex/korean-generic/README.md +0 -5
  666. package/plugin/skills/lit-docx/templates/latex/korean-generic/template.tex +0 -41
  667. package/plugin/skills/lit-docx/templates/latex/nature/README.md +0 -5
  668. package/plugin/skills/lit-docx/templates/latex/nature/template.tex +0 -41
  669. package/plugin/skills/lit-docx/templates/registry.yaml +0 -1366
  670. package/plugin/skills/lit-docx/templates/tonalities/brief.yaml +0 -28
  671. package/plugin/skills/lit-docx/templates/tonalities/journal.yaml +0 -25
  672. package/plugin/skills/lit-docx/templates/tonalities/manual.yaml +0 -26
  673. package/plugin/skills/lit-docx/templates/tonalities/memo.yaml +0 -26
  674. package/plugin/skills/lit-docx/templates/tonalities/proposal.yaml +0 -26
  675. package/plugin/skills/lit-docx/templates/tonalities/report.yaml +0 -26
  676. package/plugin/skills/lit-pptx/NOTICE +0 -35
  677. package/plugin/skills/lit-pptx/assets/azure/circle-lg.png +0 -0
  678. package/plugin/skills/lit-pptx/assets/azure/circle-md.png +0 -0
  679. package/plugin/skills/lit-pptx/assets/azure/circle-sm.png +0 -0
  680. package/plugin/skills/lit-pptx/assets/example-a.png +0 -0
  681. package/plugin/skills/lit-pptx/assets/example-b.png +0 -0
  682. package/plugin/skills/lit-pptx/assets/example-c.png +0 -0
  683. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Black.otf +0 -0
  684. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Bold.otf +0 -0
  685. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Light.otf +0 -0
  686. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Medium.otf +0 -0
  687. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Regular.otf +0 -0
  688. package/plugin/skills/lit-pptx/fonts/a2z/OFL.txt +0 -94
  689. package/plugin/skills/lit-pptx/fonts/a2z/SOURCE.md +0 -29
  690. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
  691. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
  692. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +0 -93
  693. package/plugin/skills/lit-pptx/fonts/pretendard/OFL.txt +0 -94
  694. package/plugin/skills/lit-pptx/fonts/pretendard/Pretendard-Bold.otf +0 -0
  695. package/plugin/skills/lit-pptx/fonts/pretendard/Pretendard-Regular.otf +0 -0
  696. package/plugin/skills/lit-pptx/fonts/provenance.json +0 -109
  697. package/plugin/skills/lit-pptx/references/agents/analyst.md +0 -49
  698. package/plugin/skills/lit-pptx/references/agents/antithesis.md +0 -59
  699. package/plugin/skills/lit-pptx/references/agents/architect.md +0 -44
  700. package/plugin/skills/lit-pptx/references/agents/critic.md +0 -42
  701. package/plugin/skills/lit-pptx/references/agents/synthesizer.md +0 -47
  702. package/plugin/skills/lit-pptx/references/agents/thesis.md +0 -33
  703. package/plugin/skills/lit-pptx/references/anti-slop-checklist.md +0 -131
  704. package/plugin/skills/lit-pptx/references/authoring-guide.md +0 -250
  705. package/plugin/skills/lit-pptx/references/build-loop.md +0 -117
  706. package/plugin/skills/lit-pptx/references/consensus-protocol.md +0 -125
  707. package/plugin/skills/lit-pptx/references/data-display-cookbook.md +0 -52
  708. package/plugin/skills/lit-pptx/references/density-and-fill.md +0 -163
  709. package/plugin/skills/lit-pptx/references/design-system-azure.md +0 -61
  710. package/plugin/skills/lit-pptx/references/direction-step.md +0 -203
  711. package/plugin/skills/lit-pptx/references/examples/01-pitch-signal-ko.md +0 -210
  712. package/plugin/skills/lit-pptx/references/examples/02-pitch-studio-ko.md +0 -147
  713. package/plugin/skills/lit-pptx/references/examples/03-business-review-ledger-ko.md +0 -199
  714. package/plugin/skills/lit-pptx/references/examples/04-business-review-night-en.md +0 -203
  715. package/plugin/skills/lit-pptx/references/examples/05-research-talk-paper-en.md +0 -178
  716. package/plugin/skills/lit-pptx/references/examples/06-lecture-chalk-ko.md +0 -199
  717. package/plugin/skills/lit-pptx/references/examples/07-data-review-night-en.md +0 -194
  718. package/plugin/skills/lit-pptx/references/examples/08-image-led-atlas-ko.md +0 -175
  719. package/plugin/skills/lit-pptx/references/examples/09-briefing-gazette-ko.md +0 -204
  720. package/plugin/skills/lit-pptx/references/examples/10-status-update-ledger-ko.md +0 -179
  721. package/plugin/skills/lit-pptx/references/examples/11-portfolio-studio-en.md +0 -164
  722. package/plugin/skills/lit-pptx/references/examples/12-research-tutorial-chalk-en.md +0 -174
  723. package/plugin/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +0 -173
  724. package/plugin/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +0 -154
  725. package/plugin/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +0 -139
  726. package/plugin/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +0 -158
  727. package/plugin/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +0 -179
  728. package/plugin/skills/lit-pptx/references/interview-protocol.md +0 -113
  729. package/plugin/skills/lit-pptx/references/layout-families.md +0 -194
  730. package/plugin/skills/lit-pptx/references/stages/autopilot.md +0 -48
  731. package/plugin/skills/lit-pptx/references/stages/interview.md +0 -52
  732. package/plugin/skills/lit-pptx/references/stages/plan.md +0 -42
  733. package/plugin/skills/lit-pptx/references/title-treatments.md +0 -113
  734. package/plugin/skills/lit-pptx/references/tonalities/atlas.md +0 -139
  735. package/plugin/skills/lit-pptx/references/tonalities/bauhaus.md +0 -140
  736. package/plugin/skills/lit-pptx/references/tonalities/chalk.md +0 -148
  737. package/plugin/skills/lit-pptx/references/tonalities/computational-brutalism.md +0 -150
  738. package/plugin/skills/lit-pptx/references/tonalities/gazette.md +0 -149
  739. package/plugin/skills/lit-pptx/references/tonalities/ledger.md +0 -149
  740. package/plugin/skills/lit-pptx/references/tonalities/neo-brutalism.md +0 -161
  741. package/plugin/skills/lit-pptx/references/tonalities/newsroom.md +0 -144
  742. package/plugin/skills/lit-pptx/references/tonalities/night.md +0 -147
  743. package/plugin/skills/lit-pptx/references/tonalities/paper.md +0 -151
  744. package/plugin/skills/lit-pptx/references/tonalities/riso.md +0 -137
  745. package/plugin/skills/lit-pptx/references/tonalities/signal.md +0 -150
  746. package/plugin/skills/lit-pptx/references/tonalities/studio.md +0 -131
  747. package/plugin/skills/lit-pptx/scripts/compile-deck.js +0 -462
  748. package/plugin/skills/lit-pptx/scripts/craft_extras.py +0 -1077
  749. package/plugin/skills/lit-pptx/scripts/deck_craft.py +0 -363
  750. package/plugin/skills/lit-pptx/scripts/embed_fonts.py +0 -227
  751. package/plugin/skills/lit-pptx/scripts/forbidden-terms.json +0 -55
  752. package/plugin/skills/lit-pptx/scripts/layout_inventory.py +0 -418
  753. package/plugin/skills/lit-pptx/scripts/learn_template.py +0 -446
  754. package/plugin/skills/lit-pptx/scripts/lib/derive-palette.js +0 -176
  755. package/plugin/skills/lit-pptx/scripts/lib/directive-parser.js +0 -244
  756. package/plugin/skills/lit-pptx/scripts/lib/font-map.js +0 -79
  757. package/plugin/skills/lit-pptx/scripts/lib/gen-bg.js +0 -86
  758. package/plugin/skills/lit-pptx/scripts/lib/gen-gradient-assets.js +0 -37
  759. package/plugin/skills/lit-pptx/scripts/lib/grid-resolver.js +0 -512
  760. package/plugin/skills/lit-pptx/scripts/lib/layout-resolver.js +0 -1113
  761. package/plugin/skills/lit-pptx/scripts/lib/markdown-loader.js +0 -138
  762. package/plugin/skills/lit-pptx/scripts/lib/render-adapter-html.js +0 -356
  763. package/plugin/skills/lit-pptx/scripts/lib/render-adapter-pptx.js +0 -2240
  764. package/plugin/skills/lit-pptx/scripts/lib/render-pack.js +0 -3366
  765. package/plugin/skills/lit-pptx/scripts/lib/runtime-require.js +0 -28
  766. package/plugin/skills/lit-pptx/scripts/lib/slide-ast.js +0 -565
  767. package/plugin/skills/lit-pptx/scripts/lib/slide-grid.js +0 -104
  768. package/plugin/skills/lit-pptx/scripts/lib/spec-validator.js +0 -94
  769. package/plugin/skills/lit-pptx/scripts/lib/template-registry.js +0 -730
  770. package/plugin/skills/lit-pptx/scripts/office-runtime-lock/package-lock.json +0 -793
  771. package/plugin/skills/lit-pptx/scripts/office-runtime-lock/package.json +0 -12
  772. package/plugin/skills/lit-pptx/scripts/office-runtime-lock/requirements.lock +0 -15
  773. package/plugin/skills/lit-pptx/scripts/office-runtime.mjs +0 -279
  774. package/plugin/skills/lit-pptx/scripts/office_data.py +0 -493
  775. package/plugin/skills/lit-pptx/scripts/office_runtime_bootstrap.py +0 -73
  776. package/plugin/skills/lit-pptx/scripts/ooxml_integrity.py +0 -199
  777. package/plugin/skills/lit-pptx/scripts/package.json +0 -4
  778. package/plugin/skills/lit-pptx/scripts/qa_deck.py +0 -795
  779. package/plugin/skills/lit-pptx/scripts/render_pages.py +0 -147
  780. package/plugin/skills/lit-pptx/scripts/validate_pptx.py +0 -230
  781. package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v1.md +0 -251
  782. package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v2.md +0 -214
  783. package/plugin/skills/lit-pptx/specs/slide-ast-v1.schema.json +0 -229
  784. package/plugin/skills/lit-pptx/specs/slide-ast-v2.schema.json +0 -144
  785. package/plugin/skills/lit-pptx/specs/template-enrollment-contract.md +0 -382
  786. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-A2Z/capabilities.yaml +0 -146
  787. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-A2Z/layout-mapping.yaml +0 -454
  788. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-A2Z/template.yaml +0 -40
  789. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-PRO/capabilities.yaml +0 -154
  790. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-PRO/layout-mapping.yaml +0 -475
  791. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-PRO/template.yaml +0 -40
  792. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-A2Z/capabilities.yaml +0 -179
  793. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-A2Z/layout-mapping.yaml +0 -299
  794. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-A2Z/template.yaml +0 -45
  795. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-PRETENDARD/capabilities.yaml +0 -181
  796. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-PRETENDARD/layout-mapping.yaml +0 -299
  797. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-PRETENDARD/template.yaml +0 -44
  798. package/plugin/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +0 -92
  799. package/plugin/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +0 -98
  800. package/plugin/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +0 -97
  801. package/plugin/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +0 -99
  802. package/plugin/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +0 -93
  803. package/plugin/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +0 -94
  804. package/plugin/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +0 -107
  805. package/plugin/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +0 -99
  806. package/plugin/skills/lit-pptx/templates/tonalities/night/pack.yaml +0 -93
  807. package/plugin/skills/lit-pptx/templates/tonalities/paper/pack.yaml +0 -98
  808. package/plugin/skills/lit-pptx/templates/tonalities/riso/pack.yaml +0 -99
  809. package/plugin/skills/lit-pptx/templates/tonalities/signal/pack.yaml +0 -94
  810. package/plugin/skills/lit-pptx/templates/tonalities/studio/pack.yaml +0 -92
  811. package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +0 -38
  812. package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +0 -133
  813. package/plugin/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +0 -87
  814. package/plugin/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +0 -85
  815. package/plugin/skills/lit-schematic/references/cutaway-outputs.md +0 -70
  816. package/plugin/skills/lit-schematic/references/isometric-craft.md +0 -101
  817. package/plugin/skills/lit-schematic/references/journal-figures.md +0 -72
  818. package/plugin/skills/lit-schematic/references/kit-api.md +0 -134
  819. package/plugin/skills/lit-schematic/references/pfd-and-layout.md +0 -53
  820. package/plugin/skills/lit-schematic/references/pid-drafting.md +0 -103
  821. package/plugin/skills/lit-schematic/references/pid-symbols.md +0 -163
  822. package/plugin/skills/lit-schematic/references/verification.md +0 -100
  823. package/plugin/skills/lit-schematic/scripts/doctor.mjs +0 -57
  824. package/plugin/skills/lit-schematic/scripts/lib/figure.mjs +0 -81
  825. package/plugin/skills/lit-schematic/scripts/lib/fonts.mjs +0 -27
  826. package/plugin/skills/lit-schematic/scripts/lib/geom.mjs +0 -113
  827. package/plugin/skills/lit-schematic/scripts/lib/interactive.mjs +0 -292
  828. package/plugin/skills/lit-schematic/scripts/lib/isa.mjs +0 -115
  829. package/plugin/skills/lit-schematic/scripts/lib/iso.mjs +0 -719
  830. package/plugin/skills/lit-schematic/scripts/lib/legend-sheet.mjs +0 -162
  831. package/plugin/skills/lit-schematic/scripts/lib/pid.mjs +0 -937
  832. package/plugin/skills/lit-schematic/scripts/lib/png.mjs +0 -132
  833. package/plugin/skills/lit-schematic/scripts/lib/qa-core.mjs +0 -658
  834. package/plugin/skills/lit-schematic/scripts/lib/route.mjs +0 -218
  835. package/plugin/skills/lit-schematic/scripts/lib/sheet.mjs +0 -890
  836. package/plugin/skills/lit-schematic/scripts/lib/svg.mjs +0 -82
  837. package/plugin/skills/lit-schematic/scripts/lib/theme.mjs +0 -115
  838. package/plugin/skills/lit-schematic/scripts/motion.mjs +0 -129
  839. package/plugin/skills/lit-schematic/scripts/qa.mjs +0 -92
  840. package/plugin/skills/lit-schematic/scripts/render.mjs +0 -233
  841. package/plugin/skills/lit-schematic/scripts/scaffold.mjs +0 -60
  842. package/plugin/skills/lit-scientific-visualization/LICENSE +0 -21
  843. package/plugin/skills/lit-scientific-visualization/assets/color_palettes.py +0 -197
  844. package/plugin/skills/lit-scientific-visualization/assets/nature.mplstyle +0 -75
  845. package/plugin/skills/lit-scientific-visualization/assets/presentation.mplstyle +0 -74
  846. package/plugin/skills/lit-scientific-visualization/assets/publication.mplstyle +0 -78
  847. package/plugin/skills/lit-scientific-visualization/evals/evals.json +0 -158
  848. package/plugin/skills/lit-scientific-visualization/references/canonical-workflow.md +0 -278
  849. package/plugin/skills/lit-scientific-visualization/references/color_palettes.md +0 -380
  850. package/plugin/skills/lit-scientific-visualization/references/journal_requirements.md +0 -359
  851. package/plugin/skills/lit-scientific-visualization/references/matplotlib_examples.md +0 -608
  852. package/plugin/skills/lit-scientific-visualization/references/mdanalysis_martini_visualization.md +0 -85
  853. package/plugin/skills/lit-scientific-visualization/references/publication_guidelines.md +0 -217
  854. package/plugin/skills/lit-scientific-visualization/references/seaborn_for_publications.md +0 -293
  855. package/plugin/skills/lit-scientific-visualization/scripts/figure_export.py +0 -238
  856. package/plugin/skills/lit-scientific-visualization/scripts/sciviz-runtime-requirements.lock +0 -23
  857. package/plugin/skills/lit-scientific-visualization/scripts/sciviz-runtime.mjs +0 -230
  858. package/plugin/skills/lit-scientific-visualization/scripts/style_presets.py +0 -467
  859. package/plugin/skills/lit-scientific-visualization/tests/test_figure_export.py +0 -51
  860. package/plugin/skills/lit-scientific-visualization/tests/test_style_presets.py +0 -114
  861. package/plugin/skills/lit-typographic-motion/engine/NOTICE +0 -23
  862. package/plugin/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +0 -73
  863. package/plugin/skills/lit-typographic-motion/engine/audio/beat_grid.py +0 -56
  864. package/plugin/skills/lit-typographic-motion/engine/audio/requirements.lock +0 -1084
  865. package/plugin/skills/lit-typographic-motion/engine/blender/runner.py +0 -218
  866. package/plugin/skills/lit-typographic-motion/engine/core/constants.mjs +0 -246
  867. package/plugin/skills/lit-typographic-motion/engine/core/contrast.mjs +0 -90
  868. package/plugin/skills/lit-typographic-motion/engine/core/events.mjs +0 -46
  869. package/plugin/skills/lit-typographic-motion/engine/core/flash.mjs +0 -211
  870. package/plugin/skills/lit-typographic-motion/engine/core/gate-rules.mjs +0 -550
  871. package/plugin/skills/lit-typographic-motion/engine/core/presets.mjs +0 -123
  872. package/plugin/skills/lit-typographic-motion/engine/core/text.mjs +0 -100
  873. package/plugin/skills/lit-typographic-motion/engine/core/timeline.mjs +0 -142
  874. package/plugin/skills/lit-typographic-motion/engine/core/util.mjs +0 -167
  875. package/plugin/skills/lit-typographic-motion/engine/core/voices.mjs +0 -19
  876. package/plugin/skills/lit-typographic-motion/engine/models/word-timing.json +0 -198
  877. package/plugin/skills/lit-typographic-motion/engine/node/analysis.mjs +0 -172
  878. package/plugin/skills/lit-typographic-motion/engine/node/assets.mjs +0 -298
  879. package/plugin/skills/lit-typographic-motion/engine/node/blender.mjs +0 -143
  880. package/plugin/skills/lit-typographic-motion/engine/node/board.mjs +0 -136
  881. package/plugin/skills/lit-typographic-motion/engine/node/brief.mjs +0 -164
  882. package/plugin/skills/lit-typographic-motion/engine/node/chrome.mjs +0 -328
  883. package/plugin/skills/lit-typographic-motion/engine/node/cover-assets.mjs +0 -104
  884. package/plugin/skills/lit-typographic-motion/engine/node/cover-capture.mjs +0 -210
  885. package/plugin/skills/lit-typographic-motion/engine/node/cover-gate.mjs +0 -347
  886. package/plugin/skills/lit-typographic-motion/engine/node/cover-image.mjs +0 -141
  887. package/plugin/skills/lit-typographic-motion/engine/node/cover-sheet.mjs +0 -76
  888. package/plugin/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +0 -139
  889. package/plugin/skills/lit-typographic-motion/engine/node/cover-worker.mjs +0 -32
  890. package/plugin/skills/lit-typographic-motion/engine/node/cover.mjs +0 -385
  891. package/plugin/skills/lit-typographic-motion/engine/node/coverage.mjs +0 -83
  892. package/plugin/skills/lit-typographic-motion/engine/node/done.mjs +0 -209
  893. package/plugin/skills/lit-typographic-motion/engine/node/encode.mjs +0 -105
  894. package/plugin/skills/lit-typographic-motion/engine/node/frame-worker.mjs +0 -38
  895. package/plugin/skills/lit-typographic-motion/engine/node/gallery.mjs +0 -121
  896. package/plugin/skills/lit-typographic-motion/engine/node/host.mjs +0 -34
  897. package/plugin/skills/lit-typographic-motion/engine/node/house.mjs +0 -44
  898. package/plugin/skills/lit-typographic-motion/engine/node/look.mjs +0 -178
  899. package/plugin/skills/lit-typographic-motion/engine/node/pipeline.mjs +0 -603
  900. package/plugin/skills/lit-typographic-motion/engine/node/png.mjs +0 -112
  901. package/plugin/skills/lit-typographic-motion/engine/node/report.mjs +0 -66
  902. package/plugin/skills/lit-typographic-motion/engine/node/runtime.mjs +0 -349
  903. package/plugin/skills/lit-typographic-motion/engine/node/scaffold.mjs +0 -210
  904. package/plugin/skills/lit-typographic-motion/engine/node/score.mjs +0 -639
  905. package/plugin/skills/lit-typographic-motion/engine/node/session.mjs +0 -145
  906. package/plugin/skills/lit-typographic-motion/engine/node/sound-cli.mjs +0 -77
  907. package/plugin/skills/lit-typographic-motion/engine/node/sound.mjs +0 -740
  908. package/plugin/skills/lit-typographic-motion/engine/node/stage-capture.mjs +0 -180
  909. package/plugin/skills/lit-typographic-motion/engine/node/stage-gate.mjs +0 -177
  910. package/plugin/skills/lit-typographic-motion/engine/node/stage-qa.mjs +0 -427
  911. package/plugin/skills/lit-typographic-motion/engine/node/stage-serve.mjs +0 -428
  912. package/plugin/skills/lit-typographic-motion/engine/node/stage.mjs +0 -572
  913. package/plugin/skills/lit-typographic-motion/engine/node/stills.mjs +0 -100
  914. package/plugin/skills/lit-typographic-motion/engine/node/styles.mjs +0 -213
  915. package/plugin/skills/lit-typographic-motion/engine/node/treatment.mjs +0 -645
  916. package/plugin/skills/lit-typographic-motion/engine/node/webp.mjs +0 -146
  917. package/plugin/skills/lit-typographic-motion/engine/node/ws-server.mjs +0 -132
  918. package/plugin/skills/lit-typographic-motion/engine/package-lock.json +0 -25
  919. package/plugin/skills/lit-typographic-motion/engine/package.json +0 -10
  920. package/plugin/skills/lit-typographic-motion/engine/stage/cover-init.js +0 -49
  921. package/plugin/skills/lit-typographic-motion/engine/stage/init.js +0 -298
  922. package/plugin/skills/lit-typographic-motion/engine/stage/loop-kit.js +0 -106
  923. package/plugin/skills/lit-typographic-motion/engine/stage/qa.js +0 -162
  924. package/plugin/skills/lit-typographic-motion/engine/stage/stage-kit.js +0 -823
  925. package/plugin/skills/lit-typographic-motion/engine/vendor/three/LICENSE +0 -21
  926. package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +0 -144
  927. package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +0 -155
  928. package/plugin/skills/lit-typographic-motion/engine/vendor/three/three.module.js +0 -54571
  929. package/plugin/skills/lit-typographic-motion/engine/web/boot.mjs +0 -123
  930. package/plugin/skills/lit-typographic-motion/engine/web/engine.mjs +0 -281
  931. package/plugin/skills/lit-typographic-motion/engine/web/gl.mjs +0 -319
  932. package/plugin/skills/lit-typographic-motion/engine/web/glsl-common.mjs +0 -78
  933. package/plugin/skills/lit-typographic-motion/engine/web/index.html +0 -6
  934. package/plugin/skills/lit-typographic-motion/engine/web/lines.mjs +0 -112
  935. package/plugin/skills/lit-typographic-motion/engine/web/passes/crt.mjs +0 -98
  936. package/plugin/skills/lit-typographic-motion/engine/web/passes/dither.mjs +0 -49
  937. package/plugin/skills/lit-typographic-motion/engine/web/passes/glitch.mjs +0 -77
  938. package/plugin/skills/lit-typographic-motion/engine/web/passes/swiss-grid.mjs +0 -61
  939. package/plugin/skills/lit-typographic-motion/engine/web/passes/terminal-ui.mjs +0 -88
  940. package/plugin/skills/lit-typographic-motion/engine/web/passes/tidal-gradient.mjs +0 -86
  941. package/plugin/skills/lit-typographic-motion/engine/web/post.mjs +0 -165
  942. package/plugin/skills/lit-typographic-motion/engine/web/scale.mjs +0 -15
  943. package/plugin/skills/lit-typographic-motion/engine/web/scene.mjs +0 -82
  944. package/plugin/skills/lit-typographic-motion/engine/web/scenes/end-card.mjs +0 -30
  945. package/plugin/skills/lit-typographic-motion/engine/web/scenes/index.mjs +0 -16
  946. package/plugin/skills/lit-typographic-motion/engine/web/scenes/karaoke-line.mjs +0 -47
  947. package/plugin/skills/lit-typographic-motion/engine/web/scenes/kinetic-list.mjs +0 -45
  948. package/plugin/skills/lit-typographic-motion/engine/web/scenes/number-counter.mjs +0 -29
  949. package/plugin/skills/lit-typographic-motion/engine/web/scenes/signature.mjs +0 -73
  950. package/plugin/skills/lit-typographic-motion/engine/web/scenes/title-slam.mjs +0 -73
  951. package/plugin/skills/lit-typographic-motion/engine/web/stroke.mjs +0 -236
  952. package/plugin/skills/lit-typographic-motion/engine/web/type.mjs +0 -180
  953. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w100-400.ttf +0 -0
  954. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w100-700.ttf +0 -0
  955. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w100-900.ttf +0 -0
  956. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w125-400.ttf +0 -0
  957. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w125-700.ttf +0 -0
  958. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w125-900.ttf +0 -0
  959. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w75-400.ttf +0 -0
  960. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w75-700.ttf +0 -0
  961. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w75-900.ttf +0 -0
  962. package/plugin/skills/lit-typographic-motion/fonts/archivo/OFL.txt +0 -93
  963. package/plugin/skills/lit-typographic-motion/fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2 +0 -0
  964. package/plugin/skills/lit-typographic-motion/fonts/jetbrains-mono/OFL.txt +0 -93
  965. package/plugin/skills/lit-typographic-motion/fonts/manifest.json +0 -455
  966. package/plugin/skills/lit-typographic-motion/fonts/silkscreen/OFL.txt +0 -93
  967. package/plugin/skills/lit-typographic-motion/fonts/silkscreen/Silkscreen-Bold.ttf +0 -0
  968. package/plugin/skills/lit-typographic-motion/fonts/silkscreen/Silkscreen-Regular.ttf +0 -0
  969. package/plugin/skills/lit-typographic-motion/fonts/stroke/CREDITS +0 -42
  970. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSAllure.svg +0 -216
  971. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSFelix.svg +0 -216
  972. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSOsmotron.svg +0 -216
  973. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSReadability.svg +0 -216
  974. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSTech.svg +0 -217
  975. package/plugin/skills/lit-typographic-motion/fonts/stroke/OFL.txt +0 -91
  976. package/plugin/skills/lit-typographic-motion/fonts/vt323/OFL.txt +0 -93
  977. package/plugin/skills/lit-typographic-motion/fonts/vt323/VT323-Regular.ttf +0 -0
  978. package/plugin/skills/lit-typographic-motion/recipes/hero-3d/expected.json +0 -69
  979. package/plugin/skills/lit-typographic-motion/recipes/hero-3d/index.html +0 -139
  980. package/plugin/skills/lit-typographic-motion/recipes/negatives/card-scenes/expected.json +0 -16
  981. package/plugin/skills/lit-typographic-motion/recipes/negatives/card-scenes/index.html +0 -27
  982. package/plugin/skills/lit-typographic-motion/recipes/negatives/reset-sweep/expected.json +0 -16
  983. package/plugin/skills/lit-typographic-motion/recipes/negatives/reset-sweep/index.html +0 -17
  984. package/plugin/skills/lit-typographic-motion/recipes/negatives/still-glow/expected.json +0 -17
  985. package/plugin/skills/lit-typographic-motion/recipes/negatives/still-glow/index.html +0 -18
  986. package/plugin/skills/lit-typographic-motion/recipes/negatives/title-slam/expected.json +0 -17
  987. package/plugin/skills/lit-typographic-motion/recipes/negatives/title-slam/index.html +0 -30
  988. package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +0 -69
  989. package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/index.html +0 -152
  990. package/plugin/skills/lit-typographic-motion/recipes/painted-light/expected.json +0 -97
  991. package/plugin/skills/lit-typographic-motion/recipes/painted-light/index.html +0 -202
  992. package/plugin/skills/lit-typographic-motion/recipes/weight-tide/expected.json +0 -69
  993. package/plugin/skills/lit-typographic-motion/recipes/weight-tide/index.html +0 -100
  994. package/plugin/skills/lit-typographic-motion/references/brief-schema.md +0 -119
  995. package/plugin/skills/lit-typographic-motion/references/cover.md +0 -424
  996. package/plugin/skills/lit-typographic-motion/references/craft-loop.md +0 -70
  997. package/plugin/skills/lit-typographic-motion/references/depth.md +0 -122
  998. package/plugin/skills/lit-typographic-motion/references/engine-contract.md +0 -124
  999. package/plugin/skills/lit-typographic-motion/references/look.md +0 -122
  1000. package/plugin/skills/lit-typographic-motion/references/runtime.md +0 -67
  1001. package/plugin/skills/lit-typographic-motion/references/sound.md +0 -152
  1002. package/plugin/skills/lit-typographic-motion/references/stage.md +0 -256
  1003. package/plugin/skills/lit-typographic-motion/references/studio.md +0 -245
  1004. package/plugin/skills/lit-typographic-motion/references/style-bibles.md +0 -141
  1005. package/plugin/skills/lit-typographic-motion/references/treatment.md +0 -214
  1006. package/plugin/skills/lit-typographic-motion/references/type-craft.md +0 -87
  1007. package/plugin/skills/lit-typographic-motion/scripts/motion-doctor.mjs +0 -111
  1008. package/plugin/skills/lit-typographic-motion/scripts/motion-runtime.mjs +0 -95
  1009. package/plugin/skills/lit-typographic-motion/scripts/motion.mjs +0 -205
  1010. package/plugin/skills/lit-typographic-motion/styles/paper.json +0 -41
  1011. package/plugin/skills/lit-typographic-motion/styles/swiss-signal.json +0 -41
  1012. package/plugin/skills/lit-typographic-motion/styles/terminalcore.json +0 -42
  1013. package/plugin/skills/lit-typographic-motion/styles/tidal.json +0 -41
  1014. package/plugin/skills/readme-studio/references/decoration-and-navigation.md +0 -55
  1015. package/plugin/skills/readme-studio/references/facts-and-assembly.md +0 -19
  1016. package/plugin/skills/readme-studio/references/production-interview.md +0 -11
  1017. package/plugin/skills/readme-studio/references/render-and-deliver.md +0 -44
  1018. package/plugin/skills/readme-studio/references/type-and-background.md +0 -23
  1019. package/plugin/skills/readme-studio/scripts/readme-runtime-lock/package-lock.json +0 -133
  1020. package/plugin/skills/readme-studio/scripts/readme-runtime-lock/package.json +0 -6
  1021. package/plugin/skills/readme-studio/scripts/readme-runtime.mjs +0 -77
  1022. package/plugin/skills/readme-studio/scripts/validate-readme-facts.mjs +0 -28
  1023. package/plugin/skills/readme-studio/templates/cover-source.json +0 -21
  1024. package/plugin/skills/readme-studio/templates/hyperframes-cover/index.html +0 -30
  1025. package/plugin/skills/readme-studio/templates/hyperframes-cover/index.motion.json +0 -1
  1026. package/plugin/skills/readme-studio/templates/hyperframes-cover/package-lock.json +0 -2017
  1027. package/plugin/skills/readme-studio/templates/hyperframes-cover/package.json +0 -8
  1028. package/plugin/skills/readme-studio/templates/readme-cover-section.md +0 -75
  1029. package/plugin/skills/readme-studio/templates/readme-facts.json +0 -4
  1030. package/plugin/skills/readme-studio/templates/remotion-cover/package-lock.json +0 -3783
  1031. package/plugin/skills/readme-studio/templates/remotion-cover/package.json +0 -7
  1032. package/plugin/skills/readme-studio/templates/remotion-cover/src/index.tsx +0 -36
  1033. package/plugin/skills/readme-studio/templates/typography/package-lock.json +0 -133
  1034. package/plugin/skills/readme-studio/templates/typography/package.json +0 -6
  1035. package/plugin/skills/readme-studio/templates/typography/safe-files.mjs +0 -57
  1036. package/plugin/skills/readme-studio/templates/typography/shape-text-to-svg.mjs +0 -63
  1037. package/plugin/skills/visual-qa/references/breakage-catalogue.md +0 -70
  1038. package/plugin/skills/visual-qa/references/capture-playbook.md +0 -96
  1039. package/plugin/skills/visual-qa/references/complete-contract.md +0 -411
  1040. package/plugin/skills/visual-qa/references/korean-and-mixed-script-checks.md +0 -50
  1041. package/plugin/skills/visual-qa/references/reviewer-charters.md +0 -70
  1042. package/plugin/skills/visual-qa/schemas/design-contract-v1alpha1.schema.json +0 -305
  1043. package/plugin/skills/visual-qa/schemas/design-contract-v1beta1.schema.json +0 -291
  1044. package/plugin/skills/visual-qa/schemas/design-contract-v1beta2.schema.json +0 -311
  1045. package/plugin/skills/visual-qa/schemas/evidence-manifest-v1alpha1.schema.json +0 -235
  1046. package/plugin/skills/visual-qa/schemas/evidence-manifest-v1beta1.schema.json +0 -208
  1047. package/plugin/skills/visual-qa/schemas/review-receipt-v1alpha1.schema.json +0 -66
  1048. package/plugin/skills/visual-qa/scripts/ansi.ts +0 -17
  1049. package/plugin/skills/visual-qa/scripts/cli.mjs +0 -101
  1050. package/plugin/skills/visual-qa/scripts/cli.ts +0 -96
  1051. package/plugin/skills/visual-qa/scripts/design-contract-shape.mjs +0 -448
  1052. package/plugin/skills/visual-qa/scripts/east-asian-width.ts +0 -72
  1053. package/plugin/skills/visual-qa/scripts/errors.mjs +0 -12
  1054. package/plugin/skills/visual-qa/scripts/evidence-io.mjs +0 -184
  1055. package/plugin/skills/visual-qa/scripts/evidence-semantic.mjs +0 -95
  1056. package/plugin/skills/visual-qa/scripts/evidence-shape.mjs +0 -163
  1057. package/plugin/skills/visual-qa/scripts/evidence.mjs +0 -421
  1058. package/plugin/skills/visual-qa/scripts/image-diff.mjs +0 -89
  1059. package/plugin/skills/visual-qa/scripts/image-diff.ts +0 -109
  1060. package/plugin/skills/visual-qa/scripts/png-chunks.mjs +0 -107
  1061. package/plugin/skills/visual-qa/scripts/png-crc.ts +0 -27
  1062. package/plugin/skills/visual-qa/scripts/png-decode.mjs +0 -143
  1063. package/plugin/skills/visual-qa/scripts/png-decode.ts +0 -206
  1064. package/plugin/skills/visual-qa/scripts/png-synth.ts +0 -57
  1065. package/plugin/skills/visual-qa/scripts/review-rules.mjs +0 -137
  1066. package/plugin/skills/visual-qa/scripts/strict-json.mjs +0 -143
  1067. package/plugin/skills/visual-qa/scripts/terminal-text.mjs +0 -117
  1068. package/plugin/skills/visual-qa/scripts/tui-check.mjs +0 -74
  1069. package/plugin/skills/visual-qa/scripts/tui-grid.ts +0 -88
  1070. package/plugin/skills/visual-qa/scripts/types.ts +0 -54
@@ -1,3366 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * render-pack.js — one renderer for every tonality pack.
5
- *
6
- * It reads palette roles, faces, ramp sizes, density tokens, the treatment geometry the resolver
7
- * worked out and the slide's layout family; nothing here branches on which pack it is. A family
8
- * is a plan: it splits the treatment's body zone into regions on the 12-column grid and places the
9
- * slide's content in them. A plan runs again under the pack's fill policies (larger type, wider
10
- * gaps, the visual taking the room) until the body is used, and the treatment is chosen among the
11
- * ones the role and family allow by how well the content fills it. Geometry is in points until
12
- * the moment a shape is added.
13
- */
14
-
15
- const path = require("path");
16
- const G = require("./grid-resolver");
17
- const SG = require("./slide-grid");
18
- const { runtimeRequire } = require("./runtime-require");
19
- const { looksLikeKpi } = require("./layout-resolver");
20
-
21
- // Helpers shared with the legacy renderer (hex, cleanMd, tables, charts, images, placements).
22
- let A = null;
23
- function shared() {
24
- if (!A) A = require("./render-adapter-pptx").shared;
25
- return A;
26
- }
27
-
28
- const IN = (pt) => pt / 72;
29
- const plainText = (s) => shared().cleanMd(String(s || "").replace(/\*\*/g, ""));
30
-
31
- // ── Style ───────────────────────────────────────────────────────────────────
32
-
33
- function packStyle(pack) {
34
- const P = pack.palette;
35
- const voice = pack["type-voice"] || {};
36
- return {
37
- pack, P, sizes: pack.tok.sizes, tok: pack.tok, grid: pack.grid, faces: pack.faces,
38
- deco: new Set(pack.decoration || []),
39
- // Heavier faces set wider: the advance estimate grows with the weight so frames hold their lines.
40
- wide(role = "body", text) { return G.faceWidth(pack.faces[role], text); },
41
- ems(text, role) { return G.textEms(text) * this.wide(role, text); },
42
- lines(text, w, size, role) { return G.lineCount(text, w / this.wide(role, text), size); },
43
- colour: (role) => shared().hex(P[role] || P.ink),
44
- // Tracking is a percentage of the size; Hangul body text is never tracked.
45
- tracking(face, size) {
46
- const pct = face === "display" || face === "numeral" ? voice["display-tracking"] : face === "title" ? voice["title-tracking"] : 0;
47
- return pct ? +((size * pct) / 100).toFixed(2) : 0;
48
- },
49
- };
50
- }
51
-
52
- /** `a` moved toward `b` by `t` (0-1), as #RRGGBB. */
53
- function mix(a, b, t) {
54
- const c = (h, i) => parseInt(String(h).replace("#", "").slice(i, i + 2), 16);
55
- const out = [0, 2, 4].map((i) => Math.round(c(a, i) + (c(b, i) - c(a, i)) * t).toString(16).padStart(2, "0"));
56
- return `#${out.join("").toUpperCase()}`;
57
- }
58
-
59
- // ── Drawing primitives ──────────────────────────────────────────────────────
60
-
61
- /** Title runs: **marked** words in the accent, the rest in the title colour. */
62
- function titleRuns(text, S, base) {
63
- return String(text || "").split(/(\*\*[^*]+\*\*)/g).filter(Boolean).map((part) => {
64
- const marked = part.startsWith("**") && part.endsWith("**");
65
- return { text: marked ? part.slice(2, -2) : part, options: { ...base, ...(marked ? { color: S.colour("accent") } : {}) } };
66
- });
67
- }
68
-
69
- /**
70
- * Display text broken at word boundaries into lines of near-equal width, at the line count the
71
- * frame was measured for, or one more when long words keep every split at that count too wide and
72
- * the frame holds that line (the renderer would wrap to it anyway); text with marked words is left
73
- * to the renderer's own wrapping.
74
- */
75
- function balanced(S, text, w, size, role, room = Infinity) {
76
- const s = String(text || "");
77
- if (/\*\*/u.test(s)) return s;
78
- const lines = S.lines(s, w, size, role);
79
- if (lines < 2) return s;
80
- const per = w / S.wide(role, s) / size;
81
- const set = G.balanceLines(s, lines, per);
82
- // A set ending on one word gets a line more when the frame holds it and that ends on two.
83
- const widow = (t) => t.includes("\n") && !/ /u.test(t.slice(t.lastIndexOf("\n") + 1));
84
- if (set !== s && !widow(set)) return set;
85
- const more = lines + 1 <= room ? G.balanceLines(s, lines + 1, per) : s;
86
- return more !== s && (set === s || !widow(more)) ? more : set;
87
- }
88
-
89
- /** A run split around the linked words it holds, each linked piece carrying its address. */
90
- function linkRuns(run, links) {
91
- for (const [label, url] of links) {
92
- const at = run.text.indexOf(label);
93
- if (at < 0) continue;
94
- const { breakLine, ...rest } = run.options;
95
- const parts = [
96
- at > 0 ? { text: run.text.slice(0, at), options: rest } : null,
97
- { text: label, options: { ...rest, hyperlink: { url } } },
98
- ...linkRuns({ text: run.text.slice(at + label.length), options: run.options }, links),
99
- ].filter((p) => p && p.text !== "");
100
- if (breakLine && parts.length) parts[parts.length - 1] = { ...parts[parts.length - 1], options: { ...parts[parts.length - 1].options, breakLine: true } };
101
- return parts;
102
- }
103
- return [run];
104
- }
105
-
106
- /** A flush text frame (zero insets) on the grid. */
107
- function packText(slide, S, text, box, o = {}) {
108
- const faceRole = o.face || "body";
109
- const face = S.faces[faceRole];
110
- const size = o.size || S.sizes.body;
111
- // A Markdown link is set as its words, linked; the brackets and the address never reach the page.
112
- const links = [];
113
- text = String(text == null ? "" : text).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/gu, (_, label, url) => { links.push([label, url]); return label; });
114
- if (o.balance) text = balanced(S, text, box.w, size, faceRole, Math.floor(box.h / (size * (o.lineSpacing || 1.15)) + 0.01));
115
- else if (!o.title && faceRole !== "numeral") {
116
- text = G.keepLines(text, box.w / S.wide(faceRole, plainText(text)) / size, Math.floor(box.h / (size * (o.lineSpacing || G.leading(plainText(text)))) + 0.01));
117
- }
118
- const tracking = o.tracking != null ? o.tracking : S.tracking(faceRole, size);
119
- const base = { fontFace: face.font, fontSize: size, color: o.colour || S.colour("ink"), bold: Boolean(face.bold || o.bold),
120
- ...(tracking ? { charSpacing: tracking } : {}) };
121
- const runs = (o.title ? titleRuns(text, S, base)
122
- : shared().mdRuns(text, base).map((r) => ({ ...r, options: { ...r.options, bold: base.bold || r.options.bold } })))
123
- // A break inside a run ends the line there and nowhere else (the run's last piece flows on).
124
- .flatMap((r) => r.text.split("\n").map((t, i, all) => ({ text: t, options: { ...r.options, ...(i < all.length - 1 ? { breakLine: true } : {}) } })))
125
- .flatMap((r) => linkRuns(r, links));
126
- // A numeral frame also holds the comma and the descenders that hang below a 1.15 line.
127
- const h = faceRole === "numeral" ? Math.max(box.h, size * 1.32) : box.h;
128
- slide.addText(runs, {
129
- x: IN(box.x), y: IN(box.y), w: IN(box.w), h: IN(Math.max(h, 1)),
130
- ...base,
131
- align: o.align || "left", valign: o.valign || "top",
132
- margin: [0, 0, 0, 0],
133
- // Exact leading in points, so a frame is as tall as the measure says on every renderer.
134
- lineSpacing: +(size * (o.lineSpacing || G.leading(plainText(text)))).toFixed(1),
135
- ...(o.name ? { objectName: o.name } : {}),
136
- });
137
- }
138
-
139
- function packRect(slide, S, box, o = {}) {
140
- const radius = o.radius || 0;
141
- // In a pack with hard edges a block of the field (a band, a plate, a rail) carries the border too.
142
- if (S.pack.shadow && o.fill === "field" && !o.line && box.w >= 24 && box.h >= 24) o = { ...o, line: S.pack["edge-colour"] || "line", lineWidth: S.pack["edge-weight"] };
143
- slide.addShape(radius ? "roundRect" : "rect", {
144
- x: IN(box.x), y: IN(box.y), w: IN(box.w), h: IN(box.h),
145
- ...(radius ? { rectRadius: IN(radius) } : {}),
146
- fill: o.fill ? { color: S.colour(o.fill), transparency: o.alpha || 0 } : { type: "none" },
147
- line: o.line ? { color: S.colour(o.line), width: o.lineWidth || 0.75 } : { type: "none" },
148
- // A hard offset shadow: no blur, fully opaque, down and to the right.
149
- ...(o.shadow && S.pack.shadow ? { shadow: { type: "outer", blur: 0, offset: S.pack.shadow.offset, angle: 45, color: S.colour(S.pack.shadow.colour).replace("#", ""), opacity: 1 } } : {}),
150
- ...(o.name ? { objectName: o.name } : {}),
151
- });
152
- }
153
-
154
- /** A surface (card, box, panel) in the pack's edge treatment and radius. */
155
- function surfaceRect(slide, S, box, fill = "surface") {
156
- const edge = S.pack.edge;
157
- // A shadowed surface is filled, so its shadow never shows through it.
158
- const shadow = S.pack.shadow || null;
159
- packRect(slide, S, box, {
160
- fill: edge === "border" && !shadow ? null : edge === "border" ? "ground" : fill,
161
- line: edge === "fill" ? null : S.pack["edge-colour"] || "line",
162
- lineWidth: S.pack["edge-weight"],
163
- radius: S.pack.radius,
164
- shadow,
165
- });
166
- }
167
-
168
- /** A pack with a hard shadow draws every box with its border and shadow (filled, `fill` when given). */
169
- function hardEdge(S, fill) {
170
- if (!S.pack.shadow) return {};
171
- return { line: S.pack["edge-colour"] || "line", lineWidth: S.pack["edge-weight"], shadow: S.pack.shadow, ...(fill ? { fill } : {}) };
172
- }
173
-
174
- // ── Content atoms ───────────────────────────────────────────────────────────
175
-
176
- /** Body paragraphs of a list, in reading order. */
177
- function packParas(items) {
178
- const paras = [];
179
- let counter = 0;
180
- const children = (list) => {
181
- counter = 0;
182
- for (const c of list || []) paras.push({ kind: "child", text: `(${++counter}) ${c.text || ""}` });
183
- };
184
- for (const it of items || []) {
185
- if (it.type === "section") { paras.push({ kind: "section", text: it.heading || "" }); children(it.children); }
186
- else if (it.type === "bullet") { paras.push({ kind: "bullet", text: it.text || "" }); children(it.children); }
187
- else if (it.type === "numbered") paras.push({ kind: "child", text: `(${++counter}) ${it.text || ""}` });
188
- else if (it.type === "text" && it.text) paras.push({ kind: "text", text: it.text });
189
- }
190
- return paras;
191
- }
192
-
193
- /** Paragraphs of one text item (body, summary group or callout). */
194
- function itemParas(item) {
195
- const c = item.content || {};
196
- if (item.type === "main-box") return [{ kind: "text", text: String(c) }];
197
- if (item.type === "summary-group") return [...(c.heading ? [{ kind: "section", text: c.heading }] : []), ...packParas(c.items)];
198
- return packParas(c.items);
199
- }
200
-
201
- /** Top-level entries of a list with their sub-points: a bold head, the rest of the line, children. */
202
- function entries(paras) {
203
- const out = [];
204
- for (const p of paras) {
205
- if (p.kind === "child" && out.length) { out[out.length - 1].children.push(p.text); continue; }
206
- const m = String(p.text).match(/^\*\*(.+?)\*\*\s*(.*)$/u);
207
- out.push({ kind: p.kind, head: m ? m[1].trim() : p.kind === "section" ? p.text : "", rest: m ? m[2].trim() : p.kind === "section" ? "" : p.text, children: [] });
208
- }
209
- return out;
210
- }
211
-
212
- /** A leading ordinal in a step head ("1. 수거" → 1, "수거"). */
213
- function ordinal(head, index) {
214
- const m = String(head || "").match(/^(\d{1,2})[.)]\s*(.*)$/u);
215
- return m ? { n: m[1], head: m[2] } : { n: String(index + 1), head };
216
- }
217
-
218
- const isText = (i) => ["body", "summary-group", "main-box"].includes(i.type);
219
- const isVisual = (i) => ["kpi-table", "image", "image-grid"].includes(i.type);
220
-
221
- function sortItems(items) {
222
- return {
223
- texts: items.filter(isText),
224
- visuals: items.filter(isVisual),
225
- columns: items.find((i) => i.type === "columns") || null,
226
- captions: items.filter((i) => i.type === "caption"),
227
- };
228
- }
229
-
230
- // ── Measure ─────────────────────────────────────────────────────────────────
231
-
232
- /** A ramp size under the fill state: one step up when stepped, a lead set at body size when compact. */
233
- function bodySize(S, state, role = "body") {
234
- if (state.compact && role === "lead") return S.sizes.body;
235
- return state.stepped ? S.sizes[G.stepRole(role)] : S.sizes[role];
236
- }
237
-
238
- /**
239
- * A point that opens with a bold run-in label reads "label: rest": the label keeps its own separator when it
240
- * ends in one, else it takes a colon (spec-v2 Amendments 8). A bold line with nothing after it is a heading.
241
- */
242
- function runIn(text) {
243
- const m = /^\*\*(.+?)\*\*\s+(\S[\s\S]*)$/u.exec(String(text == null ? "" : text));
244
- if (!m || /[::.)\]?!–—-]$/u.test(m[1].trim())) return text;
245
- return `**${m[1].trim()}:** ${m[2]}`;
246
- }
247
-
248
- /** A text block of paragraphs at width w. */
249
- function measureText(paras, w, S, state, o = {}) {
250
- const size = o.size || bodySize(S, state);
251
- const indent = Math.round(size * 1.1);
252
- const lines = paras.map((p, i) => {
253
- const inset = p.kind === "bullet" || p.kind === "child" ? indent : 0;
254
- const h = G.textHeight(plainText(runIn(p.text)), w - inset, size);
255
- const gap = i === 0 ? 0 : p.kind === "section" ? state.groupGap : state.itemGap;
256
- return { ...p, inset, h, gap };
257
- });
258
- return { kind: "text", paras: lines, w, size, h: lines.reduce((sum, l) => sum + l.gap + l.h, 0), muted: o.muted };
259
- }
260
-
261
- function captionText(caption) {
262
- // A source caption that already carries its own number ("표 1.") is renumbered, not doubled.
263
- const text = plainText(caption.caption).replace(/^(?:표|도|Figure|Table)\s*\d+\.\s*/u, "");
264
- return text ? `${caption.prefix} ${caption.number}. ${text}` : `${caption.prefix} ${caption.number}.`;
265
- }
266
-
267
- function captionHeight(caption, w, S) {
268
- if (!caption) return 0;
269
- return 6 + G.textHeight(captionText(caption), w, S.sizes.label, 1.3);
270
- }
271
-
272
- function measureTable(item, w, S, state) {
273
- const c = item.content;
274
- const headers = c.headers || [];
275
- const rows = c.rows || [];
276
- const header = S.sizes.label;
277
- const data = state.stepped ? S.sizes.body : S.sizes.label;
278
- const widths = headers.length ? shared().proportionalWidths(headers, rows, IN(w)).map((v) => v * 72) : [w];
279
- const cell = 6;
280
- const minRow = S.tok.rowMin * (state.anchor ? 1.25 : 1);
281
- // Rows are measured at the face's natural line (about 1.45 of the size with its gap), which is
282
- // what office renderers lay a cell out at; a smaller estimate lets rows grow past the frame.
283
- const rowH = (cells, size, role) => Math.max(minRow, ...cells.map((t, i) => G.textHeight(plainText(t), ((widths[i] || w) - cell * 2) / S.wide(role, plainText(t)), size, 1.45) + cell * 2));
284
- const heights = [rowH(headers, header, "label"), ...rows.map((r) => rowH(r, data, "body"))];
285
- const tableH = heights.reduce((a, b) => a + b, 0);
286
- return { kind: "table", heights, widths, header, data, tableH, h: tableH + captionHeight(item.caption, w, S) };
287
- }
288
-
289
- function measureKpi(item, w, S, state) {
290
- const cards = shared().kpiCards(item.content).slice(0, 6);
291
- const n = cards.length;
292
- const cardW = (w - (n - 1) * S.grid.gutter) / n;
293
- // The value stays on one line: the step-up size when it fits, else the largest that does.
294
- const longest = Math.max(...cards.map((k) => S.ems(plainText(k.value), "numeral")));
295
- const pad = S.tok.pad;
296
- const fitting = (size) => longest * size * 1.04 <= cardW - pad * 2;
297
- // A figure sits at most two steps above the body (title size), never at display or hero scale.
298
- const value = [S.sizes.title, S.sizes.lead, S.sizes.body].find((v) => fitting(v)) || S.sizes.body;
299
- const labelH = Math.max(...cards.map((k) => G.textHeight(plainText(k.label), cardW - pad * 2, S.sizes.label, 1.3)));
300
- const noteSize = S.sizes.label;
301
- const noteH = Math.max(0, ...cards.map((k) => (k.note ? G.textHeight(plainText(k.note), cardW - pad * 2, noteSize, 1.3) : 0)));
302
- const h = pad * 2 + value * 1.15 + 6 + labelH + (noteH ? 6 + noteH : 0);
303
- return { kind: "kpi", cards, n, cardW, value, pad, labelH, noteSize, noteH, h: h + captionHeight(item.caption, w, S), cardH: h };
304
- }
305
-
306
- /**
307
- * Measure one item at width w. Charts and images are flexible: they take the height the plan
308
- * gives them (the rest of their region when they anchor it).
309
- */
310
- function measureItem(item, w, S, state) {
311
- const c = item.content || {};
312
- if (isText(item)) {
313
- if (item.type === "main-box") {
314
- const pad = S.tok.pad;
315
- const m = measureText([{ kind: "text", text: String(c) }], w - pad * 2, S, state);
316
- return { kind: "callout", pad, size: m.size, h: pad * 2 + m.h };
317
- }
318
- return measureText(itemParas(item), w, S, state);
319
- }
320
- if (item.type === "kpi-table" && c.chart) return { kind: "chart", flex: true, cap: captionHeight(item.caption, w, S), min: 150 };
321
- if (item.type === "kpi-table" && !item.values && looksLikeKpi(c, { basis: true })) {
322
- const cards = shared().kpiCards(c).length;
323
- if (cards && (w - (cards - 1) * S.grid.gutter) / cards >= S.grid.span(1, 2).w) return measureKpi(item, w, S, state);
324
- }
325
- if (item.type === "kpi-table") return measureTable(item, w, S, state);
326
- if (item.type === "image" || item.type === "image-grid") return { kind: "image", flex: true, cap: captionHeight(item.caption, w, S), min: 150 };
327
- if (item.type === "caption") return { kind: "caption", h: G.textHeight(captionText(c), w, S.sizes.label, 1.3) };
328
- return { kind: "none", h: 0 };
329
- }
330
-
331
- // ── Regions ─────────────────────────────────────────────────────────────────
332
-
333
- /** Columns a…b of the deck grid as a region from y to bottom. */
334
- function region(S, a, b, y, bottom) {
335
- const s = S.grid.span(a, b);
336
- return { a, b, x: s.x, w: s.w, y, bottom };
337
- }
338
-
339
- /** Split a region's columns: the first `share` of them, and the rest. */
340
- function splitRegion(S, R, share) {
341
- const n = R.b - R.a + 1;
342
- const k = Math.max(1, Math.min(n - 1, Math.round(n * share)));
343
- return [region(S, R.a, R.a + k - 1, R.y, R.bottom), region(S, R.a + k, R.b, R.y, R.bottom)];
344
- }
345
-
346
- /** Equal parts of a region's columns (for 5 parts on 12 columns, equal slots off the column lines). */
347
- function equalParts(S, R, n) {
348
- const cols = R.b - R.a + 1;
349
- if (cols % n === 0) {
350
- const k = cols / n;
351
- return Array.from({ length: n }, (_, i) => region(S, R.a + i * k, R.a + (i + 1) * k - 1, R.y, R.bottom));
352
- }
353
- const gap = n >= 5 ? S.grid.gutter * 1.5 : S.grid.gutter;
354
- const w = (R.w - gap * (n - 1)) / n;
355
- return Array.from({ length: n }, (_, i) => ({ a: R.a, b: R.b, x: R.x + i * (w + gap), w, y: R.y, bottom: R.bottom }));
356
- }
357
-
358
- /**
359
- * Stack items down a region. Flexible visuals take an even share of the room the fixed items
360
- * leave, so a chart or image anchors the region's bottom. Returns placements with the region
361
- * bottom they must stay above.
362
- */
363
- function stack(items, R, S, state) {
364
- const placed = [];
365
- let y = R.y;
366
- items.forEach((item, i) => {
367
- if (item.type === "columns") {
368
- const weights = item.tracks.map((t) => parseFloat(String(t)) || 1);
369
- const total = weights.reduce((a, b) => a + b, 0);
370
- let at = R.a;
371
- const parts = weights.map((v, ci) => {
372
- const n = ci === weights.length - 1 ? R.b - at + 1 : Math.max(1, Math.round(((R.b - R.a + 1) * v) / total));
373
- const part = region(S, at, at + n - 1, y, R.bottom);
374
- at += n;
375
- return part;
376
- });
377
- const cols = parts.map((part, ci) => stack(item.columns[ci] || [], part, S, state));
378
- const bottom = Math.max(y, ...cols.map((c) => c.bottom));
379
- placed.push({ kind: "group", parts: cols.flatMap((c) => c.placed), y, h: bottom - y, x: R.x, w: R.w, limit: R.bottom });
380
- y = bottom + state.blockGap;
381
- return;
382
- }
383
- const m = measureItem(item, R.w, S, state);
384
- if (m.kind === "none") return;
385
- placed.push({ item, ...m, x: R.x, y, w: R.w, limit: R.bottom });
386
- y += (m.h || 0) + state.blockGap;
387
- });
388
- const flex = placed.filter((p) => p.flex);
389
- if (flex.length) {
390
- const fixed = placed.filter((p) => !p.flex).reduce((sum, p) => sum + p.h, 0);
391
- const gaps = state.blockGap * Math.max(0, placed.length - 1);
392
- const share = Math.max(...flex.map((p) => p.min), (R.bottom - R.y - fixed - gaps) / flex.length);
393
- let cursor = R.y;
394
- for (const p of placed) {
395
- if (p.flex) p.h = share;
396
- if (p.kind === "group") shiftGroup(p, cursor - p.y);
397
- p.y = cursor;
398
- cursor += p.h + state.blockGap;
399
- }
400
- y = cursor;
401
- }
402
- const bottom = placed.length ? Math.max(...placed.map((p) => p.y + p.h)) : R.y;
403
- return { placed, bottom };
404
- }
405
-
406
- function shiftGroup(p, dy) {
407
- if (!dy) return;
408
- for (const q of p.parts) {
409
- q.y += dy;
410
- if (q.kind === "group") shiftGroup(q, dy);
411
- }
412
- }
413
-
414
- /**
415
- * Pitch for n rows that share a region: the last row ends on the region floor, never closer than
416
- * the tallest row plus a gap and never wider than `max`.
417
- */
418
- function rowPitch(n, rowH, R, gap, max) {
419
- if (n <= 1) return rowH;
420
- return Math.max(rowH + gap, Math.min(max, (R.bottom - R.y - rowH) / (n - 1)));
421
- }
422
-
423
- /** A text block placed in a region. */
424
- function textAt(paras, R, S, state, o = {}) {
425
- const m = measureText(paras, R.w, S, state, o);
426
- return { ...m, x: R.x, y: R.y, limit: R.bottom };
427
- }
428
-
429
- // ── Layout families ─────────────────────────────────────────────────────────
430
- //
431
- // Each plan gets ctx = { spec, S, state, Z, cls, items } where Z is the treatment's body zone and
432
- // cls the treatment class (top, side, bottom). It returns placements; decoration placements carry
433
- // `decor: true`.
434
-
435
- /** A visual with its takeaway: beside it (share of the columns), or under it on a narrow body. */
436
- function visualWithText(ctx, visuals, texts, share, o = {}) {
437
- const { S, state, Z } = ctx;
438
- const out = [];
439
- // A visual alone (no takeaways): a table opens its rows; on the compact step a
440
- // chart carries its values under it.
441
- if (!texts.length) return ((S.tok.tight && valuesUnder(visuals, Z, S, state)) || openRows(stack(visuals, Z, S, state).placed, Z, S));
442
- if (!visuals.length) return stack(texts, Z, S, state).placed;
443
- // Takeaways too short for their column give the visual columns: a narrower column wraps them onto more
444
- // lines and a wider chart or picture grows, down to a three-column takeaway (spec-v2 Amendments 8).
445
- if (!o.fixed && Z.b - Z.a + 1 >= 6 && visuals.some((v) => v.type === "image" || (v.content || {}).chart)) {
446
- const n = Z.b - Z.a + 1;
447
- const base = visualWithText(ctx, visuals, texts, share, { ...o, fixed: true });
448
- let pick = base;
449
- // A picture drawn short of its column (a wide one in a narrow column) takes columns while either side
450
- // leaves more than a fifth of the body empty; a chart only while its takeaways leave over RAIL_EMPTY.
451
- const target = visuals.some((v) => v.type === "image") ? 0.2 : RAIL_EMPTY;
452
- for (let step = 1; shortColumn(pick, Z.bottom, S).share > target; step++) {
453
- const k = o.textFirst ? share - step / n : share + step / n;
454
- const textCols = o.textFirst ? Math.round(n * k) : n - Math.round(n * k);
455
- if (textCols < 3) break;
456
- const next = visualWithText(ctx, visuals, texts, k, { ...o, fixed: true });
457
- // A narrower column never costs the takeaways their size (a lead-size column dropping to body size read as shrunk).
458
- const size = (plan) => Math.max(0, ...plan.filter((q) => q.kind === "text" && !q.strip && !q.muted).map((q) => q.size || 0));
459
- if (!overflows(next) && size(next) >= size(base) && shortColumn(next, Z.bottom, S).share < shortColumn(pick, Z.bottom, S).share) pick = next;
460
- }
461
- // Takeaways too few for even a three-column column beside a chart run under it instead, side by side, and
462
- // the chart (with its values) takes the body's width above them.
463
- if (shortColumn(pick, Z.bottom, S).share > RAIL_EMPTY && visuals.some((v) => (v.content || {}).chart)) {
464
- const paras = texts.flatMap(itemParas);
465
- const half = Math.ceil(paras.length / 2);
466
- const parts = paras.length >= 2 ? splitRegion(S, Z, 0.5) : [Z];
467
- const measured = parts.map((R, i) => measureText(parts.length > 1 ? (i ? paras.slice(half) : paras.slice(0, half)) : paras, R.w, S, state));
468
- const notesH = Math.max(...measured.map((m) => m.h));
469
- const above = { ...Z, bottom: Z.bottom - notesH - state.blockGap };
470
- const top = (S.tok.tight && valuesUnder(visuals, above, S, state, true)) || stack(visuals, above, S, state);
471
- const chart = top.placed.find((q) => q.kind === "chart");
472
- if (chart && chart.h - chart.cap >= 150) {
473
- return [...top.placed, ...measured.map((m, i) => ({ ...m, x: parts[i].x, y: above.bottom + state.blockGap, limit: Z.bottom }))];
474
- }
475
- }
476
- return pick;
477
- }
478
- if (Z.b - Z.a + 1 >= 6) {
479
- let [left, right] = splitRegion(S, Z, share);
480
- // On the compact step takeaways too long for their column take half the body from the visual.
481
- if (S.tok.tight && share > 0.5 && stack(texts, o.textFirst ? left : right, S, state).bottom > Z.bottom) [left, right] = splitRegion(S, Z, 0.5);
482
- const [vR, full] = o.textFirst ? [right, left] : [left, right];
483
- let v = stack(visuals, vR, S, state);
484
- const col = takeawayColumn(ctx, texts, visuals, full, v.bottom);
485
- const t = col.t;
486
- // When the chart's values found no room beside it, they stand under the chart, which gives up the
487
- // height the table takes: as columns, else turned across (the categories as columns, one row a
488
- // series), which costs a row per series only.
489
- if (S.tok.tight && !col.values) {
490
- const under = valuesUnder(visuals, vR, S, state, true);
491
- if (under) v = under;
492
- }
493
- // The strip closes the column once the visual's own height is settled.
494
- if (col.strip && col.end <= col.R.bottom + 0.5 && v.bottom > col.end) t.placed.push(...col.strip.placed.map((q) => ({ ...q, strip: true })));
495
- // A table keeps its own height, so beside it a short takeaway leaves the body half empty. When
496
- // that band is over the density cap and the takeaway fits under the table, it goes there as notes on
497
- // the table above: points that pair off side by side in two columns, an odd count down one column at the
498
- // reading measure, so neither column stops a point short of the other.
499
- if (v.placed.every((p) => !p.flex) && (Z.bottom - Math.max(v.bottom, t.bottom)) / (Z.bottom - Z.y) > S.tok.cap) {
500
- const top = stack(visuals, Z, S, state);
501
- const below = { ...Z, y: top.bottom + state.blockGap };
502
- const paras = texts.flatMap(itemParas);
503
- const half = Math.ceil(paras.length / 2);
504
- const notes = paras.length >= 2 && paras.length % 2 === 0
505
- ? splitRegion(S, below, 0.5).map((R, i) => textAt(i ? paras.slice(half) : paras.slice(0, half), R, S, state))
506
- : [textAt(paras, region(S, Z.a, Math.min(Z.b, Z.a + 8), below.y, below.bottom), S, state)];
507
- const end = Math.max(...notes.map((q) => q.y + q.h));
508
- if (end <= Z.bottom) {
509
- // Still short of the density band: the table's rows open up first (half the room, at most
510
- // one more minimum row height each), then the notes stand midway in what is left under the table.
511
- let room = Z.bottom - end;
512
- let grow = 0;
513
- const table = top.placed.find((q) => q.kind === "table");
514
- if (table && room / (Z.bottom - Z.y) > S.tok.cap) {
515
- const rows = table.heights.length - 1;
516
- grow = Math.floor(Math.min(room / 2, rows * S.tok.rowMin) / rows) * rows;
517
- table.heights = table.heights.map((h, i) => (i ? h + grow / rows : h));
518
- table.tableH += grow;
519
- table.h += grow;
520
- for (const q of top.placed) if (q !== table && q.y > table.y) q.y += grow;
521
- room -= grow;
522
- }
523
- const dy = grow + (room / (Z.bottom - Z.y) > S.tok.cap ? Math.round(room / 2) : 0);
524
- return [...top.placed, ...notes.map((q) => ({ ...q, y: q.y + dy }))];
525
- }
526
- }
527
- // A picture drawn shorter than its box (a wide one in a tall column) stands on the box floor when
528
- // the takeaways beside it run past the picture's top, so the two columns leave no band empty across both.
529
- for (const q of v.placed) if (q.kind === "image") q.beside = t.bottom;
530
- out.push(...v.placed, ...t.placed);
531
- if (S.deco.has("column-hairlines")) out.push(columnHairline(S, o.textFirst ? right : right, Z));
532
- return out;
533
- }
534
- return stack([...visuals, ...texts], Z, S, state).placed;
535
- }
536
-
537
- /**
538
- * A chart over its values as a compact table in region R: as columns, else turned across (the categories
539
- * as columns, one row a series), when the chart keeps at least 150 pt and every row holds one line.
540
- * Returns the placements (or the stack result when `asStack`), or null.
541
- */
542
- function valuesUnder(visuals, R, S, state, asStack = false) {
543
- // Across the body the values run across (two or three rows under a wide chart); in a column, as columns.
544
- const order = R.w >= S.grid.span(1, 8).w ? [chartTable(visuals, true), chartTable(visuals)] : [chartTable(visuals), chartTable(visuals, true)];
545
- for (const table of order) {
546
- if (!table) continue;
547
- const under = stack([...visuals, table], R, S, state);
548
- const chart = under.placed.find((q) => q.kind === "chart");
549
- if (chart && chart.h - chart.cap >= 150 && under.bottom <= R.bottom + 0.5 && under.placed.every((q) => q.kind !== "table" || q.heights.slice(1).every((h) => h <= S.tok.rowMin * 1.6))) {
550
- return asStack ? under : under.placed;
551
- }
552
- }
553
- return null;
554
- }
555
-
556
- /**
557
- * The takeaway column beside a visual that ends at `visualBottom`. The source strip offered by the slide
558
- * closes the column (it is placed by the caller once the visual is settled), so the column reaches the
559
- * floor with the visual instead of stopping halfway; on the compact step a chart's values stand as a
560
- * compact table under the takeaways when they fit, so the exact figures are beside the shape they make.
561
- * Takeaways that still leave more than 40 % of the column empty beside a longer visual are set one step
562
- * up (lead) when they fit: scaled within the ramp, never shrunk (spec-v2 Amendments 7).
563
- */
564
- function takeawayColumn(ctx, texts, visuals, full, visualBottom) {
565
- const { S, state } = ctx;
566
- const strip = ctx.strip ? stripPlacements(ctx.strip, full, S) : null;
567
- const R = strip ? { ...full, bottom: full.bottom - strip.h - S.tok.block } : full;
568
- const at = (st) => {
569
- const t = stack(texts, R, S, st);
570
- const values = S.tok.tight ? chartValues(visuals, R, S, state, t.bottom) : null;
571
- if (values) t.placed.push(values);
572
- const end = Math.max(t.bottom, values ? values.y + values.h : 0);
573
- return { t, values, end, empty: (Math.min(visualBottom, R.bottom) - end) / Math.max(1, R.bottom - R.y) };
574
- };
575
- let pick = at(state);
576
- if (pick.empty > 0.4 && !state.stepped && R.w / S.sizes.lead >= 12) {
577
- const lead = at({ ...state, stepped: true });
578
- if (lead.end <= R.bottom + 0.5 && lead.empty < pick.empty) pick = lead;
579
- }
580
- return { ...pick, strip, R };
581
- }
582
-
583
- /**
584
- * A table standing alone in its region (no takeaways beside it) opens its rows, at most one
585
- * minimum row height each, while the region leaves more than the density band empty under it.
586
- */
587
- function openRows(placed, Z, S) {
588
- const tables = placed.filter((q) => q.kind === "table");
589
- if (tables.length !== 1 || placed.some((q) => q.flex)) return placed;
590
- const table = tables[0];
591
- const room = Z.bottom - Math.max(...placed.map((q) => q.y + q.h));
592
- if (room / (Z.bottom - Z.y) <= S.tok.cap) return placed;
593
- const rows = table.heights.length - 1;
594
- const grow = Math.floor(Math.min(room, rows * S.tok.rowMin) / rows) * rows;
595
- table.heights = table.heights.map((h, i) => (i ? h + grow / rows : h));
596
- table.tableH += grow;
597
- table.h += grow;
598
- for (const q of placed) if (q !== table && q.y > table.y) q.y += grow;
599
- return placed;
600
- }
601
-
602
- /**
603
- * The first chart's data as a plain table item (at most 8 rows and 4 columns), or null. `across`
604
- * turns it: the categories head the columns and each series is one row.
605
- */
606
- function chartTable(visuals, across = false) {
607
- const chart = visuals.find((v) => v.type === "kpi-table" && (v.content || {}).chart);
608
- const c = chart && chart.content;
609
- if (!c || !(c.headers || []).length || (c.rows || []).length > 8 || c.headers.length > 4) return null;
610
- if (!across) return { type: "kpi-table", values: true, content: { headers: c.headers, rows: c.rows } };
611
- const headers = [c.headers[0], ...c.rows.map((r) => r[0])];
612
- const rows = c.headers.slice(1).map((h, j) => [h, ...c.rows.map((r) => r[j + 1])]);
613
- return { type: "kpi-table", values: true, content: { headers, rows } };
614
- }
615
-
616
- /** The first chart's data as a table at label size under `top` in region R, or null when it does not fit. */
617
- function chartValues(visuals, R, S, state, top) {
618
- const item = chartTable(visuals);
619
- if (!item) return null;
620
- const m = measureTable(item, R.w, S, { ...state, stepped: false });
621
- const y = top + state.blockGap;
622
- if (y + m.h > R.bottom || m.heights.slice(1).some((h) => h > S.tok.rowMin * 1.6)) return null;
623
- return { item, ...m, x: R.x, y, w: R.w, limit: R.bottom };
624
- }
625
-
626
- /** A 0.5 pt guide in the gutter before region R (the visible grid of an editorial pack). */
627
- function columnHairline(S, R, Z) {
628
- return { decor: true, kind: "rect", x: R.x - S.grid.gutter / 2, y: Z.y, w: 0.5, h: Z.bottom - Z.y, fill: "line" };
629
- }
630
-
631
- const PLANS = {
632
- "text-column"(ctx) {
633
- const { S, state, Z } = ctx;
634
- const items = ctx.items;
635
- // Running text keeps its measure: cols 1-9 on the presented ramp, 1-7 on the reading ramp.
636
- const limit = S.tok.ramp === "presented" ? 9 : 7;
637
- const R = region(S, Z.a, Math.min(Z.b, Z.a + limit - 1), Z.y, Z.bottom);
638
- const { visuals, texts } = sortItems(items);
639
- if (visuals.length && texts.length) return visualWithText(ctx, visuals, texts, 7 / 12);
640
- const placed = stack(items, R, S, state).placed;
641
- // Two to five points that each open with a bold head, and that leave the body more than the
642
- // density band empty, read as rows: the head in its own column, the point beside it.
643
- const ents = !visuals.length ? entries(texts.flatMap(itemParas)) : [];
644
- // Groups of sub-points under bold heads, held to one reading measure narrower than the body,
645
- // run in two columns instead: the measure stays and the body is used across.
646
- const groups = ents.length >= 2 && ents.every((e) => e.head && !e.rest && e.children.length);
647
- if (groups && R.w < Z.w - S.grid.pitch) {
648
- const two = PLANS["text-two-column"](ctx);
649
- if (!two.some((q) => q.y + q.h > Z.bottom)) {
650
- // Each column's groups share the height left under it. A gap past a sixth of the body is one
651
- // more empty band than the page needs, so then the room is shared with the foot as well.
652
- for (const q of two.filter((x) => x.kind === "text")) {
653
- const breaks = q.paras.filter((para, i) => i > 0 && para.kind !== "child");
654
- if (!breaks.length) continue;
655
- const room = Z.bottom - (q.y + q.h);
656
- const per = Math.min(room / breaks.length > (Z.bottom - Z.y) / 6 ? room / (breaks.length + 1) : room / breaks.length, 0.25 * (Z.bottom - Z.y));
657
- for (const para of breaks) para.gap += per;
658
- q.h += per * breaks.length;
659
- }
660
- return two;
661
- }
662
- }
663
- const headed = ents.length >= 2 && ents.length <= 5 && ents.every((e) => e.head && e.rest && !e.children.length && e.kind === "bullet");
664
- if (headed && (Z.bottom - contentBottom(placed, Z.y)) / (Z.bottom - Z.y) > S.tok.cap) return headedRows(ctx, ents);
665
- return placed;
666
- },
667
-
668
- "text-two-column"(ctx) {
669
- const { S, state, Z } = ctx;
670
- const { columns, texts, visuals } = sortItems(ctx.items);
671
- // Points after the columns are the slide's takeaways: they run under both columns.
672
- if (columns) return stack([columns, ...visuals, ...texts], Z, S, state).placed;
673
- const paras = texts.flatMap(itemParas);
674
- const [l, r] = splitRegion(S, Z, 0.5);
675
- // Break at a section boundary nearest to half the height.
676
- const heights = paras.map((p) => G.textHeight(plainText(p.text), l.w, bodySize(S, state)) + state.itemGap);
677
- const total = heights.reduce((a, b) => a + b, 0);
678
- let acc = 0;
679
- let cut = paras.length;
680
- for (let i = 0; i < paras.length; i++) {
681
- if (i > 0 && paras[i].kind !== "child" && acc >= total / 2 - heights[i] / 2) { cut = i; break; }
682
- acc += heights[i];
683
- }
684
- let out = [textAt(paras.slice(0, cut), l, S, state), textAt(paras.slice(cut), r, S, state)];
685
- // Two sections of unequal length leave one column half empty: the break moves to the point (never between a
686
- // point and its sub-points) that brings the columns nearest even (spec-v2 Amendments 8).
687
- if (shortColumn(out, Z.bottom, S).share > 0.35) {
688
- const evenest = (ok) => {
689
- let best = null;
690
- for (let i = 1; i < paras.length; i++) {
691
- if (!ok(i)) continue;
692
- const pair = [textAt(paras.slice(0, i), l, S, state), textAt(paras.slice(i), r, S, state)];
693
- const diff = Math.abs(pair[0].h - pair[1].h);
694
- if (!best || diff < best.diff) best = { pair, diff };
695
- }
696
- return best;
697
- };
698
- let best = evenest((i) => paras[i].kind !== "child");
699
- // Groups too unequal to balance whole may continue in the next column, a head never parted from its first point.
700
- if (!best || shortColumn(best.pair, Z.bottom, S).share > RAIL_EMPTY) {
701
- const inside = evenest((i) => paras[i - 1].kind !== "section");
702
- if (inside && (!best || shortColumn(inside.pair, Z.bottom, S).share < shortColumn(best.pair, Z.bottom, S).share)) best = inside;
703
- }
704
- if (best && shortColumn(best.pair, Z.bottom, S).share < shortColumn(out, Z.bottom, S).share) out = best.pair;
705
- }
706
- if (S.deco.has("hairline-rule") || S.deco.has("column-hairlines")) out.push(columnHairline(S, r, Z));
707
- return out;
708
- },
709
-
710
- "summary-box-list"(ctx) {
711
- const { S, state, Z, spec } = ctx;
712
- const paras = sortItems(ctx.items).texts.flatMap(itemParas);
713
- let box = spec.lead ? [{ kind: "text", text: spec.lead }] : null;
714
- let rest = paras;
715
- if (!box) {
716
- const first = paras.findIndex((p) => p.kind === "text" || p.kind === "bullet");
717
- box = first >= 0 ? [paras[first]] : paras.slice(0, 1);
718
- rest = paras.filter((_, i) => i !== (first >= 0 ? first : 0));
719
- }
720
- const pad = 18;
721
- const boxText = measureText(box.map((p) => ({ ...p, kind: "text" })), Z.w - pad * 2, S, state, { size: S.sizes.lead });
722
- const boxH = boxText.h + pad * 2;
723
- const out = [
724
- { kind: "box", x: Z.x, y: Z.y, w: Z.w, h: boxH, outline: S.deco.has("box-outline"), limit: Z.bottom },
725
- { ...boxText, x: Z.x + pad, y: Z.y + pad, bold: true, limit: Z.bottom },
726
- ];
727
- const below = { ...Z, y: Z.y + boxH + 18 };
728
- const [l, r] = splitRegion(S, below, 0.5);
729
- const ents = entries(rest);
730
- const half = Math.ceil(ents.length / 2);
731
- const flat = (list) => list.flatMap((e) => [{ kind: e.kind === "section" ? "section" : "bullet", text: e.head ? `**${e.head}** ${e.rest}`.trim() : e.rest },
732
- ...e.children.map((c) => ({ kind: "child", text: c }))]);
733
- const split = (k) => [textAt(flat(ents.slice(0, k)), l, S, state), textAt(flat(ents.slice(k)), r, S, state)];
734
- let cols = split(half);
735
- // Groups of unequal length split by count leave one column short (OF-115 reads it whatever the longer column's
736
- // length): the split moves to the group boundary that brings the columns nearest even.
737
- const uneven = (p) => Math.abs(p[0].h - p[1].h);
738
- if (ents.length > 2 && uneven(cols) > 0.35 * (below.bottom - below.y)) {
739
- const even = ents.slice(1).map((_, i) => split(i + 1)).reduce((m, p) => (uneven(p) < uneven(m) ? p : m));
740
- if (uneven(even) < uneven(cols)) cols = even;
741
- }
742
- out.push(...cols);
743
- return out;
744
- },
745
-
746
- "sidebar-note"(ctx) {
747
- const { S, state, Z } = ctx;
748
- const { texts, visuals } = sortItems(ctx.items);
749
- // The note is the fenced main-box, else a last text block after the main one; a lone text block is the main.
750
- const note = texts.find((t) => t.type === "main-box") || (texts.length > 1 ? texts[texts.length - 1] : null);
751
- const main = [...visuals, ...texts.filter((t) => t !== note)];
752
- const [mR, nR] = splitRegion(S, Z, 8 / 12);
753
- const out = stack(main, mR, S, state).placed;
754
- if (note) {
755
- const pad = S.tok.pad;
756
- const m = measureText(itemParas(note), nR.w - pad * 2, S, state);
757
- out.push({ kind: "box", x: nR.x, y: nR.y, w: nR.w, h: m.h + pad * 2, surface: true, limit: Z.bottom },
758
- { ...m, x: nR.x + pad, y: nR.y + pad, limit: Z.bottom });
759
- // A short note beside a long main column leaves its column mostly empty: the note then stands across
760
- // the top at lead size and the main points run in two columns under it (spec-v2 Amendments 8).
761
- if (main.length && shortColumn(out, Z.bottom, S).share > RAIL_EMPTY && Z.b - Z.a + 1 >= 12) {
762
- // First a narrower note column at the body size (the note never set larger than the main points), the main
763
- // column wider beside it.
764
- const [mR3, nR3] = splitRegion(S, Z, 9 / 12);
765
- const m3 = measureText(itemParas(note), nR3.w - pad * 2, S, state);
766
- const narrow = [...stack(main, mR3, S, state).placed, { kind: "box", x: nR3.x, y: nR3.y, w: nR3.w, h: m3.h + pad * 2, surface: true, limit: Z.bottom },
767
- { ...m3, x: nR3.x + pad, y: nR3.y + pad, limit: Z.bottom }];
768
- if (!overflows(narrow) && shortColumn(narrow, Z.bottom, S).share <= RAIL_EMPTY && (Z.bottom - contentBottom(narrow, Z.y)) / (Z.bottom - Z.y) <= S.tok.cap) return narrow;
769
- }
770
- if (main.length && !visuals.length && shortColumn(out, Z.bottom, S).share > RAIL_EMPTY) {
771
- // The note keeps a reading measure inside the box (S4.4): about 32 Hangul or 70 Latin characters.
772
- const korean = G.isKorean(itemParas(note).map((p) => p.text).join(""));
773
- const inner = Math.min(Z.w - pad * 2, (korean ? 30 : 35) * S.sizes.lead);
774
- const lead = measureText(itemParas(note).map((p) => ({ ...p, kind: "text" })), inner, S, state, { size: S.sizes.lead });
775
- const boxH = lead.h + pad * 2;
776
- const below = { ...Z, y: Z.y + boxH + state.blockGap };
777
- const fits = (plan) => !plan.some((q) => !q.decor && q.y + q.h > Z.bottom + 0.5);
778
- // One column at the reading measure when it holds the points and reaches the density band (the note at lead
779
- // size, else at the points' own size); else grouped points pick their own two columns in the text-column plan
780
- // and plain points run in two columns.
781
- for (const z of [S.sizes.lead, bodySize(S, state)]) {
782
- const m = measureText(itemParas(note).map((p) => ({ ...p, kind: "text" })), Math.min(Z.w - pad * 2, (korean ? 30 : 35) * z), S, state, { size: z });
783
- const top = Z.y + m.h + pad * 2 + state.blockGap;
784
- const single = stack(main, region(S, Z.a, Math.min(Z.b, Z.a + 8), top, Z.bottom), S, state).placed;
785
- if (!fits(single)) continue;
786
- // Room left under the single column is shared between its groups (at most a sixth of the body a gap).
787
- if (single.length === 1 && single[0].kind === "text") {
788
- const q = single[0];
789
- const breaks = q.paras.filter((para, i) => i > 0 && para.kind === "section");
790
- const room = Z.bottom - (q.y + q.h);
791
- if (breaks.length && room / (Z.bottom - top) > S.tok.cap) {
792
- const per = Math.min(room / (breaks.length + 1), (Z.bottom - Z.y) / 6);
793
- for (const para of breaks) para.gap += per;
794
- q.h += per * breaks.length;
795
- }
796
- }
797
- if ((Z.bottom - contentBottom(single, top)) / (Z.bottom - top) <= S.tok.cap) {
798
- return [{ kind: "box", x: Z.x, y: Z.y, w: Z.w, h: m.h + pad * 2, surface: true, limit: Z.bottom },
799
- { ...m, x: Z.x + pad, y: Z.y + pad, limit: Z.bottom }, ...single];
800
- }
801
- }
802
- let two = PLANS["text-column"]({ ...ctx, Z: below, items: main });
803
- const across = PLANS["text-two-column"]({ ...ctx, Z: below, items: main });
804
- if (!fits(two) || (fits(across) && shortColumn(two, Z.bottom, S).share + (Z.bottom - contentBottom(two, below.y)) / (Z.bottom - below.y) > (Z.bottom - contentBottom(across, below.y)) / (Z.bottom - below.y) + 0.1)) two = across;
805
- if (fits(two)) {
806
- return [{ kind: "box", x: Z.x, y: Z.y, w: Z.w, h: boxH, surface: true, limit: Z.bottom },
807
- { ...lead, x: Z.x + pad, y: Z.y + pad, limit: Z.bottom }, ...two];
808
- }
809
- }
810
- }
811
- return out;
812
- },
813
-
814
- agenda(ctx) {
815
- const { S, state, Z } = ctx;
816
- const ents = entries(sortItems(ctx.items).texts.flatMap(itemParas));
817
- if (!ents.length) return [];
818
- const n = ents.length;
819
- const numW = S.grid.span(1, 1).w;
820
- const textX = Z.x + numW + S.grid.gutter;
821
- const textW = Z.x + Z.w - textX;
822
- const head = bodySize(S, state, "lead");
823
- const rest = bodySize(S, state);
824
- const rows = ents.map((e, i) => {
825
- const headText = e.head || e.rest;
826
- const restText = e.head ? [e.rest, ...e.children].filter(Boolean).join(" · ") : e.children.join(" · ");
827
- const h = G.textHeight(headText, textW, head) + (restText ? 6 + G.textHeight(restText, textW, rest) : 0);
828
- return { num: String(i + 1).padStart(2, "0"), head: headText, rest: restText, h };
829
- });
830
- // Rows share the body down to its floor, at most 108 pt apart.
831
- const tallest = Math.max(...rows.map((r) => r.h));
832
- const pitch = rowPitch(n, tallest, Z, state.groupGap, 108);
833
- rows.forEach((r, i) => { r.y = Z.y + i * pitch; });
834
- return [{ kind: "rows", rows, x: Z.x, numW, textX, textW, head, rest, pitch, rule: S.deco.has("hairline-rule"), y: Z.y, h: (n - 1) * pitch + rows[n - 1].h, limit: Z.bottom }];
835
- },
836
-
837
- "references-appendix"(ctx) {
838
- const { S, state, Z } = ctx;
839
- const paras = sortItems(ctx.items).texts.flatMap(itemParas).map((p) => ({ ...p, kind: "text" }));
840
- let size = S.tok.ramp === "presented" ? (state.stepped ? S.sizes.body : S.sizes.label) : bodySize(S, state);
841
- // Entries are scanned for a name or a year: one per row, rows spread down the page with rules.
842
- // A list longer than the body steps down to label size, then runs in two columns.
843
- // Rows share one pitch, so the tallest entry sets the room every row takes.
844
- const fits = (z, w, n) => n * Math.max(...paras.slice(0, n).map((p) => G.textHeight(plainText(p.text), w, z, 1.3))) + 12 * (n - 1) <= Z.bottom - Z.y;
845
- let cols = [Z];
846
- if (!fits(size, Z.w, paras.length)) {
847
- if (fits(S.sizes.label, Z.w, paras.length)) size = S.sizes.label;
848
- else if (paras.length >= 4) { size = S.sizes.label; cols = splitRegion(S, Z, 0.5); }
849
- }
850
- const per = Math.ceil(paras.length / cols.length);
851
- return cols.flatMap((R, ci) => {
852
- const part = paras.slice(ci * per, (ci + 1) * per);
853
- if (!part.length) return [];
854
- const heights = part.map((p) => G.textHeight(plainText(p.text), R.w, size, 1.3));
855
- const pitch = rowPitch(part.length, Math.max(...heights, 1), R, 12, Math.max(...heights, 1) + 72);
856
- return part.flatMap((p, i) => {
857
- const y = R.y + i * pitch;
858
- const row = { kind: "text", paras: [{ ...p, inset: 0, gap: 0, h: heights[i] }], size, x: R.x, y, w: R.w, h: heights[i], limit: Z.bottom };
859
- return i > 0 && S.deco.has("hairline-rule") ? [{ decor: true, kind: "rect", x: R.x, y: y - (pitch - heights[i - 1]) / 2, w: R.w, h: 0.5, fill: "line" }, row] : [row];
860
- });
861
- });
862
- },
863
-
864
- "kpi-row"(ctx) {
865
- const { S, state, Z } = ctx;
866
- const { visuals, texts } = sortItems(ctx.items);
867
- const kpi = visuals.find((v) => v.type === "kpi-table" && looksLikeKpi(v.content || {}, { basis: true }));
868
- if (!kpi) return PLANS["table-insight"](ctx);
869
- const others = visuals.filter((v) => v !== kpi);
870
- if (Z.b - Z.a + 1 < 10 || (state.anchor && !S.pack.shadow)) {
871
- // Under a side title, or when the values take the room, they run down the body as rows:
872
- // the value, then what it measures.
873
- const cards = shared().kpiCards(kpi.content).slice(0, 6);
874
- const out = [];
875
- const restTexts = texts;
876
- const restH = restTexts.length ? stack(restTexts, Z, S, state).bottom - Z.y + state.blockGap : 0;
877
- const rowsZone = { ...Z, bottom: Z.bottom - restH };
878
- out.push(figureRows(cards, rowsZone, S, state));
879
- if (restTexts.length) out.push(...stack(restTexts, { ...Z, y: rowsZone.bottom + state.blockGap }, S, state).placed);
880
- return out;
881
- }
882
- const top = Z.y;
883
- const cardsPlan = stack([kpi, ...others, ...texts], { ...Z, y: top }, S, state);
884
- // A row of cards with its takeaways under it that stops high on the page: the figures then run as
885
- // rows down the first seven columns (value, label, basis), the caption at their foot, and the
886
- // takeaways stand beside them. A pack with hard shadows keeps its cards: the bordered, shadowed card
887
- // is that pack's figure.
888
- if (texts.length && !others.length && !S.pack.shadow && (Z.bottom - cardsPlan.bottom) / (Z.bottom - Z.y) > S.tok.cap) {
889
- const cards = shared().kpiCards(kpi.content).slice(0, 6);
890
- const [fR, tR] = splitRegion(S, Z, 7 / 12);
891
- const capH = kpi.caption ? captionHeight(kpi.caption, fR.w, S) + 6 : 0;
892
- const rows = figureRows(cards, { ...fR, bottom: fR.bottom - capH }, S, state, 48);
893
- const col = takeawayColumn(ctx, texts, [], tR, fR.bottom);
894
- const notes = col.t;
895
- if (col.strip && col.end <= col.R.bottom + 0.5) notes.placed.push(...col.strip.placed.map((q) => ({ ...q, strip: true })));
896
- if (rows.y + rows.h <= fR.bottom - capH + 0.5 && notes.bottom <= Z.bottom + 0.5) {
897
- const out = [rows, ...notes.placed];
898
- if (kpi.caption) out.push({ kind: "caption", item: { content: kpi.caption }, x: fR.x, y: fR.bottom - capH + 6, w: fR.w, h: capH - 6, limit: Z.bottom });
899
- if (shortColumn(out, Z.bottom, S).share <= 0.35) return out;
900
- // Takeaways too few to fill the column beside the rows: the rows run across the body and the takeaways
901
- // stand under them side by side, the caption between (spec-v2 Amendments 8).
902
- const paras = texts.flatMap(itemParas);
903
- const half = Math.ceil(paras.length / 2);
904
- // Up to three points read down one column at the reading measure; four or more stand side by side.
905
- const parts = paras.length >= 4 ? splitRegion(S, Z, 0.5) : [region(S, Z.a, Math.min(Z.b, Z.a + 8), Z.y, Z.bottom)];
906
- // The takeaways keep the size they had beside the rows (lead when the column stepped up).
907
- const keep = (notes.placed.find((q) => q.kind === "text" && !q.strip) || {}).size;
908
- const measured = parts.map((R, i) => measureText(parts.length > 1 ? (i ? paras.slice(half) : paras.slice(0, half)) : paras, R.w, S, state, keep ? { size: keep } : {}));
909
- const notesH = Math.max(...measured.map((m) => m.h));
910
- const rowsBottom = Z.bottom - notesH - state.blockGap - capH;
911
- // Four figures or more stand in two columns of rows, so the rows use the body's width.
912
- const halves = cards.length >= 4 ? splitRegion(S, { ...Z, bottom: rowsBottom }, 0.5) : [{ ...Z, bottom: rowsBottom }];
913
- const split = Math.ceil(cards.length / halves.length);
914
- const across = halves.map((R, i) => figureRows(cards.slice(i * split, (i + 1) * split), R, S, state, 72));
915
- // The second column's rows stand level with the first's (an odd count leaves its last row open).
916
- if (across.length === 2) {
917
- const [a, b] = across;
918
- b.rows.forEach((r, k) => { r.y = a.rows[k].y; });
919
- Object.assign(b, { pitch: a.pitch, value: a.value, labelSize: a.labelSize, noteSize: a.noteSize, h: b.rows.length ? b.rows[b.rows.length - 1].y - b.y + (a.h - (a.rows[a.rows.length - 1].y - a.y)) : 0 });
920
- }
921
- // A band left open between the rows and the takeaways under them is worse than a column whose points share
922
- // the room beside the rows, when that sharing fills the column (spec-v2 Amendments 9).
923
- const band = (Z.bottom - notesH - state.blockGap - capH - Math.max(...across.map((q) => q.y + q.h))) / (Z.bottom - Z.y);
924
- if (band > S.tok.cap) {
925
- const filled = structuredClone(out);
926
- fillColumn(shortColumn(filled, Z.bottom, S), Z.bottom, S, state);
927
- if (shortColumn(filled, Z.bottom, S).share <= 0.35) return filled;
928
- }
929
- if (across.every((q) => q.y + q.h <= rowsBottom + 0.5)) {
930
- const res = [...across, ...measured.map((m, i) => ({ ...m, x: parts[i].x, y: Z.bottom - notesH, limit: Z.bottom }))];
931
- if (kpi.caption) res.push({ kind: "caption", item: { content: kpi.caption }, x: Z.x, y: rowsBottom + 6, w: Z.w, h: capH - 6, limit: Z.bottom });
932
- return res;
933
- }
934
- return out;
935
- }
936
- }
937
- return cardsPlan.placed;
938
- },
939
-
940
- "big-number"(ctx) {
941
- const { S, state, Z } = ctx;
942
- const { visuals, texts } = sortItems(ctx.items);
943
- const table = visuals.find((v) => v.type === "kpi-table");
944
- if (!table) return PLANS["text-column"](ctx);
945
- if ((S.pack.display || {}).number) return numberPanel(ctx, table, texts);
946
- const c = table.content || {};
947
- const value = plainText(((c.rows || [])[0] || [])[0] || (c.headers || [])[1] || "");
948
- const label = plainText((c.headers || [])[0] || "");
949
- const wide = Z.b - Z.a + 1 >= 10;
950
- const [nR, tR] = wide ? splitRegion(S, Z, 6 / 12) : [Z, null];
951
- const size = [S.sizes.title, S.sizes.lead].find((v) => S.ems(value, "numeral") * v * 1.04 <= nR.w) || S.sizes.body;
952
- const labelSize = bodySize(S, state, "lead");
953
- const labelH = G.textHeight(label, nR.w, labelSize);
954
- const capH = table.caption ? captionHeight(table.caption, nR.w, S) + 6 : 0;
955
- const blockH = size * 1.15 + 12 + labelH + capH;
956
- const out = [];
957
- // The number opens the body, its evidence beside it or under it.
958
- const y = Z.y;
959
- if (texts.length) {
960
- const R = tR ? region(S, tR.a + 1, tR.b, Z.y, Z.bottom)
961
- : { ...Z, y: Z.y + blockH + state.blockGap };
962
- out.push(...stack(texts, R, S, { ...state, stepped: true }).placed);
963
- }
964
- out.push({ kind: "number", value, label, size, labelSize, x: nR.x, y, w: nR.w, h: size * 1.15 + 12 + labelH, limit: Z.bottom });
965
- if (table.caption) out.push({ kind: "caption", item: { content: table.caption }, x: nR.x, y: y + size * 1.15 + 12 + labelH + 6, w: nR.w, h: capH - 6, limit: Z.bottom });
966
- return out;
967
- },
968
-
969
- "chart-insight"(ctx) {
970
- const { visuals, texts } = sortItems(ctx.items);
971
- return visualWithText(ctx, visuals, texts, 8 / 12);
972
- },
973
-
974
- "full-chart"(ctx) {
975
- const { S, state, Z } = ctx;
976
- const { visuals, texts } = sortItems(ctx.items);
977
- // The note runs under the chart.
978
- return stack([...visuals, ...texts], Z, S, state).placed;
979
- },
980
-
981
- "kpi-over-chart"(ctx) {
982
- const { S, state, Z } = ctx;
983
- const { visuals, texts } = sortItems(ctx.items);
984
- const kpi = visuals.find((v) => v.type === "kpi-table" && looksLikeKpi(v.content || {}, { basis: true }) && !(v.content || {}).chart);
985
- const charts = visuals.filter((v) => v !== kpi);
986
- if (!kpi || !charts.length) return PLANS["chart-insight"](ctx);
987
- return stack([kpi, ...charts, ...texts], Z, S, state).placed;
988
- },
989
-
990
- "dashboard-grid"(ctx) {
991
- const { S, state, Z } = ctx;
992
- const { visuals, texts } = sortItems(ctx.items);
993
- if (visuals.length < 2) return PLANS["chart-insight"](ctx);
994
- const panels = visuals.slice(0, 4);
995
- const out = [];
996
- const cols = panels.length === 3 ? 3 : 2;
997
- const rows = Math.ceil(panels.length / cols);
998
- const textH = texts.length ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
999
- const gridZ = { ...Z, bottom: Z.bottom - textH };
1000
- const rowH = (gridZ.bottom - gridZ.y - (rows - 1) * S.grid.gutter) / rows;
1001
- const parts = equalParts(S, Z, cols);
1002
- panels.forEach((p, i) => {
1003
- const part = parts[i % cols];
1004
- const y = gridZ.y + Math.floor(i / cols) * (rowH + S.grid.gutter);
1005
- out.push(...stack([p], { ...part, y, bottom: y + rowH }, S, state).placed);
1006
- });
1007
- if (texts.length) out.push(...stack(texts, { ...Z, y: gridZ.bottom + state.blockGap }, S, state).placed);
1008
- return out;
1009
- },
1010
-
1011
- "table-insight"(ctx) {
1012
- const { visuals, texts } = sortItems(ctx.items);
1013
- return visualWithText(ctx, visuals, texts, 8 / 12);
1014
- },
1015
-
1016
- "ledger-table"(ctx) {
1017
- const { S, state, Z } = ctx;
1018
- const { visuals, texts } = sortItems(ctx.items);
1019
- return stack([...visuals, ...texts], Z, S, state).placed;
1020
- },
1021
-
1022
- comparison(ctx) {
1023
- const { S, state } = ctx;
1024
- const { columns, texts, visuals } = sortItems(ctx.items);
1025
- if (visuals.length && !columns) return visualWithText(ctx, visuals, texts, 7 / 12);
1026
- // Beside written columns the loose points are the slide's takeaways: they run under the rows.
1027
- const notes = columns && texts.length ? measureText(texts.flatMap(itemParas), ctx.Z.w, S, state) : null;
1028
- const Z = notes ? { ...ctx.Z, bottom: ctx.Z.bottom - notes.h - state.blockGap } : ctx.Z;
1029
- let halves;
1030
- if (columns) halves = columns.columns.map((col) => (col || []).filter(isText).flatMap(itemParas));
1031
- else {
1032
- const ents = entries(texts.flatMap(itemParas));
1033
- const half = Math.ceil(ents.length / 2);
1034
- const flat = (list) => list.flatMap((e) => [{ kind: "section", text: e.head || e.rest }, ...(e.head && e.rest ? [{ kind: "text", text: e.rest }] : []), ...e.children.map((c) => ({ kind: "child", text: c }))]);
1035
- halves = [flat(ents.slice(0, half)), flat(ents.slice(half))];
1036
- }
1037
- const sides = halves.slice(0, 2).map((paras) => {
1038
- const headIdx = paras.findIndex((p) => p.kind === "section");
1039
- return { head: headIdx >= 0 ? paras[headIdx].text : null,
1040
- items: paras.filter((_, j) => j !== headIdx).map((p) => String(p.text).replace(/^\(\d+\)\s*/u, "")) };
1041
- });
1042
- // Points that open with the same label on both sides ("비용: …") read as criteria rows on the
1043
- // compact step: the label stands once in a column of its own, each side keeps the rest. A label
1044
- // is a short name (three words at most); one row whose two labels differ names both ("Limit /
1045
- // Question"), so a single odd row does not cost the whole slide its criteria.
1046
- const LABEL = /^([^::]{1,24})[::]\s*(.+)$/u;
1047
- const isLabel = (t) => { const m = LABEL.exec(plainText(t)); return Boolean(m) && m[1].trim().split(/\s+/u).length <= 3; };
1048
- let criteria = null;
1049
- if (S.tok.tight && sides.length === 2 && sides.every((sd) => sd.items.length && sd.items.every(isLabel))) {
1050
- const n = Math.max(...sides.map((sd) => sd.items.length));
1051
- const sets = Array.from({ length: n }, (_, r) => [...new Set(sides.map((sd) => sd.items[r] && LABEL.exec(plainText(sd.items[r]))[1].trim()).filter(Boolean))]);
1052
- const labels = sets.map((set) => set.join(" / "));
1053
- const odd = sets.filter((set) => set.length > 1).length;
1054
- if (odd <= 1 && odd < n / 2) {
1055
- criteria = labels;
1056
- for (const sd of sides) sd.items = sd.items.map((t) => LABEL.exec(plainText(t))[2]);
1057
- }
1058
- }
1059
- const floor = Z.bottom;
1060
- const critR = criteria ? region(S, Z.a, Z.a + 1, Z.y, Z.bottom) : null;
1061
- const parts = criteria ? splitRegion(S, region(S, Z.a + 2, Z.b, Z.y, Z.bottom), 0.5) : splitRegion(S, Z, 0.5);
1062
- const headSize = bodySize(S, state, "lead");
1063
- // Up to three rows of short points are set a step or two larger when that still keeps a dozen
1064
- // glyphs a line and fits the body; a two-row comparison otherwise holds a third of the page.
1065
- const rowsN = Math.max(...sides.map((sd) => sd.items.length));
1066
- const fitsAt = (z) => {
1067
- if (parts[0].w / z < 12) return false;
1068
- const hs = Array.from({ length: rowsN }, (_, r) => Math.max(...sides.map((sd, i) => (sd.items[r] ? G.textHeight(plainText(sd.items[r]), parts[i].w, z) : 0))));
1069
- const headRoom = Math.max(0, ...sides.map((sd, i) => (sd.head ? G.textHeight(plainText(sd.head), parts[i].w, headSize) + 30 : 0)));
1070
- return Z.y + headRoom + hs.reduce((a, b) => a + b, 0) + (rowsN - 1) * state.groupGap * 2 <= floor;
1071
- };
1072
- // The compact step never inflates type to fill: its rows keep the body size.
1073
- const itemSize = (rowsN <= 3 && !S.tok.tight ? [S.sizes.title, S.sizes.lead].filter((z) => z > bodySize(S, state)) : []).find(fitsAt) || bodySize(S, state);
1074
- const out = [];
1075
- const headH = Math.max(0, ...sides.map((sd, i) => (sd.head ? G.textHeight(plainText(sd.head), parts[i].w, headSize) : 0)));
1076
- let top = Z.y;
1077
- if (headH) {
1078
- sides.forEach((sd, i) => {
1079
- if (!sd.head) return;
1080
- out.push({ kind: "text", paras: [{ kind: "section", text: sd.head, inset: 0, h: headH, gap: 0 }], size: headSize, x: parts[i].x, y: Z.y, w: parts[i].w, h: headH, limit: Z.bottom, bold: true });
1081
- const accent = S.deco.has("accent-rule");
1082
- out.push({ decor: true, kind: "rect", x: parts[i].x, y: Z.y + headH + 12, w: accent ? S.grid.col : parts[i].w, h: accent ? 3 : 0.75, fill: accent ? "accent" : "line" });
1083
- });
1084
- top = Z.y + headH + 30;
1085
- }
1086
- // Parallel points share a row, so they are read across; the rows run down to the floor.
1087
- const n = Math.max(...sides.map((sd) => sd.items.length));
1088
- const labelH = (r) => (criteria ? G.textHeight(criteria[r], critR.w / S.wide("title", criteria[r]), itemSize) : 0);
1089
- // Measured on the lines the text frame will set (word by word), so a narrow side keeps its lines.
1090
- const sideH = (t, i) => {
1091
- const w = parts[i].w / S.wide("body");
1092
- return G.textHeight(G.keepLines(plainText(t), w / itemSize, 99), w, itemSize);
1093
- };
1094
- const rowH = Array.from({ length: n }, (_, r) => Math.max(labelH(r), ...sides.map((sd, i) => (sd.items[r] ? sideH(sd.items[r], i) : 0))));
1095
- const pitch = rowPitch(n, Math.max(...rowH), { y: top, bottom: floor }, state.groupGap, Math.max(112, Math.max(...rowH) + 72));
1096
- // On the compact step each row starts one even gap under the one before (rows of two and three
1097
- // lines alike). The gap opens up to a fifth of the body so four one-line rows across the full body
1098
- // width reach the floor, and never ends the rows higher than a pitch of the tallest row plus 48 pt would.
1099
- const sum = rowH.reduce((a, b) => a + b, 0);
1100
- const reach = n > 1 ? ((n - 1) * (Math.max(...rowH) + 48) + rowH[n - 1] - sum) / (n - 1) : 0;
1101
- const gap = n > 1 ? Math.max(state.groupGap, Math.min(Math.max(48, (floor - Z.y) / 5, reach), (floor - top - sum) / (n - 1))) : 0;
1102
- const ys = rowH.map((_, r) => (S.tok.tight ? top + rowH.slice(0, r).reduce((a, b) => a + b, 0) + r * gap : top + r * pitch));
1103
- for (let r = 0; r < n; r++) {
1104
- const y = ys[r];
1105
- if (r > 0 && (S.deco.has("hairline-rule") || S.deco.has("column-hairlines"))) {
1106
- out.push({ decor: true, kind: "rect", x: Z.x, y: y - Math.min(18, (y - ys[r - 1] - rowH[r - 1]) / 2), w: Z.w, h: 0.5, fill: "line" });
1107
- }
1108
- if (criteria) out.push({ kind: "text", paras: [{ kind: "text", text: criteria[r], inset: 0, h: labelH(r), gap: 0 }], size: itemSize, x: critR.x, y, w: critR.w, h: labelH(r), limit: floor, bold: true });
1109
- sides.forEach((sd, i) => {
1110
- if (!sd.items[r]) return;
1111
- const h = sideH(sd.items[r], i);
1112
- out.push({ kind: "text", paras: [{ kind: "text", text: sd.items[r], inset: 0, h, gap: 0 }], size: itemSize, x: parts[i].x, y, w: parts[i].w, h, limit: Z.bottom });
1113
- });
1114
- }
1115
- if (S.deco.has("column-hairlines")) out.push(columnHairline(S, parts[1], Z));
1116
- if (notes) out.push({ ...notes, x: Z.x, y: Z.bottom + state.blockGap, limit: ctx.Z.bottom });
1117
- return out;
1118
- },
1119
-
1120
- process(ctx) {
1121
- const { S, state } = ctx;
1122
- const all = entries(sortItems(ctx.items).texts.flatMap(itemParas));
1123
- // Points without a bold head after the steps are the slide's takeaways: they run under the
1124
- // steps instead of being read as more steps (or dropped past the fifth).
1125
- const headed = all.filter((e) => e.head);
1126
- const loose = headed.length >= 2 && headed.length < all.length ? all.filter((e) => !e.head) : [];
1127
- const ents = loose.length ? headed : all;
1128
- if (ents.length < 2) return PLANS["text-column"](ctx);
1129
- const notes = loose.length ? measureText(loose.flatMap((e) => [{ kind: "bullet", text: e.rest }, ...e.children.map((c) => ({ kind: "child", text: c }))]), ctx.Z.w, S, state) : null;
1130
- const Z = notes ? { ...ctx.Z, bottom: ctx.Z.bottom - notes.h - state.blockGap } : ctx.Z;
1131
- const withNotes = (placed) => (notes ? [...placed, { ...notes, x: Z.x, y: Z.bottom + state.blockGap, limit: ctx.Z.bottom }] : placed);
1132
- const steps = ents.slice(0, 5).map((e, i) => {
1133
- const o = ordinal(e.head || "", i);
1134
- // Sub-points read as details of the step, joined with the step's text, without their "(1)".
1135
- return { n: o.n, head: o.head || e.rest, rest: [o.head ? e.rest : "", ...e.children.map((c) => String(c).replace(/^\(\d+\)\s*/u, ""))].filter(Boolean).join(" · ") };
1136
- });
1137
- const numSize = S.sizes.display;
1138
- const headSize = bodySize(S, state, "lead");
1139
- const restSize = bodySize(S, state);
1140
- const asRows = () => {
1141
- if (S.tok.tight && Z.b - Z.a + 1 >= 10) {
1142
- // On the compact step a row reads across: the numeral, the step's name, then what happens.
1143
- const numW = S.grid.span(1, 1).w;
1144
- const headR = region(S, Z.a + 1, Z.a + 3, Z.y, Z.bottom);
1145
- const restX = headR.x + headR.w + S.grid.gutter;
1146
- const korean = G.isKorean(steps.map((st) => st.head + st.rest).join(""));
1147
- // The same readable measure as the stacked rows (S4.4; the gate counts spaces as characters). That
1148
- // measure at body size leaves the body's right columns empty, so what happens is set a step up (lead)
1149
- // when the rows still fit: the measure grows with the size and reaches across (spec-v2 Amendments 7).
1150
- // `flush` sets what happens against the body's right edge and gives the step's name the columns
1151
- // between, so a body-size measure still reaches across when the lead step does not fit.
1152
- const at = (size, flush = false) => {
1153
- const restW = Math.min(Z.x + Z.w - restX, (korean ? 26 : 35) * size);
1154
- const rx = flush ? Z.x + Z.w - restW : restX;
1155
- const headW = rx - S.grid.gutter - headR.x;
1156
- const rows = steps.map((st) => {
1157
- const hh = G.textHeight(st.head, headW, headSize);
1158
- const rh = st.rest ? G.textHeight(st.rest, restW, size) : 0;
1159
- return { num: st.n, head: st.head, rest: st.rest, hh, rh, h: Math.max(numSize * 1.15, hh, rh) };
1160
- });
1161
- const tallest = Math.max(...rows.map((r) => r.h));
1162
- const pitch = rowPitch(rows.length, tallest, Z, state.groupGap, tallest + 48);
1163
- rows.forEach((r, i) => { r.y = Z.y + i * pitch; });
1164
- return { kind: "rows", rows, x: Z.x, numW, textX: headR.x, textW: headW, restX: rx, restW, head: headSize, rest: size, numSize, pitch, rule: true,
1165
- y: Z.y, h: (rows.length - 1) * pitch + rows[rows.length - 1].h, limit: Z.bottom };
1166
- };
1167
- const body = at(restSize);
1168
- if ((Z.x + Z.w - (restX + body.restW)) / Z.w > 0.25) {
1169
- const lead = at(S.sizes.lead);
1170
- if (lead.y + lead.h <= Z.bottom + 0.5) return [lead];
1171
- return [at(restSize, true)];
1172
- }
1173
- return [body];
1174
- }
1175
- const numW = S.grid.span(1, 2).w;
1176
- const textX = Z.x + numW + S.grid.gutter;
1177
- // Across the full body a step's text keeps a readable measure (S4.4; the gate counts spaces and separators as characters).
1178
- const korean = G.isKorean(steps.map((s) => s.head + s.rest).join(""));
1179
- const textW = Math.min(Z.x + Z.w - textX, korean ? 26 * restSize : 35 * restSize);
1180
- const rows = steps.map((s) => ({ num: s.n, head: s.head, rest: s.rest,
1181
- h: Math.max(numSize * 1.15, G.textHeight(s.head, textW, headSize) + (s.rest ? 6 + G.textHeight(s.rest, textW, restSize) : 0)) }));
1182
- const pitch = rowPitch(rows.length, Math.max(...rows.map((r) => r.h)), Z, state.groupGap, 160);
1183
- rows.forEach((r, i) => { r.y = Z.y + i * pitch; });
1184
- return [{ kind: "rows", rows, x: Z.x, numW, textX, textW, head: headSize, rest: restSize, numSize, pitch, rule: true, y: Z.y, h: (rows.length - 1) * pitch + rows[rows.length - 1].h, limit: Z.bottom }];
1185
- };
1186
- const slots = equalParts(S, Z, steps.length);
1187
- const placedSteps = steps.map((s, i) => {
1188
- const R = slots[i];
1189
- const headH = G.textHeight(s.head, R.w, headSize);
1190
- const restH = s.rest ? G.textHeight(s.rest, R.w, restSize) : 0;
1191
- return { ...s, x: R.x, w: R.w, headH, restH };
1192
- });
1193
- const h = numSize * 1.1 + 18 + Math.max(...placedSteps.map((s) => s.headH + (s.restH ? 12 + s.restH : 0)));
1194
- // Up to four steps whose columns stop high on the body run as rows down it instead.
1195
- if (steps.length <= 4 && (Z.bottom - Z.y - h) / (Z.bottom - Z.y) > S.tok.cap) {
1196
- const rows = asRows();
1197
- if (rows[0].y + rows[0].h <= Z.bottom + 0.5) return withNotes(rows);
1198
- }
1199
- return withNotes([{ kind: "steps", steps: placedSteps, numSize, headSize, restSize, y: Z.y, h, limit: Z.bottom }]);
1200
- },
1201
-
1202
- timeline(ctx) {
1203
- const { S, state, Z } = ctx;
1204
- const { visuals, texts } = sortItems(ctx.items);
1205
- const table = visuals.find((v) => v.type === "kpi-table");
1206
- let events;
1207
- if (table) events = (table.content.rows || []).map((r) => ({ date: plainText(r[0]), label: plainText(r[1] || ""), status: plainText(r.slice(2).join(" · ")) }));
1208
- else events = entries(texts.flatMap(itemParas)).map((e) => ({ date: e.head, label: e.rest, status: e.children.join(" · ") }));
1209
- events = events.slice(0, 6);
1210
- if (!events.length) return PLANS["text-column"](ctx);
1211
- const slots = equalParts(S, Z, events.length);
1212
- const dateSize = bodySize(S, state, "lead");
1213
- const labelSize = bodySize(S, state);
1214
- // The axis runs under the tallest date at the top of the body; the room left under the whole
1215
- // plan is shared out below (see the end of this plan).
1216
- const dateH = Math.max(...events.map((e, i) => G.textHeight(e.date, slots[i].w, dateSize, 1.25)));
1217
- const axisY = Math.round(Z.y + dateH + 18);
1218
- const items = events.map((e, i) => {
1219
- const R = slots[i];
1220
- const labelH = G.textHeight(e.label, R.w, labelSize);
1221
- const statusH = e.status ? 6 + G.textHeight(e.status, R.w, S.sizes.label, 1.3) : 0;
1222
- return { ...e, x: R.x, w: R.w, labelH, statusH };
1223
- });
1224
- const below = Math.max(...items.map((e) => e.labelH + e.statusH));
1225
- const cap = table && table.caption ? { kind: "caption", item: { content: table.caption }, x: Z.x, w: Z.w, h: captionHeight(table.caption, Z.w, S) } : null;
1226
- const out = [{ kind: "timeline", events: items, axisY, dateSize, labelSize, x: Z.x, w: Z.w, y: axisY - dateH - 18, h: dateH + 18 + 18 + below, limit: Z.bottom }];
1227
- if (cap) out.push({ ...cap, y: out[0].y + out[0].h + 18, limit: Z.bottom });
1228
- // When a table carries the events, the bullets are the takeaway and run under the axis.
1229
- if (table && texts.length) {
1230
- const top = Math.max(...out.map((q) => q.y + q.h)) + state.blockGap;
1231
- out.push(...stack(texts, { ...Z, y: top }, S, state).placed);
1232
- }
1233
- // Room past the density band is shared evenly: over the axis, between the axis and its takeaways,
1234
- // and under them, so no one band holds it (an axis halfway down left the top third empty).
1235
- const room = Z.bottom - contentBottom(out, Z.y);
1236
- if (room / (Z.bottom - Z.y) > S.tok.cap) {
1237
- // A single takeaway line stays with the axis it reads (a band over one line set it adrift), so the
1238
- // pair moves together, the room shared over and under it (spec-v2 Amendments 8).
1239
- const single = texts.flatMap(itemParas).length === 1;
1240
- const blocks = out.length > (cap ? 2 : 1) && !single ? 3 : 2;
1241
- const step = Math.floor(room / blocks);
1242
- out.forEach((q, i) => {
1243
- const dy = step * (i < (cap ? 2 : 1) || single ? 1 : 2);
1244
- q.y += dy;
1245
- if (q.kind === "timeline") q.axisY += dy;
1246
- if (q.kind === "group") shiftGroup(q, dy);
1247
- });
1248
- }
1249
- return out;
1250
- },
1251
-
1252
- "matrix-2x2"(ctx) {
1253
- const { S, state, Z } = ctx;
1254
- const { visuals, texts } = sortItems(ctx.items);
1255
- const table = visuals.find((v) => v.type === "kpi-table");
1256
- const c = (table && table.content) || {};
1257
- if (!table || (c.headers || []).length !== 3 || (c.rows || []).length !== 2) return PLANS["table-insight"](ctx);
1258
- const [yName, xName] = String(plainText(c.headers[0])).split(/\s*[\\/]\s*/u);
1259
- // The takeaways stand beside the quadrants in the last four columns (under the matrix on a
1260
- // narrow body), so the matrix never drops them.
1261
- const wide = texts.length && Z.b - Z.a + 1 >= 10;
1262
- const M = wide ? region(S, Z.a, Z.b - 4, Z.y, Z.bottom) : Z;
1263
- const notesH = texts.length && !wide ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
1264
- const mBottom = M.bottom - notesH;
1265
- const labelCols = wide ? 1 : 2;
1266
- const labels = region(S, M.a, M.a + labelCols - 1, M.y, mBottom);
1267
- const grid = region(S, M.a + labelCols, M.b, M.y, mBottom);
1268
- const capH = table.caption ? captionHeight(table.caption, grid.w, S) + 6 : 0;
1269
- const headH = S.sizes.label * 1.4 + 12;
1270
- const gap = S.grid.gutter;
1271
- const top = grid.y + headH;
1272
- const qh = (grid.bottom - capH - top - gap) / 2;
1273
- const qw = (grid.w - gap) / 2;
1274
- const pad = 18;
1275
- // A cell is its item over its details: "포장재 단가 재협상 · 연 6억 원 · 즉시" sets the item as the
1276
- // cell's head and each detail on a line under it.
1277
- const head = bodySize(S, state, "lead");
1278
- const detail = bodySize(S, state);
1279
- const cells = [0, 1].flatMap((ri) => [0, 1].map((ci) => {
1280
- const [first, ...rest] = plainText(c.rows[ri][ci + 1]).split(/\s+·\s+/u);
1281
- const headH = G.textHeight(first, qw - pad * 2, head, 1.3);
1282
- const details = rest.map((t) => ({ text: t, h: G.textHeight(t, qw - pad * 2, detail) }));
1283
- return { head: first, headH, details, x: grid.x + ci * (qw + gap), y: top + ri * (qh + gap), w: qw, h: qh };
1284
- }));
1285
- const out = [{ kind: "matrix", cells, xHeads: [plainText(c.headers[1]), plainText(c.headers[2])], yHeads: [plainText(c.rows[0][0]), plainText(c.rows[1][0])],
1286
- xName: xName || "", yName: yName || "", labels, grid, top, qw, qh, gap, pad, head, detail,
1287
- caption: table.caption, x: M.x, y: M.y, w: M.w, h: grid.bottom - M.y, limit: Z.bottom }];
1288
- if (texts.length) {
1289
- const R = wide ? region(S, Z.b - 3, Z.b, Z.y, Z.bottom) : { ...Z, y: mBottom + state.blockGap };
1290
- out.push(...stack(texts, R, S, state).placed);
1291
- }
1292
- return out;
1293
- },
1294
-
1295
- quote(ctx) {
1296
- const { S, state, Z } = ctx;
1297
- const paras = sortItems(ctx.items).texts.flatMap(itemParas);
1298
- const by = paras.find((p) => /^[—–-]\s*/u.test(plainText(p.text)));
1299
- const said = paras.filter((p) => p !== by).map((p) => p.text).join(" ");
1300
- const markW = S.grid.span(1, 1).w;
1301
- const R = region(S, Math.min(Z.b, Z.a + 1), Math.max(Z.a + 1, Z.b - 2), Z.y + 24, Z.bottom);
1302
- const size = S.sizes.title;
1303
- const h = G.textHeight(plainText(said), R.w, size, 1.3);
1304
- const blockH = h + (by ? 18 + S.sizes.label * 1.4 : 0);
1305
- // Beside a side title the quote is the slide's display element: it sits in the middle of the
1306
- // body, as a statement does, instead of at the top of an empty page.
1307
- const y = R.y;
1308
- return [{ kind: "quote", text: said, by: by ? plainText(by.text) : "", size, x: R.x, w: R.w, y, h: blockH, textH: h, markX: Z.x, markW, limit: Z.bottom }];
1309
- },
1310
-
1311
- "image-split"(ctx) {
1312
- const { visuals, texts } = sortItems(ctx.items);
1313
- return visualWithText(ctx, visuals, texts, 7 / 12);
1314
- },
1315
-
1316
- "figure-academic"(ctx) {
1317
- const { visuals, texts } = sortItems(ctx.items);
1318
- return visualWithText(ctx, visuals, texts, 8 / 12);
1319
- },
1320
-
1321
- method(ctx) {
1322
- const { S, state, Z } = ctx;
1323
- const { visuals, texts } = sortItems(ctx.items);
1324
- const paras = texts.flatMap(itemParas);
1325
- const formula = paras.filter((p) => p.kind === "text");
1326
- const defs = paras.filter((p) => p.kind !== "text");
1327
- if (!visuals.length && !formula.length) return PLANS["text-column"](ctx);
1328
- const defsItem = defs.length ? [{ type: "body", content: { items: [] }, paras: defs }] : [];
1329
- const out = [];
1330
- const place = (R) => {
1331
- if (visuals.length) out.push(...stack(visuals, R, S, state).placed);
1332
- else {
1333
- const size = S.sizes.title;
1334
- const h = G.textHeight(plainText(formula.map((p) => p.text).join("\n")), R.w, size, 1.4);
1335
- out.push({ kind: "text", paras: formula.map((p) => ({ ...p, inset: 0, gap: 0, h: G.textHeight(plainText(p.text), R.w, size, 1.4) })), size, x: R.x, w: R.w, y: R.y, h, limit: R.bottom, accent: true });
1336
- }
1337
- };
1338
- if (!defsItem.length) { place(Z); return out; }
1339
- const defsAt = (R) => textAt(defs, R, S, { ...state, itemGap: Math.max(state.itemGap, 12) });
1340
- if (!visuals.length && Z.b - Z.a + 1 >= 8) {
1341
- // The formula runs across the top and its terms in columns under it, instead of one line over an empty
1342
- // column beside the terms (on every density step since spec-v2 Amendments 8; the compact step before).
1343
- place(Z);
1344
- const below = { ...Z, y: Math.max(...out.map((q) => q.y + q.h)) + state.blockGap };
1345
- // Two columns of terms, else three (a formula beside its terms left its own column four-fifths empty).
1346
- for (const n of [2, 3]) {
1347
- const cols = defsInColumns(defs, below, n);
1348
- if (cols.every((q) => q.y + q.h <= Z.bottom)) return [...out, ...cols];
1349
- }
1350
- out.length = 0;
1351
- }
1352
- // A wide figure (twice as wide as tall or more) set in half the body is drawn at a third of its column's
1353
- // height: it runs across the top instead and its terms stand in two columns under it (Amendments 8).
1354
- const size = visuals.length === 1 && visuals[0].type === "image" && visuals[0].imageSize;
1355
- if (S.tok.tight && size && size.width / size.height >= 2 && Z.b - Z.a + 1 >= 8) {
1356
- const cap = captionHeight(visuals[0].caption, Z.w, S);
1357
- for (const [share, n] of [[0.5, 2], [0.45, 2], [0.5, 3], [0.42, 3], [0.36, 3]]) {
1358
- const figH = Math.min(Math.round(Z.w * size.height / size.width) + cap, Math.round((Z.bottom - Z.y) * share));
1359
- place({ ...Z, bottom: Z.y + figH });
1360
- // Measured at their closest step first: whether the terms fit under the figure is not a question of
1361
- // how far they may then open to fill the room.
1362
- const under = { ...Z, y: Z.y + figH + state.blockGap };
1363
- let cols = defsInColumns(defs, under, n, false);
1364
- // The source strip closes the shortest column when it fits there.
1365
- const last = cols.reduce((m, q) => (q.y + q.h < m.y + m.h ? q : m));
1366
- const strip = ctx.strip ? stripPlacements(ctx.strip, { ...Z, x: last.x, w: last.w }, S) : null;
1367
- const closes = strip && last.y + last.h * 1.1 + S.tok.block + strip.h <= Z.bottom;
1368
- // A figure across the body is wider at 130 pt than it stands beside its terms at full column height.
1369
- if (figH - cap >= 130 && cols.every((q) => q.y + q.h * 1.1 <= Z.bottom) && (!strip || closes)) {
1370
- // Then the terms open over the room left above the strip, when they still fit there.
1371
- const roomy = defsInColumns(defs, { ...under, bottom: strip ? Z.bottom - strip.h - S.tok.block : Z.bottom }, n);
1372
- if (roomy.every((q) => q.y + q.h * 1.05 <= (strip ? Z.bottom - strip.h - S.tok.block : Z.bottom))) cols = roomy;
1373
- return [...out, ...cols.map((q) => ({ ...q, limit: Z.bottom - q.h * 0.1 })), ...(strip ? strip.placed.map((q) => ({ ...q, strip: true })) : [])];
1374
- }
1375
- out.length = 0;
1376
- }
1377
- }
1378
- const [vR, full] = splitRegion(S, Z, 7 / 12);
1379
- place(vR);
1380
- // Beside a figure the terms' column closes with the source strip when it ends above the figure, and
1381
- // terms that still leave 40 % of it empty are set a step up (spec-v2 Amendments 7).
1382
- const strip = ctx.strip && visuals.length ? stripPlacements(ctx.strip, full, S) : null;
1383
- const dR = strip ? { ...full, bottom: full.bottom - strip.h - S.tok.block } : full;
1384
- let beside = defsAt(dR);
1385
- if (visuals.length && (dR.bottom - (beside.y + beside.h)) / (dR.bottom - dR.y) > 0.4 && dR.w / S.sizes.lead >= 12) {
1386
- const lead = textAt(defs, dR, S, { ...state, stepped: true, itemGap: Math.max(state.itemGap, 12) });
1387
- if (lead.y + lead.h <= dR.bottom + 0.5) beside = lead;
1388
- }
1389
- if (strip && beside.y + beside.h <= dR.bottom + 0.5) out.push(...strip.placed.map((q) => ({ ...q, strip: true })));
1390
- if (S.tok.tight && visuals.length && beside.y + beside.h > Z.bottom) {
1391
- // Terms too long for five columns beside the figure: first half and half, the terms in one column
1392
- // (the figure keeps six columns, so its own labels stay readable); then the figure takes five
1393
- // columns and the terms run in two columns over the other seven.
1394
- const [hR, tR6] = splitRegion(S, Z, 6 / 12);
1395
- const strip6 = ctx.strip ? stripPlacements(ctx.strip, tR6, S) : null;
1396
- const one = textAt(defs, strip6 ? { ...tR6, bottom: tR6.bottom - strip6.h - S.tok.block } : tR6, S, { ...state, itemGap: Math.max(state.itemGap, 12) });
1397
- if (one.y + one.h * 1.1 <= (strip6 ? tR6.bottom - strip6.h - S.tok.block : Z.bottom)) {
1398
- out.length = 0;
1399
- place(hR);
1400
- return [...out, { ...one, limit: Z.bottom - one.h * 0.1 }, ...(strip6 ? strip6.placed.map((q) => ({ ...q, strip: true })) : [])];
1401
- }
1402
- // The text estimate runs short of what a renderer sets for Latin, so the columns keep a tenth
1403
- // of their height spare; the figure gives up a further column when five leave too little.
1404
- for (const share of [5 / 12, 4 / 12]) {
1405
- out.length = 0;
1406
- const [fR, tR] = splitRegion(S, Z, share);
1407
- const cols = defsInColumns(defs, tR);
1408
- if (share < 5 / 12 || cols.every((q) => q.y + q.h * 1.1 <= Z.bottom)) {
1409
- place(fR);
1410
- // The spare tenth is part of each column's limit, so a slide that cannot keep it reads as
1411
- // overflowing and takes a title that leaves the terms more room.
1412
- return [...out, ...cols.map((q) => ({ ...q, limit: Z.bottom - q.h * 0.1 }))];
1413
- }
1414
- }
1415
- }
1416
- out.push(beside);
1417
- return out;
1418
-
1419
- // The terms split between two columns at the entry that brings the first nearest half the height (three
1420
- // columns: the cuts that keep the tallest column lowest).
1421
- function defsInColumns(list, R, n = 2, open = true) {
1422
- const ents = entries(list);
1423
- const flat = (part) => part.flatMap((e) => [{ kind: e.kind === "section" ? "section" : "bullet", text: e.head ? `**${e.head}** ${e.rest}`.trim() : e.rest },
1424
- ...e.children.map((c) => ({ kind: "child", text: c }))]);
1425
- const cols = equalParts(S, R, n);
1426
- const fits = (st) => cols.every((C) => C.y + measureText(flat(ents), C.w, S, st).h / n <= C.bottom);
1427
- // Terms keep a 12 pt step between them when the columns hold it, else the item gap. Terms that leave
1428
- // more than the density band empty under them open the step, up to 36 pt, while the columns hold it.
1429
- const at = (g) => ({ ...state, itemGap: Math.max(state.itemGap, g) });
1430
- const loose = (st) => (C) => (C.bottom - C.y - measureText(flat(ents), C.w, S, st).h / n) / (C.bottom - C.y) > S.tok.cap;
1431
- let gapped = fits(at(12)) ? at(12) : state;
1432
- if (open && gapped !== state && cols.every(loose(gapped))) gapped = [36, 30, 24, 18].map(at).find(fits) || gapped;
1433
- const tall = (part) => (part.length ? measureText(flat(part), cols[0].w, S, gapped).h : 0);
1434
- if (n === 3 && ents.length >= 3) {
1435
- let best = null;
1436
- for (let a = 1; a < ents.length - 1; a++) for (let b = a + 1; b < ents.length; b++) {
1437
- const top = Math.max(tall(ents.slice(0, a)), tall(ents.slice(a, b)), tall(ents.slice(b)));
1438
- if (!best || top < best.top) best = { a, b, top };
1439
- }
1440
- const parts = [ents.slice(0, best.a), ents.slice(best.a, best.b), ents.slice(best.b)];
1441
- return cols.map((C, i) => textAt(flat(parts[i]), C, S, gapped));
1442
- }
1443
- let cut = 1;
1444
- for (let k = 1; k < ents.length; k++) if (Math.abs(tall(ents.slice(0, k)) - tall(ents.slice(k))) < Math.abs(tall(ents.slice(0, cut)) - tall(ents.slice(cut)))) cut = k;
1445
- const res = cols.map((C, i) => textAt(flat(i ? ents.slice(cut) : ents.slice(0, cut)), C, S, gapped));
1446
- return res;
1447
- }
1448
- },
1449
-
1450
- "photo-grid"(ctx) {
1451
- const { S, state, Z } = ctx;
1452
- const { visuals, texts } = sortItems(ctx.items);
1453
- const images = visuals.flatMap((v) => (v.type === "image-grid" ? (v.content.images || []).map((im) => ({ type: "image", content: im })) : v.type === "image" ? [v] : []));
1454
- if (images.length < 2) return PLANS["image-split"](ctx);
1455
- const textH = texts.length ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
1456
- const parts = equalParts(S, { ...Z, bottom: Z.bottom - textH }, Math.min(3, images.length));
1457
- const out = images.slice(0, 3).flatMap((im, i) => stack([im], parts[i], S, state).placed);
1458
- if (texts.length) out.push(...stack(texts, { ...Z, y: Z.bottom - textH + state.blockGap }, S, state).placed);
1459
- return out;
1460
- },
1461
-
1462
- "figure-pair"(ctx) {
1463
- const { S, state, Z } = ctx;
1464
- const { visuals, texts } = sortItems(ctx.items);
1465
- if (visuals.length < 2) return PLANS["figure-academic"](ctx);
1466
- const textH = texts.length ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
1467
- const [l, r] = splitRegion(S, { ...Z, bottom: Z.bottom - textH }, 0.5);
1468
- const out = [...stack([visuals[0]], l, S, state).placed, ...stack([visuals[1]], r, S, state).placed];
1469
- if (texts.length) out.push(...stack(texts, { ...Z, y: Z.bottom - textH + state.blockGap }, S, state).placed);
1470
- return out;
1471
- },
1472
-
1473
- "asymmetric-feature"(ctx) {
1474
- const { S, state, Z } = ctx;
1475
- const { visuals, texts } = sortItems(ctx.items);
1476
- const table = visuals.find((v) => v.type === "kpi-table" && (v.content.rows || []).length <= 1);
1477
- if (table && !visuals.some((v) => v.type !== "kpi-table")) return PLANS["big-number"](ctx);
1478
- return visualWithText(ctx, visuals, texts, 5 / 12);
1479
- },
1480
-
1481
- // ── Closings (content slides whose title states the ask) ──
1482
- "closing-ask"(ctx) {
1483
- const { S, state, Z } = ctx;
1484
- const { visuals, texts } = sortItems(ctx.items);
1485
- const acts = visuals.length === 1 && visuals[0].type === "kpi-table" && !visuals[0].content.chart ? actionRows(visuals[0].content) : null;
1486
- if (!acts) return visualWithText(ctx, visuals, texts, 8 / 12);
1487
- const step = texts.length ? nextStep(ctx, texts, Z, (S.pack.display || {}).closing || "box") : null;
1488
- // The rows share the room down to the step's own top, so the gap above the step is one of theirs.
1489
- const R = { ...Z, bottom: step ? step.top + state.blockGap : Z.bottom };
1490
- const rows = placeActions(ctx, acts, R, { last: Boolean(step) });
1491
- // Rows that do not fit above the step keep the table.
1492
- if (!rows) return visualWithText(ctx, visuals, texts, 8 / 12);
1493
- return [...rows, ...(step ? step.placed : [])];
1494
- },
1495
-
1496
- "closing-decision-box"(ctx) {
1497
- const { S, state, Z } = ctx;
1498
- const { visuals, texts } = sortItems(ctx.items);
1499
- const out = [];
1500
- let y = Z.y;
1501
- const acts = visuals.length === 1 && visuals[0].type === "kpi-table" && !visuals[0].content.chart ? actionRows(visuals[0].content) : null;
1502
- if (texts.length) {
1503
- const pad = 18;
1504
- const paras = texts.flatMap(itemParas).map((p) => ({ ...p, kind: "text" }));
1505
- const m = measureText(paras, Z.w - pad * 2, S, state, { size: S.sizes.lead });
1506
- out.push({ kind: "box", x: Z.x, y, w: Z.w, h: m.h + pad * 2, outline: S.deco.has("box-outline"), tint: !S.deco.has("box-outline"), limit: Z.bottom },
1507
- { ...m, x: Z.x + pad, y: y + pad, bold: true, tinted: !S.deco.has("box-outline"), limit: Z.bottom });
1508
- y += m.h + pad * 2 + state.blockGap;
1509
- }
1510
- // The items to decide on run as action rows under the box, down to the floor, when they fit.
1511
- const rows = acts ? placeActions(ctx, acts, { ...Z, y }, {}) : null;
1512
- if (rows) return [...out, ...rows];
1513
- if (visuals.length) out.push(...stack(visuals, { ...Z, y }, S, state).placed);
1514
- return out;
1515
- },
1516
-
1517
- "closing-summary-list"(ctx) {
1518
- const { S, state, Z } = ctx;
1519
- const { visuals, texts } = sortItems(ctx.items);
1520
- const [lR, bR] = splitRegion(S, Z, 8 / 12);
1521
- const out = [];
1522
- const paras = texts.flatMap(itemParas);
1523
- if (visuals.length) {
1524
- out.push(...stack(visuals, lR, S, state).placed);
1525
- if (paras.length) {
1526
- const pad = S.tok.pad;
1527
- const m = measureText(paras, bR.w - pad * 2, S, state);
1528
- out.push({ kind: "box", x: bR.x, y: bR.y, w: bR.w, h: m.h + pad * 2, surface: true, limit: Z.bottom }, { ...m, x: bR.x + pad, y: bR.y + pad, limit: Z.bottom });
1529
- }
1530
- return out;
1531
- }
1532
- // Numbered takeaways across the body, one row each, spread down to the floor.
1533
- const size = bodySize(S, state, "lead");
1534
- const heights = paras.map((p) => G.textHeight(plainText(p.text), Z.w - 48, size));
1535
- const pitch = rowPitch(paras.length, Math.max(...heights, 1), Z, state.groupGap, Math.max(...heights, 1) + 48);
1536
- paras.forEach((p, i) => {
1537
- const y = Z.y + i * pitch;
1538
- out.push({ kind: "text", paras: [{ kind: "text", text: String(i + 1), inset: 0, gap: 0, h: size * 1.3 }], size, x: Z.x, y, w: 36, h: size * 1.3, accent: true, limit: Z.bottom },
1539
- { kind: "text", paras: [{ kind: "text", text: p.text, inset: 0, gap: 0, h: heights[i] }], size, x: Z.x + 48, y, w: Z.w - 48, h: heights[i], limit: Z.bottom });
1540
- });
1541
- return out;
1542
- },
1543
-
1544
- "closing-contact-split"(ctx) {
1545
- const { S, state, Z } = ctx;
1546
- const { visuals, texts } = sortItems(ctx.items);
1547
- const acts = visuals.length === 1 && visuals[0].type === "kpi-table" && !visuals[0].content.chart ? actionRows(visuals[0].content) : null;
1548
- // The field starts where the rows' text ends (at most seven of twelve columns, at least five), so each
1549
- // key stands near the row it belongs to instead of across an empty stretch (spec-v2 Amendments 8), as long
1550
- // as the rows and the next step keep the sizes and line counts they have in seven columns.
1551
- const n = Z.b - Z.a + 1;
1552
- if (acts && !ctx.splitCols) {
1553
- const at = (k) => PLANS["closing-contact-split"]({ ...ctx, splitCols: k });
1554
- const sig = (plan) => JSON.stringify(plan.filter((q) => q.kind === "actions" || q.kind === "text").map((q) => (q.kind === "actions" ? [q.head, q.meta, q.keySize] : [q.size, Math.round(q.h)])));
1555
- const ref = at(7);
1556
- const need = Math.max(...acts.rows.map((r) => Math.max(G.textEms(r.head) * S.sizes.lead, G.textEms(r.meta) * S.sizes.label) * 1.06));
1557
- for (const k of [5, 6]) {
1558
- if (S.grid.span(Z.a, Z.a + Math.round(n * k / 12) - 1).w < need) continue;
1559
- const plan = at(k);
1560
- if (sig(plan) === sig(ref)) return plan;
1561
- }
1562
- return ref;
1563
- }
1564
- const cols = ctx.splitCols || 7;
1565
- const [lR, fR] = splitRegion(S, Z, cols / 12);
1566
- // The field bleeds off the right and bottom edges; what it holds sits inset from its edges.
1567
- const fieldX = fR.x - S.grid.gutter / 2;
1568
- const inset = 30;
1569
- const F = { ...fR, x: fieldX + inset, w: fR.x + fR.w - fieldX - inset, y: Z.y + inset, bottom: Z.bottom };
1570
- const field = { decor: true, kind: "rect", x: fieldX, y: Z.y, w: S.grid.W - fieldX, h: S.grid.H - Z.y, fill: "field", bleed: true };
1571
- if (acts) {
1572
- // The field is the ask: each row's key (the amount or the date) in line with its row, the rows
1573
- // down the left columns. The next step or contact is a band of the field's colour on the body
1574
- // floor across the left columns, meeting the field, so the two read as one L whose foot holds
1575
- // the step and the field has no empty stretch under its last key.
1576
- // A step at lead size that leaves the rows too little height drops to body size.
1577
- // Amounts add up to the ask: their total closes the field. Beside the step's band it sits on
1578
- // the band's floor, so the field below the keys ends in the sum, not in an empty stretch.
1579
- // Dates do not add up: the field's foot then states how many items run over which span.
1580
- const total = actionTotal(acts) || actionSpan(acts);
1581
- // The band stops at the field's edge. Its text runs on across the field to the field's inset
1582
- // only while the field's foot is empty; with a total there it keeps to the band's own columns.
1583
- const stepW = total ? fieldX - lR.x : F.x + F.w - lR.x;
1584
- for (const small of [false, true]) {
1585
- const step = texts.length ? nextStep(ctx, texts, { ...lR, w: stepW }, "band", { small, panelW: fieldX - lR.x }) : null;
1586
- const foot = step ? step.top + state.blockGap : null;
1587
- const bottom = step ? foot - state.groupGap : Z.bottom;
1588
- const totalH = total ? G.textHeight(total, F.w - inset, S.sizes.lead, 1.3) : 0;
1589
- const totalY = total ? (step ? Z.bottom - totalH - 6 : bottom - totalH) : null;
1590
- const rowsBottom = total && !step ? bottom - totalH - 24 : bottom;
1591
- const rows = placeActions(ctx, acts, { ...lR, y: F.y, bottom: rowsBottom }, { keys: { ...F, bottom: rowsBottom } });
1592
- if (rows) {
1593
- const sum = total ? [{ decor: true, kind: "rect", x: F.x, y: totalY - 12, w: F.w, h: 0.75, fill: "on-field" },
1594
- { kind: "text", paras: [{ kind: "text", text: total, gap: 0, h: totalH }], size: S.sizes.lead, bold: true, onField: true,
1595
- x: F.x, y: totalY, w: F.w - inset, h: totalH, limit: Z.bottom }] : [];
1596
- return [field, ...rows, ...sum, ...(step ? step.placed : [])];
1597
- }
1598
- }
1599
- }
1600
- const out = [field, ...stack(visuals.length ? visuals : texts, lR, S, state).placed];
1601
- if (visuals.length && texts.length) {
1602
- const m = measureText(texts.flatMap(itemParas), F.w, S, state);
1603
- out.push({ ...m, x: F.x, y: F.y, onField: true, limit: Z.bottom });
1604
- }
1605
- return out;
1606
- },
1607
- };
1608
-
1609
- // Families that share another's plan.
1610
- PLANS["step-diagram"] = PLANS.process;
1611
- PLANS.statement = PLANS["text-column"];
1612
-
1613
- /**
1614
- * Headed points as rows: the head bold in the first three columns, the point beside it at lead
1615
- * size when a dozen glyphs a line fit there, rows spread down to the floor with hairlines between.
1616
- */
1617
- function headedRows(ctx, ents) {
1618
- const { S, state, Z } = ctx;
1619
- const headR = region(S, Z.a, Z.a + 2, Z.y, Z.bottom);
1620
- const textR = region(S, Z.a + 3, Z.b, Z.y, Z.bottom);
1621
- const lead = bodySize(S, state, "lead");
1622
- const body = bodySize(S, state);
1623
- const rowsAt = (z) => ents.map((e) => ({ head: e.head, text: e.rest, headH: G.textHeight(e.head, headR.w, z),
1624
- textH: G.textHeight(plainText(e.rest), textR.w, z) })).map((r) => ({ ...r, h: Math.max(r.headH, r.textH) }));
1625
- let size = S.tok.tight ? body : lead;
1626
- let rows = rowsAt(size);
1627
- if (rows.reduce((a, r) => a + r.h, 0) + (rows.length - 1) * state.groupGap > Z.bottom - Z.y) { size = body; rows = rowsAt(body); }
1628
- const pitch = rowPitch(rows.length, Math.max(...rows.map((r) => r.h)), Z, state.groupGap, Math.max(...rows.map((r) => r.h)) + 96);
1629
- rows.forEach((r, i) => { r.y = Z.y + i * pitch; });
1630
- const last = rows[rows.length - 1];
1631
- return [{ kind: "headed", rows, size, headX: headR.x, headW: headR.w, textX: textR.x, textW: textR.w, pitch,
1632
- x: Z.x, w: Z.w, y: Z.y, h: last.y + last.h - Z.y, limit: Z.bottom }];
1633
- }
1634
-
1635
- /** Value rows: each KPI as one row across the body, value first. */
1636
- function figureRows(cards, Z, S, state, spread = null) {
1637
- const n = cards.length;
1638
- const longest = Math.max(...cards.map((c) => S.ems(plainText(c.value), "numeral")));
1639
- const room = (Z.bottom - Z.y - (n - 1) * 24) / n;
1640
- // At most title size (two steps above the body); the value column is as wide as the widest value.
1641
- const value = [S.sizes.title, S.sizes.lead, S.sizes.body].find((v) => longest * v * 1.15 <= Z.w * 0.5 && v * 1.15 <= room) || S.sizes.body;
1642
- const valueW = Math.min(Math.round(Z.w * 0.5), Math.max(Math.round(Z.w * 0.3), Math.ceil(longest * value * 1.15)));
1643
- const labelX = Z.x + valueW + S.grid.gutter;
1644
- const labelW = Z.x + Z.w - labelX;
1645
- // On the compact step the label is set bold at body size, its basis under it at label size.
1646
- const labelSize = S.tok.tight ? S.sizes.body : bodySize(S, state, "lead");
1647
- const noteSize = S.tok.tight ? S.sizes.label : bodySize(S, { ...state, stepped: false });
1648
- const heights = cards.map((c) => Math.max(value * 1.15, G.textHeight(plainText(c.label), labelW, labelSize)
1649
- + (c.note ? 4 + G.textHeight(plainText(c.note), labelW, noteSize) : 0)));
1650
- // Values run down to the floor, the rows evenly apart (at most `spread` apart beyond the tallest row).
1651
- const pitch = rowPitch(n, Math.max(...heights), Z, S.tok.tight ? state.groupGap : 24, spread == null ? 200 : Math.max(...heights) + spread);
1652
- const rows = cards.map((c, i) => ({ value: plainText(c.value), label: plainText(c.label), note: c.note ? plainText(c.note) : "", y: Z.y + i * pitch }));
1653
- return { kind: "figrows", rows, x: Z.x, w: Z.w, valueW, labelX, labelW, value, labelSize, noteSize, pitch, y: Z.y, h: (n - 1) * pitch + heights[n - 1], limit: Z.bottom };
1654
- }
1655
-
1656
- /**
1657
- * A big-number slide as a data panel: the panel takes seven of twelve columns under the title down to
1658
- * the zone's floor. With two to four figures (a KPI table
1659
- * whose second body row gives each figure's basis) the panel holds one row per figure: the value at
1660
- * title size, its label and its basis beside it. One figure is set at title size with its label on a
1661
- * panel as tall as they are. The
1662
- * evidence stands beside the panel as notes. The pack's display device sets the panel: the field, the
1663
- * accent tint, or the surface inside an ink outline. The panel stays under half the page, so it reads
1664
- * as the figures' ground and not as the page's. A number is never set above title size (S4.7).
1665
- */
1666
- function numberPanel(ctx, table, texts) {
1667
- const { S, state, Z } = ctx;
1668
- const c = table.content || {};
1669
- const cards = shared().kpiCards(c).slice(0, 6).filter((k) => plainText(k.value));
1670
- const device = S.pack.display.number;
1671
- const [pR, eR] = texts.length ? splitRegion(S, Z, 7 / 12) : [Z, null];
1672
- const pad = Math.max(18, S.tok.pad);
1673
- const inner = pR.w - pad * 2;
1674
- const panelH = pR.bottom - pR.y;
1675
- const role = device === "field" ? { fill: "field", number: "on-field", label: "on-field", note: "on-field" }
1676
- : device === "tint" ? { fill: "accent-tint", number: "accent", label: "ink", note: "ink" }
1677
- : { fill: "surface", line: "ink", number: "accent", label: "ink", note: "ink-muted" };
1678
- const out = [{ kind: "panel", x: pR.x, y: pR.y, w: pR.w, h: panelH, fill: role.fill, line: role.line, limit: Z.bottom }];
1679
- const capH = table.caption ? captionHeight(table.caption, inner, S) + 6 : 0;
1680
- if (cards.length >= 2 || (cards[0] && cards[0].note)) {
1681
- // One row per figure, rows spread over the panel, the caption at the panel's foot.
1682
- const R = { x: pR.x + pad, w: inner, y: pR.y + pad, bottom: pR.bottom - pad - capH, a: pR.a, b: pR.b };
1683
- const rows = figureRows(cards, R, S, state);
1684
- out.push({ ...rows, colour: role.number, labelColour: role.label, noteColour: role.note });
1685
- if (table.caption) out.push({ kind: "caption", item: { content: table.caption }, x: R.x, y: pR.bottom - pad - capH + 6, w: inner, h: capH - 6, role: role.label, limit: Z.bottom });
1686
- } else {
1687
- const value = plainText((cards[0] || {}).value || ((c.rows || [])[0] || [])[0] || "");
1688
- const label = plainText((cards[0] || {}).label || (c.headers || [])[0] || "");
1689
- const labelSize = bodySize(S, { ...state, stepped: false }, "lead");
1690
- const size = [S.sizes.title, S.sizes.lead].find((v) => S.ems(value, "numeral") * v * 1.04 <= inner) || S.sizes.body;
1691
- const labelH = label ? G.textHeight(label, inner, labelSize) : 0;
1692
- const blockH = size * 1.15 + (label ? 12 + labelH : 0) + capH;
1693
- // One figure at title size: the panel hugs it instead of standing as an empty field.
1694
- out[0].h = Math.min(panelH, Math.round(blockH + pad * 2));
1695
- const y = Math.round(pR.y + pad);
1696
- out.push({ kind: "number", value, label, size, labelSize, x: pR.x + pad, y, w: inner, h: blockH - capH, colour: role.number, labelColour: role.label, limit: Z.bottom });
1697
- if (table.caption) out.push({ kind: "caption", item: { content: table.caption }, x: pR.x + pad, y: y + blockH - capH + 6, w: inner, h: capH - 6, role: role.label, limit: Z.bottom });
1698
- }
1699
- if (eR) {
1700
- const R = region(S, eR.a, eR.b, pR.y, pR.bottom);
1701
- // The evidence reads as notes on the figures: plain lines, no list markers.
1702
- const paras = texts.flatMap(itemParas).map((q) => ({ ...q, kind: q.kind === "section" ? "section" : "text" }));
1703
- const labelSize = bodySize(S, { ...state, stepped: false }, "lead");
1704
- const evidence = R.w >= 12 * labelSize * 1.1 ? labelSize : bodySize(S, { ...state, stepped: false });
1705
- let m = measureText(paras, R.w, S, { ...state, itemGap: Math.max(state.itemGap, 12) }, { size: evidence });
1706
- if (m.h > panelH) m = measureText(paras, R.w, S, state);
1707
- out.push({ ...m, x: R.x, y: Math.round(pR.y + Math.max(0, (panelH - m.h) / 2)), limit: Z.bottom });
1708
- }
1709
- return out;
1710
- }
1711
-
1712
- // A cell that is an amount: digits, an optional Korean unit word, an optional currency or percent.
1713
- const AMOUNT = /^(\d[\d,.]*)\s*([조억만천]*)\s*(원|달러|USD|EUR|KRW|%)?$/u;
1714
- const WHEN = /기한|시점|일정|날짜|마감|언제|when|date|due|deadline/iu;
1715
-
1716
- /**
1717
- * A closing's table read as action rows. The key is the column of amounts in one unit (they add up
1718
- * to the ask), else the column headed as a date or deadline, else the last column; the row's first
1719
- * cell is what is asked or done, the other cells (owner, timing) its detail.
1720
- */
1721
- function actionRows(content) {
1722
- const headers = (content.headers || []).map((h) => plainText(h));
1723
- // A totals row is not an action: the ask line (or the field's total) carries the sum.
1724
- const rows = (content.rows || []).map((r) => r.map((cell) => plainText(cell).trim()))
1725
- .filter((r, i, all) => !(all.length > 1 && i === all.length - 1 && TOTALS.test(r[0] || "")));
1726
- if (rows.length < 1 || rows.length > 5 || headers.length < 2) return null;
1727
- // A bare number under a head that names its unit ("Budget (k USD)") carries that unit, as a key
1728
- // and in a row's detail, so no amount stands on the page without it.
1729
- const units = headers.map((h) => (/\(([^()]{1,12})\)\s*$/u.exec(h) || [])[1] || null);
1730
- const withUnit = (cell, j) => (units[j] && /^\d[\d,.]*$/u.test(cell) ? joinUnit(cell, units[j]) : cell);
1731
- let key = -1;
1732
- let kind = "date";
1733
- for (let j = 1; j < headers.length && key < 0; j++) {
1734
- const m = rows.map((r) => AMOUNT.exec(r[j] || ""));
1735
- if (m.every((x) => x && (x[2] || x[3])) && new Set(m.map((x) => `${x[2]}${x[3] || ""}`)).size === 1) {
1736
- key = j;
1737
- kind = "amount";
1738
- } else if (units[j] && !/%/u.test(units[j]) && rows.every((r) => /^\d[\d,.]*$/u.test(r[j] || ""))) {
1739
- key = j;
1740
- kind = "amount";
1741
- }
1742
- }
1743
- if (key < 0) key = headers.findIndex((h, j) => j > 0 && WHEN.test(h));
1744
- const korean = G.isKorean(headers.join(" ") + rows.map((r) => r[0]).join(" "));
1745
- if (key < 0) key = headers.length - 1;
1746
- return {
1747
- kind,
1748
- rows: rows.map((r) => ({
1749
- key: withUnit(r[key] || "", key),
1750
- num: kind === "amount" ? /^\d[\d,.]*/u.exec(r[key])[0] : null,
1751
- head: r[0] || "",
1752
- // An empty or dash-only cell ("—") says nothing about the row and is left out of its detail.
1753
- meta: r.map(withUnit).filter((cell, j) => j !== 0 && j !== key && cell && !/^[—–-]+$/u.test(cell)).join(" · "),
1754
- value: kind === "amount" ? parseFloat(/^\d[\d,.]*/u.exec(r[key])[0].replace(/,/gu, "")) : null,
1755
- })),
1756
- korean,
1757
- };
1758
- }
1759
-
1760
- /** "30k USD", "14억 원", "12 L": a figure with its unit, joined the way the unit is written. */
1761
- function joinUnit(n, unit) {
1762
- return /^(%|\p{Script=Hangul}|[kKMB](\s|$))/u.test(unit) ? `${n}${unit}` : `${n} ${unit}`;
1763
- }
1764
-
1765
- /** "합계 30억 원": the rows' amounts summed and written in the unit the keys use, or null. */
1766
- function actionTotal(acts) {
1767
- if (!acts || acts.kind !== "amount" || acts.rows.length < 2) return null;
1768
- const sum = acts.rows.reduce((a, r) => a + r.value, 0);
1769
- const digits = Math.max(...acts.rows.map((r) => ((/\.(\d+)/u.exec(r.num) || [, ""])[1]).length));
1770
- const commas = acts.rows.some((r) => r.key.includes(","));
1771
- const n = commas ? sum.toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits }) : sum.toFixed(digits);
1772
- return `${acts.korean ? "합계" : "Total"} ${acts.rows[0].key.replace(/^\d[\d,.]*/u, n)}`;
1773
- }
1774
-
1775
- /** "안건 4건 · 10월 셋째 주 – 11월 첫째 주": the count of date-keyed rows and their first and last date, or null. */
1776
- function actionSpan(acts) {
1777
- if (!acts || acts.kind !== "date" || acts.rows.length < 2) return null;
1778
- const first = acts.rows[0].key;
1779
- const last = acts.rows[acts.rows.length - 1].key;
1780
- const n = acts.rows.length;
1781
- const count = acts.korean ? `안건 ${n}건` : `${n} items`;
1782
- return first && last && first !== last ? `${count} · ${first} – ${last}` : count;
1783
- }
1784
-
1785
- /**
1786
- * Action rows down a region: the key large on the left (or in `o.keys`, a field beside the rows),
1787
- * what is asked bold at lead size with its detail under it, and for amounts a bar as long as the
1788
- * row's share of the total. The free height is shared out as equal gaps between the rows (and
1789
- * before the next step when one follows), so the rows and the step fill the body together.
1790
- */
1791
- function placeActions(ctx, acts, R, o = {}) {
1792
- const { S, state } = ctx;
1793
- const n = acts.rows.length;
1794
- const keyR = o.keys || region(S, R.a, R.a + 2, R.y, R.bottom);
1795
- const textR = o.keys ? R : region(S, R.a + 3, R.b, R.y, R.bottom);
1796
- const longest = Math.max(...acts.rows.map((r) => S.ems(r.key, "numeral")));
1797
- const sizes = [S.sizes.title, S.sizes.lead, S.sizes.body];
1798
- const total = acts.kind === "amount" ? acts.rows.reduce((a, r) => a + r.value, 0) : 0;
1799
- const gaps = o.last ? n : Math.max(1, n - 1);
1800
- // At lead size first; rows that do not fit step down (lead to body, body to label), then the
1801
- // key steps down the ramp until the rows fit.
1802
- const fit = (step) => {
1803
- const fitting = sizes.filter((v) => v && longest * v * 1.04 <= keyR.w);
1804
- const keySize = fitting[Math.min(step, fitting.length - 1)] || S.sizes.body;
1805
- const head = step ? S.sizes.body : S.sizes.lead;
1806
- const meta = step ? S.sizes.label : S.sizes.body;
1807
- const rows = acts.rows.map((r) => {
1808
- const headH = G.textHeight(r.head, textR.w, head);
1809
- const metaH = r.meta ? G.textHeight(r.meta, textR.w, meta) : 0;
1810
- const bar = total > 0 ? (o.keys ? 14 : 18) : 0;
1811
- // On the field the share bar runs under the key; beside the rows it runs under the text.
1812
- const h = o.keys ? Math.max(keySize * 1.15 + bar, headH + (metaH ? 6 + metaH : 0))
1813
- : Math.max(keySize * 1.15, headH + (metaH ? 6 + metaH : 0) + bar);
1814
- return { ...r, headH, metaH, bar, h };
1815
- });
1816
- const sum = rows.reduce((a, r) => a + r.h, 0);
1817
- return { keySize, head, meta, rows, room: R.bottom - R.y - sum - gaps * state.itemGap };
1818
- };
1819
- let chosen = fit(0);
1820
- for (let step = 1; chosen.room < 0 && step <= 3; step++) chosen = fit(step);
1821
- if (chosen.room < 0) return null;
1822
- const { keySize, head, meta, rows } = chosen;
1823
- const sum = rows.reduce((a, r) => a + r.h, 0);
1824
- // Rows sit at most 96 pt apart (wider gaps read as separate blocks, and at reading sizes left one
1825
- // empty band between two short rows); what is left over is shared above and below the rows.
1826
- const gap = Math.max(state.itemGap, Math.min(96, (R.bottom - R.y - sum) / gaps));
1827
- const spare = Math.max(0, R.bottom - R.y - sum - gap * gaps);
1828
- let y = R.y + Math.round(spare / 2);
1829
- for (const r of rows) { r.y = y; y += r.h + gap; }
1830
- const h = rows[n - 1].y + rows[n - 1].h - R.y;
1831
- return [{ kind: "actions", rows, keyX: keyR.x, keyW: keyR.w, keySize, onField: Boolean(o.keys), textX: textR.x, textW: textR.w,
1832
- head, meta, total, gap, x: R.x, y: R.y, w: (o.keys ? keyR.x + keyR.w : R.x + R.w) - R.x, h, limit: R.bottom }];
1833
- }
1834
-
1835
- /**
1836
- * The next step of a closing, set at lead size on the body floor in the pack's closing device: a
1837
- * band of the field across the region (or `o.panelW` of it, where a field drawn beside continues
1838
- * it; text in the field's colour), a tinted or outlined box, a
1839
- * rule above the line, or (field) a rule above the line inside a field already drawn. A label
1840
- * before a colon is set bold. Returns the placements and its top.
1841
- */
1842
- function nextStep(ctx, texts, R, device, o = {}) {
1843
- const { S, state } = ctx;
1844
- const lead = bodySize(S, { ...state, stepped: false }, "lead");
1845
- const ruled = device === "rules" || device === "field";
1846
- const pad = ruled ? 0 : Math.max(18, S.tok.pad);
1847
- // Each point keeps its own line; a source line is a note at label size. Lines keep a readable
1848
- // measure (S4.4) inside the band.
1849
- const paras = texts.flatMap(itemParas).map((p) => plainText(p.text));
1850
- const notes = paras.filter((t) => /^(출처|자료|sources?)\b/iu.test(t));
1851
- const points = paras.filter((t) => !notes.includes(t)).map((t) => t.replace(/^([^::]{1,16})([::])\s*/u, "**$1$2** "));
1852
- const size = points.length > 2 || o.small ? S.sizes.body : lead;
1853
- const box = R.w - pad * 2;
1854
- const inner = Math.min(box, (G.isKorean(paras.join("")) ? 34 : 70) * size * (G.isKorean(paras.join("")) ? 1 : 0.5));
1855
- // A line that fits the box on one line takes the box's width; a longer one keeps the reading measure, set
1856
- // as narrow as keeps its line count so its lines come out even and none ends on a lone word (Amendments 8).
1857
- const widthOf = (t, z) => {
1858
- if (G.lineCount(plainText(t), box, z) <= 1) return box;
1859
- const n = G.lineCount(plainText(t), inner, z);
1860
- let lo = inner / 2;
1861
- let hi = inner;
1862
- for (let i = 0; i < 12; i++) { const mid = (lo + hi) / 2; if (G.lineCount(plainText(t), mid, z) <= n) hi = mid; else lo = mid; }
1863
- return Math.min(inner, Math.ceil(hi + 2 * z));
1864
- };
1865
- const items = [...points.map((t) => ({ text: t, size })), ...notes.map((t) => ({ text: t, size: S.sizes.label }))]
1866
- .map((q) => { const w = widthOf(q.text, q.size); return { ...q, w, h: G.textHeight(plainText(q.text), w, q.size) }; });
1867
- const th = items.reduce((a, q, i) => a + q.h + (i ? 6 : 0), 0);
1868
- const top = ruled ? R.bottom - th - 18 : R.bottom - th - pad * 2;
1869
- const placed = [];
1870
- const outline = device === "box" && S.deco.has("box-outline");
1871
- if (device === "band") placed.push({ kind: "panel", x: R.x, y: top, w: o.panelW || R.w, h: R.bottom - top, fill: "field", limit: R.bottom });
1872
- else if (device === "box") placed.push({ kind: "panel", x: R.x, y: top, w: R.w, h: R.bottom - top, fill: outline ? null : "accent-tint", line: outline ? "ink" : null, limit: R.bottom });
1873
- else placed.push({ decor: true, kind: "rect", x: R.x, y: top, w: R.w, h: 0.75, fill: "line" });
1874
- let y = ruled ? top + 18 : top + pad;
1875
- for (const q of items) {
1876
- placed.push({ kind: "text", paras: [{ kind: "text", text: q.text, inset: 0, gap: 0, h: q.h }], size: q.size, x: R.x + pad, y, w: q.w, h: q.h,
1877
- onField: device === "band" || device === "field", tinted: device === "box" && !outline, muted: q.size === S.sizes.label, limit: R.bottom });
1878
- y += q.h + 6;
1879
- }
1880
- return { placed, top: top - state.blockGap };
1881
- }
1882
-
1883
- // ── Draw ────────────────────────────────────────────────────────────────────
1884
-
1885
- function drawPlaced(slide, S, p, ctx) {
1886
- const A = shared();
1887
- const c = (p.item && p.item.content) || {};
1888
- if (p.kind === "group") { for (const q of p.parts) drawPlaced(slide, S, q, ctx); return; }
1889
- if (p.kind === "rect") { packRect(slide, S, p, { fill: p.fill }); return; }
1890
- if (p.kind === "panel") { packRect(slide, S, p, { fill: p.fill, line: p.line, lineWidth: 1, radius: S.pack.radius }); return; }
1891
- if (p.kind === "actions") {
1892
- const ink = S.colour(p.onField ? "on-field" : "accent");
1893
- p.rows.forEach((r, i) => {
1894
- if (i > 0) packRect(slide, S, { x: p.textX, y: r.y - p.gap / 2, w: p.textW, h: 0.75 }, { fill: "line" });
1895
- packText(slide, S, r.key, { x: p.keyX, y: r.y, w: p.keyW, h: p.keySize * 1.15 }, { face: "numeral", size: p.keySize, colour: ink, lineSpacing: 1.15 });
1896
- packText(slide, S, r.head, { x: p.textX, y: r.y, w: p.textW, h: r.headH }, { size: p.head, bold: true });
1897
- if (r.meta) packText(slide, S, r.meta, { x: p.textX, y: r.y + r.headH + 6, w: p.textW, h: r.metaH }, { size: p.meta, colour: S.colour("ink-muted") });
1898
- if (r.bar) {
1899
- // The row's share of the ask: a bar on a full-width track, under the key on the field.
1900
- const [bx, bw] = p.onField ? [p.keyX, p.keyW] : [p.textX, p.textW];
1901
- const by = p.onField ? r.y + p.keySize * 1.15 + 8 : r.y + r.headH + (r.metaH ? 6 + r.metaH : 0) + 12;
1902
- packRect(slide, S, { x: bx, y: by, w: bw, h: 6 }, { fill: p.onField ? "ink-muted" : "accent-tint" });
1903
- packRect(slide, S, { x: bx, y: by, w: Math.max(4, (bw * r.value) / p.total), h: 6 }, { fill: p.onField ? "on-field" : "accent" });
1904
- }
1905
- });
1906
- return;
1907
- }
1908
- if (p.kind === "box") {
1909
- if (p.outline) packRect(slide, S, p, { line: "ink", lineWidth: S.pack["edge-weight"] || 1, ...hardEdge(S, "ground") });
1910
- else if (p.tint) packRect(slide, S, p, { fill: "accent-tint", radius: S.pack.radius, ...hardEdge(S) });
1911
- else surfaceRect(slide, S, p);
1912
- return;
1913
- }
1914
- if (p.kind === "text") {
1915
- let y = p.y;
1916
- const ink = p.onField ? S.colour("on-field") : p.tinted ? S.colour("accent-deep") : S.colour("ink");
1917
- const soft = p.onField ? S.colour("on-field") : S.colour("ink-muted");
1918
- for (const para of p.paras) {
1919
- y += para.gap;
1920
- // The marker is a small dot centred on the first line: a shape, so no renderer swaps in a
1921
- // symbol font for it and no checker reads it as a column of text.
1922
- if (para.kind === "bullet") {
1923
- const d = Math.max(4, Math.round(p.size * 0.28));
1924
- const lineH = p.size * G.leading(para.text);
1925
- packRect(slide, S, { x: p.x, y: y + (lineH - d) / 2, w: d, h: d }, { fill: p.onField ? "on-field" : "accent" });
1926
- }
1927
- packText(slide, S, para.kind === "section" ? para.text : runIn(para.text), { x: p.x + (para.inset || 0), y, w: p.w - (para.inset || 0), h: para.h }, {
1928
- size: p.size, bold: p.bold || para.kind === "section",
1929
- colour: p.accent ? S.colour("accent-deep") : para.kind === "child" || p.muted ? soft : ink,
1930
- });
1931
- y += para.h;
1932
- }
1933
- return;
1934
- }
1935
- if (p.kind === "callout") {
1936
- packRect(slide, S, p, { fill: "accent-tint", radius: S.pack.radius, ...hardEdge(S) });
1937
- packText(slide, S, plainText(c), { x: p.x + p.pad, y: p.y + p.pad, w: p.w - p.pad * 2, h: p.h - p.pad * 2 },
1938
- { size: p.size, bold: true, colour: S.colour("accent-deep") });
1939
- return;
1940
- }
1941
- if (p.kind === "kpi") {
1942
- p.cards.forEach((card, i) => {
1943
- const x = p.x + i * (p.cardW + S.grid.gutter);
1944
- surfaceRect(slide, S, { x, y: p.y, w: p.cardW, h: p.cardH });
1945
- const inner = p.cardW - p.pad * 2;
1946
- const valueH = p.value * 1.15;
1947
- packText(slide, S, plainText(card.value), { x: x + p.pad, y: p.y + p.pad, w: inner, h: valueH },
1948
- { face: "numeral", size: p.value, lineSpacing: 1.15, colour: S.colour(i === 0 ? "accent" : "ink") });
1949
- packText(slide, S, plainText(card.label), { x: x + p.pad, y: p.y + p.pad + valueH + 6, w: inner, h: p.labelH },
1950
- { size: S.sizes.label, colour: S.colour("ink-muted"), lineSpacing: 1.3 });
1951
- if (card.note) packText(slide, S, plainText(card.note), { x: x + p.pad, y: p.y + p.pad + valueH + 6 + p.labelH + 6, w: inner, h: p.noteH },
1952
- { size: p.noteSize, colour: S.colour("ink"), lineSpacing: 1.3 });
1953
- });
1954
- drawCaption(slide, S, p.item.caption, p.x, p.y + p.cardH + 6, p.w);
1955
- return;
1956
- }
1957
- if (p.kind === "figrows") {
1958
- p.rows.forEach((r, i) => {
1959
- if (i > 0) packRect(slide, S, { x: p.x, y: r.y - 12, w: p.w, h: 0.75 }, { fill: p.colour === "on-field" ? "on-field" : "line" });
1960
- packText(slide, S, r.value, { x: p.x, y: r.y, w: p.valueW, h: p.value * 1.15 },
1961
- { face: "numeral", size: p.value, lineSpacing: 1.15, colour: S.colour(p.colour || (i === 0 ? "accent" : "ink")) });
1962
- const lh = G.textHeight(r.label, p.labelW, p.labelSize);
1963
- const nh = r.note ? G.textHeight(r.note, p.labelW, p.noteSize) : 0;
1964
- // The label reads beside the value; the basis under the label.
1965
- packText(slide, S, r.label, { x: p.labelX, y: r.y, w: p.labelW, h: lh }, { size: p.labelSize, colour: S.colour(p.labelColour || "ink"), bold: true });
1966
- if (r.note) packText(slide, S, r.note, { x: p.labelX, y: r.y + lh + 4, w: p.labelW, h: nh }, { size: p.noteSize, colour: S.colour(p.noteColour || "ink-muted") });
1967
- });
1968
- return;
1969
- }
1970
- if (p.kind === "rows") {
1971
- p.rows.forEach((r, i) => {
1972
- const right = p.restX != null ? p.restX + p.restW : p.textX + p.textW;
1973
- if (p.rule && i > 0) packRect(slide, S, { x: p.x, y: r.y - Math.min(12, (p.pitch - r.h) / 2), w: right - p.x, h: 0.75 }, { fill: "line" });
1974
- const numSize = p.numSize || p.head;
1975
- packText(slide, S, r.num, { x: p.x, y: r.y, w: p.numW, h: numSize * 1.15 }, { face: "numeral", size: numSize, colour: S.colour("accent"), lineSpacing: 1.15 });
1976
- const hh = G.textHeight(r.head, p.textW, p.head);
1977
- packText(slide, S, r.head, { x: p.textX, y: r.y, w: p.textW, h: hh }, { size: p.head, bold: true });
1978
- // Beside the name (restX) or under it.
1979
- if (r.rest && p.restX != null) packText(slide, S, r.rest, { x: p.restX, y: r.y, w: p.restW, h: G.textHeight(r.rest, p.restW, p.rest) }, { size: p.rest });
1980
- else if (r.rest) packText(slide, S, r.rest, { x: p.textX, y: r.y + hh + 6, w: p.textW, h: G.textHeight(r.rest, p.textW, p.rest) }, { size: p.rest, colour: S.colour("ink-muted") });
1981
- });
1982
- return;
1983
- }
1984
- if (p.kind === "headed") {
1985
- p.rows.forEach((r, i) => {
1986
- if (i > 0) packRect(slide, S, { x: p.x, y: r.y - Math.min(12, (p.pitch - p.rows[i - 1].h) / 2), w: p.w, h: 0.75 }, { fill: "line" });
1987
- packText(slide, S, r.head, { x: p.headX, y: r.y, w: p.headW, h: r.headH }, { size: p.size, bold: true, colour: S.colour("accent-deep") });
1988
- packText(slide, S, r.text, { x: p.textX, y: r.y, w: p.textW, h: r.textH }, { size: p.size });
1989
- });
1990
- return;
1991
- }
1992
- if (p.kind === "steps") {
1993
- p.steps.forEach((s) => {
1994
- packText(slide, S, s.n, { x: s.x, y: p.y, w: s.w, h: p.numSize * 1.1 }, { face: "numeral", size: p.numSize, colour: S.colour("accent"), lineSpacing: 1.15 });
1995
- const ruleY = p.y + p.numSize * 1.1 + 6;
1996
- packRect(slide, S, { x: s.x, y: ruleY, w: s.w, h: 0.75 }, { fill: "line" });
1997
- packText(slide, S, s.head, { x: s.x, y: ruleY + 12, w: s.w, h: s.headH }, { size: p.headSize, bold: true });
1998
- if (s.rest) packText(slide, S, s.rest, { x: s.x, y: ruleY + 12 + s.headH + 12, w: s.w, h: s.restH }, { size: p.restSize, colour: S.colour("ink-muted") });
1999
- });
2000
- return;
2001
- }
2002
- if (p.kind === "timeline") {
2003
- packRect(slide, S, { x: p.x, y: p.axisY, w: p.w, h: 1.5 }, { fill: "line" });
2004
- p.events.forEach((e, i) => {
2005
- packRect(slide, S, { x: e.x, y: p.axisY - 4, w: 9, h: 9 }, { fill: i === p.events.length - 1 ? "accent" : "ink-muted" });
2006
- const dh = G.textHeight(e.date, e.w, p.dateSize, 1.25);
2007
- packText(slide, S, e.date, { x: e.x, y: p.axisY - 18 - dh, w: e.w, h: dh }, { size: p.dateSize, bold: true, colour: S.colour("ink"), lineSpacing: 1.25 });
2008
- packText(slide, S, e.label, { x: e.x, y: p.axisY + 18, w: e.w, h: e.labelH }, { size: p.labelSize });
2009
- if (e.status) packText(slide, S, e.status, { x: e.x, y: p.axisY + 18 + e.labelH + 6, w: e.w, h: e.statusH - 6 }, { size: S.sizes.label, colour: S.colour("ink-muted"), lineSpacing: 1.3 });
2010
- });
2011
- return;
2012
- }
2013
- if (p.kind === "matrix") {
2014
- const label = S.sizes.label;
2015
- p.xHeads.forEach((t, i) => packText(slide, S, t, { x: p.grid.x + i * (p.qw + p.gap), y: p.grid.y, w: p.qw, h: label * 1.4 }, { size: label, bold: true, colour: S.colour("ink-muted"), lineSpacing: 1.3 }));
2016
- p.yHeads.forEach((t, i) => packText(slide, S, t, { x: p.labels.x, y: p.top + i * (p.qh + p.gap), w: p.labels.w, h: label * 1.4 }, { size: label, bold: true, colour: S.colour("ink-muted"), lineSpacing: 1.3 }));
2017
- const axis = [p.yName && `↑ ${p.yName}`, p.xName && `→ ${p.xName}`].filter(Boolean).join(" ");
2018
- if (axis) {
2019
- // The axis names sit at the foot of the label column, as tall as they wrap in it.
2020
- const h = G.textHeight(axis, p.labels.w, label, 1.3);
2021
- packText(slide, S, axis, { x: p.labels.x, y: p.top + 2 * p.qh + p.gap - h, w: p.labels.w, h }, { size: label, colour: S.colour("ink-muted"), lineSpacing: 1.3 });
2022
- }
2023
- p.cells.forEach((cell) => {
2024
- packRect(slide, S, cell, { line: "line", lineWidth: 0.75 });
2025
- const w = cell.w - p.pad * 2;
2026
- // The item and its details stand in the middle of the quadrant, so a short cell reads as placed.
2027
- const blockH = cell.headH + cell.details.reduce((a, d) => a + 4 + d.h, 0);
2028
- let y = cell.y + Math.max(p.pad, Math.round((cell.h - blockH) / 2));
2029
- packText(slide, S, cell.head, { x: cell.x + p.pad, y, w, h: cell.headH }, { size: p.head, bold: true, lineSpacing: 1.3 });
2030
- y += cell.headH;
2031
- for (const d of cell.details) {
2032
- y += 4;
2033
- packText(slide, S, d.text, { x: cell.x + p.pad, y, w, h: d.h }, { size: p.detail, colour: S.colour("ink-muted") });
2034
- y += d.h;
2035
- }
2036
- });
2037
- if (p.caption) drawCaption(slide, S, p.caption, p.grid.x, p.top + 2 * p.qh + p.gap + 6, p.grid.w);
2038
- return;
2039
- }
2040
- if (p.kind === "quote") {
2041
- packText(slide, S, "“", { x: p.markX, y: p.y - 6, w: p.markW, h: S.sizes.display * 1.1 }, { face: "display", size: S.sizes.display, colour: S.colour("accent"), lineSpacing: 1.15 });
2042
- packText(slide, S, plainText(p.text).replace(/^[“"]|[”"]$/gu, ""), { x: p.x, y: p.y, w: p.w, h: p.textH }, { face: "title", size: p.size, lineSpacing: 1.3 });
2043
- if (p.by) packText(slide, S, p.by, { x: p.x, y: p.y + p.textH + 18, w: p.w, h: S.sizes.label * 1.4 }, { size: S.sizes.label, colour: S.colour("ink-muted"), lineSpacing: 1.3 });
2044
- return;
2045
- }
2046
- if (p.kind === "number") {
2047
- packText(slide, S, p.value, { x: p.x, y: p.y, w: p.w, h: p.size * 1.1 }, { face: "numeral", size: p.size, colour: S.colour(p.colour || "accent"), lineSpacing: 1.15 });
2048
- if (p.label) packText(slide, S, p.label, { x: p.x, y: p.y + p.size * 1.1 + 12, w: p.w, h: G.textHeight(p.label, p.w, p.labelSize) }, { size: p.labelSize, colour: S.colour(p.labelColour || "ink-muted") });
2049
- return;
2050
- }
2051
- if (p.kind === "table") {
2052
- drawPackTable(slide, S, c, p, ctx.title);
2053
- drawCaption(slide, S, p.item.caption, p.x, p.y + p.tableH + 6, p.w);
2054
- return;
2055
- }
2056
- if (p.kind === "chart") {
2057
- drawChart(slide, S, c, p);
2058
- drawCaption(slide, S, p.item.caption, p.x, p.y + p.h - p.cap + 6, p.w);
2059
- return;
2060
- }
2061
- if (p.kind === "image") {
2062
- const images = p.item.type === "image-grid" ? c.images || [] : [c];
2063
- const h = p.h - p.cap;
2064
- const cellW = (p.w - (images.length - 1) * S.grid.gutter) / Math.max(1, images.length);
2065
- let bottom = p.y;
2066
- images.forEach((image, i) => {
2067
- const file = forGround(A.resolveImagePath(image.src, ctx.sourceDir), S);
2068
- let fit = A.containBox(IN(p.x + i * (cellW + S.grid.gutter)), IN(p.y), IN(cellW), IN(h), A.readImageSize(file));
2069
- const low = IN(p.y + h) - fit.h;
2070
- if (p.beside != null && images.length === 1 && low * 72 <= p.beside) fit = { ...fit, y: low };
2071
- slide.addImage({ path: file, ...fit, altText: image.caption || path.basename(image.src || file) });
2072
- if (S.pack.image && S.pack.image.frame === "hairline") packRect(slide, S, { x: fit.x * 72, y: fit.y * 72, w: fit.w * 72, h: fit.h * 72 }, { line: "line", lineWidth: 0.5 });
2073
- bottom = Math.max(bottom, (fit.y + fit.h) * 72);
2074
- });
2075
- // The caption binds to the picture as drawn: a letterboxed figure keeps its caption under it.
2076
- drawCaption(slide, S, p.item.caption, p.x, bottom + 6, p.w);
2077
- return;
2078
- }
2079
- if (p.kind === "caption") drawCaption(slide, S, p.item.content, p.x, p.y, p.w, p.role === "on-field" ? "on-field" : "ink-muted");
2080
- }
2081
-
2082
- /**
2083
- * A figure on a dark ground is drawn from its dark variant when the source folder has one beside it
2084
- * (`flow.png` → `flow.dark.png`): a chart or diagram exported on white would stand as a white card.
2085
- */
2086
- function forGround(file, S) {
2087
- const c = (i) => parseInt(String(S.P.ground).replace("#", "").slice(i, i + 2), 16) / 255;
2088
- if (0.2126 * c(0) + 0.7152 * c(2) + 0.0722 * c(4) >= 0.25) return file;
2089
- const ext = path.extname(file);
2090
- const dark = `${file.slice(0, file.length - ext.length)}.dark${ext}`;
2091
- return require("fs").existsSync(dark) ? dark : file;
2092
- }
2093
-
2094
- function drawCaption(slide, S, caption, x, y, w, role = "ink-muted") {
2095
- if (!caption) return;
2096
- const text = captionText(caption);
2097
- packText(slide, S, text, { x, y, w, h: G.textHeight(text, w, S.sizes.label, 1.3) },
2098
- { size: S.sizes.label, colour: S.colour(role), lineSpacing: 1.3 });
2099
- }
2100
-
2101
- // Series names that are a reference for the measured one: a plan, target, budget, baseline, prior period.
2102
- const REFERENCE = /계획|목표|예산|전년|전기|기준|이전|기존|평균|plan|target|budget|baseline|benchmark|forecast|prior|previous|last year|average/iu;
2103
-
2104
- /** A series name's period as one comparable number (year, then half, quarter or month), or null. */
2105
- function periodOf(name) {
2106
- const t = plainText(name);
2107
- const year = /(?:^|\D)((?:19|20)\d{2})(?!\d)/u.exec(t) || /(?:^|[^\d.])(\d{2})년/u.exec(t);
2108
- const quarter = /\bQ([1-4])\b|\b([1-4])Q\b|([1-4])\s*분기/iu.exec(t);
2109
- const half = /\bH([12])\b|([상하])반기/iu.exec(t);
2110
- const month = /(?:^|\D)(1[0-2]|[1-9])월|\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\b/iu.exec(t);
2111
- const months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
2112
- const within = quarter ? 3 * Number(quarter[1] || quarter[2] || quarter[3])
2113
- : half ? 6 * (half[1] ? Number(half[1]) : half[2] === "상" ? 1 : 2)
2114
- : month ? (month[1] ? Number(month[1]) : months.indexOf(month[2].slice(0, 3).toLowerCase()) + 1) : null;
2115
- if (!year && within == null) return null;
2116
- const y = year ? Number(year[1].length === 2 ? `20${year[1]}` : year[1]) : 0;
2117
- return y * 100 + (within || 0);
2118
- }
2119
-
2120
- /**
2121
- * The series a chart highlights: the latest period when every series names one, else the one measured
2122
- * series beside its plans, targets or prior periods, else the last series (where a comparison puts the
2123
- * proposed or current one).
2124
- */
2125
- function primarySeries(names) {
2126
- const periods = names.map(periodOf);
2127
- if (periods.every((v) => v != null) && new Set(periods).size === periods.length) return periods.indexOf(Math.max(...periods));
2128
- const measured = names.map((n, i) => (REFERENCE.test(plainText(n)) ? -1 : i)).filter((i) => i >= 0);
2129
- if (measured.length && measured.length < names.length) return measured[measured.length - 1];
2130
- return names.length - 1;
2131
- }
2132
-
2133
- /** A series name without its unit or case, so "Single feed (%)" and "single feed" are one series. */
2134
- function seriesKey(name) {
2135
- return plainText(name).replace(/\s*[((][^))]*[))]\s*$/u, "").trim().toLowerCase();
2136
- }
2137
-
2138
- /**
2139
- * A native chart in the pack's chart style: one hue per series, the accent on the deck's one highlighted
2140
- * series (primarySeries), the others receding (accent-on-muted) or in the pack's other series hues.
2141
- */
2142
- function drawChart(slide, S, c, p) {
2143
- const P = S.P;
2144
- const chart = S.pack.chart || {};
2145
- const series = (c.headers || []).length - 1;
2146
- const muted = mix(P["ink-muted"], P.ground, 0.45);
2147
- let colours;
2148
- if (series <= 1) {
2149
- // One series is one hue (a per-point highlight would make the chart read as categories): the accent,
2150
- // unless the deck shows the same series receding beside another, where it keeps that colour.
2151
- const other = S.seriesRole && S.seriesRole.get(seriesKey((c.headers || [])[1])) === "other";
2152
- const receding = chart.highlight === "accent-on-muted" ? muted : P.series.find((h) => String(h).toUpperCase() !== String(P.accent).toUpperCase()) || muted;
2153
- colours = [other ? receding : P.accent];
2154
- } else {
2155
- const primary = primarySeries(c.headers.slice(1));
2156
- const others = chart.highlight === "accent-on-muted" ? (series === 2 ? [muted] : P.series.slice(1, series).reverse())
2157
- : P.series.filter((h) => String(h).toUpperCase() !== String(P.accent).toUpperCase());
2158
- let k = 0;
2159
- colours = Array.from({ length: series }, (_, i) => (i === primary ? P.accent : others[k++ % others.length]));
2160
- }
2161
- // Without a value axis, the top data label needs headroom inside the plot.
2162
- const values = (c.rows || []).flatMap((r) => r.slice(1).map((v) => Number(plainText(v).replace(/[^\d.\-]/gu, "")))).filter(Number.isFinite);
2163
- const top = values.length ? Math.max(...values) : 0;
2164
- const style = {
2165
- series: colours, ink: P.ink, ink_muted: P["ink-muted"], line: P.line,
2166
- titleFont: S.faces.title.font, bodyFont: S.faces.body.font, labelSize: S.sizes.label,
2167
- grid: chart.gridlines !== "none", valAxisHidden: chart.gridlines === "none" && chart.labels === "direct",
2168
- ...(top > 0 && !(c.chart && ["pie", "doughnut"].includes(c.chart.type)) ? { valMax: niceCeil(top * 1.15) } : {}),
2169
- };
2170
- const bottom = p.y + p.h - p.cap;
2171
- shared().renderChart(slide, c, { x: IN(p.x), y: IN(p.y), w: IN(p.w), h: IN(bottom - p.y) }, style, IN(bottom));
2172
- }
2173
-
2174
- /** A round axis maximum at or above v (1, 2 or 5 times a power of ten). */
2175
- function niceCeil(v) {
2176
- const p = 10 ** Math.floor(Math.log10(v));
2177
- return [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].map((m) => m * p).find((x) => x >= v);
2178
- }
2179
-
2180
- // A totals row's first cell; a word boundary after Hangul needs the lookahead (\b reads ASCII only).
2181
- const TOTALS = /^(합계|총계|소계|계|total|sum)(?![\p{L}\p{N}])/iu;
2182
-
2183
- /** A table in the pack's table style: header fill, rules and banding from the pack, numbers right-aligned. */
2184
- function drawPackTable(slide, S, c, p, title) {
2185
- const A = shared();
2186
- const headers = c.headers || [];
2187
- // Every row carries one cell per column, so a short source row cannot leave a ragged table.
2188
- const rows = (c.rows || []).map((r) => headers.map((_, i) => (r[i] != null ? r[i] : "")));
2189
- if (!headers.length) return;
2190
- const t = S.pack.table || {};
2191
- const numeric = A.numericColumns(headers, rows);
2192
- const hair = { type: "solid", pt: 0.75, color: S.colour("line") };
2193
- const heavy = (pt) => ({ type: "solid", pt, color: S.colour("ink") });
2194
- const none = { type: "none" };
2195
- const headerFill = t.header && t.header !== "none" ? S.colour(t.header) : null;
2196
- const headerInk = S.colour(t["header-ink"] || (t.header === "field" ? "on-field" : "ink"));
2197
- const lastIsTotal = rows.length > 1 && TOTALS.test(plainText(rows[rows.length - 1][0]));
2198
- const titleText = plainText(title);
2199
- const protagonist = t.protagonist && t.protagonist !== "none"
2200
- ? rows.findIndex((r) => { const k = plainText(r[0]); return k.length >= 2 && titleText.includes(k); })
2201
- : -1;
2202
- // [top, right, bottom, left] for the header (ri = -1) and each data row.
2203
- const border = (ri) => {
2204
- const last = ri === rows.length - 1;
2205
- switch (t.rules) {
2206
- case "grid": return Array(4).fill(S.pack["edge-weight"] ? { type: "solid", pt: S.pack["edge-weight"], color: S.colour(S.pack["edge-colour"] || "line") } : hair);
2207
- case "booktabs": return [ri === -1 ? heavy(1) : none, none, ri === -1 ? heavy(0.5) : last ? heavy(1) : none, none];
2208
- case "top-bottom": return [ri === -1 ? hair : none, none, last ? hair : ri === -1 ? hair : none, none];
2209
- case "header-rule": return [none, none, ri === -1 ? heavy(2) : none, none];
2210
- case "rows": return [none, none, hair, none];
2211
- default: // header-and-totals
2212
- return [last && lastIsTotal ? hair : none, none, ri === -1 ? hair : none, none];
2213
- }
2214
- };
2215
- const cellMargin = [IN(6), IN(6), IN(6), IN(6)];
2216
- // Cell text that wraps is broken at spaces here, as in body text (see G.keepLines).
2217
- const keep = (text, ci, ri, size, role) => G.keepLines(text, ((p.widths[ci] || p.w) - 12) / S.wide(role, text) / size,
2218
- Math.floor(((p.heights[ri + 1] || 0) - 12) / (size * 1.45) + 0.01));
2219
- const tableRows = [headers.map((h, ci) => ({
2220
- text: keep(plainText(h), ci, -1, p.header, "label"),
2221
- options: { bold: true, color: headerInk, fontFace: S.faces.label.font, fontSize: p.header, align: numeric[ci] ? "right" : "left", valign: "middle",
2222
- margin: cellMargin, border: border(-1), ...(headerFill ? { fill: { color: headerFill } } : {}) },
2223
- }))];
2224
- rows.forEach((r, ri) => {
2225
- const total = lastIsTotal && ri === rows.length - 1 && t.totals === "bold";
2226
- const band = t.banding && t.banding !== "none";
2227
- tableRows.push(r.map((cell, ci) => A.linkedTableCell(typeof cell === "string" && !/\]\(/u.test(cell) ? keep(cell, ci, ri, p.data, "body") : cell, {
2228
- color: S.colour("ink"), fontFace: S.faces.body.font, fontSize: p.data, bold: total,
2229
- align: numeric[ci] ? "right" : "left", valign: "middle", margin: cellMargin, border: border(ri),
2230
- ...(ri === protagonist ? { fill: { color: S.colour(t.protagonist) } } : band && ci === 0 ? { fill: { color: S.colour(t.banding) } } : {}),
2231
- })));
2232
- });
2233
- slide.addTable(tableRows, {
2234
- // The frame is as tall as its rows; without h the frame is declared 1in whatever the rows need.
2235
- x: IN(p.x), y: IN(p.y), w: IN(p.w), h: IN(p.tableH), colW: p.widths.map(IN), rowH: p.heights.map(IN), autoPage: false,
2236
- });
2237
- }
2238
-
2239
- // ── Fill and treatment choice ───────────────────────────────────────────────
2240
-
2241
- /** Bottom of the content, decoration excluded. */
2242
- function contentBottom(placed, top) {
2243
- const counted = placed.filter((p) => !p.decor);
2244
- return counted.length ? Math.max(...counted.map((p) => p.y + p.h)) : top;
2245
- }
2246
-
2247
- function overflows(placed) {
2248
- return placed.some((p) => !p.decor && p.limit != null && p.y + p.h > p.limit + 0.5);
2249
- }
2250
-
2251
- /**
2252
- * The zones of one treatment frame: body Z, the class and where the empty band is measured from.
2253
- * Every treatment's body is the shared body zone under the title zone, so the class is "top".
2254
- */
2255
- function zonesOf(frame, S) {
2256
- const t = frame.title;
2257
- if (!frame.body) return { cls: "none" };
2258
- const Z = region(S, frame.body.a, frame.body.b, frame.body.y, frame.body.bottom);
2259
- return { cls: "top", Z, bandTop: Math.min(t.y + t.h, Z.y) };
2260
- }
2261
-
2262
- /**
2263
- * Lay a content slide out under one frame and, when the body leaves more than the density band
2264
- * empty, try the pack's fill policies in order: larger type one ramp step, the next spacing step,
2265
- * the visual taking the room. Content is never invented and decoration never fills space.
2266
- */
2267
- // A line that names the slide's source or a note on its basis ("출처:", "주:", "Source:", "Note:").
2268
- const STRIP = /^(?:출처|자료|주|Sources?|Notes?)\s*[::]/iu;
2269
-
2270
- /**
2271
- * The source and note lines of a content slide's text, taken out of its takeaways: they are set as a
2272
- * strip at the foot of the body zone, at source size under a hairline, so the slide states where its
2273
- * figures come from without a takeaway column spending its lines on it. Closings keep theirs in the
2274
- * next step.
2275
- */
2276
- function takeStrip(spec, items) {
2277
- // A closing with a next step keeps its source there; a closing summary has no such line, so it takes the strip.
2278
- if (G.VARIANTS.closing.includes(spec.family) && spec.family !== "closing-summary-list") return { items, lines: [] };
2279
- const lines = [];
2280
- const keep = (list) => (list || []).filter((it) => {
2281
- if ((it.type === "bullet" || it.type === "text") && STRIP.test(plainText(it.text || "")) && !(it.children || []).length) { lines.push(it.text); return false; }
2282
- return true;
2283
- });
2284
- const out = items.map((item) => {
2285
- if (item.type === "body" && item.content && Array.isArray(item.content.items)) return { ...item, content: { ...item.content, items: keep(item.content.items) } };
2286
- return item;
2287
- }).filter((item) => !(item.type === "body" && item.content && Array.isArray(item.content.items) && !item.content.items.length));
2288
- return { items: out, lines };
2289
- }
2290
-
2291
- function stripPlacements(lines, Z, S) {
2292
- const size = S.sizes.source;
2293
- const paras = lines.map((t) => ({ kind: "text", text: t, inset: 0, gap: 2, h: G.textHeight(plainText(t), Z.w, size, 1.3) }));
2294
- paras[0].gap = 0;
2295
- const h = paras.reduce((a, q) => a + q.gap + q.h, 0);
2296
- const y = Z.bottom - h;
2297
- // A hairline sets the strip off where the pack draws hairlines; elsewhere the size and the muted
2298
- // ink do (a rule in a pack without them adds a colour to the slide).
2299
- return { h: h + 10, placed: [
2300
- ...(S.deco.has("hairline-rule") ? [{ decor: true, kind: "rect", x: Z.x, y: y - 6, w: Z.w, h: 0.5, fill: "line" }] : []),
2301
- { kind: "text", paras, size, x: Z.x, y, w: Z.w, h, muted: true, limit: Z.bottom },
2302
- ] };
2303
- }
2304
-
2305
- // A column more empty than this, beside a longer one, costs the slide its title (spec-v2 Amendments 7).
2306
- const RAIL_EMPTY = 0.4;
2307
-
2308
- function planSlide(spec, frame, S, items) {
2309
- const z = zonesOf(frame, S);
2310
- if (spec.lead && spec.family !== "summary-box-list") items = [{ type: "main-box", content: spec.lead }, ...items];
2311
- if (z.cls === "none") return { placed: [], band: 0, applied: [], before: 0, z };
2312
- const full = z.Z;
2313
- const taken = takeStrip(spec, items);
2314
- // The source strip: offered to a takeaway column beside a visual, and across the body's foot when no column takes it.
2315
- const lines = taken.lines;
2316
- items = taken.items;
2317
- const across = lines.length ? stripPlacements(lines, full, S) : null;
2318
- const tok = S.tok;
2319
- const plan = (spec.stacked && PLANS[STACKS[spec.family]]) || PLANS[spec.family] || PLANS["text-column"];
2320
- const state = { stepped: false, anchor: false, itemGap: tok.item, groupGap: tok.group, blockGap: tok.block };
2321
- // Offer the strip to a column first; once a run leaves it, it runs across the foot and the body ends above it.
2322
- let offer = Boolean(across);
2323
- const zone = () => (across && !offer ? { ...full, bottom: full.bottom - across.h - S.tok.block } : full);
2324
- // A later run (another fill state) that leaves the offered strip is refused like an overflow.
2325
- const run = (settle = false) => {
2326
- const ctx = { spec, S, state, Z: zone(), family: spec.family, items, strip: offer ? lines : null };
2327
- const placed = plan(ctx);
2328
- const lost = offer && !placed.some((q) => q.strip);
2329
- if (lost && settle) {
2330
- offer = false;
2331
- return run();
2332
- }
2333
- return { placed, lost, bottom: contentBottom(placed, zone().y) };
2334
- };
2335
- const band = (o) => Math.max(0, Math.min(1, (zone().bottom - o.bottom) / Math.max(1, zone().bottom - z.bandTop)));
2336
- let out = run(true);
2337
- if (overflows(out.placed)) {
2338
- // Too much for the body at the family's sizes: leads drop to body size and gaps to the item gap.
2339
- Object.assign(state, { compact: true, groupGap: tok.item, blockGap: tok.group });
2340
- out = run(true);
2341
- }
2342
- const before = band(out);
2343
- const applied = [];
2344
- if (before > tok.cap && items.length) {
2345
- for (const policy of S.pack["fill-order"] || []) {
2346
- if (band(out) <= tok.cap) break;
2347
- const saved = { ...state };
2348
- if (policy === "step-up") {
2349
- if (!tok.stepUp) continue;
2350
- state.stepped = true;
2351
- } else if (policy === "distribute") {
2352
- state.itemGap = G.stepGap(state.itemGap, 24);
2353
- state.groupGap = G.stepGap(state.groupGap, 48);
2354
- state.blockGap = G.stepGap(state.blockGap, 48);
2355
- } else if (policy === "anchor-visual") {
2356
- state.anchor = true;
2357
- } else {
2358
- continue;
2359
- }
2360
- if (JSON.stringify(saved) === JSON.stringify(state)) continue;
2361
- const next = run();
2362
- if (next.lost || overflows(next.placed)) Object.assign(state, saved);
2363
- else {
2364
- if (next.bottom > out.bottom + 0.5) applied.push(policy);
2365
- out = next;
2366
- }
2367
- }
2368
- }
2369
- z.Z = zone();
2370
- // A text column that stops short of the column beside it is filled by layout; one that still leaves more
2371
- // than RAIL_EMPTY of the body empty makes this title unfit for the slide when another fits.
2372
- const floor = full.bottom;
2373
- let short = shortColumn([...out.placed, ...(across && !offer ? across.placed : [])], floor, S);
2374
- // The fill starts a little under the line (0.35), so a column the gate reads a point or two emptier than the
2375
- // estimate still holds.
2376
- if (short.share > 0.35) {
2377
- fillColumn(short, floor, S, state);
2378
- short = shortColumn([...out.placed, ...(across && !offer ? across.placed : [])], floor, S);
2379
- }
2380
- const placed = [...out.placed, ...(across && !offer ? across.placed : [])];
2381
- const overflow = overflows(placed);
2382
- return { ...out, placed, band: band(out), before, applied, z, overflow, short: short.share,
2383
- unfit: overflow || short.share > RAIL_EMPTY };
2384
- }
2385
-
2386
- /** The frame of a treatment for this slide (a quote under a statement title says the quote). */
2387
- function frameFor(spec, treatment) {
2388
- const ctx = treatment === "statement" && spec.statementText ? { ...spec.ctx, title: spec.statementText } : spec.ctx;
2389
- return G.treatmentGeometry(treatment, ctx);
2390
- }
2391
-
2392
- /**
2393
- * Choose among the treatments the slide may take. The role default stays when its body fills to
2394
- * the density band; otherwise every allowed treatment is laid out and scored by the empty band it
2395
- * leaves, with a small cost for repeating the previous slide's title or one the deck already leans
2396
- * on and a large one past about a third of the deck, so filling never collapses a deck into one look. The variance dial keeps the number of
2397
- * distinct treatments under its maximum.
2398
- */
2399
- // The bottom-anchor style (the title frame closed by a heavy rule) is for a slide led by a chart, a picture,
2400
- // a big number, a row of figures or a timeline axis (S2.5), not for a table.
2401
- const drawn = (spec) => ["big-number", "kpi-row", "timeline"].includes(spec.family) || (spec.items || []).some((i) => (i.type === "kpi-table" && (i.content || {}).chart) || i.type === "image" || i.type === "image-grid");
2402
-
2403
- function chooseTreatment(spec, S, deck) {
2404
- const options = spec.candidates && spec.candidates.length ? spec.candidates : [spec.treatment];
2405
- const allowed = deck.used.size >= deck.max && options.some((t) => deck.used.has(t)) ? options.filter((t) => deck.used.has(t)) : options;
2406
- const tries = allowed.map((t) => ({ t, plan: planSlide(spec, frameFor(spec, t), S, spec.items || []) }));
2407
- // Titles that fit come first; a table goes under a bottom title only when nothing else fits it.
2408
- const fit = tries.filter((x) => !x.plan.unfit);
2409
- const proper = fit.filter((x) => x.t !== "bottom-anchor" || drawn(spec));
2410
- // When every title leaves the slide unfit, the one that overflows least and leaves a column least empty stands.
2411
- const badness = (x) => (x.plan.overflow ? 10 : 0) + Math.max(0, (x.plan.short || 0) - RAIL_EMPTY);
2412
- const pool = proper.length ? proper : fit.length ? fit : [...tries].sort((m, n) => badness(m) - badness(n));
2413
- const first = pool[0];
2414
- if (first.t === options[0] && first.plan.band <= S.tok.cap && first.t !== deck.prev && (deck.count[first.t] || 0) < deck.limit) return first;
2415
- const cost = (x) => x.plan.band + (x.plan.band > S.tok.cap ? 0.15 : 0) + 0.07 * (deck.count[x.t] || 0) +
2416
- (x.t === deck.prev ? 0.08 : 0) - (x.t === options[0] ? 0.03 : 0) + ((deck.count[x.t] || 0) >= deck.limit ? 1 : 0);
2417
- const best = pool.reduce((b, x) => (cost(x) < cost(b) - 1e-9 ? x : b));
2418
- // The role's own title is the pack's structure (spec-v2 Amendments 7): it stays unless another title
2419
- // leaves at least 0.10 less of the body empty (0.15 when neither fills to the density band).
2420
- // A bottom title the slide may not take (a table) hands the pack's structure to its next treatment in order.
2421
- const ownT = options[0] === "bottom-anchor" && !drawn(spec) ? options.find((t) => t !== "bottom-anchor") : options[0];
2422
- const own = pool.find((x) => x.t === ownT);
2423
- const margin = best.plan.band > S.tok.cap ? 0.15 : 0.1;
2424
- // A family the pack draws with its own title (`structure`) keeps it past the deck's share of that title.
2425
- const pinned = (S.pack.structure || {})[spec.family] === ownT;
2426
- if (own && own !== best && own.plan.band - best.plan.band < margin && (pinned || (deck.count[own.t] || 0) < deck.limit)) return own;
2427
- return best;
2428
- }
2429
-
2430
- /**
2431
- * Fill alone can settle a deck on two titles. Variance 4 and up asks for three (S13.2) once a deck
2432
- * has eight slides, so while it carries fewer, the slide that loses the least fill moves to a
2433
- * treatment the deck has not used: one of its own candidates, never one that overflows or leaves
2434
- * more than the density band (or what the slide already leaves) empty, and never the last slide of
2435
- * a treatment.
2436
- */
2437
- function spreadTreatments(choices, S, pack, slideCount) {
2438
- const need = slideCount < 8 ? 0 : Math.min(pack.dials.variance <= 3 ? 1 : 3, pack.treatments.length, pack.dials.varianceMax);
2439
- const lines = [];
2440
- const used = () => new Set([...choices.values()].map((c) => c.t));
2441
- while (used().size < need) {
2442
- const have = used();
2443
- const count = (t) => [...choices.values()].filter((c) => c.t === t).length;
2444
- let best = null;
2445
- for (const [spec, current] of choices) {
2446
- if (count(current.t) < 2) continue;
2447
- for (const t of spec.candidates || []) {
2448
- if (have.has(t)) continue;
2449
- const plan = planSlide(spec, frameFor(spec, t), S, spec.items || []);
2450
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band) + 0.05) continue;
2451
- const loss = plan.band - current.plan.band;
2452
- if (!best || loss < best.loss) best = { spec, t, plan, loss };
2453
- }
2454
- }
2455
- if (!best) break;
2456
- choices.set(best.spec, { t: best.t, plan: best.plan });
2457
- lines.push(`variety: slide ${best.spec.index + 1} drawn under ${best.t} so the deck carries ${used().size} title treatments`);
2458
- }
2459
- // No title zone on more than 40 % of the content slides (S15): a data slide (a table, chart or
2460
- // figures under their takeaway) that fills no worse under another zone's treatment moves there,
2461
- // the one that gains the most first. Agendas, sequences and definitions keep their own titles.
2462
- const content = [...choices.keys()].filter((spec) => spec.kind === "content");
2463
- const movable = (spec) => spec.role === "data" || spec.role === "data-takeaway";
2464
- const cap = 0.4 * content.length;
2465
- const zonesNow = () => {
2466
- const zones = {};
2467
- for (const spec of content) zones[ZONE_OF[choices.get(spec).t]] = (zones[ZONE_OF[choices.get(spec).t]] || 0) + 1;
2468
- return zones;
2469
- };
2470
- // The data slide in zone `from` that fills best under a title of another zone with room.
2471
- const moveOut = (from, zones, blocked) => {
2472
- let best = null;
2473
- for (const spec of content) {
2474
- const current = choices.get(spec);
2475
- if (ZONE_OF[current.t] !== from || !movable(spec)) continue;
2476
- for (const t of spec.candidates || []) {
2477
- const zone = ZONE_OF[t];
2478
- if (zone === from || blocked.has(zone) || (zones[zone] || 0) + 1 > cap) continue;
2479
- if (t === "bottom-anchor" && !drawn(spec)) continue;
2480
- const inUse = new Set([...choices.values()].map((c) => c.t));
2481
- if (!inUse.has(t) && inUse.size >= pack.dials.varianceMax) continue;
2482
- const plan = planSlide(spec, frameFor(spec, t), S, spec.items || []);
2483
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band)) continue;
2484
- const gain = current.plan.band - plan.band;
2485
- if (!best || gain > best.gain) best = { spec, t, plan, gain };
2486
- }
2487
- }
2488
- return best;
2489
- };
2490
- const say = (m) => lines.push(`variety: slide ${m.spec.index + 1} drawn under ${m.t} so no title zone covers more than 40 % of the content slides`);
2491
- for (let guard = 0; guard < content.length; guard++) {
2492
- const zones = zonesNow();
2493
- const [crowded, n] = Object.entries(zones).sort((a, b) => b[1] - a[1])[0] || [];
2494
- if (!crowded || n <= cap) break;
2495
- let best = moveOut(crowded, zones, new Set());
2496
- if (!best) {
2497
- // Every zone a crowded slide could take is full: move one of that zone's own data slides on
2498
- // to a third zone first, when that makes room.
2499
- for (const [full, m] of Object.entries(zones)) {
2500
- if (full === crowded || m + 1 <= cap) continue;
2501
- const first = moveOut(full, zones, new Set([crowded]));
2502
- if (!first) continue;
2503
- const saved = choices.get(first.spec);
2504
- choices.set(first.spec, { t: first.t, plan: first.plan });
2505
- best = moveOut(crowded, zonesNow(), new Set());
2506
- if (best) { say(first); break; }
2507
- choices.set(first.spec, saved);
2508
- }
2509
- }
2510
- if (!best) break;
2511
- choices.set(best.spec, { t: best.t, plan: best.plan });
2512
- say(best);
2513
- }
2514
- // Composition variety (S15) counts title zone x column partition over the content slides,
2515
- // closings excluded. While the deck has fewer distinct layouts than the check needs, a data slide
2516
- // whose layout another slide shares moves to a title that gives a layout the deck lacks, when that
2517
- // neither overflows nor leaves more than the density band (or what the slide already leaves).
2518
- const counted = content.filter((spec) => !G.VARIANTS.closing.includes(spec.family));
2519
- const layoutsNeeded = Math.min(5, Math.ceil(0.6 * counted.length));
2520
- const layoutOf = (t, plan) => `${ZONE_OF[t]}/${partitionOf(plan, S)}`;
2521
- // The check also fails a deck where one layout covers more than 40 % of those slides, so while
2522
- // one does, a slide of that layout moves to a title that gives a layout still under the share.
2523
- // A title style never moves the body (every treatment shares the title zone), so any slide whose
2524
- // source leaves its title open may take another here, not only a data slide.
2525
- const shareCap = 0.4 * counted.length;
2526
- for (let guard = 0; guard < counted.length; guard++) {
2527
- const keys = {};
2528
- for (const spec of counted) { const c = choices.get(spec); const k = layoutOf(c.t, c.plan); keys[k] = (keys[k] || 0) + 1; }
2529
- const [topKey, topN] = Object.entries(keys).sort((a, b) => b[1] - a[1])[0] || [];
2530
- const short = Object.keys(keys).length < layoutsNeeded;
2531
- const crowded = topN > shareCap;
2532
- if (!short && !crowded) break;
2533
- let best = null;
2534
- for (const spec of counted) {
2535
- const current = choices.get(spec);
2536
- const from = layoutOf(current.t, current.plan);
2537
- if (keys[from] < 2 || (!short && from !== topKey)) continue;
2538
- for (const t of spec.candidates || []) {
2539
- if (t === current.t || (t === "bottom-anchor" && !drawn(spec))) continue;
2540
- const inUse = new Set([...choices.values()].map((c) => c.t));
2541
- if (!inUse.has(t) && inUse.size >= pack.dials.varianceMax) continue;
2542
- const plan = planSlide(spec, frameFor(spec, t), S, spec.items || []);
2543
- const to = layoutOf(t, plan);
2544
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band) || to === from) continue;
2545
- // A move that adds a layout comes first; else one that relieves the crowded layout.
2546
- const adds = short && !keys[to];
2547
- const relieves = crowded && from === topKey && (keys[to] || 0) + 1 <= shareCap;
2548
- if (!adds && !relieves) continue;
2549
- const loss = plan.band - current.plan.band - (adds ? 2 : 0) - (relieves ? 1 : 0);
2550
- if (!best || loss < best.loss) best = { spec, t, plan, loss, added: !keys[to] };
2551
- }
2552
- }
2553
- if (!best) {
2554
- // No title gives a new layout: a table or chart slide may stack its takeaways under the visual
2555
- // across the body (the composition of the ledger-table and full-chart families) instead.
2556
- for (const spec of counted) {
2557
- const current = choices.get(spec);
2558
- const from = layoutOf(current.t, current.plan);
2559
- if (!STACKS[spec.family] || spec.stacked || keys[from] < 2 || (!short && from !== topKey)) continue;
2560
- const stacked = { ...spec, stacked: true };
2561
- for (const t of [current.t, ...(spec.candidates || []).filter((c) => c !== current.t)]) {
2562
- if (t === "bottom-anchor" && !drawn(spec)) continue;
2563
- const plan = planSlide(stacked, frameFor(spec, t), S, spec.items || []);
2564
- const to = layoutOf(t, plan);
2565
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band) || to === from) continue;
2566
- if (short ? keys[to] : (keys[to] || 0) + 1 > shareCap) continue;
2567
- const loss = plan.band - current.plan.band;
2568
- if (!best || loss < best.loss) best = { spec, t, plan, loss, added: !keys[to], stacked: true };
2569
- }
2570
- }
2571
- }
2572
- if (!best) break;
2573
- if (best.stacked) best.spec.stacked = true;
2574
- choices.set(best.spec, { t: best.t, plan: best.plan });
2575
- lines.push(best.added ? `variety: slide ${best.spec.index + 1} drawn under ${best.t} so the deck carries ${Object.keys(keys).length + 1} layouts`
2576
- : `variety: slide ${best.spec.index + 1} drawn under ${best.t} so no layout covers more than 40 % of the content slides`);
2577
- }
2578
- return lines;
2579
- }
2580
-
2581
- /**
2582
- * The boxes a placement draws as the composition check reads them from the page: text frames,
2583
- * tables, charts and pictures, and filled surfaces that hold text (cards). Rules, dots and outlines
2584
- * are decoration there and are left out.
2585
- */
2586
- function drawnBoxes(p, S) {
2587
- const B = (x, y, w, h, card = false) => ({ x, y, w, h, card });
2588
- const filled = S.pack.edge !== "border";
2589
- switch (p.kind) {
2590
- case "group": return p.parts.flatMap((q) => drawnBoxes(q, S));
2591
- case "text": {
2592
- let y = p.y;
2593
- return p.paras.map((para) => { y += para.gap || 0; const box = B(p.x + (para.inset || 0), y, p.w - (para.inset || 0), para.h); y += para.h; return box; });
2594
- }
2595
- case "callout": return [B(p.x, p.y, p.w, p.h, true)];
2596
- case "box": return p.outline || (!p.tint && !filled) ? [] : [B(p.x, p.y, p.w, p.h, true)];
2597
- case "panel": return p.fill && p.h >= 40 ? [B(p.x, p.y, p.w, p.h, true)] : [];
2598
- case "kpi": return p.cards.flatMap((card, i) => {
2599
- const x = p.x + i * (p.cardW + S.grid.gutter);
2600
- if (filled) return [B(x, p.y, p.cardW, p.cardH, true)];
2601
- const y = p.y + p.pad + p.value * 1.15 + 6;
2602
- return [B(x + p.pad, p.y + p.pad, p.cardW - p.pad * 2, p.value * 1.15), B(x + p.pad, y, p.cardW - p.pad * 2, p.labelH)];
2603
- });
2604
- case "figrows": return p.rows.flatMap((r) => [B(p.x, r.y, p.valueW, p.value * 1.15), B(p.labelX, r.y, p.labelW, p.labelSize * 1.4)]);
2605
- case "rows": return p.rows.flatMap((r) => [B(p.x, r.y, p.numW, (p.numSize || p.head) * 1.15), B(p.textX, r.y, p.textW, p.restX != null ? r.hh : r.h),
2606
- ...(p.restX != null && r.rest ? [B(p.restX, r.y, p.restW, r.rh)] : [])]);
2607
- case "headed": return p.rows.flatMap((r) => [B(p.headX, r.y, p.headW, r.headH), B(p.textX, r.y, p.textW, r.textH)]);
2608
- case "steps": return p.steps.flatMap((st) => [B(st.x, p.y, st.w, p.numSize * 1.1), B(st.x, p.y + p.numSize * 1.1 + 18, st.w, st.headH)]);
2609
- case "timeline": return p.events.flatMap((e) => [B(e.x, p.axisY - 18 - p.dateSize * 1.25, e.w, p.dateSize * 1.25), B(e.x, p.axisY + 18, e.w, e.labelH)]);
2610
- case "actions": return p.rows.flatMap((r) => [B(p.keyX, r.y, p.keyW, p.keySize * 1.15), B(p.textX, r.y, p.textW, r.headH)]);
2611
- case "matrix": return [...p.cells.map((c) => B(c.x + p.pad, c.y + p.pad, c.w - p.pad * 2, c.headH)),
2612
- ...p.xHeads.map((_, i) => B(p.grid.x + i * (p.qw + p.gap), p.grid.y, p.qw, 16)),
2613
- ...p.yHeads.map((_, i) => B(p.labels.x, p.top + i * (p.qh + p.gap), p.labels.w, 16))];
2614
- case "quote": return [B(p.x, p.y, p.w, p.h)];
2615
- case "number": return [B(p.x, p.y, p.w, p.h)];
2616
- // A chart's caption is its own frame under the plot, as the check reads it.
2617
- case "chart": return p.cap ? [B(p.x, p.y, p.w, p.h - p.cap), B(p.x, p.y + p.h - p.cap + 6, p.w, p.cap - 6)] : [B(p.x, p.y, p.w, p.h)];
2618
- case "image": {
2619
- // A single picture is drawn contained in its box (on the box floor beside a taller takeaway column),
2620
- // its caption under it: the check reads those two frames.
2621
- const size = p.item && p.item.type === "image" && p.item.imageSize;
2622
- if (!size) return [B(p.x, p.y, p.w, p.h)];
2623
- const fit = shared().containBox(p.x, p.y, p.w, p.h - p.cap, size);
2624
- const low = p.y + p.h - p.cap - fit.h;
2625
- if (p.beside != null && low <= p.beside) fit.y = low;
2626
- return [B(fit.x, fit.y, fit.w, fit.h), ...(p.cap ? [B(p.x, fit.y + fit.h + 6, p.w, p.cap - 6)] : [])];
2627
- }
2628
- case "table": case "caption": return [B(p.x, p.y, p.w, p.h)];
2629
- default: return p.x != null && p.w ? [B(p.x, p.y, p.w, p.h || 0)] : [];
2630
- }
2631
- }
2632
-
2633
- /**
2634
- * The column partition a plan draws, read the way the composition check reads the page (S15):
2635
- * boxes inside a card count as the card; boxes narrower than 70 % of the body are grouped into
2636
- * columns by overlapping x-extent (half the narrower box joins, and a box that joins two columns
2637
- * merges them); two or more columns sharing two or more rows, or four columns, are a grid.
2638
- */
2639
- function partitionOf(plan, S) {
2640
- const Z = plan.z && plan.z.Z;
2641
- const placed = (plan.placed || []).filter((q) => !q.decor);
2642
- if (!Z || !placed.length) return "one";
2643
- const all = placed.flatMap((q) => drawnBoxes(q, S)).filter((b) => b.w > 0 && b.h > 0);
2644
- const cards = all.filter((b) => b.card);
2645
- const inCard = (b) => cards.some((c) => c !== b && b.x + b.w / 2 >= c.x - 1 && b.x + b.w / 2 <= c.x + c.w + 1 && b.y + b.h / 2 >= c.y - 1 && b.y + b.h / 2 <= c.y + c.h + 1);
2646
- // A one-line caption or source on the body floor is the slide's foot, not a column (as the gate reads it).
2647
- const body = SG.zone(S.grid.canvas, "content", "body");
2648
- const floor = body.y + body.h;
2649
- const blocks = all.filter((b) => !inCard(b) && !(!b.card && b.h <= 16 && b.y + b.h >= floor - 2));
2650
- if (!blocks.length) return "one";
2651
- const bodyW = S.grid.W - 2 * S.grid.margin;
2652
- let narrow = blocks.filter((b) => b.w < 0.7 * bodyW);
2653
- if (!narrow.length) narrow = blocks;
2654
- const columns = [];
2655
- for (const b of [...narrow].sort((m, n) => m.x - n.x)) {
2656
- const hits = columns.filter((c) => Math.min(c.r, b.x + b.w) - Math.max(c.l, b.x) >= 0.5 * Math.min(c.r - c.l, b.w));
2657
- if (hits.length) {
2658
- const keep = hits[0];
2659
- for (const other of hits.slice(1)) { keep.l = Math.min(keep.l, other.l); keep.r = Math.max(keep.r, other.r); keep.items.push(...other.items); columns.splice(columns.indexOf(other), 1); }
2660
- keep.l = Math.min(keep.l, b.x); keep.r = Math.max(keep.r, b.x + b.w); keep.items.push(b);
2661
- } else columns.push({ l: b.x, r: b.x + b.w, items: [b] });
2662
- }
2663
- const columnOf = new Map(columns.flatMap((c, i) => c.items.map((b) => [b, i])));
2664
- const rows = [];
2665
- for (const b of [...narrow].sort((m, n) => m.y - n.y)) {
2666
- const last = rows[rows.length - 1];
2667
- if (last && b.y < last.bottom - 2) { last.bottom = Math.max(last.bottom, b.y + b.h); last.items.push(b); }
2668
- else rows.push({ bottom: b.y + b.h, items: [b] });
2669
- }
2670
- const gridRows = rows.filter((r) => new Set(r.items.map((b) => columnOf.get(b))).size >= 2).length;
2671
- const k = columns.length;
2672
- if (k >= 4 || (k >= 2 && gridRows >= 2)) return "grid";
2673
- if (k === 3) return "three";
2674
- if (k === 2) {
2675
- const [a, c] = columns.map((col) => col.r - col.l);
2676
- return Math.min(a, c) / Math.max(a, c) >= 0.85 ? "two-even" : "two-asym";
2677
- }
2678
- return "one";
2679
- }
2680
-
2681
- /**
2682
- * The emptiest text column of a two-column body, read as the gate reads it (OF-115, spec-v2 Amendments 8):
2683
- * for every vertical cut no block crosses, a side holding text only, beside a side that reaches at least
2684
- * three quarters of the body, is measured by the largest band its blocks leave empty from the pair's top
2685
- * down to where the other side ends (to the floor beside figure rows, Amendments 9), as a share of the body
2686
- * from that top to the floor. A source strip closing the column counts as a block but does not hide the band
2687
- * above it. Returns { share, owners }.
2688
- */
2689
- const TEXT_KINDS = new Set(["text", "caption", "callout", "box", "panel"]);
2690
- // A picture drawn smaller than its box leaves its own column empty above it as a short text column does.
2691
- const SHORT_KINDS = new Set([...TEXT_KINDS, "image"]);
2692
- function shortColumn(placed, floor, S) {
2693
- const flat = (list) => list.flatMap((q) => (q.kind === "group" ? flat(q.parts) : [q]));
2694
- const owners = flat(placed.filter((q) => !q.decor));
2695
- // A matrix's cells are drawn whole on the page, whatever its composition estimate reads of them.
2696
- const boxesOf = (q) => (q.kind === "matrix" ? q.cells.map((c) => ({ x: c.x, y: c.y, w: c.w, h: c.h })) : drawnBoxes(q, S));
2697
- // A chart's values table under its takeaways belongs to their column.
2698
- const boxes = owners.flatMap((q) => boxesOf(q).map((b) => ({ ...b, q, text: SHORT_KINDS.has(q.kind) || Boolean(q.item && q.item.values) })))
2699
- .concat(owners.filter((q) => q.kind === "box" || q.kind === "panel").map((q) => ({ x: q.x, y: q.y, w: q.w, h: q.h, q, text: true })))
2700
- .filter((b) => b.w > 0 && b.h > 0 && b.y < floor);
2701
- let worst = { share: 0, owners: [] };
2702
- if (boxes.length < 2) return worst;
2703
- const left = Math.min(...boxes.map((b) => b.x));
2704
- const right = Math.max(...boxes.map((b) => b.x + b.w));
2705
- for (const cut of [...new Set(boxes.map((b) => b.x + b.w))].sort((m, n) => m - n)) {
2706
- const a = boxes.filter((b) => b.x + b.w <= cut + 2);
2707
- const c = boxes.filter((b) => b.x >= cut - 2);
2708
- // A block across most of the body (a note under both columns) belongs to neither; a narrower one across the cut
2709
- // means there is no column line here.
2710
- const across = boxes.filter((b) => !a.includes(b) && !c.includes(b));
2711
- if (!a.length || !c.length || across.some((b) => b.w < 0.7 * (right - left))) continue;
2712
- const top = Math.min(...[...a, ...c].map((b) => b.y));
2713
- for (const [col, other] of [[a, c], [c, a]]) {
2714
- if (!col.every((b) => b.text)) continue;
2715
- // Beside figure rows (not on their own panel) the column runs to the floor: the rows stop where their
2716
- // spacing ends, not where the slide's content does (spec-v2 Amendments 9).
2717
- const figures = other.some((b) => ["figrows", "number"].includes(b.q.kind)) && !other.some((b) => b.q.kind === "panel");
2718
- const reach = figures ? floor : Math.min(floor, Math.max(...other.map((b) => b.y + b.h)));
2719
- if (reach - top < 0.75 * (floor - top)) continue;
2720
- let gap = 0;
2721
- let cursor = top;
2722
- for (const b of [...col].sort((m, n) => m.y - n.y)) {
2723
- gap = Math.max(gap, b.y - cursor);
2724
- cursor = Math.max(cursor, b.y + b.h);
2725
- }
2726
- gap = Math.max(gap, reach - cursor);
2727
- const share = gap / Math.max(1, floor - top);
2728
- if (share > worst.share) worst = { share, owners: [...new Set(col.map((b) => b.q))], top, reach, besideText: other.every((b) => b.q.kind === "text") };
2729
- }
2730
- }
2731
- return worst;
2732
- }
2733
-
2734
- /**
2735
- * Fill a short text column by layout (spec-v2 Amendments 8): its points step up to lead size when they fit
2736
- * and keep twelve glyphs a line, then the room left is shared between its points, at most a sixth of the
2737
- * body a gap. Type never shrinks and nothing is added. Changes the placements in place.
2738
- */
2739
- function fillColumn(short, floor, S, state) {
2740
- const texts = short.owners.filter((q) => q.kind === "text" && !q.muted && !q.strip && q.paras);
2741
- if (!texts.length) return;
2742
- // The chart's values under the takeaways move down with them; they bound nothing above them.
2743
- const values = short.owners.filter((q) => q.item && q.item.values);
2744
- const below = (q) => Math.min(floor, q.limit == null ? floor : q.limit, ...short.owners.filter((o) => o !== q && !values.includes(o) && o.y >= q.y + q.h - 0.5).map((o) => o.y - state.blockGap));
2745
- const carried = (q, dy) => values.every((v) => v.y < q.y + q.h - 0.5 || v.y + v.h + dy <= below(v) + 0.5);
2746
- const lead = S.sizes.lead;
2747
- // Beside another text column the points keep its size: two columns of text at two sizes read as a mistake.
2748
- for (const q of short.besideText ? [] : texts) {
2749
- if (q.size >= lead || q.w / lead < 12) continue;
2750
- const m = measureText(q.paras, q.w, S, { ...state, stepped: false }, { size: lead });
2751
- if (q.y + m.h <= below(q) + 0.5 && carried(q, m.h - q.h)) {
2752
- // Every later block in the column moves down by what the step adds.
2753
- const dy = m.h - q.h;
2754
- for (const o of short.owners) if (o !== q && o.y >= q.y + q.h - 0.5 && !o.strip && !o.muted) o.y += dy;
2755
- Object.assign(q, { paras: m.paras, size: m.size, h: m.h });
2756
- }
2757
- }
2758
- const breaks = texts.flatMap((q) => q.paras.filter((para, i) => i > 0 && para.kind !== "child").map((para) => ({ q, para })));
2759
- const last = [...texts, ...values].reduce((m, q) => (q.y + q.h > m.y + m.h ? q : m));
2760
- const room = below(last) - (last.y + last.h);
2761
- // The gap over a values table is shared like a gap between points.
2762
- const gaps = breaks.length + values.length;
2763
- if (!gaps || room <= 0) return;
2764
- const per = Math.min(room / (gaps + 1), (floor - short.top) / 6);
2765
- for (const { q, para } of breaks) { para.gap += per; q.h += per; }
2766
- // A block that grew pushes the text blocks and values under it (never the strip, which stays on the floor).
2767
- let shift = 0;
2768
- for (const q of [...texts, ...values].sort((m, n) => m.y - n.y)) {
2769
- if (values.includes(q)) shift += per;
2770
- q.y += shift;
2771
- shift += breaks.filter((b) => b.q === q).length * per;
2772
- }
2773
- }
2774
-
2775
- /** Families whose visual may take its takeaways under it across the body, and the plan that does. */
2776
- const STACKS = { "table-insight": "ledger-table", "chart-insight": "full-chart" };
2777
-
2778
- /**
2779
- * The composition title zone of each treatment (S15). Every treatment styles the one title frame of the
2780
- * slide grid, so a slide's title "zone" in its signature is its treatment, as the gate reads it.
2781
- */
2782
- const ZONE_OF = Object.fromEntries(G.TREATMENTS.map((t) => [t, t]));
2783
-
2784
- // ── Content, cover and section slides ───────────────────────────────────────
2785
-
2786
- function drawDecor(slide, S, list) {
2787
- for (const d of list || []) packRect(slide, S, d, { fill: d.role, alpha: d.alpha });
2788
- }
2789
-
2790
- /**
2791
- * A content slide: decoration, numeral, body, then the title frame of its treatment. The title is
2792
- * drawn last so the first shape on the slide is an unnamed one that can carry the family name.
2793
- */
2794
- function renderContent(slide, spec, S, ctx, chosen) {
2795
- const f = frameFor(spec, chosen.t);
2796
- const t = f.title;
2797
- const items = spec.items || [];
2798
- if (!f.image) drawDecor(slide, S, f.decor);
2799
- if (f.numeral) {
2800
- packText(slide, S, f.numeral.text, f.numeral, { face: "numeral", size: f.numeral.size, colour: S.colour("accent"), lineSpacing: 1.15, align: f.numeral.align, name: "numeral@kicker" });
2801
- }
2802
- const dctx = { sourceDir: ctx.sourceDir, title: spec.title };
2803
- let ink = t.colour;
2804
- if (f.image) {
2805
- const image = items.find((i) => i.type === "image" || i.type === "image-grid");
2806
- const src = image && (image.content.type === "image-grid" ? image.content.images[0] : image.content);
2807
- if (src) {
2808
- const file = shared().resolveImagePath(src.src, ctx.sourceDir);
2809
- slide.addImage({ path: file, ...croppedTo(file, { x: 0, y: 0, w: f.image.w, h: f.image.h }), altText: src.caption || path.basename(file) });
2810
- drawDecor(slide, S, f.decor);
2811
- if (image.caption) drawCaption(slide, S, image.caption, t.x, 432, t.w, "on-field");
2812
- }
2813
- } else if (f.support) {
2814
- const text = spec.supportText || spec.lead || items.filter(isText).flatMap(itemParas).map((p) => plainText(p.text)).join(" ");
2815
- const supportH = text ? G.textHeight(plainText(text), f.support.w, S.sizes.body) : 0;
2816
- ink = statementDevice(slide, S, f, supportH);
2817
- if (text) packText(slide, S, text, { ...f.support, h: supportH }, { colour: S.colour(ink === "on-field" ? "on-field" : "ink-muted"), name: "support@statement" });
2818
- } else if (f.body) {
2819
- const plan = chosen.plan;
2820
- if (plan.before > S.tok.cap || plan.band > S.tok.cap) {
2821
- ctx.log.push(`fill: slide ${spec.index + 1} band ${plan.before.toFixed(2)} -> ${plan.band.toFixed(2)} (${plan.applied.length ? plan.applied.join(", ") : "none: nothing on the slide can grow; choose a fuller family"})`);
2822
- }
2823
- for (const p of plan.placed.filter((q) => q.decor)) drawPlaced(slide, S, p, dctx);
2824
- for (const p of plan.placed.filter((q) => !q.decor)) drawPlaced(slide, S, p, dctx);
2825
- }
2826
- packText(slide, S, chosen.t === "statement" && spec.statementText ? spec.statementText : spec.title, t, {
2827
- // Every title that wraps is set in balanced lines, never ending on one word.
2828
- face: t.face, size: t.size, colour: S.colour(ink), lineSpacing: t.lineSpacing || 1.15, valign: t.valign, title: true, name: `title@${chosen.t}`, balance: true,
2829
- });
2830
- }
2831
-
2832
- /**
2833
- * What carries a statement, from the pack's display keys: nothing (open), the field over the whole
2834
- * page (drench), the field from just above the sentence's zone to the page foot (plate), a hairline
2835
- * above the sentence and one under its support line (rules), the primaries' composition in the side
2836
- * zone (geometry), or the rail colour filling the side zone (offset). The sentence stays in the display
2837
- * title zone whichever it is. Returns the colour role the sentence takes.
2838
- */
2839
- function statementDevice(slide, S, f, supportH) {
2840
- const g = S.grid;
2841
- const t = f.title;
2842
- const side = SG.zone(g.canvas, "display", "side");
2843
- const device = (S.pack.display || {}).statement || "open";
2844
- if (device === "drench") {
2845
- packRect(slide, S, { x: 0, y: 0, w: g.W, h: g.H }, { fill: "field" });
2846
- return "on-field";
2847
- }
2848
- if (device === "plate") {
2849
- packRect(slide, S, { x: 0, y: t.y - 24, w: g.W, h: g.H - t.y + 24 }, { fill: "field" });
2850
- return "on-field";
2851
- }
2852
- if (device === "rules") {
2853
- // The rules follow the sentence centred in its zone, not the zone's edges.
2854
- const full = g.span(1, 12);
2855
- const top = t.y + (t.h - t.textH) / 2;
2856
- const below = supportH ? f.support.y + supportH + 24 : top + t.textH + 30;
2857
- packRect(slide, S, { x: full.x, y: top - 30, w: full.w, h: 0.75 }, { fill: "line" });
2858
- packRect(slide, S, { x: full.x, y: below, w: full.w, h: 0.75 }, { fill: "line" });
2859
- return t.colour;
2860
- }
2861
- if (device === "geometry") {
2862
- geometry(slide, S, side);
2863
- return t.colour;
2864
- }
2865
- if (device === "offset") {
2866
- packRect(slide, S, { ...side, h: G.ZONE.floor }, { fill: S.pack.rail === "field" ? "field" : "surface" });
2867
- return t.colour;
2868
- }
2869
- return t.colour;
2870
- }
2871
-
2872
- function metaLine(meta) {
2873
- return [meta.date, meta.department, meta.presenter].filter(Boolean).join(" · ");
2874
- }
2875
-
2876
- /**
2877
- * The cover's words, the same places in every tonality (slide-grid cover zones): the meta line in the
2878
- * header zone, the title standing on the title zone's foot at the largest step that fits it (from the
2879
- * hero step while the pack's hero is on), and the
2880
- * subtitle in the subtitle zone. A device only paints what lies behind or beside them.
2881
- */
2882
- function coverWords(slide, spec, S, meta, o = {}) {
2883
- const Z = SG.zones(S.grid.canvas).cover;
2884
- const soft = S.colour(o.soft || "ink-muted");
2885
- const line = metaLine(meta);
2886
- if (line) packText(slide, S, line, Z.header, { size: S.sizes.label, colour: S.colour(o.meta || o.soft || "ink-muted"), lineSpacing: 1.2, name: "header@cover" });
2887
- if (meta.subtitle) {
2888
- const size = G.textHeight(meta.subtitle, Z.subtitle.w, S.sizes.lead) <= Z.subtitle.h ? S.sizes.lead : S.sizes.body;
2889
- packText(slide, S, meta.subtitle, Z.subtitle, { name: "subtitle@cover", size, colour: soft });
2890
- }
2891
- const steps = [...new Set([o.start || (S.pack.hero ? S.sizes.hero : S.sizes.cover), S.sizes.cover, S.sizes.display])].sort((a, b) => b - a);
2892
- const fits = (z) => S.lines(plainText(spec.title), Z.title.w, z, "display") * z * 1.1 <= Z.title.h;
2893
- const size = steps.find(fits) || S.sizes.display;
2894
- packText(slide, S, spec.title, Z.title, { face: "display", size, colour: S.colour(o.ink || "ink"), lineSpacing: 1.1, title: true, balance: true, valign: "bottom", name: "title@cover" });
2895
- }
2896
-
2897
- /** A row of keys over short labels in the cover's strip zone (the deck's parts or its headline figures), under a hairline. */
2898
- function coverStrip(slide, S, parts) {
2899
- const g = S.grid;
2900
- const Z = SG.zones(g.canvas).cover.strip;
2901
- const row = parts.slice(0, 4);
2902
- const cols = equalParts(S, region(S, 1, 12, Z.y, Z.y + Z.h), row.length);
2903
- packRect(slide, S, { x: Z.x, y: Z.y - 9, w: Z.w, h: 0.75 }, { fill: "line" });
2904
- row.forEach(([key, text], i) => {
2905
- const R = cols[i];
2906
- const k = [S.sizes.title, S.sizes.lead].find((z) => S.ems(key, "numeral") * z * 1.1 <= R.w) || S.sizes.body;
2907
- packText(slide, S, key, { x: R.x, y: Z.y, w: R.w, h: k * 1.15 }, { face: "numeral", size: k, colour: S.colour(i === 0 ? "accent" : "ink"), lineSpacing: 1.15 });
2908
- const top = Z.y + k * 1.32 + 4;
2909
- packText(slide, S, text, { x: R.x, y: top, w: R.w, h: Math.max(S.sizes.body * 1.4, Z.y + Z.h - top) }, { size: S.sizes.body, colour: S.colour("ink-muted") });
2910
- });
2911
- }
2912
-
2913
- /** The deck's parts, else its headline figures, as strip entries. */
2914
- function stripParts(facts) {
2915
- if ((facts.index || []).length >= 2) return facts.index.map((name, i) => [String(i + 1).padStart(2, "0"), name]);
2916
- if ((facts.figures || []).length >= 2) return facts.figures.map((f) => [f.value, f.label]);
2917
- return [];
2918
- }
2919
-
2920
- function coverImage(slide, box, src, sourceDir) {
2921
- const file = shared().resolveImagePath(src.src, sourceDir);
2922
- slide.addImage({ path: file, ...croppedTo(file, box), altText: src.caption || path.basename(file) });
2923
- }
2924
-
2925
- /**
2926
- * A picture that fills a box by cropping, never by stretching: the cover sizing reads the picture's
2927
- * own proportions from w and h and crops it to the box (without them it is stretched to the box).
2928
- */
2929
- function croppedTo(file, box) {
2930
- const size = shared().readImageSize(file);
2931
- const ratio = size && size.width && size.height ? size.height / size.width : box.h / box.w;
2932
- return { x: IN(box.x), y: IN(box.y), w: IN(box.w), h: IN(box.w * ratio), sizing: { type: "cover", w: IN(box.w), h: IN(box.h) } };
2933
- }
2934
-
2935
- /** The field behind the title zone and what stands on it, from `top` down to 6 pt under the title's foot. */
2936
- function titleField(slide, S, top) {
2937
- const T = SG.zones(S.grid.canvas).cover.title;
2938
- packRect(slide, S, { x: 0, y: top, w: S.grid.W, h: T.y + T.h + 6 - top }, { fill: "field" });
2939
- }
2940
-
2941
- /**
2942
- * A type-led cover drawn with the pack's display device. Every device leaves the words where
2943
- * coverWords puts them and paints only around them: the field over the whole page (drench), a field
2944
- * plate from over the title to the page foot (plate), a journal page between rules (rules), the
2945
- * composition in the side zone (geometry), or the plain page.
2946
- */
2947
- const TYPE_COVERS = {
2948
- drench(slide, spec, S, meta) {
2949
- packRect(slide, S, { x: 0, y: 0, w: S.grid.W, h: S.grid.H }, { fill: "field" });
2950
- coverWords(slide, spec, S, meta, { ink: "on-field", soft: "on-field", start: S.pack.hero ? S.sizes.hero : S.sizes.cover });
2951
- },
2952
- plate(slide, spec, S, meta) {
2953
- // The plate runs from over the title to the page foot; the meta line stays on the ground above it.
2954
- const top = SG.zones(S.grid.canvas).cover.title.y - 24;
2955
- packRect(slide, S, { x: 0, y: top, w: S.grid.W, h: S.grid.H - top }, { fill: "field" });
2956
- coverWords(slide, spec, S, meta, { ink: "on-field", soft: "on-field", meta: "ink-muted" });
2957
- },
2958
- rules(slide, spec, S, meta) {
2959
- const Z = SG.zones(S.grid.canvas).cover;
2960
- packRect(slide, S, { x: Z.strip.x, y: Z.title.y - 18, w: Z.strip.w, h: 2 }, { fill: "ink" });
2961
- packRect(slide, S, { x: Z.strip.x, y: Z.strip.y - 9, w: Z.strip.w, h: 0.75 }, { fill: "line" });
2962
- coverWords(slide, spec, S, meta);
2963
- },
2964
- geometry(slide, spec, S, meta) {
2965
- geometry(slide, S, SG.zones(S.grid.canvas).cover.side);
2966
- coverWords(slide, spec, S, meta);
2967
- },
2968
- plain(slide, spec, S, meta) {
2969
- coverWords(slide, spec, S, meta);
2970
- },
2971
- };
2972
-
2973
- const COVERS = {
2974
- "cover-typographic"(slide, spec, S, meta) {
2975
- const device = (S.pack.display || {}).cover || "plain";
2976
- const facts = spec.cover || {};
2977
- if (device === "rail") return COVERS["cover-rail"](slide, spec, S, meta);
2978
- if (device === "band") return COVERS["cover-band"](slide, spec, S, meta);
2979
- if (device === "figures" && (facts.figures || []).length >= 2) return COVERS["cover-figures"](slide, spec, S, meta);
2980
- if (device === "numeral" && facts.numeral) return COVERS["cover-numeral"](slide, spec, S, meta);
2981
- return (TYPE_COVERS[device] || TYPE_COVERS.plain)(slide, spec, S, meta);
2982
- },
2983
- "cover-split-field"(slide, spec, S, meta) {
2984
- const side = SG.zones(S.grid.canvas).cover.side;
2985
- packRect(slide, S, side, { fill: "field" });
2986
- if (spec.cover.numeral) {
2987
- const s = S.grid.span(side.a, side.b);
2988
- packText(slide, S, spec.cover.numeral, { ...s, y: 384, h: S.sizes.title * 1.15 }, { face: "numeral", size: S.sizes.title, colour: S.colour("on-field"), lineSpacing: 1.15 });
2989
- }
2990
- coverWords(slide, spec, S, meta);
2991
- },
2992
- "cover-split-image"(slide, spec, S, meta) {
2993
- coverImage(slide, SG.zones(S.grid.canvas).cover.side, spec.cover.image, spec.sourceDir);
2994
- coverWords(slide, spec, S, meta);
2995
- },
2996
- "cover-full-image"(slide, spec, S, meta) {
2997
- const g = S.grid;
2998
- coverImage(slide, { x: 0, y: 0, w: g.W, h: g.H }, spec.cover.image, spec.sourceDir);
2999
- // A translucent field panel under the words' columns, the full page height; the picture keeps the side zone.
3000
- const side = SG.zones(g.canvas).cover.side;
3001
- packRect(slide, S, { x: 0, y: 0, w: side.x, h: g.H }, { fill: "field", alpha: 12 });
3002
- coverWords(slide, spec, S, meta, { ink: "on-field", soft: "on-field" });
3003
- },
3004
- "cover-band"(slide, spec, S, meta) {
3005
- // The header band deepened behind the title; the subtitle and the deck's parts sit on the ground under it.
3006
- titleField(slide, S, 0);
3007
- const parts = stripParts(spec.cover || {});
3008
- if (parts.length) coverStrip(slide, S, parts);
3009
- coverWords(slide, spec, S, meta, { ink: "on-field", meta: "on-field" });
3010
- },
3011
- "cover-numeral"(slide, spec, S, meta) {
3012
- // A number is never the display element: title size at most (spec-v2 Amendments 5). It stands in the
3013
- // side zone level with the title zone's top.
3014
- const Z = SG.zones(S.grid.canvas).cover;
3015
- const s = S.grid.span(Z.side.a, Z.side.b);
3016
- packText(slide, S, spec.cover.numeral, { ...s, y: Z.title.y, h: S.sizes.title * 1.15 }, { face: "numeral", size: S.sizes.title, colour: S.colour("accent"), align: "right", lineSpacing: 1.15 });
3017
- coverWords(slide, spec, S, meta);
3018
- },
3019
- "cover-index"(slide, spec, S, meta) {
3020
- coverStrip(slide, S, stripParts({ index: spec.cover.index }));
3021
- coverWords(slide, spec, S, meta);
3022
- },
3023
- "cover-figures"(slide, spec, S, meta) {
3024
- coverStrip(slide, S, stripParts({ figures: spec.cover.figures }));
3025
- coverWords(slide, spec, S, meta);
3026
- },
3027
- "cover-rail"(slide, spec, S, meta) {
3028
- // The rail is the left margin in the field, the page's height; the words keep their zones.
3029
- packRect(slide, S, { x: 0, y: 0, w: 12, h: S.grid.H }, { fill: "field" });
3030
- coverWords(slide, spec, S, meta);
3031
- },
3032
- };
3033
-
3034
- /**
3035
- * Section slides use the display zones (slide-grid), the same in every tonality: the part number in
3036
- * the header zone, the part title centred in the title zone, and what the part opens with (its slide
3037
- * titles, or their first lines) in the support zone. A part number shows only when the deck says how
3038
- * many parts there are; without one the title takes the cover step (the hero step in a hero tonality).
3039
- * A variant paints only the device around the words.
3040
- */
3041
- const SECTIONS = {
3042
- "section-field"(slide, spec, S) {
3043
- const g = S.grid;
3044
- packRect(slide, S, { x: 0, y: 0, w: g.W, h: g.H }, { fill: "field" });
3045
- sectionWords(slide, spec, S, { onField: true });
3046
- },
3047
- "section-numeral"(slide, spec, S) {
3048
- // With the agenda known, the numeral's page is the index page: the title is never alone on it.
3049
- if (spec.parts && ((spec.cover || {}).index || []).length >= 2) { sectionIndex(slide, spec, S); return; }
3050
- sectionWords(slide, spec, S);
3051
- },
3052
- "section-rule"(slide, spec, S) {
3053
- if (showsIndex(spec, S)) { sectionIndex(slide, spec, S); return; }
3054
- const Z = SG.zones(S.grid.canvas).display;
3055
- packRect(slide, S, { ...S.grid.span(1, 12), y: Z.support.y - 12, h: 0.75 }, { fill: "line" });
3056
- sectionWords(slide, spec, S);
3057
- },
3058
- "section-band"(slide, spec, S) {
3059
- // The header band deepened to hold the header zone. With the deck's part index the band carries that
3060
- // index (this part marked) in place of the part number.
3061
- const g = S.grid;
3062
- const Z = SG.zones(g.canvas).display;
3063
- packRect(slide, S, { x: 0, y: 0, w: g.W, h: Z.header.y + Z.header.h + 6 }, { fill: "field" });
3064
- const index = showsIndex(spec, S);
3065
- if (index) partIndex(slide, S, spec, Z.header, true);
3066
- sectionWords(slide, spec, S, { headerOnField: true, numeral: !index });
3067
- },
3068
- "section-rail"(slide, spec, S) {
3069
- packRect(slide, S, { x: 0, y: 0, w: 12, h: S.grid.H }, { fill: "field" });
3070
- sectionWords(slide, spec, S);
3071
- },
3072
- "section-image"(slide, spec, S) {
3073
- // A translucent field panel under the words' columns, the page's height; the picture keeps the side zone.
3074
- const g = S.grid;
3075
- coverImage(slide, { x: 0, y: 0, w: g.W, h: g.H }, spec.cover.image, spec.sourceDir);
3076
- packRect(slide, S, { x: 0, y: 0, w: SG.zones(g.canvas).display.side.x, h: g.H }, { fill: "field", alpha: 12 });
3077
- sectionWords(slide, spec, S, { onField: true });
3078
- },
3079
- };
3080
-
3081
- function sectionWords(slide, spec, S, o = {}) {
3082
- const Z = SG.zones(S.grid.canvas).display;
3083
- const ink = S.colour(o.onField ? "on-field" : "ink");
3084
- const soft = S.colour(o.onField ? "on-field" : "ink-muted");
3085
- if (spec.parts && o.numeral !== false) partNumeral(slide, S, spec, Z.header, S.sizes.title, o.onField || o.headerOnField ? "on-field" : "accent");
3086
- // A numbered part sets its title at the display step; an unnumbered one at the cover step, down to display to fit.
3087
- const steps = spec.parts ? [S.sizes.display] : [...new Set([S.pack.hero ? S.sizes.hero : S.sizes.cover, S.sizes.cover, S.sizes.display])].sort((a, b) => b - a);
3088
- const fits = (z) => S.lines(plainText(spec.title), Z.title.w, z, "display") * z * 1.1 <= Z.title.h;
3089
- const size = steps.find(fits) || S.sizes.display;
3090
- sectionSupport(slide, spec, S, Z.support, ink, soft);
3091
- packText(slide, S, spec.title, Z.title, { face: "display", size, colour: ink, lineSpacing: 1.1, title: true, balance: true, valign: "middle", name: "title@section" });
3092
- }
3093
-
3094
- /**
3095
- * What an unnumbered section opens with, in the support zone: one row per opened slide (its title, then
3096
- * up to two of its first lines) when the slides carry body lines, else their titles one to a line. Lines
3097
- * and then rows drop until the preview fits the zone.
3098
- */
3099
- function sectionSupport(slide, spec, S, Z, ink, soft) {
3100
- const head = S.sizes.lead;
3101
- const body = S.sizes.body;
3102
- const digest = (spec.digest || []).filter((d) => d.lines.length);
3103
- if (!digest.length) {
3104
- const text = (spec.contents || []).join("\n");
3105
- if (text) packText(slide, S, text, Z, { size: head, colour: soft, lineSpacing: 1.4 });
3106
- return;
3107
- }
3108
- // About 70 characters of body text at most (spec-v2 Amendments 7): the widest column span inside the zone under that.
3109
- const korean = G.isKorean(digest.map((e) => e.title + e.lines.join("")).join(""));
3110
- const cap = 70 * body * (korean ? 0.94 : 0.5);
3111
- let k = Z.b;
3112
- while (k > Z.a && S.grid.span(Z.a, k).w > cap) k--;
3113
- const span = S.grid.span(Z.a, k);
3114
- const gap = 12;
3115
- const build = (entries, per) => entries.map((e) => {
3116
- const text = e.lines.slice(0, per).join("\n");
3117
- const headH = G.textHeight(e.title, span.w, head, 1.3);
3118
- const textH = text ? G.textHeight(plainText(text), span.w, body) : 0;
3119
- return { ...e, text, headH, textH, h: headH + (text ? 4 + textH : 0) };
3120
- });
3121
- const height = (rows) => rows.reduce((a, r) => a + r.h, 0) + gap * (rows.length - 1);
3122
- let rows = null;
3123
- for (let n = digest.length; n >= 1 && !rows; n--) {
3124
- for (let per = 2; per >= 1; per--) {
3125
- const tried = build(digest.slice(0, n), per);
3126
- if (height(tried) <= Z.h) { rows = tried; break; }
3127
- }
3128
- }
3129
- if (!rows) rows = build(digest.slice(0, 1), 0);
3130
- let at = Z.y;
3131
- for (const r of rows) {
3132
- packText(slide, S, r.title, { ...span, y: at, h: r.headH }, { size: head, bold: true, colour: ink, lineSpacing: 1.3 });
3133
- if (r.text) packText(slide, S, r.text, { ...span, y: at + r.headH + 4, h: r.textH }, { size: body, colour: soft });
3134
- at += r.h + gap;
3135
- }
3136
- }
3137
-
3138
- /**
3139
- * A section in a deck with an agenda, set as its index page: the part number in the header zone over the
3140
- * part title, and the agenda down the side zone, one part a line from the title zone's top, a hairline
3141
- * above each and a heavier accent rule above this part, which is set in the accent.
3142
- */
3143
- function sectionIndex(slide, spec, S) {
3144
- const Z = SG.zones(S.grid.canvas).display;
3145
- const right = S.grid.span(Z.side.a, Z.side.b);
3146
- const names = spec.cover.index;
3147
- const lead = S.sizes.lead;
3148
- const rowH = lead * 1.4;
3149
- const label = (name, i) => `${String(i + 1).padStart(2, "0")} ${name}`;
3150
- const heights = names.map((name, i) => G.textHeight(label(name, i), right.w, lead, 1.4));
3151
- const sum = heights.reduce((a, h) => a + h, 0);
3152
- const floor = Z.support.y + Z.support.h;
3153
- const after = Math.max(12, Math.min(60 - rowH, (floor - Z.title.y - sum) / Math.max(1, names.length - 1)));
3154
- const listH = sum + (names.length - 1) * after;
3155
- const listY = Z.title.y + 12;
3156
- const quiet = S.colour("ink-muted");
3157
- const runs = [];
3158
- let ruleY = listY - 12;
3159
- names.forEach((name, i) => {
3160
- const current = i + 1 === spec.part;
3161
- const colour = current ? S.colour("accent") : quiet;
3162
- packRect(slide, S, { x: right.x, y: ruleY - (current ? 1 : 0), w: right.w, h: current ? 2 : 0.75 }, { fill: current ? "accent" : "line" });
3163
- ruleY += heights[i] + after;
3164
- runs.push({ text: `${String(i + 1).padStart(2, "0")} `, options: { fontFace: S.faces.body.font, fontSize: lead, color: colour, bold: current,
3165
- ...(i ? { paraSpaceBefore: +after.toFixed(1) } : {}) } });
3166
- runs.push({ text: name, options: { fontFace: (current ? S.faces.title : S.faces.body).font, fontSize: lead, color: colour,
3167
- bold: current || Boolean(S.faces.body.bold), breakLine: i < names.length - 1 } });
3168
- });
3169
- // The gap goes before each part after the first, so the frame ends on the last line.
3170
- slide.addText(runs, { x: IN(right.x), y: IN(listY), w: IN(right.w), h: IN(listH), align: "left", valign: "top", margin: [0, 0, 0, 0],
3171
- lineSpacing: +rowH.toFixed(1) });
3172
- sectionWords(slide, spec, S);
3173
- }
3174
-
3175
- /** The part number as the agenda writes it ("03"), followed by the part count when it is known, standing on the box's foot. */
3176
- function partNumeral(slide, S, spec, box, size, colour) {
3177
- const face = S.faces.numeral;
3178
- const base = { fontFace: face.font, bold: Boolean(face.bold), color: S.colour(colour) };
3179
- const pad = (n) => (spec.parts ? String(n).padStart(2, "0") : String(n));
3180
- const tracking = S.tracking("numeral", size);
3181
- const runs = [{ text: pad(spec.part), options: { ...base, fontSize: size, ...(tracking ? { charSpacing: tracking } : {}) } }];
3182
- // The count is a step below the number, so the number stays the display element.
3183
- if (spec.parts) runs.push({ text: ` / ${pad(spec.parts)}`, options: { ...base, fontSize: S.sizes.title, color: S.colour(colour === "on-field" ? "on-field" : "ink-muted") } });
3184
- slide.addText(runs, { x: IN(box.x), y: IN(box.y), w: IN(box.w), h: IN(box.h), align: "left", valign: "bottom", margin: [0, 0, 0, 0],
3185
- lineSpacing: +(size * 1.15).toFixed(1), objectName: "header@section" });
3186
- }
3187
-
3188
- function showsIndex(spec, S) {
3189
- return Boolean((S.pack.display || {}).index && spec.parts && ((spec.cover || {}).index || []).length >= 2);
3190
- }
3191
-
3192
- /** The deck's parts in one line, numbered as in the agenda; this section's part bold in the accent, on the box's foot. */
3193
- function partIndex(slide, S, spec, box, onField = false) {
3194
- const size = S.sizes.body;
3195
- const quiet = onField ? mix(S.P["on-field"], S.P.field, 0.3) : S.P["ink-muted"];
3196
- const runs = [];
3197
- spec.cover.index.forEach((name, i) => {
3198
- const current = i + 1 === spec.part;
3199
- if (i) runs.push({ text: " ", options: { fontFace: S.faces.body.font, fontSize: size } });
3200
- runs.push({ text: `${String(i + 1).padStart(2, "0")} ${name}`, options: {
3201
- fontFace: (current ? S.faces.title : S.faces.body).font, fontSize: size, bold: current || Boolean(S.faces.body.bold),
3202
- color: current ? S.colour(onField ? "on-field" : "accent") : shared().hex(quiet),
3203
- } });
3204
- });
3205
- slide.addText(runs, { x: IN(box.x), y: IN(box.y), w: IN(box.w), h: IN(box.h), align: "left", valign: "bottom", margin: [0, 0, 0, 0],
3206
- lineSpacing: +(size * 1.4).toFixed(1), objectName: "header@section" });
3207
- }
3208
-
3209
- /** The sample-data tag in the footer zone, on the grid's left edge, in the pack's colours. */
3210
- /**
3211
- * The grid shown on purpose: a tick and a two-digit number over each column start in the top margin,
3212
- * and the slide's place in the deck at the right, all in the label face and the muted ink.
3213
- */
3214
- function gridMarks(slide, S, n, total) {
3215
- const g = S.grid;
3216
- const size = S.sizes.source;
3217
- const y = 12;
3218
- for (let a = 1; a <= 12; a++) {
3219
- const x = g.colX(a);
3220
- packRect(slide, S, { x, y, w: 0.75, h: size * 1.2 }, { fill: "line", name: "grid-mark" });
3221
- if (a < 11) packText(slide, S, String(a).padStart(2, "0"), { x: x + 4, y, w: g.col - 4, h: size * 1.2 }, { face: "label", size, colour: S.colour("ink-muted"), lineSpacing: 1.2, name: "grid-mark" });
3222
- }
3223
- const index = `[${String(n).padStart(2, "0")}/${String(total).padStart(2, "0")}]`;
3224
- const right = g.span(11, 12);
3225
- packText(slide, S, index, { ...right, y, h: size * 1.2 }, { face: "label", size, colour: S.colour("ink"), align: "right", lineSpacing: 1.2, name: "grid-mark index" });
3226
- }
3227
-
3228
- /**
3229
- * Elementary geometry in the primaries, in a region of the page that holds no text: a square in the
3230
- * surface colour, a circle in the accent, a bar in the ink and a triangle in the field, one per cell
3231
- * of a two-by-two grid, so no shape overlaps another or the text.
3232
- */
3233
- function geometry(slide, S, region) {
3234
- const cw = region.w / 2;
3235
- const ch = region.h / 2;
3236
- const d = Math.min(cw, ch);
3237
- const cell = (i, j) => ({ x: region.x + i * cw, y: region.y + j * ch });
3238
- const shape = (kind, box, fill) => slide.addShape(kind, { x: IN(box.x), y: IN(box.y), w: IN(box.w), h: IN(box.h), fill: { color: S.colour(fill) }, line: { type: "none" } });
3239
- const a = cell(0, 0);
3240
- shape("rect", { x: a.x, y: a.y, w: cw, h: ch }, "accent-tint");
3241
- const b = cell(1, 0);
3242
- shape("ellipse", { x: b.x + (cw - d) / 2, y: b.y + (ch - d) / 2, w: d, h: d }, "accent");
3243
- const c = cell(0, 1);
3244
- shape("rect", { x: c.x + cw * 0.38, y: c.y, w: cw * 0.24, h: ch }, "ink");
3245
- const e = cell(1, 1);
3246
- shape("triangle", { x: e.x, y: e.y + (ch - d), w: cw, h: d }, "field");
3247
- }
3248
-
3249
- function packNotice(slide, S, text) {
3250
- const label = plainText(text);
3251
- const size = S.sizes.source;
3252
- // A tenth of slack over the measured width keeps a Latin notice on one line in every renderer.
3253
- const w = Math.min(S.grid.span(1, 8).w, G.textEms(label) * size * 1.1 + 24);
3254
- const box = { x: S.grid.margin, y: G.ZONE.footer, w, h: G.ZONE.footerH };
3255
- packRect(slide, S, box, { fill: "accent-tint", radius: S.pack.radius, name: "lit-notice tag" });
3256
- slide.addText(label, {
3257
- objectName: "lit-notice text",
3258
- x: IN(box.x + 12), y: IN(box.y), w: IN(w - 24), h: IN(box.h),
3259
- fontFace: S.faces.label.font, fontSize: size, bold: true, color: S.colour("accent-deep"),
3260
- align: "left", valign: "middle", margin: [0, 0, 0, 0], fit: "shrink",
3261
- });
3262
- }
3263
-
3264
- async function renderPack(resolved, templateObj, outputPath) {
3265
- const A = shared();
3266
- const pack = templateObj.pack;
3267
- const S = packStyle(pack);
3268
- A.usePackFonts(S.faces.title.font, S.faces.body.font, pack.tokens);
3269
-
3270
- const PptxGenJS = runtimeRequire("pptxgenjs");
3271
- const pptx = new PptxGenJS();
3272
- pptx.defineLayout({ name: "LIT_PACK", width: IN(S.grid.W), height: IN(S.grid.H) });
3273
- pptx.layout = "LIT_PACK";
3274
- pptx.title = (resolved.deck && resolved.deck.title) || "Presentation";
3275
- pptx.subject = `lit-pptx tonality=${pack.id} density=${pack.dials.density} grid=${S.grid.name} variance=${pack.dials.variance}`;
3276
- const meta = (resolved.deck && resolved.deck.metadata) || {};
3277
- const notice = typeof meta.notice === "string" && meta.notice.trim() ? meta.notice.trim() : null;
3278
- const log = [...(resolved.notes || []).map((n) => `note: ${n}`)];
3279
- const ctx = { sourceDir: resolved.sourceDir, log };
3280
- const placementCtx = { rich: false, P: {}, fontRoles: {}, pageH: IN(S.grid.H), sourceDir: resolved.sourceDir, layout: "content" };
3281
- // No title treatment chosen for fill may cover more than about a third of the content slides.
3282
- const contentSlides = (resolved.slides || []).filter((s) => s.kind === "content").length;
3283
- const deck = { used: new Set(), max: pack.dials.varianceMax, count: {}, prev: null, limit: Math.max(3, Math.floor(contentSlides * 0.34)) };
3284
- const chosenBy = {};
3285
- const choices = new Map();
3286
- // One colour per series name across the deck (spec-v2 Amendments 8): a series that recedes beside the
3287
- // highlighted one on a chart with several series keeps that colour when it stands alone on another chart.
3288
- S.seriesRole = new Map();
3289
- for (const spec of resolved.slides || []) {
3290
- for (const item of spec.items || []) {
3291
- const c = item.type === "kpi-table" && item.content;
3292
- if (!c || !c.chart || (c.headers || []).length < 3) continue;
3293
- const names = c.headers.slice(1);
3294
- const primary = primarySeries(names);
3295
- names.forEach((n, i) => { const key = seriesKey(n); if (!S.seriesRole.has(key) || i === primary) S.seriesRole.set(key, i === primary ? "primary" : "other"); });
3296
- }
3297
- }
3298
- // A picture's own proportions, so the layout reads it as drawn (contained in its box).
3299
- for (const spec of resolved.slides || []) {
3300
- for (const item of spec.items || []) {
3301
- if (item.type !== "image" || !item.content || !item.content.src) continue;
3302
- try { item.imageSize = A.readImageSize(A.resolveImagePath(item.content.src, resolved.sourceDir)); } catch { /* drawn as its box */ }
3303
- }
3304
- }
3305
- for (const spec of resolved.slides || []) {
3306
- if (spec.kind === "cover" || spec.kind === "section") continue;
3307
- const chosen = chooseTreatment(spec, S, deck);
3308
- deck.used.add(chosen.t);
3309
- deck.count[chosen.t] = (deck.count[chosen.t] || 0) + 1;
3310
- deck.prev = chosen.t;
3311
- choices.set(spec, chosen);
3312
- }
3313
- for (const line of spreadTreatments(choices, S, pack, (resolved.slides || []).length)) log.push(line);
3314
-
3315
- for (const spec of resolved.slides || []) {
3316
- const slide = pptx.addSlide();
3317
- slide.background = { color: S.colour("ground") };
3318
- const stamped = A.stampFamily(slide, spec.family);
3319
- A.renderPlacements(slide, spec.placements || [], "under", placementCtx);
3320
- const withDir = { ...spec, sourceDir: resolved.sourceDir };
3321
- if (spec.kind === "cover") COVERS[spec.variant](slide, withDir, S, meta);
3322
- else if (spec.kind === "section") SECTIONS[spec.variant](slide, withDir, S);
3323
- else {
3324
- const chosen = choices.get(spec);
3325
- chosenBy[spec.index] = chosen.t;
3326
- renderContent(slide, spec, S, ctx, chosen);
3327
- }
3328
- A.renderPlacements(slide, spec.placements || [], "content", placementCtx);
3329
- A.renderPlacements(slide, spec.placements || [], "over", placementCtx);
3330
- if (!stamped()) {
3331
- // Nothing unnamed was drawn (a statement alone): an empty marker carries the family.
3332
- slide.addShape("rect", { x: IN(S.grid.margin), y: IN(G.ZONE.top), w: 0, h: 0, fill: { type: "none" }, line: { type: "none" }, objectName: `family@${spec.family}` });
3333
- }
3334
- // The marks read on the ground; a statement page may be drenched in the field, so it goes without.
3335
- if (spec.kind === "content" && chosenBy[spec.index] !== "statement" && S.deco.has("grid-marks")) gridMarks(slide, S, spec.index + 1, (resolved.slides || []).length);
3336
- if (notice) packNotice(slide, S, notice);
3337
- }
3338
- for (const line of log) console.log(line);
3339
- console.log(`Treatments: ${Object.entries(chosenBy).map(([i, t]) => `${Number(i) + 1}:${t}`).join(" ")}`);
3340
- await writeWithEastAsianFaces(pptx, S.faces.body.font, outputPath, Object.values(S.faces).filter((f) => f.ea), Boolean(S.pack.shadow));
3341
- return outputPath;
3342
- }
3343
-
3344
- /**
3345
- * Write the deck with the pack's body face also named for East Asian text in charts and the theme.
3346
- * Chart text otherwise carries only a Latin face, and a renderer sets Hangul axis labels in
3347
- * whatever system font it finds. Korean runs are tagged ko-KR on the way (see writeTagged).
3348
- */
3349
- async function writeWithEastAsianFaces(pptx, face, outputPath, latinOnly = [], hardShadows = false) {
3350
- await shared().writeTagged(pptx, outputPath, (name, xml) => {
3351
- if (/^ppt\/(charts\/chart\d+|theme\/theme\d+)\.xml$/u.test(name)) {
3352
- xml = xml.replace(/<a:ea typeface=""\/>/gu, `<a:ea typeface="${face}"/>`).replace(/(<a:latin typeface="([^"]*)"\/>)(?!<a:ea)/gu, `$1<a:ea typeface="$2"/>`);
3353
- }
3354
- // A Latin-only face names its East Asian face for the Hangul in its runs.
3355
- if (/^ppt\/(slides\/slide\d+|charts\/chart\d+)\.xml$/u.test(name)) {
3356
- for (const f of latinOnly) xml = xml.split(`<a:ea typeface="${f.font}"`).join(`<a:ea typeface="${f.ea}"`);
3357
- }
3358
- // pptxgenjs reads a blur of 0 as "unset" and writes its default; a pack's shadow is drawn with none.
3359
- if (hardShadows && /^ppt\/slides\/slide\d+\.xml$/u.test(name)) {
3360
- xml = xml.replace(/(<a:outerShdw\b[^>]*?\bblurRad=")\d+"/gu, '$10"');
3361
- }
3362
- return xml;
3363
- });
3364
- }
3365
-
3366
- module.exports = { renderPack, PLANS, COVERS, SECTIONS };