@litfamily/litmuse 0.1.11 → 0.1.13

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 (1036) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +260 -105
  3. package/README_ko-KR.md +260 -105
  4. package/bin/litmuse.mjs +10 -4
  5. package/lib/bundle.mjs +1 -1
  6. package/lib/doctor.mjs +31 -31
  7. package/lib/extensions.mjs +504 -0
  8. package/lib/install.mjs +38 -1
  9. package/lib/paths.mjs +1 -0
  10. package/lib/safe-write.mjs +1 -1
  11. package/package.json +2 -2
  12. package/plugin/.muse-plugin/plugin.json +11 -11
  13. package/plugin/hooks/lib/digest.mjs +4 -7
  14. package/plugin/hooks/lib/extensions.mjs +80 -0
  15. package/plugin/hooks/lib/moved.mjs +42 -0
  16. package/plugin/hooks/post-tool-use.mjs +0 -4
  17. package/plugin/hooks/session-start.mjs +6 -1
  18. package/plugin/hooks/stop.mjs +1 -7
  19. package/plugin/hooks/user-prompt-submit.mjs +4 -4
  20. package/plugin/skills/frontend-ui-ux/SKILL.md +85 -234
  21. package/plugin/skills/lit-diagram-drawer/SKILL.md +69 -200
  22. package/plugin/skills/lit-docx/SKILL.md +65 -225
  23. package/plugin/skills/lit-pptx/SKILL.md +64 -266
  24. package/plugin/skills/lit-schematic/SKILL.md +69 -212
  25. package/plugin/skills/lit-scientific-visualization/SKILL.md +90 -229
  26. package/plugin/skills/lit-typographic-motion/SKILL.md +76 -162
  27. package/plugin/skills/readme-studio/SKILL.md +94 -113
  28. package/plugin/skills/visual-qa/SKILL.md +94 -188
  29. package/lib/runtime.mjs +0 -73
  30. package/plugin/hooks/lib/motion.mjs +0 -156
  31. package/plugin/lib/office-runtime-lock/package-lock.json +0 -793
  32. package/plugin/lib/office-runtime-lock/package.json +0 -12
  33. package/plugin/lib/office-runtime-lock/requirements.lock +0 -15
  34. package/plugin/lib/office-runtime.mjs +0 -274
  35. package/plugin/lib/office_data.py +0 -493
  36. package/plugin/lib/office_runtime_bootstrap.py +0 -76
  37. package/plugin/lib/ooxml_integrity.py +0 -199
  38. package/plugin/lib/pdf_fonts.py +0 -91
  39. package/plugin/lib/render_pages.py +0 -133
  40. package/plugin/lib/strict-json.mjs +0 -143
  41. package/plugin/skills/frontend-ui-ux/ATTRIBUTION.md +0 -23
  42. package/plugin/skills/frontend-ui-ux/LICENSE +0 -21
  43. package/plugin/skills/frontend-ui-ux/PROVENANCE.json +0 -38
  44. package/plugin/skills/frontend-ui-ux/SOURCE-MANIFEST.json +0 -1060
  45. package/plugin/skills/frontend-ui-ux/THIRD-PARTY-NOTICE.txt +0 -14
  46. package/plugin/skills/frontend-ui-ux/data/design-intelligence.json +0 -1
  47. package/plugin/skills/frontend-ui-ux/examples/design-contract.example.json +0 -186
  48. package/plugin/skills/frontend-ui-ux/examples/phase-3-readme-ab/README.md +0 -9
  49. package/plugin/skills/frontend-ui-ux/kit/components.css +0 -414
  50. package/plugin/skills/frontend-ui-ux/kit/fonts.json +0 -22
  51. package/plugin/skills/frontend-ui-ux/kit/layouts/landing.html +0 -164
  52. package/plugin/skills/frontend-ui-ux/kit/layouts/settings.html +0 -114
  53. package/plugin/skills/frontend-ui-ux/kit/layouts/workspace.html +0 -115
  54. package/plugin/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +0 -227
  55. package/plugin/skills/frontend-ui-ux/kit/styles/field-notes.json +0 -205
  56. package/plugin/skills/frontend-ui-ux/kit/styles/graphite.json +0 -200
  57. package/plugin/skills/frontend-ui-ux/kit/styles/meadow.json +0 -199
  58. package/plugin/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +0 -222
  59. package/plugin/skills/frontend-ui-ux/kit/ui.js +0 -226
  60. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-ATTRIBUTION.md +0 -217
  61. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-LICENSE-Apache-2.0.txt +0 -201
  62. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/legal/root-LICENSE +0 -21
  63. package/plugin/skills/frontend-ui-ux/references/_canonical-corpus/manifest.json +0 -873
  64. package/plugin/skills/frontend-ui-ux/references/adaptive-layout.md +0 -92
  65. package/plugin/skills/frontend-ui-ux/references/brand-and-imagery.md +0 -93
  66. package/plugin/skills/frontend-ui-ux/references/complete-contract.md +0 -579
  67. package/plugin/skills/frontend-ui-ux/references/composition.md +0 -85
  68. package/plugin/skills/frontend-ui-ux/references/craft-floor.md +0 -264
  69. package/plugin/skills/frontend-ui-ux/references/creative-directions.md +0 -80
  70. package/plugin/skills/frontend-ui-ux/references/default-editorial-pixel.json +0 -79
  71. package/plugin/skills/frontend-ui-ux/references/design/README.md +0 -248
  72. package/plugin/skills/frontend-ui-ux/references/design/_INDEX.md +0 -191
  73. package/plugin/skills/frontend-ui-ux/references/design/airbnb.md +0 -393
  74. package/plugin/skills/frontend-ui-ux/references/design/airtable.md +0 -92
  75. package/plugin/skills/frontend-ui-ux/references/design/apple.md +0 -250
  76. package/plugin/skills/frontend-ui-ux/references/design/aside.md +0 -209
  77. package/plugin/skills/frontend-ui-ux/references/design/binance.md +0 -348
  78. package/plugin/skills/frontend-ui-ux/references/design/bmw.md +0 -183
  79. package/plugin/skills/frontend-ui-ux/references/design/brutalist-skill.md +0 -92
  80. package/plugin/skills/frontend-ui-ux/references/design/bugatti.md +0 -271
  81. package/plugin/skills/frontend-ui-ux/references/design/cal.md +0 -262
  82. package/plugin/skills/frontend-ui-ux/references/design/claude.md +0 -315
  83. package/plugin/skills/frontend-ui-ux/references/design/clay.md +0 -307
  84. package/plugin/skills/frontend-ui-ux/references/design/clickhouse.md +0 -284
  85. package/plugin/skills/frontend-ui-ux/references/design/clone-from-url.md +0 -65
  86. package/plugin/skills/frontend-ui-ux/references/design/cohere.md +0 -269
  87. package/plugin/skills/frontend-ui-ux/references/design/coinbase.md +0 -132
  88. package/plugin/skills/frontend-ui-ux/references/design/composio.md +0 -310
  89. package/plugin/skills/frontend-ui-ux/references/design/cursor.md +0 -312
  90. package/plugin/skills/frontend-ui-ux/references/design/design-system-architecture.md +0 -244
  91. package/plugin/skills/frontend-ui-ux/references/design/elevenlabs.md +0 -268
  92. package/plugin/skills/frontend-ui-ux/references/design/expo.md +0 -284
  93. package/plugin/skills/frontend-ui-ux/references/design/ferrari.md +0 -317
  94. package/plugin/skills/frontend-ui-ux/references/design/figma.md +0 -223
  95. package/plugin/skills/frontend-ui-ux/references/design/framer.md +0 -249
  96. package/plugin/skills/frontend-ui-ux/references/design/gpt-tasteskill.md +0 -74
  97. package/plugin/skills/frontend-ui-ux/references/design/hashicorp.md +0 -281
  98. package/plugin/skills/frontend-ui-ux/references/design/ibm.md +0 -335
  99. package/plugin/skills/frontend-ui-ux/references/design/image-to-code-skill.md +0 -1228
  100. package/plugin/skills/frontend-ui-ux/references/design/imagegen-brandkit.md +0 -798
  101. package/plugin/skills/frontend-ui-ux/references/design/imagegen-frontend-mobile.md +0 -1465
  102. package/plugin/skills/frontend-ui-ux/references/design/imagegen-frontend-web.md +0 -987
  103. package/plugin/skills/frontend-ui-ux/references/design/intercom.md +0 -149
  104. package/plugin/skills/frontend-ui-ux/references/design/kraken.md +0 -128
  105. package/plugin/skills/frontend-ui-ux/references/design/lamborghini.md +0 -291
  106. package/plugin/skills/frontend-ui-ux/references/design/layout-skill.md +0 -107
  107. package/plugin/skills/frontend-ui-ux/references/design/lazyweb.md +0 -77
  108. package/plugin/skills/frontend-ui-ux/references/design/linear.app.md +0 -370
  109. package/plugin/skills/frontend-ui-ux/references/design/lovable.md +0 -301
  110. package/plugin/skills/frontend-ui-ux/references/design/mastercard.md +0 -368
  111. package/plugin/skills/frontend-ui-ux/references/design/meta.md +0 -369
  112. package/plugin/skills/frontend-ui-ux/references/design/minimalist-skill.md +0 -85
  113. package/plugin/skills/frontend-ui-ux/references/design/minimax.md +0 -260
  114. package/plugin/skills/frontend-ui-ux/references/design/mintlify.md +0 -329
  115. package/plugin/skills/frontend-ui-ux/references/design/miro.md +0 -111
  116. package/plugin/skills/frontend-ui-ux/references/design/mistral.ai.md +0 -264
  117. package/plugin/skills/frontend-ui-ux/references/design/mongodb.md +0 -269
  118. package/plugin/skills/frontend-ui-ux/references/design/nike.md +0 -366
  119. package/plugin/skills/frontend-ui-ux/references/design/notion.md +0 -312
  120. package/plugin/skills/frontend-ui-ux/references/design/nvidia.md +0 -296
  121. package/plugin/skills/frontend-ui-ux/references/design/ollama.md +0 -270
  122. package/plugin/skills/frontend-ui-ux/references/design/opencode.ai.md +0 -284
  123. package/plugin/skills/frontend-ui-ux/references/design/output-skill.md +0 -49
  124. package/plugin/skills/frontend-ui-ux/references/design/pinterest.md +0 -233
  125. package/plugin/skills/frontend-ui-ux/references/design/playstation.md +0 -367
  126. package/plugin/skills/frontend-ui-ux/references/design/posthog.md +0 -259
  127. package/plugin/skills/frontend-ui-ux/references/design/raycast.md +0 -271
  128. package/plugin/skills/frontend-ui-ux/references/design/react-dev-tooling-skill.md +0 -230
  129. package/plugin/skills/frontend-ui-ux/references/design/redesign-skill.md +0 -178
  130. package/plugin/skills/frontend-ui-ux/references/design/renault.md +0 -314
  131. package/plugin/skills/frontend-ui-ux/references/design/replicate.md +0 -264
  132. package/plugin/skills/frontend-ui-ux/references/design/resend.md +0 -306
  133. package/plugin/skills/frontend-ui-ux/references/design/revolut.md +0 -188
  134. package/plugin/skills/frontend-ui-ux/references/design/runwayml.md +0 -247
  135. package/plugin/skills/frontend-ui-ux/references/design/sanity.md +0 -360
  136. package/plugin/skills/frontend-ui-ux/references/design/sentry.md +0 -265
  137. package/plugin/skills/frontend-ui-ux/references/design/shopify.md +0 -353
  138. package/plugin/skills/frontend-ui-ux/references/design/soft-skill.md +0 -98
  139. package/plugin/skills/frontend-ui-ux/references/design/spacex.md +0 -197
  140. package/plugin/skills/frontend-ui-ux/references/design/spotify.md +0 -249
  141. package/plugin/skills/frontend-ui-ux/references/design/starbucks.md +0 -583
  142. package/plugin/skills/frontend-ui-ux/references/design/stitch-design-example.md +0 -121
  143. package/plugin/skills/frontend-ui-ux/references/design/stitch-skill.md +0 -184
  144. package/plugin/skills/frontend-ui-ux/references/design/stripe.md +0 -325
  145. package/plugin/skills/frontend-ui-ux/references/design/supabase.md +0 -258
  146. package/plugin/skills/frontend-ui-ux/references/design/superhuman.md +0 -255
  147. package/plugin/skills/frontend-ui-ux/references/design/taste-skill.md +0 -1206
  148. package/plugin/skills/frontend-ui-ux/references/design/tesla.md +0 -289
  149. package/plugin/skills/frontend-ui-ux/references/design/theverge.md +0 -342
  150. package/plugin/skills/frontend-ui-ux/references/design/together.ai.md +0 -266
  151. package/plugin/skills/frontend-ui-ux/references/design/uber.md +0 -298
  152. package/plugin/skills/frontend-ui-ux/references/design/vercel.md +0 -313
  153. package/plugin/skills/frontend-ui-ux/references/design/vodafone.md +0 -426
  154. package/plugin/skills/frontend-ui-ux/references/design/voltagent.md +0 -326
  155. package/plugin/skills/frontend-ui-ux/references/design/warp.md +0 -256
  156. package/plugin/skills/frontend-ui-ux/references/design/webflow.md +0 -95
  157. package/plugin/skills/frontend-ui-ux/references/design/wired.md +0 -281
  158. package/plugin/skills/frontend-ui-ux/references/design/wise.md +0 -176
  159. package/plugin/skills/frontend-ui-ux/references/design/x.ai.md +0 -260
  160. package/plugin/skills/frontend-ui-ux/references/design/zapier.md +0 -331
  161. package/plugin/skills/frontend-ui-ux/references/designpowers/EVIDENCE.md +0 -97
  162. package/plugin/skills/frontend-ui-ux/references/designpowers/README.md +0 -48
  163. package/plugin/skills/frontend-ui-ux/references/designpowers/UPSTREAM.md +0 -80
  164. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-a-direction.md +0 -64
  165. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-b-execution.md +0 -65
  166. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-c-review.md +0 -65
  167. package/plugin/skills/frontend-ui-ux/references/designpowers/lane-d-memory.md +0 -83
  168. package/plugin/skills/frontend-ui-ux/references/designpowers/orchestration.md +0 -80
  169. package/plugin/skills/frontend-ui-ux/references/designpowers/routing.md +0 -79
  170. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/LICENSE +0 -21
  171. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/accessibility-reviewer.md +0 -83
  172. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/content-writer.md +0 -132
  173. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-builder.md +0 -109
  174. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-critic.md +0 -89
  175. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-lead.md +0 -113
  176. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-scout.md +0 -78
  177. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-strategist.md +0 -121
  178. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/heuristic-evaluator.md +0 -268
  179. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/inspiration-scout.md +0 -107
  180. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/agents/motion-designer.md +0 -120
  181. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/accessible-content/reference.md +0 -101
  182. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/adaptive-interfaces/reference.md +0 -109
  183. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/cognitive-accessibility/reference.md +0 -107
  184. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debate/reference.md +0 -199
  185. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debt-tracker/reference.md +0 -174
  186. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-handoff/reference.md +0 -125
  187. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-md/reference.md +0 -106
  188. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-retrospective/reference.md +0 -266
  189. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-review/reference.md +0 -123
  190. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-system-alignment/reference.md +0 -120
  191. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/designpowers-critique/reference.md +0 -164
  192. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/heuristic-evaluation/reference.md +0 -85
  193. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/inclusive-personas/reference.md +0 -98
  194. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/inspiration-scouting/reference.md +0 -165
  195. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/interaction-design/reference.md +0 -122
  196. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/motion-choreography/reference.md +0 -81
  197. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/research-planning/reference.md +0 -96
  198. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/responsive-patterns/reference.md +0 -77
  199. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/synthetic-user-testing/reference.md +0 -192
  200. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-feedback/reference.md +0 -165
  201. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-report/reference.md +0 -78
  202. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/token-architecture/reference.md +0 -75
  203. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/ui-composition/reference.md +0 -117
  204. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/usability-testing/reference.md +0 -78
  205. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/verification-before-shipping/reference.md +0 -125
  206. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/voice-and-tone/reference.md +0 -79
  207. package/plugin/skills/frontend-ui-ux/references/designpowers/vendor/skills/writing-design-plans/reference.md +0 -119
  208. package/plugin/skills/frontend-ui-ux/references/evidence-review.md +0 -126
  209. package/plugin/skills/frontend-ui-ux/references/house-styles.md +0 -234
  210. package/plugin/skills/frontend-ui-ux/references/implementation-platforms.md +0 -109
  211. package/plugin/skills/frontend-ui-ux/references/inclusive-interface.md +0 -92
  212. package/plugin/skills/frontend-ui-ux/references/interaction-motion.md +0 -47
  213. package/plugin/skills/frontend-ui-ux/references/motion-guide.md +0 -130
  214. package/plugin/skills/frontend-ui-ux/references/operating-lanes.md +0 -92
  215. package/plugin/skills/frontend-ui-ux/references/perfection/README.md +0 -160
  216. package/plugin/skills/frontend-ui-ux/references/perfection/react-perf-tooling.md +0 -127
  217. package/plugin/skills/frontend-ui-ux/references/performance-delivery.md +0 -93
  218. package/plugin/skills/frontend-ui-ux/references/product-direction.md +0 -84
  219. package/plugin/skills/frontend-ui-ux/references/production-interview.md +0 -17
  220. package/plugin/skills/frontend-ui-ux/references/redesign-playbook.md +0 -97
  221. package/plugin/skills/frontend-ui-ux/references/slop-register.md +0 -150
  222. package/plugin/skills/frontend-ui-ux/references/system-foundations.md +0 -84
  223. package/plugin/skills/frontend-ui-ux/references/taste-direction.md +0 -86
  224. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/README.md +0 -659
  225. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/charts.csv +0 -26
  226. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/colors.csv +0 -162
  227. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/icons.csv +0 -106
  228. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/landing.csv +0 -35
  229. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/products.csv +0 -162
  230. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/react-performance.csv +0 -45
  231. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/astro.csv +0 -54
  232. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/flutter.csv +0 -53
  233. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/html-tailwind.csv +0 -56
  234. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/jetpack-compose.csv +0 -53
  235. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nextjs.csv +0 -53
  236. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxt-ui.csv +0 -51
  237. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxtjs.csv +0 -59
  238. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react-native.csv +0 -52
  239. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react.csv +0 -54
  240. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/shadcn.csv +0 -61
  241. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/svelte.csv +0 -54
  242. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/swiftui.csv +0 -51
  243. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/vue.csv +0 -50
  244. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/styles.csv +0 -85
  245. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/typography.csv +0 -74
  246. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/ui-reasoning.csv +0 -162
  247. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/ux-guidelines.csv +0 -100
  248. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/data/web-interface.csv +0 -31
  249. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/scripts/core.py +0 -262
  250. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/scripts/design_system.py +0 -1148
  251. package/plugin/skills/frontend-ui-ux/references/ui-ux-db/scripts/search.py +0 -114
  252. package/plugin/skills/frontend-ui-ux/references/visual-language.md +0 -84
  253. package/plugin/skills/frontend-ui-ux/references/visual-reconstruction.md +0 -51
  254. package/plugin/skills/frontend-ui-ux/schemas/design-contract-v1alpha1.schema.json +0 -306
  255. package/plugin/skills/frontend-ui-ux/schemas/design-contract-v1beta1.schema.json +0 -291
  256. package/plugin/skills/frontend-ui-ux/schemas/design-contract-v1beta2.schema.json +0 -311
  257. package/plugin/skills/frontend-ui-ux/scripts/chrome-driver.mjs +0 -202
  258. package/plugin/skills/frontend-ui-ux/scripts/design-contract-format.mjs +0 -286
  259. package/plugin/skills/frontend-ui-ux/scripts/design-contract-inventory-rules.mjs +0 -354
  260. package/plugin/skills/frontend-ui-ux/scripts/design-contract-rules.mjs +0 -361
  261. package/plugin/skills/frontend-ui-ux/scripts/design-contract-surface-rules.mjs +0 -313
  262. package/plugin/skills/frontend-ui-ux/scripts/design-data.mjs +0 -68
  263. package/plugin/skills/frontend-ui-ux/scripts/design-lock.mjs +0 -400
  264. package/plugin/skills/frontend-ui-ux/scripts/errors.mjs +0 -12
  265. package/plugin/skills/frontend-ui-ux/scripts/import-design-intelligence.mjs +0 -124
  266. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +0 -196
  267. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +0 -1555
  268. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +0 -153
  269. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-server.mjs +0 -57
  270. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-static.mjs +0 -133
  271. package/plugin/skills/frontend-ui-ux/scripts/interface-probe.mjs +0 -341
  272. package/plugin/skills/frontend-ui-ux/scripts/json-boundary.mjs +0 -63
  273. package/plugin/skills/frontend-ui-ux/scripts/pixel-art.mjs +0 -60
  274. package/plugin/skills/frontend-ui-ux/scripts/query-design-intelligence.mjs +0 -106
  275. package/plugin/skills/frontend-ui-ux/scripts/search.mjs +0 -43
  276. package/plugin/skills/frontend-ui-ux/scripts/source-replay.mjs +0 -153
  277. package/plugin/skills/frontend-ui-ux/scripts/validate-design-contract.mjs +0 -52
  278. package/plugin/skills/frontend-ui-ux/scripts/verify-corpus.mjs +0 -90
  279. package/plugin/skills/lit-diagram-drawer/NOTICE +0 -33
  280. package/plugin/skills/lit-diagram-drawer/assets/examples/type-architecture-dark.html +0 -1
  281. package/plugin/skills/lit-diagram-drawer/assets/examples/type-architecture-full.html +0 -1
  282. package/plugin/skills/lit-diagram-drawer/assets/examples/type-architecture-light.html +0 -1
  283. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bar-dark.html +0 -1
  284. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bar-full.html +0 -1
  285. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bar-light.html +0 -1
  286. package/plugin/skills/lit-diagram-drawer/assets/examples/type-beeswarm-dark.html +0 -1
  287. package/plugin/skills/lit-diagram-drawer/assets/examples/type-beeswarm-full.html +0 -1
  288. package/plugin/skills/lit-diagram-drawer/assets/examples/type-beeswarm-light.html +0 -1
  289. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bubble-dark.html +0 -1
  290. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bubble-full.html +0 -1
  291. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bubble-light.html +0 -1
  292. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bump-dark.html +0 -1
  293. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bump-full.html +0 -1
  294. package/plugin/skills/lit-diagram-drawer/assets/examples/type-bump-light.html +0 -1
  295. package/plugin/skills/lit-diagram-drawer/assets/examples/type-data-flow-dark.html +0 -1
  296. package/plugin/skills/lit-diagram-drawer/assets/examples/type-data-flow-full.html +0 -1
  297. package/plugin/skills/lit-diagram-drawer/assets/examples/type-data-flow-light.html +0 -1
  298. package/plugin/skills/lit-diagram-drawer/assets/examples/type-datalake-dark.html +0 -1
  299. package/plugin/skills/lit-diagram-drawer/assets/examples/type-datalake-full.html +0 -1
  300. package/plugin/skills/lit-diagram-drawer/assets/examples/type-datalake-light.html +0 -1
  301. package/plugin/skills/lit-diagram-drawer/assets/examples/type-db-schema-dark.html +0 -1
  302. package/plugin/skills/lit-diagram-drawer/assets/examples/type-db-schema-full.html +0 -1
  303. package/plugin/skills/lit-diagram-drawer/assets/examples/type-db-schema-light.html +0 -1
  304. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dependency-dark.html +0 -1
  305. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dependency-full.html +0 -1
  306. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dependency-light.html +0 -1
  307. package/plugin/skills/lit-diagram-drawer/assets/examples/type-deployment-dark.html +0 -1
  308. package/plugin/skills/lit-diagram-drawer/assets/examples/type-deployment-full.html +0 -1
  309. package/plugin/skills/lit-diagram-drawer/assets/examples/type-deployment-light.html +0 -1
  310. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-integration-dark.html +0 -1
  311. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-integration-full.html +0 -1
  312. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-integration-light.html +0 -1
  313. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-security-matrix-dark.html +0 -1
  314. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-security-matrix-full.html +0 -1
  315. package/plugin/skills/lit-diagram-drawer/assets/examples/type-dp-security-matrix-light.html +0 -1
  316. package/plugin/skills/lit-diagram-drawer/assets/examples/type-er-dark.html +0 -1
  317. package/plugin/skills/lit-diagram-drawer/assets/examples/type-er-full.html +0 -1
  318. package/plugin/skills/lit-diagram-drawer/assets/examples/type-er-light.html +0 -1
  319. package/plugin/skills/lit-diagram-drawer/assets/examples/type-fishbone-dark.html +0 -1
  320. package/plugin/skills/lit-diagram-drawer/assets/examples/type-fishbone-full.html +0 -1
  321. package/plugin/skills/lit-diagram-drawer/assets/examples/type-fishbone-light.html +0 -1
  322. package/plugin/skills/lit-diagram-drawer/assets/examples/type-flowchart-dark.html +0 -1
  323. package/plugin/skills/lit-diagram-drawer/assets/examples/type-flowchart-full.html +0 -1
  324. package/plugin/skills/lit-diagram-drawer/assets/examples/type-flowchart-light.html +0 -1
  325. package/plugin/skills/lit-diagram-drawer/assets/examples/type-gantt-dark.html +0 -1
  326. package/plugin/skills/lit-diagram-drawer/assets/examples/type-gantt-full.html +0 -1
  327. package/plugin/skills/lit-diagram-drawer/assets/examples/type-gantt-light.html +0 -1
  328. package/plugin/skills/lit-diagram-drawer/assets/examples/type-heatmap-dark.html +0 -1
  329. package/plugin/skills/lit-diagram-drawer/assets/examples/type-heatmap-full.html +0 -1
  330. package/plugin/skills/lit-diagram-drawer/assets/examples/type-heatmap-light.html +0 -1
  331. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-dark.html +0 -1
  332. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-full.html +0 -1
  333. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-light.html +0 -1
  334. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-vertical-dark.html +0 -1
  335. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-vertical-full.html +0 -1
  336. package/plugin/skills/lit-diagram-drawer/assets/examples/type-high-level-vertical-light.html +0 -1
  337. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-drawio-dark.html +0 -1
  338. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-drawio-full.html +0 -1
  339. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-drawio-light.html +0 -1
  340. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-excalidraw-dark.html +0 -1
  341. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-excalidraw-full.html +0 -1
  342. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-excalidraw-light.html +0 -1
  343. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-mermaid-dark.html +0 -1
  344. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-mermaid-full.html +0 -1
  345. package/plugin/skills/lit-diagram-drawer/assets/examples/type-import-mermaid-light.html +0 -1
  346. package/plugin/skills/lit-diagram-drawer/assets/examples/type-it-state-dark.html +0 -1
  347. package/plugin/skills/lit-diagram-drawer/assets/examples/type-it-state-full.html +0 -1
  348. package/plugin/skills/lit-diagram-drawer/assets/examples/type-it-state-light.html +0 -1
  349. package/plugin/skills/lit-diagram-drawer/assets/examples/type-journey-dark.html +0 -1
  350. package/plugin/skills/lit-diagram-drawer/assets/examples/type-journey-full.html +0 -1
  351. package/plugin/skills/lit-diagram-drawer/assets/examples/type-journey-light.html +0 -1
  352. package/plugin/skills/lit-diagram-drawer/assets/examples/type-kanban-dark.html +0 -1
  353. package/plugin/skills/lit-diagram-drawer/assets/examples/type-kanban-full.html +0 -1
  354. package/plugin/skills/lit-diagram-drawer/assets/examples/type-kanban-light.html +0 -1
  355. package/plugin/skills/lit-diagram-drawer/assets/examples/type-layers-dark.html +0 -1
  356. package/plugin/skills/lit-diagram-drawer/assets/examples/type-layers-full.html +0 -1
  357. package/plugin/skills/lit-diagram-drawer/assets/examples/type-layers-light.html +0 -1
  358. package/plugin/skills/lit-diagram-drawer/assets/examples/type-line-dark.html +0 -1
  359. package/plugin/skills/lit-diagram-drawer/assets/examples/type-line-full.html +0 -1
  360. package/plugin/skills/lit-diagram-drawer/assets/examples/type-line-light.html +0 -1
  361. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-dark.html +0 -1
  362. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-full.html +0 -1
  363. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-light.html +0 -1
  364. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-terminal-dark.html +0 -1
  365. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-terminal-full.html +0 -1
  366. package/plugin/skills/lit-diagram-drawer/assets/examples/type-loop-terminal-light.html +0 -1
  367. package/plugin/skills/lit-diagram-drawer/assets/examples/type-marimekko-dark.html +0 -1
  368. package/plugin/skills/lit-diagram-drawer/assets/examples/type-marimekko-full.html +0 -1
  369. package/plugin/skills/lit-diagram-drawer/assets/examples/type-marimekko-light.html +0 -1
  370. package/plugin/skills/lit-diagram-drawer/assets/examples/type-medallion-dark.html +0 -1
  371. package/plugin/skills/lit-diagram-drawer/assets/examples/type-medallion-full.html +0 -1
  372. package/plugin/skills/lit-diagram-drawer/assets/examples/type-medallion-light.html +0 -1
  373. package/plugin/skills/lit-diagram-drawer/assets/examples/type-nested-dark.html +0 -1
  374. package/plugin/skills/lit-diagram-drawer/assets/examples/type-nested-full.html +0 -1
  375. package/plugin/skills/lit-diagram-drawer/assets/examples/type-nested-light.html +0 -1
  376. package/plugin/skills/lit-diagram-drawer/assets/examples/type-org-chart-dark.html +0 -1
  377. package/plugin/skills/lit-diagram-drawer/assets/examples/type-org-chart-full.html +0 -1
  378. package/plugin/skills/lit-diagram-drawer/assets/examples/type-org-chart-light.html +0 -1
  379. package/plugin/skills/lit-diagram-drawer/assets/examples/type-paved-road-animated-dark.html +0 -1
  380. package/plugin/skills/lit-diagram-drawer/assets/examples/type-paved-road-animated-full.html +0 -1
  381. package/plugin/skills/lit-diagram-drawer/assets/examples/type-paved-road-animated-light.html +0 -1
  382. package/plugin/skills/lit-diagram-drawer/assets/examples/type-polar-dark.html +0 -1
  383. package/plugin/skills/lit-diagram-drawer/assets/examples/type-polar-full.html +0 -1
  384. package/plugin/skills/lit-diagram-drawer/assets/examples/type-polar-light.html +0 -1
  385. package/plugin/skills/lit-diagram-drawer/assets/examples/type-policy-trace-animated-dark.html +0 -1
  386. package/plugin/skills/lit-diagram-drawer/assets/examples/type-policy-trace-animated-full.html +0 -1
  387. package/plugin/skills/lit-diagram-drawer/assets/examples/type-policy-trace-animated-light.html +0 -1
  388. package/plugin/skills/lit-diagram-drawer/assets/examples/type-process-dark.html +0 -1
  389. package/plugin/skills/lit-diagram-drawer/assets/examples/type-process-full.html +0 -1
  390. package/plugin/skills/lit-diagram-drawer/assets/examples/type-process-light.html +0 -1
  391. package/plugin/skills/lit-diagram-drawer/assets/examples/type-pyramid-dark.html +0 -1
  392. package/plugin/skills/lit-diagram-drawer/assets/examples/type-pyramid-full.html +0 -1
  393. package/plugin/skills/lit-diagram-drawer/assets/examples/type-pyramid-light.html +0 -1
  394. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-consultant-dark.html +0 -1
  395. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-consultant-full.html +0 -1
  396. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-consultant-light.html +0 -1
  397. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-dark.html +0 -1
  398. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-full.html +0 -1
  399. package/plugin/skills/lit-diagram-drawer/assets/examples/type-quadrant-light.html +0 -1
  400. package/plugin/skills/lit-diagram-drawer/assets/examples/type-queue-animated-dark.html +0 -1
  401. package/plugin/skills/lit-diagram-drawer/assets/examples/type-queue-animated-full.html +0 -1
  402. package/plugin/skills/lit-diagram-drawer/assets/examples/type-queue-animated-light.html +0 -1
  403. package/plugin/skills/lit-diagram-drawer/assets/examples/type-radar-dark.html +0 -1
  404. package/plugin/skills/lit-diagram-drawer/assets/examples/type-radar-full.html +0 -1
  405. package/plugin/skills/lit-diagram-drawer/assets/examples/type-radar-light.html +0 -1
  406. package/plugin/skills/lit-diagram-drawer/assets/examples/type-ridgeline-dark.html +0 -1
  407. package/plugin/skills/lit-diagram-drawer/assets/examples/type-ridgeline-full.html +0 -1
  408. package/plugin/skills/lit-diagram-drawer/assets/examples/type-ridgeline-light.html +0 -1
  409. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sankey-dark.html +0 -1
  410. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sankey-full.html +0 -1
  411. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sankey-light.html +0 -1
  412. package/plugin/skills/lit-diagram-drawer/assets/examples/type-scatter-dark.html +0 -1
  413. package/plugin/skills/lit-diagram-drawer/assets/examples/type-scatter-full.html +0 -1
  414. package/plugin/skills/lit-diagram-drawer/assets/examples/type-scatter-light.html +0 -1
  415. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-dark.html +0 -1
  416. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-full.html +0 -1
  417. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-light.html +0 -1
  418. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-oauth-dark.html +0 -1
  419. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-oauth-full.html +0 -1
  420. package/plugin/skills/lit-diagram-drawer/assets/examples/type-sequence-oauth-light.html +0 -1
  421. package/plugin/skills/lit-diagram-drawer/assets/examples/type-slopegraph-dark.html +0 -1
  422. package/plugin/skills/lit-diagram-drawer/assets/examples/type-slopegraph-full.html +0 -1
  423. package/plugin/skills/lit-diagram-drawer/assets/examples/type-slopegraph-light.html +0 -1
  424. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-dark.html +0 -1
  425. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-full.html +0 -1
  426. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-lifecycle-dark.html +0 -1
  427. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-lifecycle-full.html +0 -1
  428. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-lifecycle-light.html +0 -1
  429. package/plugin/skills/lit-diagram-drawer/assets/examples/type-state-light.html +0 -1
  430. package/plugin/skills/lit-diagram-drawer/assets/examples/type-story-map-dark.html +0 -1
  431. package/plugin/skills/lit-diagram-drawer/assets/examples/type-story-map-full.html +0 -1
  432. package/plugin/skills/lit-diagram-drawer/assets/examples/type-story-map-light.html +0 -1
  433. package/plugin/skills/lit-diagram-drawer/assets/examples/type-streamgraph-dark.html +0 -1
  434. package/plugin/skills/lit-diagram-drawer/assets/examples/type-streamgraph-full.html +0 -1
  435. package/plugin/skills/lit-diagram-drawer/assets/examples/type-streamgraph-light.html +0 -1
  436. package/plugin/skills/lit-diagram-drawer/assets/examples/type-swimlane-dark.html +0 -1
  437. package/plugin/skills/lit-diagram-drawer/assets/examples/type-swimlane-full.html +0 -1
  438. package/plugin/skills/lit-diagram-drawer/assets/examples/type-swimlane-light.html +0 -1
  439. package/plugin/skills/lit-diagram-drawer/assets/examples/type-timeline-dark.html +0 -1
  440. package/plugin/skills/lit-diagram-drawer/assets/examples/type-timeline-full.html +0 -1
  441. package/plugin/skills/lit-diagram-drawer/assets/examples/type-timeline-light.html +0 -1
  442. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-block-decomposition-dark.html +0 -1
  443. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-block-decomposition-full.html +0 -1
  444. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-block-decomposition-light.html +0 -1
  445. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-dark.html +0 -1
  446. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-full.html +0 -1
  447. package/plugin/skills/lit-diagram-drawer/assets/examples/type-tree-light.html +0 -1
  448. package/plugin/skills/lit-diagram-drawer/assets/examples/type-treemap-dark.html +0 -1
  449. package/plugin/skills/lit-diagram-drawer/assets/examples/type-treemap-full.html +0 -1
  450. package/plugin/skills/lit-diagram-drawer/assets/examples/type-treemap-light.html +0 -1
  451. package/plugin/skills/lit-diagram-drawer/assets/examples/type-uml-class-dark.html +0 -1
  452. package/plugin/skills/lit-diagram-drawer/assets/examples/type-uml-class-full.html +0 -1
  453. package/plugin/skills/lit-diagram-drawer/assets/examples/type-uml-class-light.html +0 -1
  454. package/plugin/skills/lit-diagram-drawer/assets/examples/type-venn-dark.html +0 -1
  455. package/plugin/skills/lit-diagram-drawer/assets/examples/type-venn-full.html +0 -1
  456. package/plugin/skills/lit-diagram-drawer/assets/examples/type-venn-light.html +0 -1
  457. package/plugin/skills/lit-diagram-drawer/assets/examples/type-wardley-dark.html +0 -1
  458. package/plugin/skills/lit-diagram-drawer/assets/examples/type-wardley-full.html +0 -1
  459. package/plugin/skills/lit-diagram-drawer/assets/examples/type-wardley-light.html +0 -1
  460. package/plugin/skills/lit-diagram-drawer/assets/examples/type-waterfall-dark.html +0 -1
  461. package/plugin/skills/lit-diagram-drawer/assets/examples/type-waterfall-full.html +0 -1
  462. package/plugin/skills/lit-diagram-drawer/assets/examples/type-waterfall-light.html +0 -1
  463. package/plugin/skills/lit-diagram-drawer/assets/fonts/OFL.txt +0 -94
  464. package/plugin/skills/lit-diagram-drawer/assets/fonts/PretendardVariable.woff2 +0 -0
  465. package/plugin/skills/lit-diagram-drawer/assets/fonts/provenance.json +0 -22
  466. package/plugin/skills/lit-diagram-drawer/assets/icons.html +0 -231
  467. package/plugin/skills/lit-diagram-drawer/assets/index.html +0 -1
  468. package/plugin/skills/lit-diagram-drawer/assets/licenses/devicon-MIT.txt +0 -20
  469. package/plugin/skills/lit-diagram-drawer/assets/licenses/diagram-design-MIT.txt +0 -21
  470. package/plugin/skills/lit-diagram-drawer/assets/licenses/log-z-MIT.txt +0 -21
  471. package/plugin/skills/lit-diagram-drawer/assets/licenses/simple-icons-CC0.md +0 -30
  472. package/plugin/skills/lit-diagram-drawer/assets/licenses/tabler-MIT.txt +0 -21
  473. package/plugin/skills/lit-diagram-drawer/examples/01-service-architecture/after.html +0 -1
  474. package/plugin/skills/lit-diagram-drawer/examples/01-service-architecture/brief.md +0 -33
  475. package/plugin/skills/lit-diagram-drawer/examples/01-service-architecture/constructed-naive-foil.html +0 -1
  476. package/plugin/skills/lit-diagram-drawer/examples/02-release-decision/after.html +0 -1
  477. package/plugin/skills/lit-diagram-drawer/examples/02-release-decision/brief.md +0 -18
  478. package/plugin/skills/lit-diagram-drawer/examples/02-release-decision/constructed-naive-foil.html +0 -1
  479. package/plugin/skills/lit-diagram-drawer/examples/03-data-retention/after.html +0 -1
  480. package/plugin/skills/lit-diagram-drawer/examples/03-data-retention/brief.md +0 -19
  481. package/plugin/skills/lit-diagram-drawer/examples/03-data-retention/constructed-naive-foil.html +0 -1
  482. package/plugin/skills/lit-diagram-drawer/examples/04-oauth-sequence/after.html +0 -1
  483. package/plugin/skills/lit-diagram-drawer/examples/04-oauth-sequence/brief.md +0 -17
  484. package/plugin/skills/lit-diagram-drawer/examples/04-oauth-sequence/constructed-naive-foil.html +0 -1
  485. package/plugin/skills/lit-diagram-drawer/examples/05-review-lanes/after.html +0 -1
  486. package/plugin/skills/lit-diagram-drawer/examples/05-review-lanes/brief.md +0 -17
  487. package/plugin/skills/lit-diagram-drawer/examples/05-review-lanes/constructed-naive-foil.html +0 -1
  488. package/plugin/skills/lit-diagram-drawer/examples/06-rollout-gates/after.html +0 -1
  489. package/plugin/skills/lit-diagram-drawer/examples/06-rollout-gates/brief.md +0 -17
  490. package/plugin/skills/lit-diagram-drawer/examples/06-rollout-gates/constructed-naive-foil.html +0 -1
  491. package/plugin/skills/lit-diagram-drawer/examples/07-deployment-boundary/after.html +0 -1
  492. package/plugin/skills/lit-diagram-drawer/examples/07-deployment-boundary/brief.md +0 -19
  493. package/plugin/skills/lit-diagram-drawer/examples/07-deployment-boundary/constructed-naive-foil.html +0 -1
  494. package/plugin/skills/lit-diagram-drawer/examples/08-policy-traces/after.html +0 -1
  495. package/plugin/skills/lit-diagram-drawer/examples/08-policy-traces/brief.md +0 -20
  496. package/plugin/skills/lit-diagram-drawer/examples/08-policy-traces/constructed-naive-foil.html +0 -1
  497. package/plugin/skills/lit-diagram-drawer/references/accessibility.md +0 -37
  498. package/plugin/skills/lit-diagram-drawer/references/export.md +0 -29
  499. package/plugin/skills/lit-diagram-drawer/references/import-drawio.md +0 -21
  500. package/plugin/skills/lit-diagram-drawer/references/import-excalidraw.md +0 -14
  501. package/plugin/skills/lit-diagram-drawer/references/import-mermaid.md +0 -18
  502. package/plugin/skills/lit-diagram-drawer/references/import-schema.md +0 -28
  503. package/plugin/skills/lit-diagram-drawer/references/korean-typography.md +0 -34
  504. package/plugin/skills/lit-diagram-drawer/references/motion.md +0 -29
  505. package/plugin/skills/lit-diagram-drawer/references/office-pptx-docx.md +0 -42
  506. package/plugin/skills/lit-diagram-drawer/references/output-spec.md +0 -48
  507. package/plugin/skills/lit-diagram-drawer/references/primitive-annotation.md +0 -12
  508. package/plugin/skills/lit-diagram-drawer/references/primitive-icons.md +0 -21
  509. package/plugin/skills/lit-diagram-drawer/references/primitive-sketchy.md +0 -11
  510. package/plugin/skills/lit-diagram-drawer/references/primitive-terminal.md +0 -11
  511. package/plugin/skills/lit-diagram-drawer/references/profiles.md +0 -24
  512. package/plugin/skills/lit-diagram-drawer/references/semantic-patterns.md +0 -27
  513. package/plugin/skills/lit-diagram-drawer/references/style-guide.md +0 -67
  514. package/plugin/skills/lit-diagram-drawer/references/type-architecture.md +0 -51
  515. package/plugin/skills/lit-diagram-drawer/references/type-bar.md +0 -51
  516. package/plugin/skills/lit-diagram-drawer/references/type-beeswarm.md +0 -49
  517. package/plugin/skills/lit-diagram-drawer/references/type-bubble.md +0 -49
  518. package/plugin/skills/lit-diagram-drawer/references/type-bump.md +0 -49
  519. package/plugin/skills/lit-diagram-drawer/references/type-catalog.json +0 -1433
  520. package/plugin/skills/lit-diagram-drawer/references/type-data-flow.md +0 -51
  521. package/plugin/skills/lit-diagram-drawer/references/type-datalake.md +0 -49
  522. package/plugin/skills/lit-diagram-drawer/references/type-db-schema.md +0 -49
  523. package/plugin/skills/lit-diagram-drawer/references/type-dependency.md +0 -49
  524. package/plugin/skills/lit-diagram-drawer/references/type-deployment.md +0 -49
  525. package/plugin/skills/lit-diagram-drawer/references/type-dp-integration.md +0 -49
  526. package/plugin/skills/lit-diagram-drawer/references/type-dp-security-matrix.md +0 -49
  527. package/plugin/skills/lit-diagram-drawer/references/type-er.md +0 -49
  528. package/plugin/skills/lit-diagram-drawer/references/type-fishbone.md +0 -49
  529. package/plugin/skills/lit-diagram-drawer/references/type-flowchart.md +0 -49
  530. package/plugin/skills/lit-diagram-drawer/references/type-gantt.md +0 -49
  531. package/plugin/skills/lit-diagram-drawer/references/type-heatmap.md +0 -53
  532. package/plugin/skills/lit-diagram-drawer/references/type-high-level-vertical.md +0 -53
  533. package/plugin/skills/lit-diagram-drawer/references/type-high-level.md +0 -53
  534. package/plugin/skills/lit-diagram-drawer/references/type-import-drawio.md +0 -53
  535. package/plugin/skills/lit-diagram-drawer/references/type-import-excalidraw.md +0 -53
  536. package/plugin/skills/lit-diagram-drawer/references/type-import-mermaid.md +0 -53
  537. package/plugin/skills/lit-diagram-drawer/references/type-it-state.md +0 -54
  538. package/plugin/skills/lit-diagram-drawer/references/type-journey.md +0 -54
  539. package/plugin/skills/lit-diagram-drawer/references/type-kanban.md +0 -54
  540. package/plugin/skills/lit-diagram-drawer/references/type-layers.md +0 -54
  541. package/plugin/skills/lit-diagram-drawer/references/type-line.md +0 -54
  542. package/plugin/skills/lit-diagram-drawer/references/type-loop-terminal.md +0 -53
  543. package/plugin/skills/lit-diagram-drawer/references/type-loop.md +0 -54
  544. package/plugin/skills/lit-diagram-drawer/references/type-marimekko.md +0 -54
  545. package/plugin/skills/lit-diagram-drawer/references/type-medallion.md +0 -54
  546. package/plugin/skills/lit-diagram-drawer/references/type-nested.md +0 -59
  547. package/plugin/skills/lit-diagram-drawer/references/type-org-chart.md +0 -58
  548. package/plugin/skills/lit-diagram-drawer/references/type-paved-road-animated.md +0 -72
  549. package/plugin/skills/lit-diagram-drawer/references/type-polar.md +0 -67
  550. package/plugin/skills/lit-diagram-drawer/references/type-policy-trace-animated.md +0 -69
  551. package/plugin/skills/lit-diagram-drawer/references/type-process.md +0 -58
  552. package/plugin/skills/lit-diagram-drawer/references/type-pyramid.md +0 -59
  553. package/plugin/skills/lit-diagram-drawer/references/type-quadrant-consultant.md +0 -60
  554. package/plugin/skills/lit-diagram-drawer/references/type-quadrant.md +0 -57
  555. package/plugin/skills/lit-diagram-drawer/references/type-queue-animated.md +0 -63
  556. package/plugin/skills/lit-diagram-drawer/references/type-radar.md +0 -57
  557. package/plugin/skills/lit-diagram-drawer/references/type-ridgeline.md +0 -63
  558. package/plugin/skills/lit-diagram-drawer/references/type-sankey.md +0 -68
  559. package/plugin/skills/lit-diagram-drawer/references/type-scatter.md +0 -60
  560. package/plugin/skills/lit-diagram-drawer/references/type-sequence-oauth.md +0 -66
  561. package/plugin/skills/lit-diagram-drawer/references/type-sequence.md +0 -63
  562. package/plugin/skills/lit-diagram-drawer/references/type-slopegraph.md +0 -65
  563. package/plugin/skills/lit-diagram-drawer/references/type-state-lifecycle.md +0 -53
  564. package/plugin/skills/lit-diagram-drawer/references/type-state.md +0 -59
  565. package/plugin/skills/lit-diagram-drawer/references/type-story-map.md +0 -52
  566. package/plugin/skills/lit-diagram-drawer/references/type-streamgraph.md +0 -53
  567. package/plugin/skills/lit-diagram-drawer/references/type-swimlane.md +0 -52
  568. package/plugin/skills/lit-diagram-drawer/references/type-timeline.md +0 -52
  569. package/plugin/skills/lit-diagram-drawer/references/type-tree-block-decomposition.md +0 -57
  570. package/plugin/skills/lit-diagram-drawer/references/type-tree.md +0 -54
  571. package/plugin/skills/lit-diagram-drawer/references/type-treemap.md +0 -54
  572. package/plugin/skills/lit-diagram-drawer/references/type-uml-class.md +0 -52
  573. package/plugin/skills/lit-diagram-drawer/references/type-venn.md +0 -51
  574. package/plugin/skills/lit-diagram-drawer/references/type-wardley.md +0 -52
  575. package/plugin/skills/lit-diagram-drawer/references/type-waterfall.md +0 -54
  576. package/plugin/skills/lit-diagram-drawer/references/verifier-guide.md +0 -59
  577. package/plugin/skills/lit-diagram-drawer/scripts/block-registry.mjs +0 -43
  578. package/plugin/skills/lit-diagram-drawer/scripts/brief-contract.mjs +0 -94
  579. package/plugin/skills/lit-diagram-drawer/scripts/check-visible-text.mjs +0 -15
  580. package/plugin/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +0 -13
  581. package/plugin/skills/lit-diagram-drawer/scripts/diagram-metrics.mjs +0 -219
  582. package/plugin/skills/lit-diagram-drawer/scripts/diagram-runtime-lock/package.json +0 -9
  583. package/plugin/skills/lit-diagram-drawer/scripts/diagram-runtime.mjs +0 -275
  584. package/plugin/skills/lit-diagram-drawer/scripts/doctor.mjs +0 -25
  585. package/plugin/skills/lit-diagram-drawer/scripts/drawio-model.mjs +0 -162
  586. package/plugin/skills/lit-diagram-drawer/scripts/drawio-source.mjs +0 -147
  587. package/plugin/skills/lit-diagram-drawer/scripts/drawio-xml.mjs +0 -148
  588. package/plugin/skills/lit-diagram-drawer/scripts/export.mjs +0 -119
  589. package/plugin/skills/lit-diagram-drawer/scripts/import-common.mjs +0 -85
  590. package/plugin/skills/lit-diagram-drawer/scripts/import-drawio.mjs +0 -48
  591. package/plugin/skills/lit-diagram-drawer/scripts/import-excalidraw.mjs +0 -234
  592. package/plugin/skills/lit-diagram-drawer/scripts/import-mermaid.mjs +0 -104
  593. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-common.mjs +0 -115
  594. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-er.mjs +0 -70
  595. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-flowchart.mjs +0 -178
  596. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-sequence.mjs +0 -137
  597. package/plugin/skills/lit-diagram-drawer/scripts/mermaid-state.mjs +0 -80
  598. package/plugin/skills/lit-diagram-drawer/scripts/office-safety.mjs +0 -54
  599. package/plugin/skills/lit-diagram-drawer/scripts/runtime-probes.mjs +0 -11
  600. package/plugin/skills/lit-diagram-drawer/scripts/verify-all.mjs +0 -85
  601. package/plugin/skills/lit-diagram-drawer/scripts/verify-brief.mjs +0 -16
  602. package/plugin/skills/lit-diagram-drawer/scripts/verify-diagram.mjs +0 -27
  603. package/plugin/skills/lit-diagram-drawer/scripts/verify-motion.mjs +0 -12
  604. package/plugin/skills/lit-diagram-drawer/scripts/verify-type.mjs +0 -48
  605. package/plugin/skills/lit-diagram-drawer/scripts/visual-quality-geometry.mjs +0 -226
  606. package/plugin/skills/lit-diagram-drawer/scripts/visual-quality.mjs +0 -146
  607. package/plugin/skills/lit-docx/NOTICE +0 -33
  608. package/plugin/skills/lit-docx/references/components.md +0 -207
  609. package/plugin/skills/lit-docx/references/direction-step.md +0 -277
  610. package/plugin/skills/lit-docx/references/examples/01-report-ko.md +0 -166
  611. package/plugin/skills/lit-docx/references/examples/02-brief-ko.md +0 -105
  612. package/plugin/skills/lit-docx/references/examples/03-manual-ko.md +0 -164
  613. package/plugin/skills/lit-docx/references/examples/04-proposal-ko.md +0 -138
  614. package/plugin/skills/lit-docx/references/examples/05-memo-en.md +0 -55
  615. package/plugin/skills/lit-docx/references/examples/06-journal-en.md +0 -130
  616. package/plugin/skills/lit-docx/references/examples/07-report-en.md +0 -123
  617. package/plugin/skills/lit-docx/references/examples/08-proposal-en.md +0 -123
  618. package/plugin/skills/lit-docx/references/examples/09-memo-ko.md +0 -45
  619. package/plugin/skills/lit-docx/references/frontmatter_schema.md +0 -42
  620. package/plugin/skills/lit-docx/references/journal_style_spec.md +0 -17
  621. package/plugin/skills/lit-docx/references/markdown_quality_checklist.md +0 -37
  622. package/plugin/skills/lit-docx/references/page-composition.md +0 -221
  623. package/plugin/skills/lit-docx/references/slop_phrase_list.yaml +0 -58
  624. package/plugin/skills/lit-docx/references/slop_rules.md +0 -35
  625. package/plugin/skills/lit-docx/references/tonalities/brief.md +0 -143
  626. package/plugin/skills/lit-docx/references/tonalities/journal.md +0 -142
  627. package/plugin/skills/lit-docx/references/tonalities/manual.md +0 -148
  628. package/plugin/skills/lit-docx/references/tonalities/memo.md +0 -137
  629. package/plugin/skills/lit-docx/references/tonalities/proposal.md +0 -140
  630. package/plugin/skills/lit-docx/references/tonalities/report.md +0 -156
  631. package/plugin/skills/lit-docx/scripts/clean_markdown.py +0 -95
  632. package/plugin/skills/lit-docx/scripts/convert_md_to_docx.py +0 -1395
  633. package/plugin/skills/lit-docx/scripts/convert_md_to_pdf.py +0 -302
  634. package/plugin/skills/lit-docx/scripts/convert_pdf.py +0 -139
  635. package/plugin/skills/lit-docx/scripts/docx_design.py +0 -2449
  636. package/plugin/skills/lit-docx/scripts/docx_layout.py +0 -959
  637. package/plugin/skills/lit-docx/scripts/edit_docx.py +0 -306
  638. package/plugin/skills/lit-docx/scripts/embed_images.py +0 -78
  639. package/plugin/skills/lit-docx/scripts/generate_docx_templates.py +0 -500
  640. package/plugin/skills/lit-docx/scripts/qa_docx.py +0 -234
  641. package/plugin/skills/lit-docx/scripts/slop_lint.py +0 -573
  642. package/plugin/skills/lit-docx/scripts/visual_audit.py +0 -48
  643. package/plugin/skills/lit-docx/templates/docx/acs.docx +0 -0
  644. package/plugin/skills/lit-docx/templates/docx/elsevier.docx +0 -0
  645. package/plugin/skills/lit-docx/templates/docx/ieee.docx +0 -0
  646. package/plugin/skills/lit-docx/templates/docx/korean-generic.docx +0 -0
  647. package/plugin/skills/lit-docx/templates/docx/nature.docx +0 -0
  648. package/plugin/skills/lit-docx/templates/latex/acs/README.md +0 -5
  649. package/plugin/skills/lit-docx/templates/latex/acs/template.tex +0 -39
  650. package/plugin/skills/lit-docx/templates/latex/elsevier/README.md +0 -5
  651. package/plugin/skills/lit-docx/templates/latex/elsevier/template.tex +0 -40
  652. package/plugin/skills/lit-docx/templates/latex/ieee/README.md +0 -5
  653. package/plugin/skills/lit-docx/templates/latex/ieee/template.tex +0 -39
  654. package/plugin/skills/lit-docx/templates/latex/korean-generic/README.md +0 -5
  655. package/plugin/skills/lit-docx/templates/latex/korean-generic/template.tex +0 -39
  656. package/plugin/skills/lit-docx/templates/latex/nature/README.md +0 -5
  657. package/plugin/skills/lit-docx/templates/latex/nature/template.tex +0 -39
  658. package/plugin/skills/lit-docx/templates/registry.yaml +0 -1366
  659. package/plugin/skills/lit-docx/templates/tonalities/brief.yaml +0 -28
  660. package/plugin/skills/lit-docx/templates/tonalities/journal.yaml +0 -25
  661. package/plugin/skills/lit-docx/templates/tonalities/manual.yaml +0 -26
  662. package/plugin/skills/lit-docx/templates/tonalities/memo.yaml +0 -26
  663. package/plugin/skills/lit-docx/templates/tonalities/proposal.yaml +0 -26
  664. package/plugin/skills/lit-docx/templates/tonalities/report.yaml +0 -26
  665. package/plugin/skills/lit-pptx/NOTICE +0 -38
  666. package/plugin/skills/lit-pptx/assets/azure/circle-lg.png +0 -0
  667. package/plugin/skills/lit-pptx/assets/azure/circle-md.png +0 -0
  668. package/plugin/skills/lit-pptx/assets/azure/circle-sm.png +0 -0
  669. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Black.otf +0 -0
  670. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Bold.otf +0 -0
  671. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Light.otf +0 -0
  672. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Medium.otf +0 -0
  673. package/plugin/skills/lit-pptx/fonts/a2z/A2Z-Regular.otf +0 -0
  674. package/plugin/skills/lit-pptx/fonts/a2z/OFL.txt +0 -94
  675. package/plugin/skills/lit-pptx/fonts/a2z/SOURCE.md +0 -29
  676. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
  677. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
  678. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +0 -93
  679. package/plugin/skills/lit-pptx/fonts/pretendard/OFL.txt +0 -94
  680. package/plugin/skills/lit-pptx/fonts/pretendard/Pretendard-Bold.otf +0 -0
  681. package/plugin/skills/lit-pptx/fonts/pretendard/Pretendard-Regular.otf +0 -0
  682. package/plugin/skills/lit-pptx/fonts/provenance.json +0 -109
  683. package/plugin/skills/lit-pptx/references/agents/analyst.md +0 -49
  684. package/plugin/skills/lit-pptx/references/agents/antithesis.md +0 -59
  685. package/plugin/skills/lit-pptx/references/agents/architect.md +0 -44
  686. package/plugin/skills/lit-pptx/references/agents/critic.md +0 -42
  687. package/plugin/skills/lit-pptx/references/agents/synthesizer.md +0 -47
  688. package/plugin/skills/lit-pptx/references/agents/thesis.md +0 -33
  689. package/plugin/skills/lit-pptx/references/anti-slop-checklist.md +0 -110
  690. package/plugin/skills/lit-pptx/references/authoring-guide.md +0 -250
  691. package/plugin/skills/lit-pptx/references/consensus-protocol.md +0 -125
  692. package/plugin/skills/lit-pptx/references/data-display-cookbook.md +0 -52
  693. package/plugin/skills/lit-pptx/references/density-and-fill.md +0 -164
  694. package/plugin/skills/lit-pptx/references/design-system-azure.md +0 -61
  695. package/plugin/skills/lit-pptx/references/direction-step.md +0 -203
  696. package/plugin/skills/lit-pptx/references/examples/01-pitch-signal-ko.md +0 -210
  697. package/plugin/skills/lit-pptx/references/examples/02-pitch-studio-ko.md +0 -147
  698. package/plugin/skills/lit-pptx/references/examples/03-business-review-ledger-ko.md +0 -199
  699. package/plugin/skills/lit-pptx/references/examples/04-business-review-night-en.md +0 -203
  700. package/plugin/skills/lit-pptx/references/examples/05-research-talk-paper-en.md +0 -178
  701. package/plugin/skills/lit-pptx/references/examples/06-lecture-chalk-ko.md +0 -199
  702. package/plugin/skills/lit-pptx/references/examples/07-data-review-night-en.md +0 -194
  703. package/plugin/skills/lit-pptx/references/examples/08-image-led-atlas-ko.md +0 -175
  704. package/plugin/skills/lit-pptx/references/examples/09-briefing-gazette-ko.md +0 -204
  705. package/plugin/skills/lit-pptx/references/examples/10-status-update-ledger-ko.md +0 -179
  706. package/plugin/skills/lit-pptx/references/examples/11-portfolio-studio-en.md +0 -164
  707. package/plugin/skills/lit-pptx/references/examples/12-research-tutorial-chalk-en.md +0 -174
  708. package/plugin/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +0 -173
  709. package/plugin/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +0 -154
  710. package/plugin/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +0 -139
  711. package/plugin/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +0 -158
  712. package/plugin/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +0 -179
  713. package/plugin/skills/lit-pptx/references/interview-protocol.md +0 -113
  714. package/plugin/skills/lit-pptx/references/layout-families.md +0 -198
  715. package/plugin/skills/lit-pptx/references/stages/autopilot.md +0 -48
  716. package/plugin/skills/lit-pptx/references/stages/interview.md +0 -52
  717. package/plugin/skills/lit-pptx/references/stages/plan.md +0 -42
  718. package/plugin/skills/lit-pptx/references/title-treatments.md +0 -109
  719. package/plugin/skills/lit-pptx/references/tonalities/atlas.md +0 -139
  720. package/plugin/skills/lit-pptx/references/tonalities/bauhaus.md +0 -112
  721. package/plugin/skills/lit-pptx/references/tonalities/chalk.md +0 -148
  722. package/plugin/skills/lit-pptx/references/tonalities/computational-brutalism.md +0 -118
  723. package/plugin/skills/lit-pptx/references/tonalities/gazette.md +0 -149
  724. package/plugin/skills/lit-pptx/references/tonalities/ledger.md +0 -149
  725. package/plugin/skills/lit-pptx/references/tonalities/neo-brutalism.md +0 -125
  726. package/plugin/skills/lit-pptx/references/tonalities/newsroom.md +0 -115
  727. package/plugin/skills/lit-pptx/references/tonalities/night.md +0 -147
  728. package/plugin/skills/lit-pptx/references/tonalities/paper.md +0 -151
  729. package/plugin/skills/lit-pptx/references/tonalities/riso.md +0 -109
  730. package/plugin/skills/lit-pptx/references/tonalities/signal.md +0 -150
  731. package/plugin/skills/lit-pptx/references/tonalities/studio.md +0 -132
  732. package/plugin/skills/lit-pptx/scripts/compile-deck.js +0 -462
  733. package/plugin/skills/lit-pptx/scripts/craft_extras.py +0 -1078
  734. package/plugin/skills/lit-pptx/scripts/deck_craft.py +0 -363
  735. package/plugin/skills/lit-pptx/scripts/embed_fonts.py +0 -227
  736. package/plugin/skills/lit-pptx/scripts/forbidden-terms.json +0 -55
  737. package/plugin/skills/lit-pptx/scripts/layout_inventory.py +0 -418
  738. package/plugin/skills/lit-pptx/scripts/learn_template.py +0 -446
  739. package/plugin/skills/lit-pptx/scripts/lib/derive-palette.js +0 -176
  740. package/plugin/skills/lit-pptx/scripts/lib/directive-parser.js +0 -244
  741. package/plugin/skills/lit-pptx/scripts/lib/font-map.js +0 -79
  742. package/plugin/skills/lit-pptx/scripts/lib/gen-bg.js +0 -86
  743. package/plugin/skills/lit-pptx/scripts/lib/gen-gradient-assets.js +0 -37
  744. package/plugin/skills/lit-pptx/scripts/lib/grid-resolver.js +0 -510
  745. package/plugin/skills/lit-pptx/scripts/lib/layout-resolver.js +0 -1113
  746. package/plugin/skills/lit-pptx/scripts/lib/markdown-loader.js +0 -138
  747. package/plugin/skills/lit-pptx/scripts/lib/render-adapter-html.js +0 -356
  748. package/plugin/skills/lit-pptx/scripts/lib/render-adapter-pptx.js +0 -2240
  749. package/plugin/skills/lit-pptx/scripts/lib/render-pack.js +0 -3366
  750. package/plugin/skills/lit-pptx/scripts/lib/runtime-require.js +0 -28
  751. package/plugin/skills/lit-pptx/scripts/lib/slide-ast.js +0 -565
  752. package/plugin/skills/lit-pptx/scripts/lib/slide-grid.js +0 -104
  753. package/plugin/skills/lit-pptx/scripts/lib/spec-validator.js +0 -94
  754. package/plugin/skills/lit-pptx/scripts/lib/template-registry.js +0 -730
  755. package/plugin/skills/lit-pptx/scripts/package.json +0 -4
  756. package/plugin/skills/lit-pptx/scripts/qa_deck.py +0 -795
  757. package/plugin/skills/lit-pptx/scripts/validate_pptx.py +0 -230
  758. package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v1.md +0 -251
  759. package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v2.md +0 -214
  760. package/plugin/skills/lit-pptx/specs/slide-ast-v1.schema.json +0 -229
  761. package/plugin/skills/lit-pptx/specs/slide-ast-v2.schema.json +0 -144
  762. package/plugin/skills/lit-pptx/specs/template-enrollment-contract.md +0 -382
  763. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-A2Z/capabilities.yaml +0 -146
  764. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-A2Z/layout-mapping.yaml +0 -454
  765. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-A2Z/template.yaml +0 -40
  766. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-PRO/capabilities.yaml +0 -154
  767. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-PRO/layout-mapping.yaml +0 -475
  768. package/plugin/skills/lit-pptx/templates/enrolled/AZURE-PRO/template.yaml +0 -40
  769. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-A2Z/capabilities.yaml +0 -179
  770. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-A2Z/layout-mapping.yaml +0 -299
  771. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-A2Z/template.yaml +0 -45
  772. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-PRETENDARD/capabilities.yaml +0 -181
  773. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-PRETENDARD/layout-mapping.yaml +0 -299
  774. package/plugin/skills/lit-pptx/templates/enrolled/BOILERPLATE-PRETENDARD/template.yaml +0 -44
  775. package/plugin/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +0 -92
  776. package/plugin/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +0 -98
  777. package/plugin/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +0 -97
  778. package/plugin/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +0 -99
  779. package/plugin/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +0 -93
  780. package/plugin/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +0 -94
  781. package/plugin/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +0 -107
  782. package/plugin/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +0 -99
  783. package/plugin/skills/lit-pptx/templates/tonalities/night/pack.yaml +0 -93
  784. package/plugin/skills/lit-pptx/templates/tonalities/paper/pack.yaml +0 -98
  785. package/plugin/skills/lit-pptx/templates/tonalities/riso/pack.yaml +0 -99
  786. package/plugin/skills/lit-pptx/templates/tonalities/signal/pack.yaml +0 -94
  787. package/plugin/skills/lit-pptx/templates/tonalities/studio/pack.yaml +0 -92
  788. package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +0 -14
  789. package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +0 -8
  790. package/plugin/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +0 -22
  791. package/plugin/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +0 -81
  792. package/plugin/skills/lit-schematic/references/cutaway-outputs.md +0 -25
  793. package/plugin/skills/lit-schematic/references/isometric-craft.md +0 -24
  794. package/plugin/skills/lit-schematic/references/journal-figures.md +0 -19
  795. package/plugin/skills/lit-schematic/references/kit-api.md +0 -42
  796. package/plugin/skills/lit-schematic/references/pfd-and-layout.md +0 -20
  797. package/plugin/skills/lit-schematic/references/pid-drafting.md +0 -30
  798. package/plugin/skills/lit-schematic/references/pid-symbols.md +0 -35
  799. package/plugin/skills/lit-schematic/references/verification.md +0 -31
  800. package/plugin/skills/lit-schematic/scripts/doctor.mjs +0 -13
  801. package/plugin/skills/lit-schematic/scripts/lib/figure.mjs +0 -49
  802. package/plugin/skills/lit-schematic/scripts/lib/isa.mjs +0 -18
  803. package/plugin/skills/lit-schematic/scripts/lib/iso.mjs +0 -58
  804. package/plugin/skills/lit-schematic/scripts/lib/legend-sheet.mjs +0 -10
  805. package/plugin/skills/lit-schematic/scripts/lib/qa-core.mjs +0 -349
  806. package/plugin/skills/lit-schematic/scripts/lib/sheet.mjs +0 -497
  807. package/plugin/skills/lit-schematic/scripts/lib/svg.mjs +0 -39
  808. package/plugin/skills/lit-schematic/scripts/lib/theme.mjs +0 -25
  809. package/plugin/skills/lit-schematic/scripts/motion.mjs +0 -8
  810. package/plugin/skills/lit-schematic/scripts/qa.mjs +0 -21
  811. package/plugin/skills/lit-schematic/scripts/render.mjs +0 -38
  812. package/plugin/skills/lit-schematic/scripts/scaffold.mjs +0 -73
  813. package/plugin/skills/lit-scientific-visualization/LICENSE +0 -21
  814. package/plugin/skills/lit-scientific-visualization/assets/color_palettes.py +0 -197
  815. package/plugin/skills/lit-scientific-visualization/assets/nature.mplstyle +0 -75
  816. package/plugin/skills/lit-scientific-visualization/assets/presentation.mplstyle +0 -74
  817. package/plugin/skills/lit-scientific-visualization/assets/publication.mplstyle +0 -78
  818. package/plugin/skills/lit-scientific-visualization/evals/evals.json +0 -158
  819. package/plugin/skills/lit-scientific-visualization/references/canonical-workflow.md +0 -283
  820. package/plugin/skills/lit-scientific-visualization/references/color_palettes.md +0 -380
  821. package/plugin/skills/lit-scientific-visualization/references/journal_requirements.md +0 -359
  822. package/plugin/skills/lit-scientific-visualization/references/matplotlib_examples.md +0 -608
  823. package/plugin/skills/lit-scientific-visualization/references/mdanalysis_martini_visualization.md +0 -85
  824. package/plugin/skills/lit-scientific-visualization/references/publication_guidelines.md +0 -217
  825. package/plugin/skills/lit-scientific-visualization/references/seaborn_for_publications.md +0 -293
  826. package/plugin/skills/lit-scientific-visualization/scripts/figure_export.py +0 -238
  827. package/plugin/skills/lit-scientific-visualization/scripts/sciviz-runtime-requirements.lock +0 -23
  828. package/plugin/skills/lit-scientific-visualization/scripts/sciviz-runtime.mjs +0 -225
  829. package/plugin/skills/lit-scientific-visualization/scripts/style_presets.py +0 -467
  830. package/plugin/skills/lit-scientific-visualization/tests/test_figure_export.py +0 -51
  831. package/plugin/skills/lit-scientific-visualization/tests/test_style_presets.py +0 -114
  832. package/plugin/skills/lit-typographic-motion/engine/NOTICE +0 -23
  833. package/plugin/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +0 -73
  834. package/plugin/skills/lit-typographic-motion/engine/audio/beat_grid.py +0 -56
  835. package/plugin/skills/lit-typographic-motion/engine/audio/requirements.lock +0 -1084
  836. package/plugin/skills/lit-typographic-motion/engine/blender/runner.py +0 -218
  837. package/plugin/skills/lit-typographic-motion/engine/core/constants.mjs +0 -246
  838. package/plugin/skills/lit-typographic-motion/engine/core/contrast.mjs +0 -90
  839. package/plugin/skills/lit-typographic-motion/engine/core/events.mjs +0 -46
  840. package/plugin/skills/lit-typographic-motion/engine/core/flash.mjs +0 -211
  841. package/plugin/skills/lit-typographic-motion/engine/core/gate-rules.mjs +0 -550
  842. package/plugin/skills/lit-typographic-motion/engine/core/presets.mjs +0 -123
  843. package/plugin/skills/lit-typographic-motion/engine/core/text.mjs +0 -100
  844. package/plugin/skills/lit-typographic-motion/engine/core/timeline.mjs +0 -142
  845. package/plugin/skills/lit-typographic-motion/engine/core/util.mjs +0 -167
  846. package/plugin/skills/lit-typographic-motion/engine/core/voices.mjs +0 -19
  847. package/plugin/skills/lit-typographic-motion/engine/models/word-timing.json +0 -198
  848. package/plugin/skills/lit-typographic-motion/engine/node/analysis.mjs +0 -108
  849. package/plugin/skills/lit-typographic-motion/engine/node/assets.mjs +0 -218
  850. package/plugin/skills/lit-typographic-motion/engine/node/blender.mjs +0 -144
  851. package/plugin/skills/lit-typographic-motion/engine/node/board.mjs +0 -136
  852. package/plugin/skills/lit-typographic-motion/engine/node/brief.mjs +0 -158
  853. package/plugin/skills/lit-typographic-motion/engine/node/chrome.mjs +0 -330
  854. package/plugin/skills/lit-typographic-motion/engine/node/cover-assets.mjs +0 -102
  855. package/plugin/skills/lit-typographic-motion/engine/node/cover-capture.mjs +0 -213
  856. package/plugin/skills/lit-typographic-motion/engine/node/cover-gate.mjs +0 -346
  857. package/plugin/skills/lit-typographic-motion/engine/node/cover-image.mjs +0 -141
  858. package/plugin/skills/lit-typographic-motion/engine/node/cover-sheet.mjs +0 -76
  859. package/plugin/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +0 -106
  860. package/plugin/skills/lit-typographic-motion/engine/node/cover-worker.mjs +0 -32
  861. package/plugin/skills/lit-typographic-motion/engine/node/cover.mjs +0 -373
  862. package/plugin/skills/lit-typographic-motion/engine/node/coverage.mjs +0 -83
  863. package/plugin/skills/lit-typographic-motion/engine/node/done.mjs +0 -209
  864. package/plugin/skills/lit-typographic-motion/engine/node/encode.mjs +0 -102
  865. package/plugin/skills/lit-typographic-motion/engine/node/frame-worker.mjs +0 -36
  866. package/plugin/skills/lit-typographic-motion/engine/node/gallery.mjs +0 -120
  867. package/plugin/skills/lit-typographic-motion/engine/node/house.mjs +0 -44
  868. package/plugin/skills/lit-typographic-motion/engine/node/look.mjs +0 -164
  869. package/plugin/skills/lit-typographic-motion/engine/node/pipeline.mjs +0 -603
  870. package/plugin/skills/lit-typographic-motion/engine/node/png.mjs +0 -112
  871. package/plugin/skills/lit-typographic-motion/engine/node/report.mjs +0 -66
  872. package/plugin/skills/lit-typographic-motion/engine/node/runtime.mjs +0 -348
  873. package/plugin/skills/lit-typographic-motion/engine/node/scaffold.mjs +0 -210
  874. package/plugin/skills/lit-typographic-motion/engine/node/score.mjs +0 -639
  875. package/plugin/skills/lit-typographic-motion/engine/node/session.mjs +0 -145
  876. package/plugin/skills/lit-typographic-motion/engine/node/sound-cli.mjs +0 -77
  877. package/plugin/skills/lit-typographic-motion/engine/node/sound.mjs +0 -740
  878. package/plugin/skills/lit-typographic-motion/engine/node/stage-capture.mjs +0 -179
  879. package/plugin/skills/lit-typographic-motion/engine/node/stage-gate.mjs +0 -123
  880. package/plugin/skills/lit-typographic-motion/engine/node/stage-qa.mjs +0 -295
  881. package/plugin/skills/lit-typographic-motion/engine/node/stage-serve.mjs +0 -430
  882. package/plugin/skills/lit-typographic-motion/engine/node/stage.mjs +0 -572
  883. package/plugin/skills/lit-typographic-motion/engine/node/stills.mjs +0 -100
  884. package/plugin/skills/lit-typographic-motion/engine/node/styles.mjs +0 -214
  885. package/plugin/skills/lit-typographic-motion/engine/node/treatment.mjs +0 -645
  886. package/plugin/skills/lit-typographic-motion/engine/node/webp.mjs +0 -145
  887. package/plugin/skills/lit-typographic-motion/engine/node/ws-server.mjs +0 -132
  888. package/plugin/skills/lit-typographic-motion/engine/package-lock.json +0 -25
  889. package/plugin/skills/lit-typographic-motion/engine/package.json +0 -10
  890. package/plugin/skills/lit-typographic-motion/engine/stage/cover-init.js +0 -37
  891. package/plugin/skills/lit-typographic-motion/engine/stage/init.js +0 -288
  892. package/plugin/skills/lit-typographic-motion/engine/stage/loop-kit.js +0 -106
  893. package/plugin/skills/lit-typographic-motion/engine/stage/qa.js +0 -157
  894. package/plugin/skills/lit-typographic-motion/engine/stage/stage-kit.js +0 -741
  895. package/plugin/skills/lit-typographic-motion/engine/vendor/three/LICENSE +0 -21
  896. package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +0 -144
  897. package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +0 -155
  898. package/plugin/skills/lit-typographic-motion/engine/vendor/three/three.module.js +0 -54571
  899. package/plugin/skills/lit-typographic-motion/engine/web/boot.mjs +0 -123
  900. package/plugin/skills/lit-typographic-motion/engine/web/engine.mjs +0 -281
  901. package/plugin/skills/lit-typographic-motion/engine/web/gl.mjs +0 -319
  902. package/plugin/skills/lit-typographic-motion/engine/web/glsl-common.mjs +0 -78
  903. package/plugin/skills/lit-typographic-motion/engine/web/index.html +0 -6
  904. package/plugin/skills/lit-typographic-motion/engine/web/lines.mjs +0 -112
  905. package/plugin/skills/lit-typographic-motion/engine/web/passes/crt.mjs +0 -98
  906. package/plugin/skills/lit-typographic-motion/engine/web/passes/dither.mjs +0 -49
  907. package/plugin/skills/lit-typographic-motion/engine/web/passes/glitch.mjs +0 -77
  908. package/plugin/skills/lit-typographic-motion/engine/web/passes/swiss-grid.mjs +0 -61
  909. package/plugin/skills/lit-typographic-motion/engine/web/passes/terminal-ui.mjs +0 -88
  910. package/plugin/skills/lit-typographic-motion/engine/web/passes/tidal-gradient.mjs +0 -86
  911. package/plugin/skills/lit-typographic-motion/engine/web/post.mjs +0 -165
  912. package/plugin/skills/lit-typographic-motion/engine/web/scale.mjs +0 -15
  913. package/plugin/skills/lit-typographic-motion/engine/web/scene.mjs +0 -82
  914. package/plugin/skills/lit-typographic-motion/engine/web/scenes/end-card.mjs +0 -30
  915. package/plugin/skills/lit-typographic-motion/engine/web/scenes/index.mjs +0 -16
  916. package/plugin/skills/lit-typographic-motion/engine/web/scenes/karaoke-line.mjs +0 -47
  917. package/plugin/skills/lit-typographic-motion/engine/web/scenes/kinetic-list.mjs +0 -45
  918. package/plugin/skills/lit-typographic-motion/engine/web/scenes/number-counter.mjs +0 -29
  919. package/plugin/skills/lit-typographic-motion/engine/web/scenes/signature.mjs +0 -73
  920. package/plugin/skills/lit-typographic-motion/engine/web/scenes/title-slam.mjs +0 -73
  921. package/plugin/skills/lit-typographic-motion/engine/web/stroke.mjs +0 -236
  922. package/plugin/skills/lit-typographic-motion/engine/web/type.mjs +0 -180
  923. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w100-400.ttf +0 -0
  924. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w100-700.ttf +0 -0
  925. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w100-900.ttf +0 -0
  926. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w125-400.ttf +0 -0
  927. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w125-700.ttf +0 -0
  928. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w125-900.ttf +0 -0
  929. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w75-400.ttf +0 -0
  930. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w75-700.ttf +0 -0
  931. package/plugin/skills/lit-typographic-motion/fonts/archivo/Archivo-w75-900.ttf +0 -0
  932. package/plugin/skills/lit-typographic-motion/fonts/archivo/OFL.txt +0 -93
  933. package/plugin/skills/lit-typographic-motion/fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2 +0 -0
  934. package/plugin/skills/lit-typographic-motion/fonts/jetbrains-mono/OFL.txt +0 -93
  935. package/plugin/skills/lit-typographic-motion/fonts/manifest.json +0 -455
  936. package/plugin/skills/lit-typographic-motion/fonts/silkscreen/OFL.txt +0 -93
  937. package/plugin/skills/lit-typographic-motion/fonts/silkscreen/Silkscreen-Bold.ttf +0 -0
  938. package/plugin/skills/lit-typographic-motion/fonts/silkscreen/Silkscreen-Regular.ttf +0 -0
  939. package/plugin/skills/lit-typographic-motion/fonts/stroke/CREDITS +0 -42
  940. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSAllure.svg +0 -216
  941. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSFelix.svg +0 -216
  942. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSOsmotron.svg +0 -216
  943. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSReadability.svg +0 -216
  944. package/plugin/skills/lit-typographic-motion/fonts/stroke/EMSTech.svg +0 -217
  945. package/plugin/skills/lit-typographic-motion/fonts/stroke/OFL.txt +0 -91
  946. package/plugin/skills/lit-typographic-motion/fonts/vt323/OFL.txt +0 -93
  947. package/plugin/skills/lit-typographic-motion/fonts/vt323/VT323-Regular.ttf +0 -0
  948. package/plugin/skills/lit-typographic-motion/recipes/hero-3d/expected.json +0 -69
  949. package/plugin/skills/lit-typographic-motion/recipes/hero-3d/index.html +0 -139
  950. package/plugin/skills/lit-typographic-motion/recipes/negatives/card-scenes/expected.json +0 -16
  951. package/plugin/skills/lit-typographic-motion/recipes/negatives/card-scenes/index.html +0 -27
  952. package/plugin/skills/lit-typographic-motion/recipes/negatives/reset-sweep/expected.json +0 -16
  953. package/plugin/skills/lit-typographic-motion/recipes/negatives/reset-sweep/index.html +0 -17
  954. package/plugin/skills/lit-typographic-motion/recipes/negatives/still-glow/expected.json +0 -17
  955. package/plugin/skills/lit-typographic-motion/recipes/negatives/still-glow/index.html +0 -18
  956. package/plugin/skills/lit-typographic-motion/recipes/negatives/title-slam/expected.json +0 -17
  957. package/plugin/skills/lit-typographic-motion/recipes/negatives/title-slam/index.html +0 -30
  958. package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +0 -67
  959. package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/index.html +0 -152
  960. package/plugin/skills/lit-typographic-motion/recipes/painted-light/expected.json +0 -95
  961. package/plugin/skills/lit-typographic-motion/recipes/painted-light/index.html +0 -202
  962. package/plugin/skills/lit-typographic-motion/recipes/weight-tide/expected.json +0 -67
  963. package/plugin/skills/lit-typographic-motion/recipes/weight-tide/index.html +0 -100
  964. package/plugin/skills/lit-typographic-motion/references/brief-schema.md +0 -119
  965. package/plugin/skills/lit-typographic-motion/references/cover.md +0 -475
  966. package/plugin/skills/lit-typographic-motion/references/craft-loop.md +0 -100
  967. package/plugin/skills/lit-typographic-motion/references/depth.md +0 -122
  968. package/plugin/skills/lit-typographic-motion/references/engine-contract.md +0 -124
  969. package/plugin/skills/lit-typographic-motion/references/look.md +0 -157
  970. package/plugin/skills/lit-typographic-motion/references/runtime.md +0 -98
  971. package/plugin/skills/lit-typographic-motion/references/sound.md +0 -181
  972. package/plugin/skills/lit-typographic-motion/references/stage.md +0 -310
  973. package/plugin/skills/lit-typographic-motion/references/studio.md +0 -245
  974. package/plugin/skills/lit-typographic-motion/references/style-bibles.md +0 -130
  975. package/plugin/skills/lit-typographic-motion/references/treatment.md +0 -189
  976. package/plugin/skills/lit-typographic-motion/references/type-craft.md +0 -87
  977. package/plugin/skills/lit-typographic-motion/scripts/motion-doctor.mjs +0 -99
  978. package/plugin/skills/lit-typographic-motion/scripts/motion-runtime.mjs +0 -95
  979. package/plugin/skills/lit-typographic-motion/scripts/motion.mjs +0 -206
  980. package/plugin/skills/lit-typographic-motion/styles/paper.json +0 -41
  981. package/plugin/skills/lit-typographic-motion/styles/swiss-signal.json +0 -41
  982. package/plugin/skills/lit-typographic-motion/styles/terminalcore.json +0 -42
  983. package/plugin/skills/lit-typographic-motion/styles/tidal.json +0 -41
  984. package/plugin/skills/readme-studio/references/decoration-and-navigation.md +0 -55
  985. package/plugin/skills/readme-studio/references/facts-and-assembly.md +0 -19
  986. package/plugin/skills/readme-studio/references/production-interview.md +0 -11
  987. package/plugin/skills/readme-studio/references/render-and-deliver.md +0 -44
  988. package/plugin/skills/readme-studio/references/type-and-background.md +0 -23
  989. package/plugin/skills/readme-studio/scripts/readme-runtime-lock/package-lock.json +0 -133
  990. package/plugin/skills/readme-studio/scripts/readme-runtime-lock/package.json +0 -6
  991. package/plugin/skills/readme-studio/scripts/readme-runtime.mjs +0 -77
  992. package/plugin/skills/readme-studio/scripts/validate-readme-facts.mjs +0 -28
  993. package/plugin/skills/readme-studio/templates/cover-source.json +0 -21
  994. package/plugin/skills/readme-studio/templates/hyperframes-cover/index.html +0 -30
  995. package/plugin/skills/readme-studio/templates/hyperframes-cover/index.motion.json +0 -1
  996. package/plugin/skills/readme-studio/templates/hyperframes-cover/package-lock.json +0 -2017
  997. package/plugin/skills/readme-studio/templates/hyperframes-cover/package.json +0 -8
  998. package/plugin/skills/readme-studio/templates/readme-cover-section.md +0 -75
  999. package/plugin/skills/readme-studio/templates/readme-facts.json +0 -4
  1000. package/plugin/skills/readme-studio/templates/remotion-cover/package-lock.json +0 -3783
  1001. package/plugin/skills/readme-studio/templates/remotion-cover/package.json +0 -7
  1002. package/plugin/skills/readme-studio/templates/remotion-cover/src/index.tsx +0 -36
  1003. package/plugin/skills/readme-studio/templates/typography/package-lock.json +0 -133
  1004. package/plugin/skills/readme-studio/templates/typography/package.json +0 -6
  1005. package/plugin/skills/readme-studio/templates/typography/safe-files.mjs +0 -57
  1006. package/plugin/skills/readme-studio/templates/typography/shape-text-to-svg.mjs +0 -63
  1007. package/plugin/skills/visual-qa/references/capture-playbook.md +0 -126
  1008. package/plugin/skills/visual-qa/references/complete-contract.md +0 -677
  1009. package/plugin/skills/visual-qa/schemas/design-contract-v1alpha1.schema.json +0 -305
  1010. package/plugin/skills/visual-qa/schemas/design-contract-v1beta1.schema.json +0 -291
  1011. package/plugin/skills/visual-qa/schemas/design-contract-v1beta2.schema.json +0 -311
  1012. package/plugin/skills/visual-qa/schemas/evidence-manifest-v1alpha1.schema.json +0 -235
  1013. package/plugin/skills/visual-qa/schemas/evidence-manifest-v1beta1.schema.json +0 -208
  1014. package/plugin/skills/visual-qa/schemas/review-receipt-v1alpha1.schema.json +0 -66
  1015. package/plugin/skills/visual-qa/scripts/ansi.ts +0 -17
  1016. package/plugin/skills/visual-qa/scripts/cli.mjs +0 -101
  1017. package/plugin/skills/visual-qa/scripts/cli.ts +0 -96
  1018. package/plugin/skills/visual-qa/scripts/design-contract-shape.mjs +0 -448
  1019. package/plugin/skills/visual-qa/scripts/east-asian-width.ts +0 -72
  1020. package/plugin/skills/visual-qa/scripts/errors.mjs +0 -12
  1021. package/plugin/skills/visual-qa/scripts/evidence-io.mjs +0 -184
  1022. package/plugin/skills/visual-qa/scripts/evidence-semantic.mjs +0 -95
  1023. package/plugin/skills/visual-qa/scripts/evidence-shape.mjs +0 -163
  1024. package/plugin/skills/visual-qa/scripts/evidence.mjs +0 -421
  1025. package/plugin/skills/visual-qa/scripts/image-diff.mjs +0 -89
  1026. package/plugin/skills/visual-qa/scripts/image-diff.ts +0 -109
  1027. package/plugin/skills/visual-qa/scripts/png-chunks.mjs +0 -107
  1028. package/plugin/skills/visual-qa/scripts/png-crc.ts +0 -27
  1029. package/plugin/skills/visual-qa/scripts/png-decode.mjs +0 -143
  1030. package/plugin/skills/visual-qa/scripts/png-decode.ts +0 -206
  1031. package/plugin/skills/visual-qa/scripts/png-synth.ts +0 -57
  1032. package/plugin/skills/visual-qa/scripts/review-rules.mjs +0 -137
  1033. package/plugin/skills/visual-qa/scripts/terminal-text.mjs +0 -117
  1034. package/plugin/skills/visual-qa/scripts/tui-check.mjs +0 -74
  1035. package/plugin/skills/visual-qa/scripts/tui-grid.ts +0 -88
  1036. 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 SG = require("./slide-grid");
17
- const G = require("./grid-resolver");
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
- // When the values take the room, they run down the body as rows: the value, then what it measures.
872
- const cards = shared().kpiCards(kpi.content).slice(0, 6);
873
- const out = [];
874
- const restTexts = texts;
875
- const restH = restTexts.length ? stack(restTexts, Z, S, state).bottom - Z.y + state.blockGap : 0;
876
- const rowsZone = { ...Z, bottom: Z.bottom - restH };
877
- out.push(figureRows(cards, rowsZone, S, state));
878
- if (restTexts.length) out.push(...stack(restTexts, { ...Z, y: rowsZone.bottom + state.blockGap }, S, state).placed);
879
- return out;
880
- }
881
- const top = Z.y;
882
- const cardsPlan = stack([kpi, ...others, ...texts], { ...Z, y: top }, S, state);
883
- // A row of cards with its takeaways under it that stops high on the page: the figures then run as
884
- // rows down the first seven columns (value, label, basis), the caption at their foot, and the
885
- // takeaways stand beside them. A pack with hard shadows keeps its cards: the bordered, shadowed card
886
- // is that pack's figure.
887
- if (texts.length && !others.length && !S.pack.shadow && (Z.bottom - cardsPlan.bottom) / (Z.bottom - Z.y) > S.tok.cap) {
888
- const cards = shared().kpiCards(kpi.content).slice(0, 6);
889
- const [fR, tR] = splitRegion(S, Z, 7 / 12);
890
- const capH = kpi.caption ? captionHeight(kpi.caption, fR.w, S) + 6 : 0;
891
- const rows = figureRows(cards, { ...fR, bottom: fR.bottom - capH }, S, state, 48);
892
- const col = takeawayColumn(ctx, texts, [], tR, fR.bottom);
893
- const notes = col.t;
894
- if (col.strip && col.end <= col.R.bottom + 0.5) notes.placed.push(...col.strip.placed.map((q) => ({ ...q, strip: true })));
895
- if (rows.y + rows.h <= fR.bottom - capH + 0.5 && notes.bottom <= Z.bottom + 0.5) {
896
- const out = [rows, ...notes.placed];
897
- 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 });
898
- if (shortColumn(out, Z.bottom, S).share <= 0.35) return out;
899
- // Takeaways too few to fill the column beside the rows: the rows run across the body and the takeaways
900
- // stand under them side by side, the caption between (spec-v2 Amendments 8).
901
- const paras = texts.flatMap(itemParas);
902
- const half = Math.ceil(paras.length / 2);
903
- // Up to three points read down one column at the reading measure; four or more stand side by side.
904
- 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)];
905
- // The takeaways keep the size they had beside the rows (lead when the column stepped up).
906
- const keep = (notes.placed.find((q) => q.kind === "text" && !q.strip) || {}).size;
907
- 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 } : {}));
908
- const notesH = Math.max(...measured.map((m) => m.h));
909
- const rowsBottom = Z.bottom - notesH - state.blockGap - capH;
910
- // Four figures or more stand in two columns of rows, so the rows use the body's width.
911
- const halves = cards.length >= 4 ? splitRegion(S, { ...Z, bottom: rowsBottom }, 0.5) : [{ ...Z, bottom: rowsBottom }];
912
- const split = Math.ceil(cards.length / halves.length);
913
- const across = halves.map((R, i) => figureRows(cards.slice(i * split, (i + 1) * split), R, S, state, 72));
914
- // The second column's rows stand level with the first's (an odd count leaves its last row open).
915
- if (across.length === 2) {
916
- const [a, b] = across;
917
- b.rows.forEach((r, k) => { r.y = a.rows[k].y; });
918
- 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 });
919
- }
920
- // A band left open between the rows and the takeaways under them is worse than a column whose points share
921
- // the room beside the rows, when that sharing fills the column (spec-v2 Amendments 9).
922
- const band = (Z.bottom - notesH - state.blockGap - capH - Math.max(...across.map((q) => q.y + q.h))) / (Z.bottom - Z.y);
923
- if (band > S.tok.cap) {
924
- const filled = structuredClone(out);
925
- fillColumn(shortColumn(filled, Z.bottom, S), Z.bottom, S, state);
926
- if (shortColumn(filled, Z.bottom, S).share <= 0.35) return filled;
927
- }
928
- if (across.every((q) => q.y + q.h <= rowsBottom + 0.5)) {
929
- const res = [...across, ...measured.map((m, i) => ({ ...m, x: parts[i].x, y: Z.bottom - notesH, limit: Z.bottom }))];
930
- 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 });
931
- return res;
932
- }
933
- return out;
934
- }
935
- }
936
- return cardsPlan.placed;
937
- },
938
-
939
- "big-number"(ctx) {
940
- const { S, state, Z } = ctx;
941
- const { visuals, texts } = sortItems(ctx.items);
942
- const table = visuals.find((v) => v.type === "kpi-table");
943
- if (!table) return PLANS["text-column"](ctx);
944
- if ((S.pack.display || {}).number) return numberPanel(ctx, table, texts);
945
- const c = table.content || {};
946
- const value = plainText(((c.rows || [])[0] || [])[0] || (c.headers || [])[1] || "");
947
- const label = plainText((c.headers || [])[0] || "");
948
- const wide = Z.b - Z.a + 1 >= 10;
949
- const [nR, tR] = wide ? splitRegion(S, Z, 6 / 12) : [Z, null];
950
- const size = [S.sizes.title, S.sizes.lead].find((v) => S.ems(value, "numeral") * v * 1.04 <= nR.w) || S.sizes.body;
951
- const labelSize = bodySize(S, state, "lead");
952
- const labelH = G.textHeight(label, nR.w, labelSize);
953
- const capH = table.caption ? captionHeight(table.caption, nR.w, S) + 6 : 0;
954
- const blockH = size * 1.15 + 12 + labelH + capH;
955
- const out = [];
956
- // The number opens the body, its evidence beside it or under it.
957
- const y = Z.y;
958
- if (texts.length) {
959
- const R = tR ? region(S, tR.a + 1, tR.b, Z.y, Z.bottom)
960
- : { ...Z, y: Z.y + blockH + state.blockGap };
961
- const evidence = stack(texts, R, S, { ...state, stepped: true });
962
- out.push(...evidence.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
- // Beside written columns the loose points are the slide's takeaways: they run under the rows.
1026
- const notes = columns && texts.length ? measureText(texts.flatMap(itemParas), ctx.Z.w, S, state) : null;
1027
- const Z = notes ? { ...ctx.Z, bottom: ctx.Z.bottom - notes.h - state.blockGap } : ctx.Z;
1028
- if (visuals.length && !columns) return visualWithText(ctx, visuals, texts, 7 / 12);
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
- // Points that open with the same label on both sides read as criteria rows on the compact
1050
- // step: the label stands once in a column of its own, each side keeps the rest.
1051
- if (S.tok.tight && sides.length === 2 && sides.every((sd) => sd.items.length && sd.items.every(isLabel))) {
1052
- const n = Math.max(...sides.map((sd) => sd.items.length));
1053
- 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))]);
1054
- const labels = sets.map((set) => set.join(" / "));
1055
- const odd = sets.filter((set) => set.length > 1).length;
1056
- if (odd <= 1 && odd < n / 2) {
1057
- criteria = labels;
1058
- for (const sd of sides) sd.items = sd.items.map((t) => LABEL.exec(plainText(t))[2]);
1059
- }
1060
- }
1061
- const floor = Z.bottom;
1062
- const critR = criteria ? region(S, Z.a, Z.a + 1, Z.y, Z.bottom) : null;
1063
- const parts = criteria ? splitRegion(S, region(S, Z.a + 2, Z.b, Z.y, Z.bottom), 0.5) : splitRegion(S, Z, 0.5);
1064
- const headSize = bodySize(S, state, "lead");
1065
- // Up to three rows of short points are set a step or two larger when that still keeps a dozen
1066
- // glyphs a line and fits the body; a two-row comparison otherwise holds a third of the page.
1067
- const rowsN = Math.max(...sides.map((sd) => sd.items.length));
1068
- const fitsAt = (z) => {
1069
- if (parts[0].w / z < 12) return false;
1070
- 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))));
1071
- const headRoom = Math.max(0, ...sides.map((sd, i) => (sd.head ? G.textHeight(plainText(sd.head), parts[i].w, headSize) + 30 : 0)));
1072
- return Z.y + headRoom + hs.reduce((a, b) => a + b, 0) + (rowsN - 1) * state.groupGap * 2 <= floor;
1073
- };
1074
- // The compact step never inflates type to fill: its rows keep the body size.
1075
- const itemSize = (rowsN <= 3 && !S.tok.tight ? [S.sizes.title, S.sizes.lead].filter((z) => z > bodySize(S, state)) : []).find(fitsAt) || bodySize(S, state);
1076
- const out = [];
1077
- const headH = Math.max(0, ...sides.map((sd, i) => (sd.head ? G.textHeight(plainText(sd.head), parts[i].w, headSize) : 0)));
1078
- let top = Z.y;
1079
- if (headH) {
1080
- sides.forEach((sd, i) => {
1081
- if (!sd.head) return;
1082
- 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 });
1083
- const accent = S.deco.has("accent-rule");
1084
- 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" });
1085
- });
1086
- top = Z.y + headH + 30;
1087
- }
1088
- // Parallel points share a row, so they are read across; the rows run down to the floor.
1089
- const n = Math.max(...sides.map((sd) => sd.items.length));
1090
- const labelH = (r) => (criteria ? G.textHeight(criteria[r], critR.w / S.wide("title", criteria[r]), itemSize) : 0);
1091
- // Measured on the lines the text frame will set (word by word), so a narrow side keeps its lines.
1092
- const sideH = (t, i) => {
1093
- const w = parts[i].w / S.wide("body");
1094
- return G.textHeight(G.keepLines(plainText(t), w / itemSize, 99), w, itemSize);
1095
- };
1096
- const rowH = Array.from({ length: n }, (_, r) => Math.max(labelH(r), ...sides.map((sd, i) => (sd.items[r] ? sideH(sd.items[r], i) : 0))));
1097
- const pitch = rowPitch(n, Math.max(...rowH), { y: top, bottom: floor }, state.groupGap, Math.max(112, Math.max(...rowH) + 72));
1098
- // On the compact step each row starts one even gap under the one before (rows of two and three
1099
- // lines alike). The gap opens up to a fifth of the body so four one-line rows across the full body
1100
- // width reach the floor, and never ends the rows higher than a pitch of the tallest row plus 48 pt would.
1101
- const sum = rowH.reduce((a, b) => a + b, 0);
1102
- const reach = n > 1 ? ((n - 1) * (Math.max(...rowH) + 48) + rowH[n - 1] - sum) / (n - 1) : 0;
1103
- const gap = n > 1 ? Math.max(state.groupGap, Math.min(Math.max(48, (floor - Z.y) / 5, reach), (floor - top - sum) / (n - 1))) : 0;
1104
- const ys = rowH.map((_, r) => (S.tok.tight ? top + rowH.slice(0, r).reduce((a, b) => a + b, 0) + r * gap : top + r * pitch));
1105
- for (let r = 0; r < n; r++) {
1106
- const y = ys[r];
1107
- if (r > 0 && (S.deco.has("hairline-rule") || S.deco.has("column-hairlines"))) {
1108
- 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" });
1109
- }
1110
- 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 });
1111
- sides.forEach((sd, i) => {
1112
- if (!sd.items[r]) return;
1113
- const h = sideH(sd.items[r], i);
1114
- 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 });
1115
- });
1116
- }
1117
- if (S.deco.has("column-hairlines")) out.push(columnHairline(S, parts[1], Z));
1118
- if (notes) out.push({ ...notes, x: Z.x, y: Z.bottom + state.blockGap, limit: ctx.Z.bottom });
1119
- return out;
1120
- },
1121
-
1122
- process(ctx) {
1123
- const { S, state } = ctx;
1124
- const all = entries(sortItems(ctx.items).texts.flatMap(itemParas));
1125
- // Points without a bold head after the steps are the slide's takeaways: they run under the
1126
- // steps instead of being read as more steps (or dropped past the fifth).
1127
- const headed = all.filter((e) => e.head);
1128
- const loose = headed.length >= 2 && headed.length < all.length ? all.filter((e) => !e.head) : [];
1129
- const ents = loose.length ? headed : all;
1130
- if (ents.length < 2) return PLANS["text-column"](ctx);
1131
- 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;
1132
- const Z = notes ? { ...ctx.Z, bottom: ctx.Z.bottom - notes.h - state.blockGap } : ctx.Z;
1133
- const withNotes = (placed) => (notes ? [...placed, { ...notes, x: Z.x, y: Z.bottom + state.blockGap, limit: ctx.Z.bottom }] : placed);
1134
- const steps = ents.slice(0, 5).map((e, i) => {
1135
- const o = ordinal(e.head || "", i);
1136
- // Sub-points read as details of the step, joined with the step's text, without their "(1)".
1137
- 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(" · ") };
1138
- });
1139
- const numSize = S.sizes.display;
1140
- const headSize = bodySize(S, state, "lead");
1141
- const restSize = bodySize(S, state);
1142
- const asRows = () => {
1143
- if (S.tok.tight && Z.b - Z.a + 1 >= 10) {
1144
- // On the compact step a row reads across: the numeral, the step's name, then what happens.
1145
- const numW = S.grid.span(1, 1).w;
1146
- const headR = region(S, Z.a + 1, Z.a + 3, Z.y, Z.bottom);
1147
- const restX = headR.x + headR.w + S.grid.gutter;
1148
- const korean = G.isKorean(steps.map((st) => st.head + st.rest).join(""));
1149
- // The same readable measure as the stacked rows (S4.4; the gate counts spaces as characters). That
1150
- // measure at body size leaves the body's right columns empty, so what happens is set a step up (lead)
1151
- // when the rows still fit: the measure grows with the size and reaches across (spec-v2 Amendments 7).
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
- // `flush` sets what happens against the body's right edge and gives the step's name the columns
1168
- // between, so a body-size measure still reaches across when the lead step does not fit.
1169
- const body = at(restSize);
1170
- if ((Z.x + Z.w - (restX + body.restW)) / Z.w > 0.25) {
1171
- const lead = at(S.sizes.lead);
1172
- if (lead.y + lead.h <= Z.bottom + 0.5) return [lead];
1173
- return [at(restSize, true)];
1174
- }
1175
- return [body];
1176
- }
1177
- const numW = S.grid.span(1, 2).w;
1178
- const textX = Z.x + numW + S.grid.gutter;
1179
- // Across the full body a step's text keeps a readable measure (S4.4; the gate counts spaces and separators as characters).
1180
- const korean = G.isKorean(steps.map((s) => s.head + s.rest).join(""));
1181
- const textW = Math.min(Z.x + Z.w - textX, korean ? 26 * restSize : 35 * restSize);
1182
- const rows = steps.map((s) => ({ num: s.n, head: s.head, rest: s.rest,
1183
- h: Math.max(numSize * 1.15, G.textHeight(s.head, textW, headSize) + (s.rest ? 6 + G.textHeight(s.rest, textW, restSize) : 0)) }));
1184
- const pitch = rowPitch(rows.length, Math.max(...rows.map((r) => r.h)), Z, state.groupGap, 160);
1185
- rows.forEach((r, i) => { r.y = Z.y + i * pitch; });
1186
- 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 }];
1187
- };
1188
- const slots = equalParts(S, Z, steps.length);
1189
- const placedSteps = steps.map((s, i) => {
1190
- const R = slots[i];
1191
- const headH = G.textHeight(s.head, R.w, headSize);
1192
- const restH = s.rest ? G.textHeight(s.rest, R.w, restSize) : 0;
1193
- return { ...s, x: R.x, w: R.w, headH, restH };
1194
- });
1195
- const h = numSize * 1.1 + 18 + Math.max(...placedSteps.map((s) => s.headH + (s.restH ? 12 + s.restH : 0)));
1196
- // Up to four steps whose columns stop high on the body run as rows down it instead.
1197
- if (steps.length <= 4 && (Z.bottom - Z.y - h) / (Z.bottom - Z.y) > S.tok.cap) {
1198
- const rows = asRows();
1199
- if (rows[0].y + rows[0].h <= Z.bottom + 0.5) return withNotes(rows);
1200
- }
1201
- return withNotes([{ kind: "steps", steps: placedSteps, numSize, headSize, restSize, y: Z.y, h, limit: Z.bottom }]);
1202
- },
1203
-
1204
- timeline(ctx) {
1205
- const { S, state, Z } = ctx;
1206
- const { visuals, texts } = sortItems(ctx.items);
1207
- const table = visuals.find((v) => v.type === "kpi-table");
1208
- let events;
1209
- if (table) events = (table.content.rows || []).map((r) => ({ date: plainText(r[0]), label: plainText(r[1] || ""), status: plainText(r.slice(2).join(" · ")) }));
1210
- else events = entries(texts.flatMap(itemParas)).map((e) => ({ date: e.head, label: e.rest, status: e.children.join(" · ") }));
1211
- events = events.slice(0, 6);
1212
- if (!events.length) return PLANS["text-column"](ctx);
1213
- const slots = equalParts(S, Z, events.length);
1214
- const dateSize = bodySize(S, state, "lead");
1215
- const labelSize = bodySize(S, state);
1216
- // The axis runs under the tallest date at the top of the body; the room left under the whole
1217
- // plan is shared out below (see the end of this plan).
1218
- const dateH = Math.max(...events.map((e, i) => G.textHeight(e.date, slots[i].w, dateSize, 1.25)));
1219
- const axisY = Math.round(Z.y + dateH + 18);
1220
- const items = events.map((e, i) => {
1221
- const R = slots[i];
1222
- const labelH = G.textHeight(e.label, R.w, labelSize);
1223
- const statusH = e.status ? 6 + G.textHeight(e.status, R.w, S.sizes.label, 1.3) : 0;
1224
- return { ...e, x: R.x, w: R.w, labelH, statusH };
1225
- });
1226
- const below = Math.max(...items.map((e) => e.labelH + e.statusH));
1227
- 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;
1228
- 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 }];
1229
- if (cap) out.push({ ...cap, y: out[0].y + out[0].h + 18, limit: Z.bottom });
1230
- // When a table carries the events, the bullets are the takeaway and run under the axis.
1231
- if (table && texts.length) {
1232
- const top = Math.max(...out.map((q) => q.y + q.h)) + state.blockGap;
1233
- out.push(...stack(texts, { ...Z, y: top }, S, state).placed);
1234
- }
1235
- // Room past the density band is shared evenly: over the axis, between the axis and its takeaways,
1236
- // and under them, so no one band holds it (an axis halfway down left the top third empty).
1237
- const room = Z.bottom - contentBottom(out, Z.y);
1238
- if (room / (Z.bottom - Z.y) > S.tok.cap) {
1239
- // A single takeaway line stays with the axis it reads (a band over one line set it adrift), so the
1240
- // pair moves together, the room shared over and under it (spec-v2 Amendments 8).
1241
- const single = texts.flatMap(itemParas).length === 1;
1242
- const blocks = out.length > (cap ? 2 : 1) && !single ? 3 : 2;
1243
- const step = Math.floor(room / blocks);
1244
- out.forEach((q, i) => {
1245
- const dy = step * (i < (cap ? 2 : 1) || single ? 1 : 2);
1246
- q.y += dy;
1247
- if (q.kind === "timeline") q.axisY += dy;
1248
- if (q.kind === "group") shiftGroup(q, dy);
1249
- });
1250
- }
1251
- return out;
1252
- },
1253
-
1254
- "matrix-2x2"(ctx) {
1255
- const { S, state, Z } = ctx;
1256
- const { visuals, texts } = sortItems(ctx.items);
1257
- const table = visuals.find((v) => v.type === "kpi-table");
1258
- const c = (table && table.content) || {};
1259
- if (!table || (c.headers || []).length !== 3 || (c.rows || []).length !== 2) return PLANS["table-insight"](ctx);
1260
- const [yName, xName] = String(plainText(c.headers[0])).split(/\s*[\\/]\s*/u);
1261
- // The takeaways stand beside the quadrants in the last four columns (under the matrix on a
1262
- // narrow body), so the matrix never drops them.
1263
- const wide = texts.length && Z.b - Z.a + 1 >= 10;
1264
- const M = wide ? region(S, Z.a, Z.b - 4, Z.y, Z.bottom) : Z;
1265
- const notesH = texts.length && !wide ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
1266
- const mBottom = M.bottom - notesH;
1267
- const labelCols = wide ? 1 : 2;
1268
- const labels = region(S, M.a, M.a + labelCols - 1, M.y, mBottom);
1269
- const grid = region(S, M.a + labelCols, M.b, M.y, mBottom);
1270
- const capH = table.caption ? captionHeight(table.caption, grid.w, S) + 6 : 0;
1271
- const headH = S.sizes.label * 1.4 + 12;
1272
- const gap = S.grid.gutter;
1273
- const top = grid.y + headH;
1274
- const qh = (grid.bottom - capH - top - gap) / 2;
1275
- const qw = (grid.w - gap) / 2;
1276
- const pad = 18;
1277
- // A cell is its item over its details: "포장재 단가 재협상 · 연 6억 원 · 즉시" sets the item as the
1278
- // cell's head and each detail on a line under it.
1279
- const head = bodySize(S, state, "lead");
1280
- const detail = bodySize(S, state);
1281
- const cells = [0, 1].flatMap((ri) => [0, 1].map((ci) => {
1282
- const [first, ...rest] = plainText(c.rows[ri][ci + 1]).split(/\s+·\s+/u);
1283
- const headH = G.textHeight(first, qw - pad * 2, head, 1.3);
1284
- const details = rest.map((t) => ({ text: t, h: G.textHeight(t, qw - pad * 2, detail) }));
1285
- return { head: first, headH, details, x: grid.x + ci * (qw + gap), y: top + ri * (qh + gap), w: qw, h: qh };
1286
- }));
1287
- 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])],
1288
- xName: xName || "", yName: yName || "", labels, grid, top, qw, qh, gap, pad, head, detail,
1289
- caption: table.caption, x: M.x, y: M.y, w: M.w, h: grid.bottom - M.y, limit: Z.bottom }];
1290
- if (texts.length) {
1291
- const R = wide ? region(S, Z.b - 3, Z.b, Z.y, Z.bottom) : { ...Z, y: mBottom + state.blockGap };
1292
- out.push(...stack(texts, R, S, state).placed);
1293
- }
1294
- return out;
1295
- },
1296
-
1297
- quote(ctx) {
1298
- const { S, state, Z } = ctx;
1299
- const paras = sortItems(ctx.items).texts.flatMap(itemParas);
1300
- const by = paras.find((p) => /^[—–-]\s*/u.test(plainText(p.text)));
1301
- const said = paras.filter((p) => p !== by).map((p) => p.text).join(" ");
1302
- const markW = S.grid.span(1, 1).w;
1303
- const R = region(S, Math.min(Z.b, Z.a + 1), Math.max(Z.a + 1, Z.b - 2), Z.y + 24, Z.bottom);
1304
- const size = S.sizes.title;
1305
- const h = G.textHeight(plainText(said), R.w, size, 1.3);
1306
- const blockH = h + (by ? 18 + S.sizes.label * 1.4 : 0);
1307
- // Beside a side title the quote is the slide's display element: it sits in the middle of the
1308
- // body, as a statement does, instead of at the top of an empty page.
1309
- const y = R.y;
1310
- 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 }];
1311
- },
1312
-
1313
- "image-split"(ctx) {
1314
- const { visuals, texts } = sortItems(ctx.items);
1315
- return visualWithText(ctx, visuals, texts, 7 / 12);
1316
- },
1317
-
1318
- "figure-academic"(ctx) {
1319
- const { visuals, texts } = sortItems(ctx.items);
1320
- return visualWithText(ctx, visuals, texts, 8 / 12);
1321
- },
1322
-
1323
- method(ctx) {
1324
- const { S, state, Z } = ctx;
1325
- const { visuals, texts } = sortItems(ctx.items);
1326
- const paras = texts.flatMap(itemParas);
1327
- const formula = paras.filter((p) => p.kind === "text");
1328
- const defs = paras.filter((p) => p.kind !== "text");
1329
- if (!visuals.length && !formula.length) return PLANS["text-column"](ctx);
1330
- const defsItem = defs.length ? [{ type: "body", content: { items: [] }, paras: defs }] : [];
1331
- const out = [];
1332
- const place = (R) => {
1333
- if (visuals.length) out.push(...stack(visuals, R, S, state).placed);
1334
- else {
1335
- const size = S.sizes.title;
1336
- const h = G.textHeight(plainText(formula.map((p) => p.text).join("\n")), R.w, size, 1.4);
1337
- 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 });
1338
- }
1339
- };
1340
- if (!defsItem.length) { place(Z); return out; }
1341
- const defsAt = (R) => textAt(defs, R, S, { ...state, itemGap: Math.max(state.itemGap, 12) });
1342
- if (!visuals.length && Z.b - Z.a + 1 >= 8) {
1343
- // The formula runs across the top and its terms in columns under it, instead of one line over an empty
1344
- // column beside the terms (on every density step since spec-v2 Amendments 8; the compact step before).
1345
- place(Z);
1346
- const below = { ...Z, y: Math.max(...out.map((q) => q.y + q.h)) + state.blockGap };
1347
- // Two columns of terms, else three (a formula beside its terms left its own column four-fifths empty).
1348
- for (const n of [2, 3]) {
1349
- const cols = defsInColumns(defs, below, n);
1350
- if (cols.every((q) => q.y + q.h <= Z.bottom)) return [...out, ...cols];
1351
- }
1352
- out.length = 0;
1353
- }
1354
- // A wide figure (twice as wide as tall or more) set in half the body is drawn at a third of its column's
1355
- // height: it runs across the top instead and its terms stand in two columns under it (Amendments 8).
1356
- const size = visuals.length === 1 && visuals[0].type === "image" && visuals[0].imageSize;
1357
- if (S.tok.tight && size && size.width / size.height >= 2 && Z.b - Z.a + 1 >= 8) {
1358
- const cap = captionHeight(visuals[0].caption, Z.w, S);
1359
- for (const [share, n] of [[0.5, 2], [0.45, 2], [0.5, 3], [0.42, 3], [0.36, 3]]) {
1360
- const figH = Math.min(Math.round(Z.w * size.height / size.width) + cap, Math.round((Z.bottom - Z.y) * share));
1361
- place({ ...Z, bottom: Z.y + figH });
1362
- // Measured at their closest step first: whether the terms fit under the figure is not a question of
1363
- // how far they may then open to fill the room.
1364
- const under = { ...Z, y: Z.y + figH + state.blockGap };
1365
- let cols = defsInColumns(defs, under, n, false);
1366
- // The source strip closes the shortest column when it fits there.
1367
- const last = cols.reduce((m, q) => (q.y + q.h < m.y + m.h ? q : m));
1368
- const strip = ctx.strip ? stripPlacements(ctx.strip, { ...Z, x: last.x, w: last.w }, S) : null;
1369
- const closes = strip && last.y + last.h * 1.1 + S.tok.block + strip.h <= Z.bottom;
1370
- // A figure across the body is wider at 130 pt than it stands beside its terms at full column height.
1371
- if (figH - cap >= 130 && cols.every((q) => q.y + q.h * 1.1 <= Z.bottom) && (!strip || closes)) {
1372
- // Then the terms open over the room left above the strip, when they still fit there.
1373
- const roomy = defsInColumns(defs, { ...under, bottom: strip ? Z.bottom - strip.h - S.tok.block : Z.bottom }, n);
1374
- if (roomy.every((q) => q.y + q.h * 1.05 <= (strip ? Z.bottom - strip.h - S.tok.block : Z.bottom))) cols = roomy;
1375
- return [...out, ...cols.map((q) => ({ ...q, limit: Z.bottom - q.h * 0.1 })), ...(strip ? strip.placed.map((q) => ({ ...q, strip: true })) : [])];
1376
- }
1377
- out.length = 0;
1378
- }
1379
- }
1380
- const [vR, full] = splitRegion(S, Z, 7 / 12);
1381
- place(vR);
1382
- // Beside a figure the terms' column closes with the source strip when it ends above the figure, and
1383
- // terms that still leave 40 % of it empty are set a step up (spec-v2 Amendments 7).
1384
- const strip = ctx.strip && visuals.length ? stripPlacements(ctx.strip, full, S) : null;
1385
- const dR = strip ? { ...full, bottom: full.bottom - strip.h - S.tok.block } : full;
1386
- let beside = defsAt(dR);
1387
- if (visuals.length && (dR.bottom - (beside.y + beside.h)) / (dR.bottom - dR.y) > 0.4 && dR.w / S.sizes.lead >= 12) {
1388
- const lead = textAt(defs, dR, S, { ...state, stepped: true, itemGap: Math.max(state.itemGap, 12) });
1389
- if (lead.y + lead.h <= dR.bottom + 0.5) beside = lead;
1390
- }
1391
- if (strip && beside.y + beside.h <= dR.bottom + 0.5) out.push(...strip.placed.map((q) => ({ ...q, strip: true })));
1392
- if (S.tok.tight && visuals.length && beside.y + beside.h > Z.bottom) {
1393
- // Terms too long for five columns beside the figure: first half and half, the terms in one column
1394
- // (the figure keeps six columns, so its own labels stay readable); then the figure takes five
1395
- // columns and the terms run in two columns over the other seven.
1396
- const [hR, tR6] = splitRegion(S, Z, 6 / 12);
1397
- const strip6 = ctx.strip ? stripPlacements(ctx.strip, tR6, S) : null;
1398
- const one = textAt(defs, strip6 ? { ...tR6, bottom: tR6.bottom - strip6.h - S.tok.block } : tR6, S, { ...state, itemGap: Math.max(state.itemGap, 12) });
1399
- if (one.y + one.h * 1.1 <= (strip6 ? tR6.bottom - strip6.h - S.tok.block : Z.bottom)) {
1400
- out.length = 0;
1401
- place(hR);
1402
- return [...out, { ...one, limit: Z.bottom - one.h * 0.1 }, ...(strip6 ? strip6.placed.map((q) => ({ ...q, strip: true })) : [])];
1403
- }
1404
- // The text estimate runs short of what a renderer sets for Latin, so the columns keep a tenth
1405
- // of their height spare; the figure gives up a further column when five leave too little.
1406
- for (const share of [5 / 12, 4 / 12]) {
1407
- out.length = 0;
1408
- const [fR, tR] = splitRegion(S, Z, share);
1409
- const cols = defsInColumns(defs, tR);
1410
- if (share < 5 / 12 || cols.every((q) => q.y + q.h * 1.1 <= Z.bottom)) {
1411
- place(fR);
1412
- // The spare tenth is part of each column's limit, so a slide that cannot keep it reads as
1413
- // overflowing and takes a title that leaves the terms more room.
1414
- return [...out, ...cols.map((q) => ({ ...q, limit: Z.bottom - q.h * 0.1 }))];
1415
- }
1416
- }
1417
- }
1418
- out.push(beside);
1419
- return out;
1420
-
1421
- // The terms split between two columns at the entry that brings the first nearest half the height (three
1422
- // columns: the cuts that keep the tallest column lowest).
1423
- function defsInColumns(list, R, n = 2, open = true) {
1424
- const ents = entries(list);
1425
- const flat = (part) => part.flatMap((e) => [{ kind: e.kind === "section" ? "section" : "bullet", text: e.head ? `**${e.head}** ${e.rest}`.trim() : e.rest },
1426
- ...e.children.map((c) => ({ kind: "child", text: c }))]);
1427
- const cols = equalParts(S, R, n);
1428
- const fits = (st) => cols.every((C) => C.y + measureText(flat(ents), C.w, S, st).h / n <= C.bottom);
1429
- // Terms keep a 12 pt step between them when the columns hold it, else the item gap. Terms that leave
1430
- // more than the density band empty under them open the step, up to 36 pt, while the columns hold it.
1431
- const at = (g) => ({ ...state, itemGap: Math.max(state.itemGap, g) });
1432
- const loose = (st) => (C) => (C.bottom - C.y - measureText(flat(ents), C.w, S, st).h / n) / (C.bottom - C.y) > S.tok.cap;
1433
- let gapped = fits(at(12)) ? at(12) : state;
1434
- if (open && gapped !== state && cols.every(loose(gapped))) gapped = [36, 30, 24, 18].map(at).find(fits) || gapped;
1435
- const tall = (part) => (part.length ? measureText(flat(part), cols[0].w, S, gapped).h : 0);
1436
- if (n === 3 && ents.length >= 3) {
1437
- let best = null;
1438
- for (let a = 1; a < ents.length - 1; a++) for (let b = a + 1; b < ents.length; b++) {
1439
- const top = Math.max(tall(ents.slice(0, a)), tall(ents.slice(a, b)), tall(ents.slice(b)));
1440
- if (!best || top < best.top) best = { a, b, top };
1441
- }
1442
- const parts = [ents.slice(0, best.a), ents.slice(best.a, best.b), ents.slice(best.b)];
1443
- return cols.map((C, i) => textAt(flat(parts[i]), C, S, gapped));
1444
- }
1445
- let cut = 1;
1446
- 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;
1447
- const res = cols.map((C, i) => textAt(flat(i ? ents.slice(cut) : ents.slice(0, cut)), C, S, gapped));
1448
- return res;
1449
- }
1450
- },
1451
-
1452
- "photo-grid"(ctx) {
1453
- const { S, state, Z } = ctx;
1454
- const { visuals, texts } = sortItems(ctx.items);
1455
- const images = visuals.flatMap((v) => (v.type === "image-grid" ? (v.content.images || []).map((im) => ({ type: "image", content: im })) : v.type === "image" ? [v] : []));
1456
- if (images.length < 2) return PLANS["image-split"](ctx);
1457
- const textH = texts.length ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
1458
- const parts = equalParts(S, { ...Z, bottom: Z.bottom - textH }, Math.min(3, images.length));
1459
- const out = images.slice(0, 3).flatMap((im, i) => stack([im], parts[i], S, state).placed);
1460
- if (texts.length) out.push(...stack(texts, { ...Z, y: Z.bottom - textH + state.blockGap }, S, state).placed);
1461
- return out;
1462
- },
1463
-
1464
- "figure-pair"(ctx) {
1465
- const { S, state, Z } = ctx;
1466
- const { visuals, texts } = sortItems(ctx.items);
1467
- if (visuals.length < 2) return PLANS["figure-academic"](ctx);
1468
- const textH = texts.length ? stack(texts, Z, S, state).bottom - Z.y + state.blockGap : 0;
1469
- const [l, r] = splitRegion(S, { ...Z, bottom: Z.bottom - textH }, 0.5);
1470
- const out = [...stack([visuals[0]], l, S, state).placed, ...stack([visuals[1]], r, S, state).placed];
1471
- if (texts.length) out.push(...stack(texts, { ...Z, y: Z.bottom - textH + state.blockGap }, S, state).placed);
1472
- return out;
1473
- },
1474
-
1475
- "asymmetric-feature"(ctx) {
1476
- const { S, state, Z } = ctx;
1477
- const { visuals, texts } = sortItems(ctx.items);
1478
- const table = visuals.find((v) => v.type === "kpi-table" && (v.content.rows || []).length <= 1);
1479
- if (table && !visuals.some((v) => v.type !== "kpi-table")) return PLANS["big-number"](ctx);
1480
- return visualWithText(ctx, visuals, texts, 5 / 12);
1481
- },
1482
-
1483
- // ── Closings (content slides whose title states the ask) ──
1484
- "closing-ask"(ctx) {
1485
- const { S, state, Z } = ctx;
1486
- const { visuals, texts } = sortItems(ctx.items);
1487
- const acts = visuals.length === 1 && visuals[0].type === "kpi-table" && !visuals[0].content.chart ? actionRows(visuals[0].content) : null;
1488
- if (!acts) return visualWithText(ctx, visuals, texts, 8 / 12);
1489
- const step = texts.length ? nextStep(ctx, texts, Z, (S.pack.display || {}).closing || "box") : null;
1490
- // The rows share the room down to the step's own top, so the gap above the step is one of theirs.
1491
- const R = { ...Z, bottom: step ? step.top + state.blockGap : Z.bottom };
1492
- const rows = placeActions(ctx, acts, R, { last: Boolean(step) });
1493
- // Rows that do not fit above the step keep the table.
1494
- if (!rows) return visualWithText(ctx, visuals, texts, 8 / 12);
1495
- return [...rows, ...(step ? step.placed : [])];
1496
- },
1497
-
1498
- "closing-decision-box"(ctx) {
1499
- const { S, state, Z } = ctx;
1500
- const { visuals, texts } = sortItems(ctx.items);
1501
- const out = [];
1502
- let y = Z.y;
1503
- const acts = visuals.length === 1 && visuals[0].type === "kpi-table" && !visuals[0].content.chart ? actionRows(visuals[0].content) : null;
1504
- if (texts.length) {
1505
- const pad = 18;
1506
- const paras = texts.flatMap(itemParas).map((p) => ({ ...p, kind: "text" }));
1507
- const m = measureText(paras, Z.w - pad * 2, S, state, { size: S.sizes.lead });
1508
- 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 },
1509
- { ...m, x: Z.x + pad, y: y + pad, bold: true, tinted: !S.deco.has("box-outline"), limit: Z.bottom });
1510
- y += m.h + pad * 2 + state.blockGap;
1511
- }
1512
- // The items to decide on run as action rows under the box, down to the floor, when they fit.
1513
- const rows = acts ? placeActions(ctx, acts, { ...Z, y }, {}) : null;
1514
- if (rows) return [...out, ...rows];
1515
- if (visuals.length) out.push(...stack(visuals, { ...Z, y }, S, state).placed);
1516
- return out;
1517
- },
1518
-
1519
- "closing-summary-list"(ctx) {
1520
- const { S, state, Z } = ctx;
1521
- const { visuals, texts } = sortItems(ctx.items);
1522
- const [lR, bR] = splitRegion(S, Z, 8 / 12);
1523
- const out = [];
1524
- const paras = texts.flatMap(itemParas);
1525
- if (visuals.length) {
1526
- out.push(...stack(visuals, lR, S, state).placed);
1527
- if (paras.length) {
1528
- const pad = S.tok.pad;
1529
- const m = measureText(paras, bR.w - pad * 2, S, state);
1530
- 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 });
1531
- }
1532
- return out;
1533
- }
1534
- // Numbered takeaways across the body, one row each, spread down to the floor.
1535
- const size = bodySize(S, state, "lead");
1536
- const heights = paras.map((p) => G.textHeight(plainText(p.text), Z.w - 48, size));
1537
- const pitch = rowPitch(paras.length, Math.max(...heights, 1), Z, state.groupGap, Math.max(...heights, 1) + 48);
1538
- paras.forEach((p, i) => {
1539
- const y = Z.y + i * pitch;
1540
- 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 },
1541
- { 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 });
1542
- });
1543
- return out;
1544
- },
1545
-
1546
- "closing-contact-split"(ctx) {
1547
- const { S, state, Z } = ctx;
1548
- const { visuals, texts } = sortItems(ctx.items);
1549
- const acts = visuals.length === 1 && visuals[0].type === "kpi-table" && !visuals[0].content.chart ? actionRows(visuals[0].content) : null;
1550
- // The field starts where the rows' text ends (at most seven of twelve columns, at least five), so each
1551
- // key stands near the row it belongs to instead of across an empty stretch (spec-v2 Amendments 8), as long
1552
- // as the rows and the next step keep the sizes and line counts they have in seven columns.
1553
- const n = Z.b - Z.a + 1;
1554
- if (acts && !ctx.splitCols) {
1555
- const at = (k) => PLANS["closing-contact-split"]({ ...ctx, splitCols: k });
1556
- 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)])));
1557
- const ref = at(7);
1558
- 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));
1559
- for (const k of [5, 6]) {
1560
- if (S.grid.span(Z.a, Z.a + Math.round(n * k / 12) - 1).w < need) continue;
1561
- const plan = at(k);
1562
- if (sig(plan) === sig(ref)) return plan;
1563
- }
1564
- return ref;
1565
- }
1566
- const cols = ctx.splitCols || 7;
1567
- const [lR, fR] = splitRegion(S, Z, cols / 12);
1568
- // The field bleeds off the right and bottom edges; what it holds sits inset from its edges.
1569
- const fieldX = fR.x - S.grid.gutter / 2;
1570
- const inset = 30;
1571
- const F = { ...fR, x: fieldX + inset, w: fR.x + fR.w - fieldX - inset, y: Z.y + inset, bottom: Z.bottom };
1572
- 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 };
1573
- if (acts) {
1574
- // The field is the ask: each row's key (the amount or the date) in line with its row, the rows
1575
- // down the left columns. The next step or contact is a band of the field's colour on the body
1576
- // floor across the left columns, meeting the field, so the two read as one L whose foot holds
1577
- // the step and the field has no empty stretch under its last key.
1578
- // A step at lead size that leaves the rows too little height drops to body size.
1579
- // Amounts add up to the ask: their total closes the field. Beside the step's band it sits on
1580
- // the band's floor, so the field below the keys ends in the sum, not in an empty stretch.
1581
- // Dates do not add up: the field's foot then states how many items run over which span.
1582
- const total = actionTotal(acts) || actionSpan(acts);
1583
- // The band stops at the field's edge. Its text runs on across the field to the field's inset
1584
- // only while the field's foot is empty; with a total there it keeps to the band's own columns.
1585
- const stepW = total ? fieldX - lR.x : F.x + F.w - lR.x;
1586
- for (const small of [false, true]) {
1587
- const step = texts.length ? nextStep(ctx, texts, { ...lR, w: stepW }, "band", { small, panelW: fieldX - lR.x }) : null;
1588
- const foot = step ? step.top + state.blockGap : null;
1589
- const bottom = step ? foot - state.groupGap : Z.bottom;
1590
- const totalH = total ? G.textHeight(total, F.w - inset, S.sizes.lead, 1.3) : 0;
1591
- const totalY = total ? (step ? Z.bottom - totalH - 6 : bottom - totalH) : null;
1592
- const rowsBottom = total && !step ? bottom - totalH - 24 : bottom;
1593
- const rows = placeActions(ctx, acts, { ...lR, y: F.y, bottom: rowsBottom }, { keys: { ...F, bottom: rowsBottom } });
1594
- if (rows) {
1595
- const sum = total ? [{ decor: true, kind: "rect", x: F.x, y: totalY - 12, w: F.w, h: 0.75, fill: "on-field" },
1596
- { kind: "text", paras: [{ kind: "text", text: total, gap: 0, h: totalH }], size: S.sizes.lead, bold: true, onField: true,
1597
- x: F.x, y: totalY, w: F.w - inset, h: totalH, limit: Z.bottom }] : [];
1598
- return [field, ...rows, ...sum, ...(step ? step.placed : [])];
1599
- }
1600
- }
1601
- }
1602
- const out = [field, ...stack(visuals.length ? visuals : texts, lR, S, state).placed];
1603
- if (visuals.length && texts.length) {
1604
- const m = measureText(texts.flatMap(itemParas), F.w, S, state);
1605
- out.push({ ...m, x: F.x, y: F.y, onField: true, limit: Z.bottom });
1606
- }
1607
- return out;
1608
- },
1609
- };
1610
-
1611
- // Families that share another's plan.
1612
- PLANS["step-diagram"] = PLANS.process;
1613
- PLANS.statement = PLANS["text-column"];
1614
-
1615
- /**
1616
- * Headed points as rows: the head bold in the first three columns, the point beside it at lead
1617
- * size when a dozen glyphs a line fit there, rows spread down to the floor with hairlines between.
1618
- */
1619
- function headedRows(ctx, ents) {
1620
- const { S, state, Z } = ctx;
1621
- const headR = region(S, Z.a, Z.a + 2, Z.y, Z.bottom);
1622
- const textR = region(S, Z.a + 3, Z.b, Z.y, Z.bottom);
1623
- const lead = bodySize(S, state, "lead");
1624
- const body = bodySize(S, state);
1625
- const rowsAt = (z) => ents.map((e) => ({ head: e.head, text: e.rest, headH: G.textHeight(e.head, headR.w, z),
1626
- textH: G.textHeight(plainText(e.rest), textR.w, z) })).map((r) => ({ ...r, h: Math.max(r.headH, r.textH) }));
1627
- let size = S.tok.tight ? body : lead;
1628
- let rows = rowsAt(size);
1629
- if (rows.reduce((a, r) => a + r.h, 0) + (rows.length - 1) * state.groupGap > Z.bottom - Z.y) { size = body; rows = rowsAt(body); }
1630
- const pitch = rowPitch(rows.length, Math.max(...rows.map((r) => r.h)), Z, state.groupGap, Math.max(...rows.map((r) => r.h)) + 96);
1631
- rows.forEach((r, i) => { r.y = Z.y + i * pitch; });
1632
- const last = rows[rows.length - 1];
1633
- return [{ kind: "headed", rows, size, headX: headR.x, headW: headR.w, textX: textR.x, textW: textR.w, pitch,
1634
- x: Z.x, w: Z.w, y: Z.y, h: last.y + last.h - Z.y, limit: Z.bottom }];
1635
- }
1636
-
1637
- /** Value rows: each KPI as one row across the body, value first. */
1638
- function figureRows(cards, Z, S, state, spread = null) {
1639
- const n = cards.length;
1640
- const longest = Math.max(...cards.map((c) => S.ems(plainText(c.value), "numeral")));
1641
- const room = (Z.bottom - Z.y - (n - 1) * 24) / n;
1642
- // At most title size (two steps above the body); the value column is as wide as the widest value.
1643
- 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;
1644
- const valueW = Math.min(Math.round(Z.w * 0.5), Math.max(Math.round(Z.w * 0.3), Math.ceil(longest * value * 1.15)));
1645
- const labelX = Z.x + valueW + S.grid.gutter;
1646
- const labelW = Z.x + Z.w - labelX;
1647
- // On the compact step the label is set bold at body size, its basis under it at label size.
1648
- const labelSize = S.tok.tight ? S.sizes.body : bodySize(S, state, "lead");
1649
- const noteSize = S.tok.tight ? S.sizes.label : bodySize(S, { ...state, stepped: false });
1650
- const heights = cards.map((c) => Math.max(value * 1.15, G.textHeight(plainText(c.label), labelW, labelSize)
1651
- + (c.note ? 4 + G.textHeight(plainText(c.note), labelW, noteSize) : 0)));
1652
- // Values run down to the floor, the rows evenly apart (at most `spread` apart beyond the tallest row).
1653
- const pitch = rowPitch(n, Math.max(...heights), Z, S.tok.tight ? state.groupGap : 24, spread == null ? 200 : Math.max(...heights) + spread);
1654
- 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 }));
1655
- 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 };
1656
- }
1657
-
1658
- /**
1659
- * A big-number slide as a data panel: the panel takes seven of twelve columns under the title down to
1660
- * the zone's floor. With two to four figures (a KPI table
1661
- * whose second body row gives each figure's basis) the panel holds one row per figure: the value at
1662
- * title size, its label and its basis beside it. One figure is set at title size with its label on a
1663
- * panel as tall as they are. The
1664
- * evidence stands beside the panel as notes. The pack's display device sets the panel: the field, the
1665
- * accent tint, or the surface inside an ink outline. The panel stays under half the page, so it reads
1666
- * as the figures' ground and not as the page's. A number is never set above title size (S4.7).
1667
- */
1668
- function numberPanel(ctx, table, texts) {
1669
- const { S, state, Z } = ctx;
1670
- const c = table.content || {};
1671
- const cards = shared().kpiCards(c).slice(0, 6).filter((k) => plainText(k.value));
1672
- const device = S.pack.display.number;
1673
- const [pR, eR] = texts.length ? splitRegion(S, Z, 7 / 12) : [Z, null];
1674
- const pad = Math.max(18, S.tok.pad);
1675
- const inner = pR.w - pad * 2;
1676
- const panelH = pR.bottom - pR.y;
1677
- const role = device === "field" ? { fill: "field", number: "on-field", label: "on-field", note: "on-field" }
1678
- : device === "tint" ? { fill: "accent-tint", number: "accent", label: "ink", note: "ink" }
1679
- : { fill: "surface", line: "ink", number: "accent", label: "ink", note: "ink-muted" };
1680
- const out = [{ kind: "panel", x: pR.x, y: pR.y, w: pR.w, h: panelH, fill: role.fill, line: role.line, limit: Z.bottom }];
1681
- const capH = table.caption ? captionHeight(table.caption, inner, S) + 6 : 0;
1682
- if (cards.length >= 2 || (cards[0] && cards[0].note)) {
1683
- // One row per figure, rows spread over the panel, the caption at the panel's foot.
1684
- const R = { x: pR.x + pad, w: inner, y: pR.y + pad, bottom: pR.bottom - pad - capH, a: pR.a, b: pR.b };
1685
- const rows = figureRows(cards, R, S, state);
1686
- out.push({ ...rows, colour: role.number, labelColour: role.label, noteColour: role.note });
1687
- 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 });
1688
- } else {
1689
- const value = plainText((cards[0] || {}).value || ((c.rows || [])[0] || [])[0] || "");
1690
- const label = plainText((cards[0] || {}).label || (c.headers || [])[0] || "");
1691
- const labelSize = bodySize(S, { ...state, stepped: false }, "lead");
1692
- const size = [S.sizes.title, S.sizes.lead].find((v) => S.ems(value, "numeral") * v * 1.04 <= inner) || S.sizes.body;
1693
- const labelH = label ? G.textHeight(label, inner, labelSize) : 0;
1694
- const blockH = size * 1.15 + (label ? 12 + labelH : 0) + capH;
1695
- // One figure at title size: the panel hugs it instead of standing as an empty field.
1696
- out[0].h = Math.min(panelH, Math.round(blockH + pad * 2));
1697
- const y = Math.round(pR.y + pad);
1698
- 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 });
1699
- 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 });
1700
- }
1701
- if (eR) {
1702
- const R = region(S, eR.a, eR.b, pR.y, pR.bottom);
1703
- // The evidence reads as notes on the figures: plain lines, no list markers.
1704
- const paras = texts.flatMap(itemParas).map((q) => ({ ...q, kind: q.kind === "section" ? "section" : "text" }));
1705
- const labelSize = bodySize(S, { ...state, stepped: false }, "lead");
1706
- const evidence = R.w >= 12 * labelSize * 1.1 ? labelSize : bodySize(S, { ...state, stepped: false });
1707
- let m = measureText(paras, R.w, S, { ...state, itemGap: Math.max(state.itemGap, 12) }, { size: evidence });
1708
- if (m.h > panelH) m = measureText(paras, R.w, S, state);
1709
- out.push({ ...m, x: R.x, y: Math.round(pR.y + Math.max(0, (panelH - m.h) / 2)), limit: Z.bottom });
1710
- }
1711
- return out;
1712
- }
1713
-
1714
- // A cell that is an amount: digits, an optional Korean unit word, an optional currency or percent.
1715
- const AMOUNT = /^(\d[\d,.]*)\s*([조억만천]*)\s*(원|달러|USD|EUR|KRW|%)?$/u;
1716
- const WHEN = /기한|시점|일정|날짜|마감|언제|when|date|due|deadline/iu;
1717
-
1718
- /**
1719
- * A closing's table read as action rows. The key is the column of amounts in one unit (they add up
1720
- * to the ask), else the column headed as a date or deadline, else the last column; the row's first
1721
- * cell is what is asked or done, the other cells (owner, timing) its detail.
1722
- */
1723
- function actionRows(content) {
1724
- const headers = (content.headers || []).map((h) => plainText(h));
1725
- // A totals row is not an action: the ask line (or the field's total) carries the sum.
1726
- const rows = (content.rows || []).map((r) => r.map((cell) => plainText(cell).trim()))
1727
- .filter((r, i, all) => !(all.length > 1 && i === all.length - 1 && TOTALS.test(r[0] || "")));
1728
- if (rows.length < 1 || rows.length > 5 || headers.length < 2) return null;
1729
- // A bare number under a head that names its unit ("Budget (k USD)") carries that unit, as a key
1730
- // and in a row's detail, so no amount stands on the page without it.
1731
- const units = headers.map((h) => (/\(([^()]{1,12})\)\s*$/u.exec(h) || [])[1] || null);
1732
- const withUnit = (cell, j) => (units[j] && /^\d[\d,.]*$/u.test(cell) ? joinUnit(cell, units[j]) : cell);
1733
- let key = -1;
1734
- let kind = "date";
1735
- for (let j = 1; j < headers.length && key < 0; j++) {
1736
- const m = rows.map((r) => AMOUNT.exec(r[j] || ""));
1737
- if (m.every((x) => x && (x[2] || x[3])) && new Set(m.map((x) => `${x[2]}${x[3] || ""}`)).size === 1) {
1738
- key = j;
1739
- kind = "amount";
1740
- } else if (units[j] && !/%/u.test(units[j]) && rows.every((r) => /^\d[\d,.]*$/u.test(r[j] || ""))) {
1741
- key = j;
1742
- kind = "amount";
1743
- }
1744
- }
1745
- if (key < 0) key = headers.findIndex((h, j) => j > 0 && WHEN.test(h));
1746
- const korean = G.isKorean(headers.join(" ") + rows.map((r) => r[0]).join(" "));
1747
- if (key < 0) key = headers.length - 1;
1748
- return {
1749
- kind,
1750
- rows: rows.map((r) => ({
1751
- key: withUnit(r[key] || "", key),
1752
- num: kind === "amount" ? /^\d[\d,.]*/u.exec(r[key])[0] : null,
1753
- head: r[0] || "",
1754
- // An empty or dash-only cell ("—") says nothing about the row and is left out of its detail.
1755
- meta: r.map(withUnit).filter((cell, j) => j !== 0 && j !== key && cell && !/^[—–-]+$/u.test(cell)).join(" · "),
1756
- value: kind === "amount" ? parseFloat(/^\d[\d,.]*/u.exec(r[key])[0].replace(/,/gu, "")) : null,
1757
- })),
1758
- korean,
1759
- };
1760
- }
1761
-
1762
- /** "30k USD", "14억 원", "12 L": a figure with its unit, joined the way the unit is written. */
1763
- function joinUnit(n, unit) {
1764
- return /^(%|\p{Script=Hangul}|[kKMB](\s|$))/u.test(unit) ? `${n}${unit}` : `${n} ${unit}`;
1765
- }
1766
-
1767
- /** "합계 30억 원": the rows' amounts summed and written in the unit the keys use, or null. */
1768
- function actionTotal(acts) {
1769
- if (!acts || acts.kind !== "amount" || acts.rows.length < 2) return null;
1770
- const sum = acts.rows.reduce((a, r) => a + r.value, 0);
1771
- const digits = Math.max(...acts.rows.map((r) => ((/\.(\d+)/u.exec(r.num) || [, ""])[1]).length));
1772
- const commas = acts.rows.some((r) => r.key.includes(","));
1773
- const n = commas ? sum.toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits }) : sum.toFixed(digits);
1774
- return `${acts.korean ? "합계" : "Total"} ${acts.rows[0].key.replace(/^\d[\d,.]*/u, n)}`;
1775
- }
1776
-
1777
- /** "안건 4건 · 10월 셋째 주 – 11월 첫째 주": the count of date-keyed rows and their first and last date, or null. */
1778
- function actionSpan(acts) {
1779
- if (!acts || acts.kind !== "date" || acts.rows.length < 2) return null;
1780
- const first = acts.rows[0].key;
1781
- const last = acts.rows[acts.rows.length - 1].key;
1782
- const n = acts.rows.length;
1783
- const count = acts.korean ? `안건 ${n}건` : `${n} items`;
1784
- return first && last && first !== last ? `${count} · ${first} – ${last}` : count;
1785
- }
1786
-
1787
- /**
1788
- * Action rows down a region: the key large on the left (or in `o.keys`, a field beside the rows),
1789
- * what is asked bold at lead size with its detail under it, and for amounts a bar as long as the
1790
- * row's share of the total. The free height is shared out as equal gaps between the rows (and
1791
- * before the next step when one follows), so the rows and the step fill the body together.
1792
- */
1793
- function placeActions(ctx, acts, R, o = {}) {
1794
- const { S, state } = ctx;
1795
- const n = acts.rows.length;
1796
- const keyR = o.keys || region(S, R.a, R.a + 2, R.y, R.bottom);
1797
- const textR = o.keys ? R : region(S, R.a + 3, R.b, R.y, R.bottom);
1798
- const longest = Math.max(...acts.rows.map((r) => S.ems(r.key, "numeral")));
1799
- const sizes = [S.sizes.title, S.sizes.lead, S.sizes.body];
1800
- const total = acts.kind === "amount" ? acts.rows.reduce((a, r) => a + r.value, 0) : 0;
1801
- const gaps = o.last ? n : Math.max(1, n - 1);
1802
- // At lead size first; rows that do not fit step down (lead to body, body to label), then the
1803
- // key steps down the ramp until the rows fit.
1804
- const fit = (step) => {
1805
- const fitting = sizes.filter((v) => v && longest * v * 1.04 <= keyR.w);
1806
- const keySize = fitting[Math.min(step, fitting.length - 1)] || S.sizes.body;
1807
- const head = step ? S.sizes.body : S.sizes.lead;
1808
- const meta = step ? S.sizes.label : S.sizes.body;
1809
- const rows = acts.rows.map((r) => {
1810
- const headH = G.textHeight(r.head, textR.w, head);
1811
- const metaH = r.meta ? G.textHeight(r.meta, textR.w, meta) : 0;
1812
- const bar = total > 0 ? (o.keys ? 14 : 18) : 0;
1813
- // On the field the share bar runs under the key; beside the rows it runs under the text.
1814
- const h = o.keys ? Math.max(keySize * 1.15 + bar, headH + (metaH ? 6 + metaH : 0))
1815
- : Math.max(keySize * 1.15, headH + (metaH ? 6 + metaH : 0) + bar);
1816
- return { ...r, headH, metaH, bar, h };
1817
- });
1818
- const sum = rows.reduce((a, r) => a + r.h, 0);
1819
- return { keySize, head, meta, rows, room: R.bottom - R.y - sum - gaps * state.itemGap };
1820
- };
1821
- let chosen = fit(0);
1822
- for (let step = 1; chosen.room < 0 && step <= 3; step++) chosen = fit(step);
1823
- if (chosen.room < 0) return null;
1824
- const { keySize, head, meta, rows } = chosen;
1825
- const sum = rows.reduce((a, r) => a + r.h, 0);
1826
- // Rows sit at most 96 pt apart (wider gaps read as separate blocks, and at reading sizes left one
1827
- // empty band between two short rows); what is left over is shared above and below the rows.
1828
- const gap = Math.max(state.itemGap, Math.min(96, (R.bottom - R.y - sum) / gaps));
1829
- const spare = Math.max(0, R.bottom - R.y - sum - gap * gaps);
1830
- let y = R.y + Math.round(spare / 2);
1831
- for (const r of rows) { r.y = y; y += r.h + gap; }
1832
- const h = rows[n - 1].y + rows[n - 1].h - R.y;
1833
- return [{ kind: "actions", rows, keyX: keyR.x, keyW: keyR.w, keySize, onField: Boolean(o.keys), textX: textR.x, textW: textR.w,
1834
- 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 }];
1835
- }
1836
-
1837
- /**
1838
- * The next step of a closing, set at lead size on the body floor in the pack's closing device: a
1839
- * band of the field across the region (or `o.panelW` of it, where a field drawn beside continues
1840
- * it; text in the field's colour), a tinted or outlined box, a
1841
- * rule above the line, or (field) a rule above the line inside a field already drawn. A label
1842
- * before a colon is set bold. Returns the placements and its top.
1843
- */
1844
- function nextStep(ctx, texts, R, device, o = {}) {
1845
- const { S, state } = ctx;
1846
- const lead = bodySize(S, { ...state, stepped: false }, "lead");
1847
- const ruled = device === "rules" || device === "field";
1848
- const pad = ruled ? 0 : Math.max(18, S.tok.pad);
1849
- // Each point keeps its own line; a source line is a note at label size. Lines keep a readable
1850
- // measure (S4.4) inside the band.
1851
- const paras = texts.flatMap(itemParas).map((p) => plainText(p.text));
1852
- const notes = paras.filter((t) => /^(출처|자료|sources?)\b/iu.test(t));
1853
- const points = paras.filter((t) => !notes.includes(t)).map((t) => t.replace(/^([^::]{1,16})([::])\s*/u, "**$1$2** "));
1854
- const size = points.length > 2 || o.small ? S.sizes.body : lead;
1855
- const box = R.w - pad * 2;
1856
- const inner = Math.min(box, (G.isKorean(paras.join("")) ? 34 : 70) * size * (G.isKorean(paras.join("")) ? 1 : 0.5));
1857
- // A line that fits the box on one line takes the box's width; a longer one keeps the reading measure, set
1858
- // as narrow as keeps its line count so its lines come out even and none ends on a lone word (Amendments 8).
1859
- const widthOf = (t, z) => {
1860
- if (G.lineCount(plainText(t), box, z) <= 1) return box;
1861
- const n = G.lineCount(plainText(t), inner, z);
1862
- let lo = inner / 2;
1863
- let hi = inner;
1864
- 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; }
1865
- return Math.min(inner, Math.ceil(hi + 2 * z));
1866
- };
1867
- const items = [...points.map((t) => ({ text: t, size })), ...notes.map((t) => ({ text: t, size: S.sizes.label }))]
1868
- .map((q) => { const w = widthOf(q.text, q.size); return { ...q, w, h: G.textHeight(plainText(q.text), w, q.size) }; });
1869
- const th = items.reduce((a, q, i) => a + q.h + (i ? 6 : 0), 0);
1870
- const top = ruled ? R.bottom - th - 18 : R.bottom - th - pad * 2;
1871
- const placed = [];
1872
- const outline = device === "box" && S.deco.has("box-outline");
1873
- 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 });
1874
- 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 });
1875
- else placed.push({ decor: true, kind: "rect", x: R.x, y: top, w: R.w, h: 0.75, fill: "line" });
1876
- let y = ruled ? top + 18 : top + pad;
1877
- for (const q of items) {
1878
- 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,
1879
- onField: device === "band" || device === "field", tinted: device === "box" && !outline, muted: q.size === S.sizes.label, limit: R.bottom });
1880
- y += q.h + 6;
1881
- }
1882
- return { placed, top: top - state.blockGap };
1883
- }
1884
-
1885
- // ── Draw ────────────────────────────────────────────────────────────────────
1886
-
1887
- function drawPlaced(slide, S, p, ctx) {
1888
- const A = shared();
1889
- const c = (p.item && p.item.content) || {};
1890
- if (p.kind === "group") { for (const q of p.parts) drawPlaced(slide, S, q, ctx); return; }
1891
- if (p.kind === "rect") { packRect(slide, S, p, { fill: p.fill }); return; }
1892
- if (p.kind === "panel") { packRect(slide, S, p, { fill: p.fill, line: p.line, lineWidth: 1, radius: S.pack.radius }); return; }
1893
- if (p.kind === "actions") {
1894
- const ink = S.colour(p.onField ? "on-field" : "accent");
1895
- p.rows.forEach((r, i) => {
1896
- if (i > 0) packRect(slide, S, { x: p.textX, y: r.y - p.gap / 2, w: p.textW, h: 0.75 }, { fill: "line" });
1897
- 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 });
1898
- packText(slide, S, r.head, { x: p.textX, y: r.y, w: p.textW, h: r.headH }, { size: p.head, bold: true });
1899
- 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") });
1900
- if (r.bar) {
1901
- // The row's share of the ask: a bar on a full-width track, under the key on the field.
1902
- const [bx, bw] = p.onField ? [p.keyX, p.keyW] : [p.textX, p.textW];
1903
- const by = p.onField ? r.y + p.keySize * 1.15 + 8 : r.y + r.headH + (r.metaH ? 6 + r.metaH : 0) + 12;
1904
- packRect(slide, S, { x: bx, y: by, w: bw, h: 6 }, { fill: p.onField ? "ink-muted" : "accent-tint" });
1905
- packRect(slide, S, { x: bx, y: by, w: Math.max(4, (bw * r.value) / p.total), h: 6 }, { fill: p.onField ? "on-field" : "accent" });
1906
- }
1907
- });
1908
- return;
1909
- }
1910
- if (p.kind === "box") {
1911
- if (p.outline) packRect(slide, S, p, { line: "ink", lineWidth: S.pack["edge-weight"] || 1, ...hardEdge(S, "ground") });
1912
- else if (p.tint) packRect(slide, S, p, { fill: "accent-tint", radius: S.pack.radius, ...hardEdge(S) });
1913
- else surfaceRect(slide, S, p);
1914
- return;
1915
- }
1916
- if (p.kind === "text") {
1917
- let y = p.y;
1918
- const ink = p.onField ? S.colour("on-field") : p.tinted ? S.colour("accent-deep") : S.colour("ink");
1919
- const soft = p.onField ? S.colour("on-field") : S.colour("ink-muted");
1920
- for (const para of p.paras) {
1921
- y += para.gap;
1922
- // The marker is a small dot centred on the first line: a shape, so no renderer swaps in a
1923
- // symbol font for it and no checker reads it as a column of text.
1924
- if (para.kind === "bullet") {
1925
- const d = Math.max(4, Math.round(p.size * 0.28));
1926
- const lineH = p.size * G.leading(para.text);
1927
- packRect(slide, S, { x: p.x, y: y + (lineH - d) / 2, w: d, h: d }, { fill: p.onField ? "on-field" : "accent" });
1928
- }
1929
- 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 }, {
1930
- size: p.size, bold: p.bold || para.kind === "section",
1931
- colour: p.accent ? S.colour("accent-deep") : para.kind === "child" || p.muted ? soft : ink,
1932
- });
1933
- y += para.h;
1934
- }
1935
- return;
1936
- }
1937
- if (p.kind === "callout") {
1938
- packRect(slide, S, p, { fill: "accent-tint", radius: S.pack.radius, ...hardEdge(S) });
1939
- 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 },
1940
- { size: p.size, bold: true, colour: S.colour("accent-deep") });
1941
- return;
1942
- }
1943
- if (p.kind === "kpi") {
1944
- p.cards.forEach((card, i) => {
1945
- const x = p.x + i * (p.cardW + S.grid.gutter);
1946
- surfaceRect(slide, S, { x, y: p.y, w: p.cardW, h: p.cardH });
1947
- const inner = p.cardW - p.pad * 2;
1948
- const valueH = p.value * 1.15;
1949
- packText(slide, S, plainText(card.value), { x: x + p.pad, y: p.y + p.pad, w: inner, h: valueH },
1950
- { face: "numeral", size: p.value, lineSpacing: 1.15, colour: S.colour(i === 0 ? "accent" : "ink") });
1951
- packText(slide, S, plainText(card.label), { x: x + p.pad, y: p.y + p.pad + valueH + 6, w: inner, h: p.labelH },
1952
- { size: S.sizes.label, colour: S.colour("ink-muted"), lineSpacing: 1.3 });
1953
- 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 },
1954
- { size: p.noteSize, colour: S.colour("ink"), lineSpacing: 1.3 });
1955
- });
1956
- drawCaption(slide, S, p.item.caption, p.x, p.y + p.cardH + 6, p.w);
1957
- return;
1958
- }
1959
- if (p.kind === "figrows") {
1960
- p.rows.forEach((r, i) => {
1961
- 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" });
1962
- packText(slide, S, r.value, { x: p.x, y: r.y, w: p.valueW, h: p.value * 1.15 },
1963
- { face: "numeral", size: p.value, lineSpacing: 1.15, colour: S.colour(p.colour || (i === 0 ? "accent" : "ink")) });
1964
- const lh = G.textHeight(r.label, p.labelW, p.labelSize);
1965
- const nh = r.note ? G.textHeight(r.note, p.labelW, p.noteSize) : 0;
1966
- // The label reads beside the value; the basis under the label.
1967
- 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 });
1968
- 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") });
1969
- });
1970
- return;
1971
- }
1972
- if (p.kind === "rows") {
1973
- p.rows.forEach((r, i) => {
1974
- const right = p.restX != null ? p.restX + p.restW : p.textX + p.textW;
1975
- 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" });
1976
- const numSize = p.numSize || p.head;
1977
- 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 });
1978
- const hh = G.textHeight(r.head, p.textW, p.head);
1979
- packText(slide, S, r.head, { x: p.textX, y: r.y, w: p.textW, h: hh }, { size: p.head, bold: true });
1980
- // Beside the name (restX) or under it.
1981
- 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 });
1982
- 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") });
1983
- });
1984
- return;
1985
- }
1986
- if (p.kind === "headed") {
1987
- p.rows.forEach((r, i) => {
1988
- 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" });
1989
- 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") });
1990
- packText(slide, S, r.text, { x: p.textX, y: r.y, w: p.textW, h: r.textH }, { size: p.size });
1991
- });
1992
- return;
1993
- }
1994
- if (p.kind === "steps") {
1995
- p.steps.forEach((s) => {
1996
- 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 });
1997
- const ruleY = p.y + p.numSize * 1.1 + 6;
1998
- packRect(slide, S, { x: s.x, y: ruleY, w: s.w, h: 0.75 }, { fill: "line" });
1999
- packText(slide, S, s.head, { x: s.x, y: ruleY + 12, w: s.w, h: s.headH }, { size: p.headSize, bold: true });
2000
- 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") });
2001
- });
2002
- return;
2003
- }
2004
- if (p.kind === "timeline") {
2005
- packRect(slide, S, { x: p.x, y: p.axisY, w: p.w, h: 1.5 }, { fill: "line" });
2006
- p.events.forEach((e, i) => {
2007
- packRect(slide, S, { x: e.x, y: p.axisY - 4, w: 9, h: 9 }, { fill: i === p.events.length - 1 ? "accent" : "ink-muted" });
2008
- const dh = G.textHeight(e.date, e.w, p.dateSize, 1.25);
2009
- 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 });
2010
- packText(slide, S, e.label, { x: e.x, y: p.axisY + 18, w: e.w, h: e.labelH }, { size: p.labelSize });
2011
- 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 });
2012
- });
2013
- return;
2014
- }
2015
- if (p.kind === "matrix") {
2016
- const label = S.sizes.label;
2017
- 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 }));
2018
- 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 }));
2019
- const axis = [p.yName && `↑ ${p.yName}`, p.xName && `→ ${p.xName}`].filter(Boolean).join(" ");
2020
- if (axis) {
2021
- // The axis names sit at the foot of the label column, as tall as they wrap in it.
2022
- const h = G.textHeight(axis, p.labels.w, label, 1.3);
2023
- 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 });
2024
- }
2025
- p.cells.forEach((cell) => {
2026
- packRect(slide, S, cell, { line: "line", lineWidth: 0.75 });
2027
- const w = cell.w - p.pad * 2;
2028
- // The item and its details stand in the middle of the quadrant, so a short cell reads as placed.
2029
- const blockH = cell.headH + cell.details.reduce((a, d) => a + 4 + d.h, 0);
2030
- let y = cell.y + Math.max(p.pad, Math.round((cell.h - blockH) / 2));
2031
- packText(slide, S, cell.head, { x: cell.x + p.pad, y, w, h: cell.headH }, { size: p.head, bold: true, lineSpacing: 1.3 });
2032
- y += cell.headH;
2033
- for (const d of cell.details) {
2034
- y += 4;
2035
- packText(slide, S, d.text, { x: cell.x + p.pad, y, w, h: d.h }, { size: p.detail, colour: S.colour("ink-muted") });
2036
- y += d.h;
2037
- }
2038
- });
2039
- if (p.caption) drawCaption(slide, S, p.caption, p.grid.x, p.top + 2 * p.qh + p.gap + 6, p.grid.w);
2040
- return;
2041
- }
2042
- if (p.kind === "quote") {
2043
- 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 });
2044
- 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 });
2045
- 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 });
2046
- return;
2047
- }
2048
- if (p.kind === "number") {
2049
- 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 });
2050
- 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") });
2051
- return;
2052
- }
2053
- if (p.kind === "table") {
2054
- drawPackTable(slide, S, c, p, ctx.title);
2055
- drawCaption(slide, S, p.item.caption, p.x, p.y + p.tableH + 6, p.w);
2056
- return;
2057
- }
2058
- if (p.kind === "chart") {
2059
- drawChart(slide, S, c, p);
2060
- drawCaption(slide, S, p.item.caption, p.x, p.y + p.h - p.cap + 6, p.w);
2061
- return;
2062
- }
2063
- if (p.kind === "image") {
2064
- const images = p.item.type === "image-grid" ? c.images || [] : [c];
2065
- const h = p.h - p.cap;
2066
- const cellW = (p.w - (images.length - 1) * S.grid.gutter) / Math.max(1, images.length);
2067
- let bottom = p.y;
2068
- images.forEach((image, i) => {
2069
- const file = forGround(A.resolveImagePath(image.src, ctx.sourceDir), S);
2070
- let fit = A.containBox(IN(p.x + i * (cellW + S.grid.gutter)), IN(p.y), IN(cellW), IN(h), A.readImageSize(file));
2071
- const low = IN(p.y + h) - fit.h;
2072
- if (p.beside != null && images.length === 1 && low * 72 <= p.beside) fit = { ...fit, y: low };
2073
- slide.addImage({ path: file, ...fit, altText: image.caption || path.basename(image.src || file) });
2074
- 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 });
2075
- bottom = Math.max(bottom, (fit.y + fit.h) * 72);
2076
- });
2077
- // The caption binds to the picture as drawn: a letterboxed figure keeps its caption under it.
2078
- drawCaption(slide, S, p.item.caption, p.x, bottom + 6, p.w);
2079
- return;
2080
- }
2081
- if (p.kind === "caption") drawCaption(slide, S, p.item.content, p.x, p.y, p.w, p.role === "on-field" ? "on-field" : "ink-muted");
2082
- }
2083
-
2084
- /**
2085
- * A figure on a dark ground is drawn from its dark variant when the source folder has one beside it
2086
- * (`flow.png` → `flow.dark.png`): a chart or diagram exported on white would stand as a white card.
2087
- */
2088
- function forGround(file, S) {
2089
- const c = (i) => parseInt(String(S.P.ground).replace("#", "").slice(i, i + 2), 16) / 255;
2090
- if (0.2126 * c(0) + 0.7152 * c(2) + 0.0722 * c(4) >= 0.25) return file;
2091
- const ext = path.extname(file);
2092
- const dark = `${file.slice(0, file.length - ext.length)}.dark${ext}`;
2093
- return require("fs").existsSync(dark) ? dark : file;
2094
- }
2095
-
2096
- function drawCaption(slide, S, caption, x, y, w, role = "ink-muted") {
2097
- if (!caption) return;
2098
- const text = captionText(caption);
2099
- packText(slide, S, text, { x, y, w, h: G.textHeight(text, w, S.sizes.label, 1.3) },
2100
- { size: S.sizes.label, colour: S.colour(role), lineSpacing: 1.3 });
2101
- }
2102
-
2103
- // Series names that are a reference for the measured one: a plan, target, budget, baseline, prior period.
2104
- const REFERENCE = /계획|목표|예산|전년|전기|기준|이전|기존|평균|plan|target|budget|baseline|benchmark|forecast|prior|previous|last year|average/iu;
2105
-
2106
- /** A series name's period as one comparable number (year, then half, quarter or month), or null. */
2107
- function periodOf(name) {
2108
- const t = plainText(name);
2109
- const year = /(?:^|\D)((?:19|20)\d{2})(?!\d)/u.exec(t) || /(?:^|[^\d.])(\d{2})년/u.exec(t);
2110
- const quarter = /\bQ([1-4])\b|\b([1-4])Q\b|([1-4])\s*분기/iu.exec(t);
2111
- const half = /\bH([12])\b|([상하])반기/iu.exec(t);
2112
- 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);
2113
- const months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
2114
- const within = quarter ? 3 * Number(quarter[1] || quarter[2] || quarter[3])
2115
- : half ? 6 * (half[1] ? Number(half[1]) : half[2] === "상" ? 1 : 2)
2116
- : month ? (month[1] ? Number(month[1]) : months.indexOf(month[2].slice(0, 3).toLowerCase()) + 1) : null;
2117
- if (!year && within == null) return null;
2118
- const y = year ? Number(year[1].length === 2 ? `20${year[1]}` : year[1]) : 0;
2119
- return y * 100 + (within || 0);
2120
- }
2121
-
2122
- /**
2123
- * The series a chart highlights: the latest period when every series names one, else the one measured
2124
- * series beside its plans, targets or prior periods, else the last series (where a comparison puts the
2125
- * proposed or current one).
2126
- */
2127
- function primarySeries(names) {
2128
- const periods = names.map(periodOf);
2129
- if (periods.every((v) => v != null) && new Set(periods).size === periods.length) return periods.indexOf(Math.max(...periods));
2130
- const measured = names.map((n, i) => (REFERENCE.test(plainText(n)) ? -1 : i)).filter((i) => i >= 0);
2131
- if (measured.length && measured.length < names.length) return measured[measured.length - 1];
2132
- return names.length - 1;
2133
- }
2134
-
2135
- /** A series name without its unit or case, so "Single feed (%)" and "single feed" are one series. */
2136
- function seriesKey(name) {
2137
- return plainText(name).replace(/\s*[((][^))]*[))]\s*$/u, "").trim().toLowerCase();
2138
- }
2139
-
2140
- /**
2141
- * A native chart in the pack's chart style: one hue per series, the accent on the deck's one highlighted
2142
- * series (primarySeries), the others receding (accent-on-muted) or in the pack's other series hues.
2143
- */
2144
- function drawChart(slide, S, c, p) {
2145
- const P = S.P;
2146
- const chart = S.pack.chart || {};
2147
- const series = (c.headers || []).length - 1;
2148
- const muted = mix(P["ink-muted"], P.ground, 0.45);
2149
- let colours;
2150
- if (series <= 1) {
2151
- // One series is one hue (a per-point highlight would make the chart read as categories): the accent,
2152
- // unless the deck shows the same series receding beside another, where it keeps that colour.
2153
- const other = S.seriesRole && S.seriesRole.get(seriesKey((c.headers || [])[1])) === "other";
2154
- const receding = chart.highlight === "accent-on-muted" ? muted : P.series.find((h) => String(h).toUpperCase() !== String(P.accent).toUpperCase()) || muted;
2155
- colours = [other ? receding : P.accent];
2156
- } else {
2157
- const primary = primarySeries(c.headers.slice(1));
2158
- const others = chart.highlight === "accent-on-muted" ? (series === 2 ? [muted] : P.series.slice(1, series).reverse())
2159
- : P.series.filter((h) => String(h).toUpperCase() !== String(P.accent).toUpperCase());
2160
- let k = 0;
2161
- colours = Array.from({ length: series }, (_, i) => (i === primary ? P.accent : others[k++ % others.length]));
2162
- }
2163
- // Without a value axis, the top data label needs headroom inside the plot.
2164
- const values = (c.rows || []).flatMap((r) => r.slice(1).map((v) => Number(plainText(v).replace(/[^\d.\-]/gu, "")))).filter(Number.isFinite);
2165
- const top = values.length ? Math.max(...values) : 0;
2166
- const style = {
2167
- series: colours, ink: P.ink, ink_muted: P["ink-muted"], line: P.line,
2168
- titleFont: S.faces.title.font, bodyFont: S.faces.body.font, labelSize: S.sizes.label,
2169
- grid: chart.gridlines !== "none", valAxisHidden: chart.gridlines === "none" && chart.labels === "direct",
2170
- ...(top > 0 && !(c.chart && ["pie", "doughnut"].includes(c.chart.type)) ? { valMax: niceCeil(top * 1.15) } : {}),
2171
- };
2172
- const bottom = p.y + p.h - p.cap;
2173
- shared().renderChart(slide, c, { x: IN(p.x), y: IN(p.y), w: IN(p.w), h: IN(bottom - p.y) }, style, IN(bottom));
2174
- }
2175
-
2176
- /** A round axis maximum at or above v (1, 2 or 5 times a power of ten). */
2177
- function niceCeil(v) {
2178
- const p = 10 ** Math.floor(Math.log10(v));
2179
- return [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].map((m) => m * p).find((x) => x >= v);
2180
- }
2181
-
2182
- // A totals row's first cell; a word boundary after Hangul needs the lookahead (\b reads ASCII only).
2183
- const TOTALS = /^(합계|총계|소계|계|total|sum)(?![\p{L}\p{N}])/iu;
2184
-
2185
- /** A table in the pack's table style: header fill, rules and banding from the pack, numbers right-aligned. */
2186
- function drawPackTable(slide, S, c, p, title) {
2187
- const A = shared();
2188
- const headers = c.headers || [];
2189
- // Every row carries one cell per column, so a short source row cannot leave a ragged table.
2190
- const rows = (c.rows || []).map((r) => headers.map((_, i) => (r[i] != null ? r[i] : "")));
2191
- if (!headers.length) return;
2192
- const t = S.pack.table || {};
2193
- const numeric = A.numericColumns(headers, rows);
2194
- const hair = { type: "solid", pt: 0.75, color: S.colour("line") };
2195
- const heavy = (pt) => ({ type: "solid", pt, color: S.colour("ink") });
2196
- const none = { type: "none" };
2197
- const headerFill = t.header && t.header !== "none" ? S.colour(t.header) : null;
2198
- const headerInk = S.colour(t["header-ink"] || (t.header === "field" ? "on-field" : "ink"));
2199
- const lastIsTotal = rows.length > 1 && TOTALS.test(plainText(rows[rows.length - 1][0]));
2200
- const titleText = plainText(title);
2201
- const protagonist = t.protagonist && t.protagonist !== "none"
2202
- ? rows.findIndex((r) => { const k = plainText(r[0]); return k.length >= 2 && titleText.includes(k); })
2203
- : -1;
2204
- // [top, right, bottom, left] for the header (ri = -1) and each data row.
2205
- const border = (ri) => {
2206
- const last = ri === rows.length - 1;
2207
- switch (t.rules) {
2208
- 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);
2209
- case "booktabs": return [ri === -1 ? heavy(1) : none, none, ri === -1 ? heavy(0.5) : last ? heavy(1) : none, none];
2210
- case "top-bottom": return [ri === -1 ? hair : none, none, last ? hair : ri === -1 ? hair : none, none];
2211
- case "header-rule": return [none, none, ri === -1 ? heavy(2) : none, none];
2212
- case "rows": return [none, none, hair, none];
2213
- default: // header-and-totals
2214
- return [last && lastIsTotal ? hair : none, none, ri === -1 ? hair : none, none];
2215
- }
2216
- };
2217
- const cellMargin = [IN(6), IN(6), IN(6), IN(6)];
2218
- // Cell text that wraps is broken at spaces here, as in body text (see G.keepLines).
2219
- const keep = (text, ci, ri, size, role) => G.keepLines(text, ((p.widths[ci] || p.w) - 12) / S.wide(role, text) / size,
2220
- Math.floor(((p.heights[ri + 1] || 0) - 12) / (size * 1.45) + 0.01));
2221
- const tableRows = [headers.map((h, ci) => ({
2222
- text: keep(plainText(h), ci, -1, p.header, "label"),
2223
- options: { bold: true, color: headerInk, fontFace: S.faces.label.font, fontSize: p.header, align: numeric[ci] ? "right" : "left", valign: "middle",
2224
- margin: cellMargin, border: border(-1), ...(headerFill ? { fill: { color: headerFill } } : {}) },
2225
- }))];
2226
- rows.forEach((r, ri) => {
2227
- const total = lastIsTotal && ri === rows.length - 1 && t.totals === "bold";
2228
- const band = t.banding && t.banding !== "none";
2229
- tableRows.push(r.map((cell, ci) => A.linkedTableCell(typeof cell === "string" && !/\]\(/u.test(cell) ? keep(cell, ci, ri, p.data, "body") : cell, {
2230
- color: S.colour("ink"), fontFace: S.faces.body.font, fontSize: p.data, bold: total,
2231
- align: numeric[ci] ? "right" : "left", valign: "middle", margin: cellMargin, border: border(ri),
2232
- ...(ri === protagonist ? { fill: { color: S.colour(t.protagonist) } } : band && ci === 0 ? { fill: { color: S.colour(t.banding) } } : {}),
2233
- })));
2234
- });
2235
- slide.addTable(tableRows, {
2236
- // The frame is as tall as its rows; without h the frame is declared 1in whatever the rows need.
2237
- 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,
2238
- });
2239
- }
2240
-
2241
- // ── Fill and treatment choice ───────────────────────────────────────────────
2242
-
2243
- /** Bottom of the content, decoration excluded. */
2244
- function contentBottom(placed, top) {
2245
- const counted = placed.filter((p) => !p.decor);
2246
- return counted.length ? Math.max(...counted.map((p) => p.y + p.h)) : top;
2247
- }
2248
-
2249
- function overflows(placed) {
2250
- return placed.some((p) => !p.decor && p.limit != null && p.y + p.h > p.limit + 0.5);
2251
- }
2252
-
2253
- /**
2254
- * The zones of one treatment frame: body Z and where the empty band is measured from.
2255
- * Every treatment's body is the shared body zone under the title zone, so the class is "top".
2256
- */
2257
- function zonesOf(frame, S) {
2258
- const t = frame.title;
2259
- const cls = "top";
2260
- if (!frame.body) return { cls: "none" };
2261
- const Z = region(S, frame.body.a, frame.body.b, frame.body.y, frame.body.bottom);
2262
- return { cls, Z, bandTop: Math.min(t.y + t.h, Z.y) };
2263
- }
2264
-
2265
- /**
2266
- * Lay a content slide out under one frame and, when the body leaves more than the density band
2267
- * empty, try the pack's fill policies in order: larger type one ramp step, the next spacing step,
2268
- * the visual taking the room. Content is never invented and decoration never fills space.
2269
- */
2270
- // A line that names the slide's source or a note on its basis ("출처:", "주:", "Source:", "Note:").
2271
- const STRIP = /^(?:출처|자료|주|Sources?|Notes?)\s*[::]/iu;
2272
-
2273
- /**
2274
- * The source and note lines of a content slide's text, taken out of its takeaways: they are set as a
2275
- * strip at the foot of the body zone, at source size under a hairline, so the slide states where its
2276
- * figures come from without a takeaway column spending its lines on it. Closings keep theirs in the
2277
- * next step.
2278
- */
2279
- function takeStrip(spec, items) {
2280
- // A closing with a next step keeps its source there; a closing summary has no such line, so it takes the strip.
2281
- if (G.VARIANTS.closing.includes(spec.family) && spec.family !== "closing-summary-list") return { items, lines: [] };
2282
- const lines = [];
2283
- const keep = (list) => (list || []).filter((it) => {
2284
- if ((it.type === "bullet" || it.type === "text") && STRIP.test(plainText(it.text || "")) && !(it.children || []).length) { lines.push(it.text); return false; }
2285
- return true;
2286
- });
2287
- const out = items.map((item) => {
2288
- if (item.type === "body" && item.content && Array.isArray(item.content.items)) return { ...item, content: { ...item.content, items: keep(item.content.items) } };
2289
- return item;
2290
- }).filter((item) => !(item.type === "body" && item.content && Array.isArray(item.content.items) && !item.content.items.length));
2291
- return { items: out, lines };
2292
- }
2293
-
2294
- function stripPlacements(lines, Z, S) {
2295
- const size = S.sizes.source;
2296
- const paras = lines.map((t) => ({ kind: "text", text: t, inset: 0, gap: 2, h: G.textHeight(plainText(t), Z.w, size, 1.3) }));
2297
- paras[0].gap = 0;
2298
- const h = paras.reduce((a, q) => a + q.gap + q.h, 0);
2299
- const y = Z.bottom - h;
2300
- // A hairline sets the strip off where the pack draws hairlines; elsewhere the size and the muted
2301
- // ink do (a rule in a pack without them adds a colour to the slide).
2302
- return { h: h + 10, placed: [
2303
- ...(S.deco.has("hairline-rule") ? [{ decor: true, kind: "rect", x: Z.x, y: y - 6, w: Z.w, h: 0.5, fill: "line" }] : []),
2304
- { kind: "text", paras, size, x: Z.x, y, w: Z.w, h, muted: true, limit: Z.bottom },
2305
- ] };
2306
- }
2307
-
2308
- // A column more empty than this, beside a longer one, costs the slide its title (spec-v2 Amendments 7).
2309
- const RAIL_EMPTY = 0.4;
2310
-
2311
- function planSlide(spec, frame, S, items) {
2312
- const z = zonesOf(frame, S);
2313
- if (spec.lead && spec.family !== "summary-box-list") items = [{ type: "main-box", content: spec.lead }, ...items];
2314
- if (z.cls === "none") return { placed: [], band: 0, applied: [], before: 0, z };
2315
- const full = z.Z;
2316
- const taken = takeStrip(spec, items);
2317
- // The source strip: offered to a takeaway column beside a visual, and across the body's foot
2318
- // when no column takes it.
2319
- const lines = taken.lines;
2320
- items = taken.items;
2321
- const across = lines.length ? stripPlacements(lines, full, S) : null;
2322
- const tok = S.tok;
2323
- const plan = (spec.stacked && PLANS[STACKS[spec.family]]) || PLANS[spec.family] || PLANS["text-column"];
2324
- const state = { stepped: false, anchor: false, itemGap: tok.item, groupGap: tok.group, blockGap: tok.block };
2325
- // Offer the strip to a column first; once a run leaves it, it runs across the foot and the body ends above it.
2326
- let offer = Boolean(across);
2327
- const zone = () => (across && !offer ? { ...full, bottom: full.bottom - across.h - S.tok.block } : full);
2328
- // A later run (another fill state) that leaves the offered strip is refused like an overflow.
2329
- const run = (settle = false) => {
2330
- const ctx = { spec, S, state, Z: zone(), family: spec.family, items, strip: offer ? lines : null };
2331
- const placed = plan(ctx);
2332
- const lost = offer && !placed.some((q) => q.strip);
2333
- if (lost && settle) {
2334
- offer = false;
2335
- return run();
2336
- }
2337
- return { placed, lost, bottom: contentBottom(placed, zone().y) };
2338
- };
2339
- const band = (o) => Math.max(0, Math.min(1, (zone().bottom - o.bottom) / Math.max(1, zone().bottom - z.bandTop)));
2340
- let out = run(true);
2341
- if (overflows(out.placed)) {
2342
- // Too much for the body at the family's sizes: leads drop to body size and gaps to the item gap.
2343
- Object.assign(state, { compact: true, groupGap: tok.item, blockGap: tok.group });
2344
- out = run(true);
2345
- }
2346
- const before = band(out);
2347
- const applied = [];
2348
- if (before > tok.cap && items.length) {
2349
- for (const policy of S.pack["fill-order"] || []) {
2350
- if (band(out) <= tok.cap) break;
2351
- const saved = { ...state };
2352
- if (policy === "step-up") {
2353
- if (!tok.stepUp) continue;
2354
- state.stepped = true;
2355
- } else if (policy === "distribute") {
2356
- state.itemGap = G.stepGap(state.itemGap, 24);
2357
- state.groupGap = G.stepGap(state.groupGap, 48);
2358
- state.blockGap = G.stepGap(state.blockGap, 48);
2359
- } else if (policy === "anchor-visual") {
2360
- state.anchor = true;
2361
- } else {
2362
- continue;
2363
- }
2364
- if (JSON.stringify(saved) === JSON.stringify(state)) continue;
2365
- const next = run();
2366
- if (next.lost || overflows(next.placed)) Object.assign(state, saved);
2367
- else {
2368
- if (next.bottom > out.bottom + 0.5) applied.push(policy);
2369
- out = next;
2370
- }
2371
- }
2372
- }
2373
- z.Z = zone();
2374
- // A text column that stops short of the column beside it is filled by layout; one that still leaves more
2375
- // than RAIL_EMPTY of the body empty makes this title unfit for the slide when another fits.
2376
- const floor = full.bottom;
2377
- let short = shortColumn([...out.placed, ...(across && !offer ? across.placed : [])], floor, S);
2378
- // The fill starts a little under the line (0.35), so a column the gate reads a point or two emptier than the
2379
- // estimate still holds.
2380
- if (short.share > 0.35) {
2381
- fillColumn(short, floor, S, state);
2382
- short = shortColumn([...out.placed, ...(across && !offer ? across.placed : [])], floor, S);
2383
- }
2384
- const placed = [...out.placed, ...(across && !offer ? across.placed : [])];
2385
- const overflow = overflows(placed);
2386
- return { ...out, placed, band: band(out), before, applied, z, overflow, short: short.share,
2387
- unfit: overflow || short.share > RAIL_EMPTY };
2388
- }
2389
-
2390
- /** The frame of a treatment for this slide (a quote under a statement title says the quote). */
2391
- function frameFor(spec, treatment) {
2392
- const ctx = treatment === "statement" && spec.statementText ? { ...spec.ctx, title: spec.statementText } : spec.ctx;
2393
- return G.treatmentGeometry(treatment, ctx);
2394
- }
2395
-
2396
- /**
2397
- * Choose among the treatments the slide may take. The role default stays when its body fills to
2398
- * the density band; otherwise every allowed treatment is laid out and scored by the empty band it
2399
- * leaves, with a small cost for repeating the previous slide's title or one the deck already leans
2400
- * 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
2401
- * distinct treatments under its maximum.
2402
- */
2403
- // The bottom-anchor style (the title frame closed by a heavy rule) is for a slide led by a chart, a picture,
2404
- // a big number, a row of figures or a timeline axis (S2.5), not for a table.
2405
- 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");
2406
-
2407
- function chooseTreatment(spec, S, deck) {
2408
- const options = spec.candidates && spec.candidates.length ? spec.candidates : [spec.treatment];
2409
- const allowed = deck.used.size >= deck.max && options.some((t) => deck.used.has(t)) ? options.filter((t) => deck.used.has(t)) : options;
2410
- const tries = allowed.map((t) => ({ t, plan: planSlide(spec, frameFor(spec, t), S, spec.items || []) }));
2411
- // Titles that fit come first; a table goes under a bottom title only when nothing else fits it.
2412
- const fit = tries.filter((x) => !x.plan.unfit);
2413
- const proper = fit.filter((x) => x.t !== "bottom-anchor" || drawn(spec));
2414
- // When every title leaves the slide unfit, the one that overflows least and leaves a column least empty stands.
2415
- const badness = (x) => (x.plan.overflow ? 10 : 0) + Math.max(0, (x.plan.short || 0) - RAIL_EMPTY);
2416
- const pool = proper.length ? proper : fit.length ? fit : [...tries].sort((m, n) => badness(m) - badness(n));
2417
- const first = pool[0];
2418
- if (first.t === options[0] && first.plan.band <= S.tok.cap && first.t !== deck.prev && (deck.count[first.t] || 0) < deck.limit) return first;
2419
- const cost = (x) => x.plan.band + (x.plan.band > S.tok.cap ? 0.15 : 0) + 0.07 * (deck.count[x.t] || 0) +
2420
- (x.t === deck.prev ? 0.08 : 0) - (x.t === options[0] ? 0.03 : 0) + ((deck.count[x.t] || 0) >= deck.limit ? 1 : 0);
2421
- const best = pool.reduce((b, x) => (cost(x) < cost(b) - 1e-9 ? x : b));
2422
- // The role's own title is the pack's structure (spec-v2 Amendments 7): it stays unless another title
2423
- // leaves at least 0.10 less of the body empty (0.15 when neither fills to the density band).
2424
- // A bottom title the slide may not take (a table) hands the pack's structure to its next treatment in order.
2425
- const ownT = options[0] === "bottom-anchor" && !drawn(spec) ? options.find((t) => t !== "bottom-anchor") : options[0];
2426
- const own = pool.find((x) => x.t === ownT);
2427
- const margin = best.plan.band > S.tok.cap ? 0.15 : 0.1;
2428
- // A family the pack draws with its own title (`structure`) keeps it past the deck's share of that title.
2429
- const pinned = (S.pack.structure || {})[spec.family] === ownT;
2430
- if (own && own !== best && own.plan.band - best.plan.band < margin && (pinned || (deck.count[own.t] || 0) < deck.limit)) return own;
2431
- return best;
2432
- }
2433
-
2434
- /**
2435
- * Fill alone can settle a deck on two titles. Variance 4 and up asks for three (S13.2) once a deck
2436
- * has eight slides, so while it carries fewer, the slide that loses the least fill moves to a
2437
- * treatment the deck has not used: one of its own candidates, never one that overflows or leaves
2438
- * more than the density band (or what the slide already leaves) empty, and never the last slide of
2439
- * a treatment.
2440
- */
2441
- function spreadTreatments(choices, S, pack, slideCount) {
2442
- const need = slideCount < 8 ? 0 : Math.min(pack.dials.variance <= 3 ? 1 : 3, pack.treatments.length, pack.dials.varianceMax);
2443
- const lines = [];
2444
- const used = () => new Set([...choices.values()].map((c) => c.t));
2445
- while (used().size < need) {
2446
- const have = used();
2447
- const count = (t) => [...choices.values()].filter((c) => c.t === t).length;
2448
- let best = null;
2449
- for (const [spec, current] of choices) {
2450
- if (count(current.t) < 2) continue;
2451
- for (const t of spec.candidates || []) {
2452
- if (have.has(t)) continue;
2453
- const plan = planSlide(spec, frameFor(spec, t), S, spec.items || []);
2454
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band) + 0.05) continue;
2455
- const loss = plan.band - current.plan.band;
2456
- if (!best || loss < best.loss) best = { spec, t, plan, loss };
2457
- }
2458
- }
2459
- if (!best) break;
2460
- choices.set(best.spec, { t: best.t, plan: best.plan });
2461
- lines.push(`variety: slide ${best.spec.index + 1} drawn under ${best.t} so the deck carries ${used().size} title treatments`);
2462
- }
2463
- // No title zone on more than 40 % of the content slides (S15): a data slide (a table, chart or
2464
- // figures under their takeaway) that fills no worse under another zone's treatment moves there,
2465
- // the one that gains the most first. Agendas, sequences and definitions keep their own titles.
2466
- const content = [...choices.keys()].filter((spec) => spec.kind === "content");
2467
- const movable = (spec) => spec.role === "data" || spec.role === "data-takeaway";
2468
- const cap = 0.4 * content.length;
2469
- const zonesNow = () => {
2470
- const zones = {};
2471
- for (const spec of content) zones[ZONE_OF[choices.get(spec).t]] = (zones[ZONE_OF[choices.get(spec).t]] || 0) + 1;
2472
- return zones;
2473
- };
2474
- // The data slide in zone `from` that fills best under a title of another zone with room.
2475
- const moveOut = (from, zones, blocked) => {
2476
- let best = null;
2477
- for (const spec of content) {
2478
- const current = choices.get(spec);
2479
- if (ZONE_OF[current.t] !== from || !movable(spec)) continue;
2480
- for (const t of spec.candidates || []) {
2481
- const zone = ZONE_OF[t];
2482
- if (zone === from || blocked.has(zone) || (zones[zone] || 0) + 1 > cap) continue;
2483
- if (t === "bottom-anchor" && !drawn(spec)) continue;
2484
- const inUse = new Set([...choices.values()].map((c) => c.t));
2485
- if (!inUse.has(t) && inUse.size >= pack.dials.varianceMax) continue;
2486
- const plan = planSlide(spec, frameFor(spec, t), S, spec.items || []);
2487
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band)) continue;
2488
- const gain = current.plan.band - plan.band;
2489
- if (!best || gain > best.gain) best = { spec, t, plan, gain };
2490
- }
2491
- }
2492
- return best;
2493
- };
2494
- 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`);
2495
- for (let guard = 0; guard < content.length; guard++) {
2496
- const zones = zonesNow();
2497
- const [crowded, n] = Object.entries(zones).sort((a, b) => b[1] - a[1])[0] || [];
2498
- if (!crowded || n <= cap) break;
2499
- let best = moveOut(crowded, zones, new Set());
2500
- if (!best) {
2501
- // Every zone a crowded slide could take is full: move one of that zone's own data slides on
2502
- // to a third zone first, when that makes room.
2503
- for (const [full, m] of Object.entries(zones)) {
2504
- if (full === crowded || m + 1 <= cap) continue;
2505
- const first = moveOut(full, zones, new Set([crowded]));
2506
- if (!first) continue;
2507
- const saved = choices.get(first.spec);
2508
- choices.set(first.spec, { t: first.t, plan: first.plan });
2509
- best = moveOut(crowded, zonesNow(), new Set());
2510
- if (best) { say(first); break; }
2511
- choices.set(first.spec, saved);
2512
- }
2513
- }
2514
- if (!best) break;
2515
- choices.set(best.spec, { t: best.t, plan: best.plan });
2516
- say(best);
2517
- }
2518
- // Composition variety (S15) counts title zone x column partition over the content slides,
2519
- // closings excluded. While the deck has fewer distinct layouts than the check needs, a data slide
2520
- // whose layout another slide shares moves to a title that gives a layout the deck lacks, when that
2521
- // neither overflows nor leaves more than the density band (or what the slide already leaves).
2522
- const counted = content.filter((spec) => !G.VARIANTS.closing.includes(spec.family));
2523
- const layoutsNeeded = Math.min(5, Math.ceil(0.6 * counted.length));
2524
- const layoutOf = (t, plan) => `${ZONE_OF[t]}/${partitionOf(plan, S)}`;
2525
- // The check also fails a deck where one layout covers more than 40 % of those slides, so while
2526
- // one does, a slide of that layout moves to a title that gives a layout still under the share.
2527
- // A title style never moves the body (every treatment shares the title zone), so any slide whose
2528
- // source leaves its title open may take another here, not only a data slide.
2529
- const shareCap = 0.4 * counted.length;
2530
- for (let guard = 0; guard < counted.length; guard++) {
2531
- const keys = {};
2532
- for (const spec of counted) { const c = choices.get(spec); const k = layoutOf(c.t, c.plan); keys[k] = (keys[k] || 0) + 1; }
2533
- const [topKey, topN] = Object.entries(keys).sort((a, b) => b[1] - a[1])[0] || [];
2534
- const short = Object.keys(keys).length < layoutsNeeded;
2535
- const crowded = topN > shareCap;
2536
- if (!short && !crowded) break;
2537
- let best = null;
2538
- for (const spec of counted) {
2539
- const current = choices.get(spec);
2540
- const from = layoutOf(current.t, current.plan);
2541
- if (keys[from] < 2 || (!short && from !== topKey)) continue;
2542
- for (const t of spec.candidates || []) {
2543
- if (t === current.t || (t === "bottom-anchor" && !drawn(spec))) continue;
2544
- const inUse = new Set([...choices.values()].map((c) => c.t));
2545
- if (!inUse.has(t) && inUse.size >= pack.dials.varianceMax) continue;
2546
- const plan = planSlide(spec, frameFor(spec, t), S, spec.items || []);
2547
- const to = layoutOf(t, plan);
2548
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band) || to === from) continue;
2549
- // A move that adds a layout comes first; else one that relieves the crowded layout.
2550
- const adds = short && !keys[to];
2551
- const relieves = crowded && from === topKey && (keys[to] || 0) + 1 <= shareCap;
2552
- if (!adds && !relieves) continue;
2553
- const loss = plan.band - current.plan.band - (adds ? 2 : 0) - (relieves ? 1 : 0);
2554
- if (!best || loss < best.loss) best = { spec, t, plan, loss, added: !keys[to] };
2555
- }
2556
- }
2557
- if (!best) {
2558
- // No title gives a new layout: a table or chart slide may stack its takeaways under the visual
2559
- // across the body (the composition of the ledger-table and full-chart families) instead.
2560
- for (const spec of counted) {
2561
- const current = choices.get(spec);
2562
- const from = layoutOf(current.t, current.plan);
2563
- if (!STACKS[spec.family] || spec.stacked || keys[from] < 2 || (!short && from !== topKey)) continue;
2564
- const stacked = { ...spec, stacked: true };
2565
- for (const t of [current.t, ...(spec.candidates || []).filter((c) => c !== current.t)]) {
2566
- if (t === "bottom-anchor" && !drawn(spec)) continue;
2567
- const plan = planSlide(stacked, frameFor(spec, t), S, spec.items || []);
2568
- const to = layoutOf(t, plan);
2569
- if (plan.unfit || plan.band > Math.max(S.tok.cap, current.plan.band) || to === from) continue;
2570
- if (short ? keys[to] : (keys[to] || 0) + 1 > shareCap) continue;
2571
- const loss = plan.band - current.plan.band;
2572
- if (!best || loss < best.loss) best = { spec, t, plan, loss, added: !keys[to], stacked: true };
2573
- }
2574
- }
2575
- }
2576
- if (!best) break;
2577
- if (best.stacked) best.spec.stacked = true;
2578
- choices.set(best.spec, { t: best.t, plan: best.plan });
2579
- lines.push(best.added ? `variety: slide ${best.spec.index + 1} drawn under ${best.t} so the deck carries ${Object.keys(keys).length + 1} layouts`
2580
- : `variety: slide ${best.spec.index + 1} drawn under ${best.t} so no layout covers more than 40 % of the content slides`);
2581
- }
2582
- return lines;
2583
- }
2584
-
2585
- /**
2586
- * The boxes a placement draws as the composition check reads them from the page: text frames,
2587
- * tables, charts and pictures, and filled surfaces that hold text (cards). Rules, dots and outlines
2588
- * are decoration there and are left out.
2589
- */
2590
- function drawnBoxes(p, S) {
2591
- const B = (x, y, w, h, card = false) => ({ x, y, w, h, card });
2592
- const filled = S.pack.edge !== "border";
2593
- switch (p.kind) {
2594
- case "group": return p.parts.flatMap((q) => drawnBoxes(q, S));
2595
- case "text": {
2596
- let y = p.y;
2597
- 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; });
2598
- }
2599
- case "callout": return [B(p.x, p.y, p.w, p.h, true)];
2600
- case "box": return p.outline || (!p.tint && !filled) ? [] : [B(p.x, p.y, p.w, p.h, true)];
2601
- case "panel": return p.fill && p.h >= 40 ? [B(p.x, p.y, p.w, p.h, true)] : [];
2602
- case "kpi": return p.cards.flatMap((card, i) => {
2603
- const x = p.x + i * (p.cardW + S.grid.gutter);
2604
- if (filled) return [B(x, p.y, p.cardW, p.cardH, true)];
2605
- const y = p.y + p.pad + p.value * 1.15 + 6;
2606
- 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)];
2607
- });
2608
- 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)]);
2609
- 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),
2610
- ...(p.restX != null && r.rest ? [B(p.restX, r.y, p.restW, r.rh)] : [])]);
2611
- 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)]);
2612
- 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)]);
2613
- 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)]);
2614
- 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)]);
2615
- case "matrix": return [...p.cells.map((c) => B(c.x + p.pad, c.y + p.pad, c.w - p.pad * 2, c.headH)),
2616
- ...p.xHeads.map((_, i) => B(p.grid.x + i * (p.qw + p.gap), p.grid.y, p.qw, 16)),
2617
- ...p.yHeads.map((_, i) => B(p.labels.x, p.top + i * (p.qh + p.gap), p.labels.w, 16))];
2618
- case "quote": return [B(p.x, p.y, p.w, p.h)];
2619
- case "number": return [B(p.x, p.y, p.w, p.h)];
2620
- // A chart's caption is its own frame under the plot, as the check reads it.
2621
- 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)];
2622
- case "image": {
2623
- // A single picture is drawn contained in its box (on the box floor beside a taller takeaway column),
2624
- // its caption under it: the check reads those two frames.
2625
- const size = p.item && p.item.type === "image" && p.item.imageSize;
2626
- if (!size) return [B(p.x, p.y, p.w, p.h)];
2627
- const fit = shared().containBox(p.x, p.y, p.w, p.h - p.cap, size);
2628
- const low = p.y + p.h - p.cap - fit.h;
2629
- if (p.beside != null && low <= p.beside) fit.y = low;
2630
- 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)] : [])];
2631
- }
2632
- case "table": case "caption": return [B(p.x, p.y, p.w, p.h)];
2633
- default: return p.x != null && p.w ? [B(p.x, p.y, p.w, p.h || 0)] : [];
2634
- }
2635
- }
2636
-
2637
- /**
2638
- * The column partition a plan draws, read the way the composition check reads the page (S15):
2639
- * boxes inside a card count as the card; boxes narrower than 70 % of the body are grouped into
2640
- * columns by overlapping x-extent (half the narrower box joins, and a box that joins two columns
2641
- * merges them); two or more columns sharing two or more rows, or four columns, are a grid.
2642
- */
2643
- function partitionOf(plan, S) {
2644
- const Z = plan.z && plan.z.Z;
2645
- const placed = (plan.placed || []).filter((q) => !q.decor);
2646
- if (!Z || !placed.length) return "one";
2647
- const all = placed.flatMap((q) => drawnBoxes(q, S)).filter((b) => b.w > 0 && b.h > 0);
2648
- const cards = all.filter((b) => b.card);
2649
- 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);
2650
- // A one-line caption or source on the body floor is the slide's foot, not a column (as the gate reads it).
2651
- const body = SG.zone(S.grid.canvas, "content", "body");
2652
- const floor = body.y + body.h;
2653
- const blocks = all.filter((b) => !inCard(b) && !(!b.card && b.h <= 16 && b.y + b.h >= floor - 2));
2654
- if (!blocks.length) return "one";
2655
- const bodyW = S.grid.W - 2 * S.grid.margin;
2656
- let narrow = blocks.filter((b) => b.w < 0.7 * bodyW);
2657
- if (!narrow.length) narrow = blocks;
2658
- const columns = [];
2659
- for (const b of [...narrow].sort((m, n) => m.x - n.x)) {
2660
- 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));
2661
- if (hits.length) {
2662
- const keep = hits[0];
2663
- 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); }
2664
- keep.l = Math.min(keep.l, b.x); keep.r = Math.max(keep.r, b.x + b.w); keep.items.push(b);
2665
- } else columns.push({ l: b.x, r: b.x + b.w, items: [b] });
2666
- }
2667
- const columnOf = new Map(columns.flatMap((c, i) => c.items.map((b) => [b, i])));
2668
- const rows = [];
2669
- for (const b of [...narrow].sort((m, n) => m.y - n.y)) {
2670
- const last = rows[rows.length - 1];
2671
- if (last && b.y < last.bottom - 2) { last.bottom = Math.max(last.bottom, b.y + b.h); last.items.push(b); }
2672
- else rows.push({ bottom: b.y + b.h, items: [b] });
2673
- }
2674
- const gridRows = rows.filter((r) => new Set(r.items.map((b) => columnOf.get(b))).size >= 2).length;
2675
- const k = columns.length;
2676
- if (k >= 4 || (k >= 2 && gridRows >= 2)) return "grid";
2677
- if (k === 3) return "three";
2678
- if (k === 2) {
2679
- const [a, c] = columns.map((col) => col.r - col.l);
2680
- return Math.min(a, c) / Math.max(a, c) >= 0.85 ? "two-even" : "two-asym";
2681
- }
2682
- return "one";
2683
- }
2684
-
2685
- /**
2686
- * The emptiest text column of a two-column body, read as the gate reads it (OF-115, spec-v2 Amendments 8):
2687
- * for every vertical cut no block crosses, a side holding text only, beside a side that reaches at least
2688
- * three quarters of the body, is measured by the largest band its blocks leave empty from the pair's top
2689
- * down to where the other side ends (to the floor beside figure rows, Amendments 9), as a share of the body
2690
- * from that top to the floor. A source strip closing the column counts as a block but does not hide the band
2691
- * above it. Returns { share, owners }.
2692
- */
2693
- const TEXT_KINDS = new Set(["text", "caption", "callout", "box", "panel"]);
2694
- // A picture drawn smaller than its box leaves its own column empty above it as a short text column does.
2695
- const SHORT_KINDS = new Set([...TEXT_KINDS, "image"]);
2696
- function shortColumn(placed, floor, S) {
2697
- const flat = (list) => list.flatMap((q) => (q.kind === "group" ? flat(q.parts) : [q]));
2698
- const owners = flat(placed.filter((q) => !q.decor));
2699
- // A matrix's cells are drawn whole on the page, whatever its composition estimate reads of them.
2700
- 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));
2701
- // A chart's values table under its takeaways belongs to their column.
2702
- const boxes = owners.flatMap((q) => boxesOf(q).map((b) => ({ ...b, q, text: SHORT_KINDS.has(q.kind) || Boolean(q.item && q.item.values) })))
2703
- .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 })))
2704
- .filter((b) => b.w > 0 && b.h > 0 && b.y < floor);
2705
- let worst = { share: 0, owners: [] };
2706
- if (boxes.length < 2) return worst;
2707
- const left = Math.min(...boxes.map((b) => b.x));
2708
- const right = Math.max(...boxes.map((b) => b.x + b.w));
2709
- for (const cut of [...new Set(boxes.map((b) => b.x + b.w))].sort((m, n) => m - n)) {
2710
- const a = boxes.filter((b) => b.x + b.w <= cut + 2);
2711
- const c = boxes.filter((b) => b.x >= cut - 2);
2712
- // A block across most of the body (a note under both columns) belongs to neither; a narrower one across the cut
2713
- // means there is no column line here.
2714
- const across = boxes.filter((b) => !a.includes(b) && !c.includes(b));
2715
- if (!a.length || !c.length || across.some((b) => b.w < 0.7 * (right - left))) continue;
2716
- const top = Math.min(...[...a, ...c].map((b) => b.y));
2717
- for (const [col, other] of [[a, c], [c, a]]) {
2718
- if (!col.every((b) => b.text)) continue;
2719
- // Beside figure rows (not on their own panel) the column runs to the floor: the rows stop where their
2720
- // spacing ends, not where the slide's content does (spec-v2 Amendments 9).
2721
- const figures = other.some((b) => ["figrows", "number"].includes(b.q.kind)) && !other.some((b) => b.q.kind === "panel");
2722
- const reach = figures ? floor : Math.min(floor, Math.max(...other.map((b) => b.y + b.h)));
2723
- if (reach - top < 0.75 * (floor - top)) continue;
2724
- let gap = 0;
2725
- let cursor = top;
2726
- for (const b of [...col].sort((m, n) => m.y - n.y)) {
2727
- gap = Math.max(gap, b.y - cursor);
2728
- cursor = Math.max(cursor, b.y + b.h);
2729
- }
2730
- gap = Math.max(gap, reach - cursor);
2731
- const share = gap / Math.max(1, floor - top);
2732
- if (share > worst.share) worst = { share, owners: [...new Set(col.map((b) => b.q))], top, reach, besideText: other.every((b) => b.q.kind === "text") };
2733
- }
2734
- }
2735
- return worst;
2736
- }
2737
-
2738
- /**
2739
- * Fill a short text column by layout (spec-v2 Amendments 8): its points step up to lead size when they fit
2740
- * and keep twelve glyphs a line, then the room left is shared between its points, at most a sixth of the
2741
- * body a gap. Type never shrinks and nothing is added. Changes the placements in place.
2742
- */
2743
- function fillColumn(short, floor, S, state) {
2744
- const texts = short.owners.filter((q) => q.kind === "text" && !q.muted && !q.strip && q.paras);
2745
- if (!texts.length) return;
2746
- // The chart's values under the takeaways move down with them; they bound nothing above them.
2747
- const values = short.owners.filter((q) => q.item && q.item.values);
2748
- 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));
2749
- const carried = (q, dy) => values.every((v) => v.y < q.y + q.h - 0.5 || v.y + v.h + dy <= below(v) + 0.5);
2750
- const lead = S.sizes.lead;
2751
- // Beside another text column the points keep its size: two columns of text at two sizes read as a mistake.
2752
- for (const q of short.besideText ? [] : texts) {
2753
- if (q.size >= lead || q.w / lead < 12) continue;
2754
- const m = measureText(q.paras, q.w, S, { ...state, stepped: false }, { size: lead });
2755
- if (q.y + m.h <= below(q) + 0.5 && carried(q, m.h - q.h)) {
2756
- // Every later block in the column moves down by what the step adds.
2757
- const dy = m.h - q.h;
2758
- for (const o of short.owners) if (o !== q && o.y >= q.y + q.h - 0.5 && !o.strip && !o.muted) o.y += dy;
2759
- Object.assign(q, { paras: m.paras, size: m.size, h: m.h });
2760
- }
2761
- }
2762
- const breaks = texts.flatMap((q) => q.paras.filter((para, i) => i > 0 && para.kind !== "child").map((para) => ({ q, para })));
2763
- const last = [...texts, ...values].reduce((m, q) => (q.y + q.h > m.y + m.h ? q : m));
2764
- const room = below(last) - (last.y + last.h);
2765
- // The gap over a values table is shared like a gap between points.
2766
- const gaps = breaks.length + values.length;
2767
- if (!gaps || room <= 0) return;
2768
- const per = Math.min(room / (gaps + 1), (floor - short.top) / 6);
2769
- for (const { q, para } of breaks) { para.gap += per; q.h += per; }
2770
- // A block that grew pushes the text blocks and values under it (never the strip, which stays on the floor).
2771
- let shift = 0;
2772
- for (const q of [...texts, ...values].sort((m, n) => m.y - n.y)) {
2773
- if (values.includes(q)) shift += per;
2774
- q.y += shift;
2775
- shift += breaks.filter((b) => b.q === q).length * per;
2776
- }
2777
- }
2778
-
2779
- /** Families whose visual may take its takeaways under it across the body, and the plan that does. */
2780
- const STACKS = { "table-insight": "ledger-table", "chart-insight": "full-chart" };
2781
-
2782
- /** The composition title zone of each treatment (S15). */
2783
- const ZONE_OF = Object.fromEntries(G.TREATMENTS.map((t) => [t, t]));
2784
-
2785
- // ── Content, cover and section slides ───────────────────────────────────────
2786
-
2787
- function drawDecor(slide, S, list) {
2788
- for (const d of list || []) packRect(slide, S, d, { fill: d.role, alpha: d.alpha });
2789
- }
2790
-
2791
- /**
2792
- * A content slide: decoration, numeral, body, then the title frame of its treatment. The title is
2793
- * drawn last so the first shape on the slide is an unnamed one that can carry the family name.
2794
- */
2795
- function renderContent(slide, spec, S, ctx, chosen) {
2796
- const f = frameFor(spec, chosen.t);
2797
- const t = f.title;
2798
- const items = spec.items || [];
2799
- if (!f.image) drawDecor(slide, S, f.decor);
2800
- if (f.numeral) {
2801
- 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" });
2802
- }
2803
- const dctx = { sourceDir: ctx.sourceDir, title: spec.title };
2804
- let ink = t.colour;
2805
- if (f.image) {
2806
- const image = items.find((i) => i.type === "image" || i.type === "image-grid");
2807
- const src = image && (image.content.type === "image-grid" ? image.content.images[0] : image.content);
2808
- if (src) {
2809
- const file = shared().resolveImagePath(src.src, ctx.sourceDir);
2810
- slide.addImage({ path: file, ...croppedTo(file, { x: 0, y: 0, w: f.image.w, h: f.image.h }), altText: src.caption || path.basename(file) });
2811
- drawDecor(slide, S, f.decor);
2812
- if (image.caption) drawCaption(slide, S, image.caption, t.x, 432, t.w, "on-field");
2813
- }
2814
- } else if (f.support) {
2815
- const text = spec.supportText || spec.lead || items.filter(isText).flatMap(itemParas).map((p) => plainText(p.text)).join(" ");
2816
- const supportH = text ? G.textHeight(plainText(text), f.support.w, S.sizes.body) : 0;
2817
- ink = statementDevice(slide, S, f, supportH);
2818
- if (text) packText(slide, S, text, { ...f.support, h: supportH }, { colour: S.colour(ink === "on-field" ? "on-field" : "ink-muted"), name: "support@statement" });
2819
- } else if (f.body) {
2820
- const plan = chosen.plan;
2821
- if (plan.before > S.tok.cap || plan.band > S.tok.cap) {
2822
- 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"})`);
2823
- }
2824
- for (const p of plan.placed.filter((q) => q.decor)) drawPlaced(slide, S, p, dctx);
2825
- for (const p of plan.placed.filter((q) => !q.decor)) drawPlaced(slide, S, p, dctx);
2826
- }
2827
- packText(slide, S, chosen.t === "statement" && spec.statementText ? spec.statementText : spec.title, t, {
2828
- // Every title that wraps is set in balanced lines, never ending on one word.
2829
- face: t.face, size: t.size, colour: S.colour(ink), lineSpacing: t.lineSpacing || 1.15, title: true, name: `title@${chosen.t}`, balance: true,
2830
- });
2831
- }
2832
-
2833
- /**
2834
- * What carries a statement, from the pack's display keys: nothing (open), the field over the whole
2835
- * page (drench), the field under the sentence from just above it to the foot (plate), a hairline
2836
- * above the sentence and one under its support line (rules), or a rail beside a sentence set off
2837
- * the left edge (offset). 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
- /**
3210
- * The grid shown on purpose: a tick and a two-digit number over each column start in the top margin,
3211
- * and the slide's place in the deck at the right, all in the label face and the muted ink.
3212
- */
3213
- function gridMarks(slide, S, n, total) {
3214
- const g = S.grid;
3215
- const size = S.sizes.source;
3216
- const y = 12;
3217
- for (let a = 1; a <= 12; a++) {
3218
- const x = g.colX(a);
3219
- packRect(slide, S, { x, y, w: 0.75, h: size * 1.2 }, { fill: "line", name: "grid-mark" });
3220
- 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" });
3221
- }
3222
- const index = `[${String(n).padStart(2, "0")}/${String(total).padStart(2, "0")}]`;
3223
- const right = g.span(11, 12);
3224
- 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" });
3225
- }
3226
-
3227
- /**
3228
- * Elementary geometry in the primaries, in a region of the page that holds no text: a square in the
3229
- * surface colour, a circle in the accent, a bar in the ink and a triangle in the field, one per cell
3230
- * of a two-by-two grid, so no shape overlaps another or the text.
3231
- */
3232
- function geometry(slide, S, region) {
3233
- const cw = region.w / 2;
3234
- const ch = region.h / 2;
3235
- const d = Math.min(cw, ch);
3236
- const cell = (i, j) => ({ x: region.x + i * cw, y: region.y + j * ch });
3237
- 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" } });
3238
- const a = cell(0, 0);
3239
- shape("rect", { x: a.x, y: a.y, w: cw, h: ch }, "accent-tint");
3240
- const b = cell(1, 0);
3241
- shape("ellipse", { x: b.x + (cw - d) / 2, y: b.y + (ch - d) / 2, w: d, h: d }, "accent");
3242
- const c = cell(0, 1);
3243
- shape("rect", { x: c.x + cw * 0.38, y: c.y, w: cw * 0.24, h: ch }, "ink");
3244
- const e = cell(1, 1);
3245
- shape("triangle", { x: e.x, y: e.y + (ch - d), w: cw, h: d }, "field");
3246
- }
3247
-
3248
- /** The sample-data tag in the footer zone, on the grid's left edge, in the pack's colours. */
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
- if (notice) packNotice(slide, S, notice);
3335
- // The marks read on the ground; a statement page may be drenched in the field, so it goes without.
3336
- if (spec.kind === "content" && chosenBy[spec.index] !== "statement" && S.deco.has("grid-marks")) gridMarks(slide, S, spec.index + 1, (resolved.slides || []).length);
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 };