allyhub 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/commands/frames/report.js +1 -1
  3. package/dist/commands/frames.js +11 -11
  4. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  5. package/dist/node_modules/@allyhub/audio/dist/render.js +1 -1
  6. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  7. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  8. package/dist/node_modules/@allyhub/build/dist/media.js +1 -1
  9. package/dist/node_modules/@allyhub/build/package.json +1 -1
  10. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  11. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  12. package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
  13. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +3 -2
  14. package/dist/node_modules/@allyhub/chart/dist/chart.js +2 -1
  15. package/dist/node_modules/@allyhub/chart/dist/color.js +2 -0
  16. package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
  17. package/dist/node_modules/@allyhub/chart/dist/svg.js +1 -1
  18. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  19. package/dist/node_modules/@allyhub/check/package.json +1 -1
  20. package/dist/node_modules/@allyhub/cloud/dist/call.js +1 -1
  21. package/dist/node_modules/@allyhub/cloud/dist/records.d.ts +1 -1
  22. package/dist/node_modules/@allyhub/cloud/dist/uploads.d.ts +1 -1
  23. package/dist/node_modules/@allyhub/cloud/dist/uploads.js +1 -1
  24. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  25. package/dist/node_modules/@allyhub/components/package.json +1 -1
  26. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  27. package/dist/node_modules/@allyhub/dev-server/dist/server.js +1 -1
  28. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  29. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  30. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  31. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  32. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  33. package/dist/node_modules/@allyhub/export/package.json +1 -1
  34. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  35. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  36. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +130 -0
  37. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
  38. package/dist/node_modules/@allyhub/formats/dist/data/gen.d.ts +3 -1
  39. package/dist/node_modules/@allyhub/formats/dist/data/gen.js +1 -1
  40. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +512 -166
  41. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  42. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +2523 -136
  43. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  44. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +931 -87
  45. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  46. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  47. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  48. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  49. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  50. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  51. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  52. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  53. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  54. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  55. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  56. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
  57. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  58. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  59. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  60. package/dist/node_modules/@allyhub/media/dist/run.d.ts +6 -1
  61. package/dist/node_modules/@allyhub/media/dist/run.js +2 -2
  62. package/dist/node_modules/@allyhub/media/package.json +1 -1
  63. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  64. package/dist/node_modules/@allyhub/model/package.json +1 -1
  65. package/dist/node_modules/@allyhub/ooxml/dist/color.js +1 -1
  66. package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
  67. package/dist/node_modules/@allyhub/ooxml/dist/index.js +1 -1
  68. package/dist/node_modules/@allyhub/ooxml/dist/transform.js +2 -0
  69. package/dist/node_modules/@allyhub/ooxml/package.json +5 -1
  70. package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +4 -4
  71. package/dist/node_modules/@allyhub/piece/dist/media.d.ts +2 -2
  72. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  73. package/dist/node_modules/@allyhub/project/dist/part-keys.js +1 -1
  74. package/dist/node_modules/@allyhub/project/package.json +1 -1
  75. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +35 -0
  76. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  77. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +19 -0
  78. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  79. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +35 -20
  80. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  81. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +3 -3
  82. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +28 -2
  83. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  84. package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
  85. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +73 -10
  86. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  87. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +9 -9
  88. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  89. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  90. package/dist/node_modules/@allyhub/render/package.json +1 -1
  91. package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +1 -1
  92. package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +3 -3
  93. package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +29 -1
  94. package/dist/node_modules/@allyhub/report-extension/package.json +1 -1
  95. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +11 -4
  96. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +6 -2
  97. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +1 -1
  98. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +3 -1
  99. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  100. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  101. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  102. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  103. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  104. package/dist/node_modules/@allyhub/sheet/dist/annotations.js +2 -0
  105. package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
  106. package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
  107. package/dist/node_modules/@allyhub/sheet/dist/api/rules.js +1 -1
  108. package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
  109. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  110. package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
  111. package/dist/node_modules/@allyhub/sheet/dist/data-tools.js +2 -0
  112. package/dist/node_modules/@allyhub/sheet/dist/edit.js +1 -1
  113. package/dist/node_modules/@allyhub/sheet/dist/fill.js +1 -1
  114. package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
  115. package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.js +1 -1
  116. package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
  117. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  118. package/dist/node_modules/@allyhub/sheet/dist/outline.js +2 -0
  119. package/dist/node_modules/@allyhub/sheet/dist/rich.js +2 -0
  120. package/dist/node_modules/@allyhub/sheet/dist/rules.js +1 -1
  121. package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
  122. package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
  123. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  124. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  125. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  126. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  127. package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.js +2 -0
  128. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  129. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  130. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  131. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  132. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  133. package/dist/node_modules/@allyhub/slides-core/dist/api.js +3 -3
  134. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  135. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
  136. package/dist/node_modules/@allyhub/slides-core/dist/check.js +1 -1
  137. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  138. package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
  139. package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.js +2 -0
  140. package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
  141. package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
  142. package/dist/node_modules/@allyhub/slides-core/dist/numbering.js +2 -0
  143. package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
  144. package/dist/node_modules/@allyhub/slides-core/dist/patterns.js +2 -0
  145. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  146. package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
  147. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
  148. package/dist/node_modules/@allyhub/slides-core/dist/table-style.js +2 -0
  149. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  150. package/dist/node_modules/@allyhub/slides-extension/dist/deck-pptx.js +1 -1
  151. package/dist/node_modules/@allyhub/slides-extension/dist/workspace.js +1 -1
  152. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  153. package/dist/node_modules/@allyhub/slides-pptx/dist/audio-icon.js +2 -0
  154. package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +3 -3
  155. package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +2 -2
  156. package/dist/node_modules/@allyhub/slides-pptx/dist/import/script.js +1 -1
  157. package/dist/node_modules/@allyhub/slides-pptx/dist/read/chart.js +2 -1
  158. package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
  159. package/dist/node_modules/@allyhub/slides-pptx/dist/read/index.js +2 -2
  160. package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
  161. package/dist/node_modules/@allyhub/slides-pptx/dist/read/table.js +1 -1
  162. package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
  163. package/dist/node_modules/@allyhub/slides-pptx/dist/read/timing.js +1 -1
  164. package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
  165. package/dist/node_modules/@allyhub/slides-pptx/dist/table-styles.js +2 -0
  166. package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
  167. package/dist/node_modules/@allyhub/slides-pptx/dist/theme.js +1 -1
  168. package/dist/node_modules/@allyhub/slides-pptx/dist/timing.js +1 -1
  169. package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
  170. package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +2 -2
  171. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  172. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
  173. package/dist/node_modules/@allyhub/slides-runtime/dist/index.js +1 -1
  174. package/dist/node_modules/@allyhub/slides-runtime/dist/ink.js +1 -1
  175. package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
  176. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  177. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  178. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  179. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +101 -49
  180. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  181. package/dist/node_modules/@allyhub/telemetry/dist/errors.js +2 -0
  182. package/dist/node_modules/@allyhub/telemetry/package.json +5 -1
  183. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +1 -1
  184. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  185. package/dist/node_modules/@allyhub/video-extension/dist/inspect/timeline-text.js +1 -1
  186. package/dist/node_modules/@allyhub/video-extension/package.json +3 -3
  187. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  188. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  189. package/dist/node_modules/@allyhub/website/package.json +1 -1
  190. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  191. package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
  192. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  193. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  194. package/dist/package.json +12 -12
  195. package/editor-web/assets/{abnfDiagram-WEYOIA3C-BKmMA6gn.js → abnfDiagram-WEYOIA3C-D70jg8mE.js} +1 -1
  196. package/editor-web/assets/{architecture-WOLXFQ4H-BEFBgb4k.js → architecture-WOLXFQ4H-CrXS3E8e.js} +1 -1
  197. package/editor-web/assets/{architectureDiagram-ZHVYKT53-_u5YfCjY.js → architectureDiagram-ZHVYKT53-JrBljCOx.js} +1 -1
  198. package/editor-web/assets/arrow-down-DzZjFrBL.js +1 -0
  199. package/editor-web/assets/arrow-up-hdmh9LVD.js +1 -0
  200. package/editor-web/assets/{article-BUmD3xtR.js → article-BWrfVMRA.js} +6 -6
  201. package/editor-web/assets/article-hxHjqzV1.js +7 -0
  202. package/editor-web/assets/{audio-lines-CzuzsGjI.js → audio-lines-1s1eRs4Q.js} +1 -1
  203. package/editor-web/assets/{blockDiagram-RJAE7QA3-DybfaO3Z.js → blockDiagram-RJAE7QA3-BzfC1xTS.js} +1 -1
  204. package/editor-web/assets/{bookmark-Dsd3kHJJ.js → bookmark-Dfji3syX.js} +1 -1
  205. package/editor-web/assets/{button-eGxLxbv9.js → button-EftXSfev.js} +1 -1
  206. package/editor-web/assets/{c4Diagram-XDPPPE54-BfqLHB5i.js → c4Diagram-XDPPPE54-s2TpXKgH.js} +1 -1
  207. package/editor-web/assets/calc-worker-jImBXoeb.js +45 -0
  208. package/editor-web/assets/channel-BFbXY6R0.js +1 -0
  209. package/editor-web/assets/chart-BC3kUUDD.js +2 -0
  210. package/editor-web/assets/{chart-no-axes-column-BVkeF_Mr.js → chart-no-axes-column-CJmeYOSo.js} +1 -1
  211. package/editor-web/assets/{chunk-2E7WHVMD-BVp1I_d0.js → chunk-2E7WHVMD-DyE9v6UX.js} +1 -1
  212. package/editor-web/assets/{chunk-4EMNKR2T-CTdgWEMr.js → chunk-4EMNKR2T-CCunMMcT.js} +1 -1
  213. package/editor-web/assets/{chunk-55XCU76K-7pnsxeaP.js → chunk-55XCU76K-CZgJYrN4.js} +1 -1
  214. package/editor-web/assets/{chunk-7S6XSTFO-Dc0Dvkq7.js → chunk-7S6XSTFO-B01FlTFf.js} +1 -1
  215. package/editor-web/assets/{chunk-AQDTSKZB-VAILIsfx.js → chunk-AQDTSKZB-latWUvVu.js} +1 -1
  216. package/editor-web/assets/{chunk-DSNLSHJZ-CUDx1Rv5.js → chunk-DSNLSHJZ-BHFiQInN.js} +1 -1
  217. package/editor-web/assets/{chunk-HAGFOTED-DAoEe-dJ.js → chunk-HAGFOTED-C4hR36ab.js} +1 -1
  218. package/editor-web/assets/{chunk-HNE4Q36P-g0akya12.js → chunk-HNE4Q36P-CNrxiD2Q.js} +1 -1
  219. package/editor-web/assets/{chunk-NQOKRVIF-hTGjzXdJ.js → chunk-NQOKRVIF-DpyEHKEY.js} +1 -1
  220. package/editor-web/assets/{chunk-UHW7PFBP-BgLV8BIJ.js → chunk-UHW7PFBP-SIEJdixh.js} +1 -1
  221. package/editor-web/assets/{chunk-VQ5W62QI-Bw19OOSD.js → chunk-VQ5W62QI-CxWnQRxx.js} +1 -1
  222. package/editor-web/assets/{chunk-WQQL4CDK-CMST9dyE.js → chunk-WQQL4CDK-CbRuCBm6.js} +1 -1
  223. package/editor-web/assets/{chunk-YZO67HFG-Bbpu36XF.js → chunk-YZO67HFG-Cgu-EQvs.js} +1 -1
  224. package/editor-web/assets/{chunk-ZAUX2LTX-C48Ri0Gs.js → chunk-ZAUX2LTX-pAl5CV3o.js} +1 -1
  225. package/editor-web/assets/{chunk-ZCHMQSOR-DN1g01Oe.js → chunk-ZCHMQSOR-Du5hY-FP.js} +1 -1
  226. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-U6jbPr2d.js → classDiagram-v2-4MYWR3UA-CevU94T6.js} +1 -1
  227. package/editor-web/assets/{collaborator-B1u2td9m.js → collaborator-C6IJkcGR.js} +1 -1
  228. package/editor-web/assets/copy-DvOiv9Ra.js +1 -0
  229. package/editor-web/assets/{createLucideIcon-GFZ_fxLc.js → createLucideIcon-REX213UO.js} +1 -1
  230. package/editor-web/assets/{cynefin-EF2NZ3EQ-gzkai_7-.js → cynefin-EF2NZ3EQ-DBHwpMRJ.js} +1 -1
  231. package/editor-web/assets/{cynefinDiagram-WF24UDRP-DtSekSr6.js → cynefinDiagram-WF24UDRP-CxUzpjvG.js} +1 -1
  232. package/editor-web/assets/{dagre-NK4GIZVX-CiUwYVT6.js → dagre-NK4GIZVX-BAJNBDYO.js} +1 -1
  233. package/editor-web/assets/{diagram-CBK3MWTC-r9XHCV-k.js → diagram-CBK3MWTC-BQW9Fbw-.js} +1 -1
  234. package/editor-web/assets/{diagram-I5XIIV2D-DxVsDZ34.js → diagram-I5XIIV2D-DQBROUfn.js} +1 -1
  235. package/editor-web/assets/{diagram-ODIL2UCW-B0eNQoHV.js → diagram-ODIL2UCW-DEoK31qy.js} +1 -1
  236. package/editor-web/assets/{diagram-PFBEJUXE-C7f2MfJT.js → diagram-PFBEJUXE-BTCa2We1.js} +1 -1
  237. package/editor-web/assets/{diagram-RJA3I4VV-CSXcnvct.js → diagram-RJA3I4VV-DNM8qWC3.js} +1 -1
  238. package/editor-web/assets/{diagram-TYUNFSNR-DXzOD_ii.js → diagram-TYUNFSNR-BcKpED4d.js} +1 -1
  239. package/editor-web/assets/dist-90dg0B0d.js +2 -0
  240. package/editor-web/assets/dist-BSPs7tZR.js +1 -0
  241. package/editor-web/assets/dist-CP9XwbBS.js +45 -0
  242. package/editor-web/assets/dist-CRxtC7DG.js +24 -0
  243. package/editor-web/assets/{dist-CC7OeU1e.js → dist-Cmnq14RO.js} +3 -3
  244. package/editor-web/assets/dist-CrZwqOm2.js +1 -0
  245. package/editor-web/assets/dist-CzUWTcvC.js +38 -0
  246. package/editor-web/assets/dist-D2a_y4AE.js +1 -0
  247. package/editor-web/assets/{dist-DDv_SbKw.js → dist-DMZ1VHPK.js} +1 -1
  248. package/editor-web/assets/dist-DYnXIW8F.js +16 -0
  249. package/editor-web/assets/{dist-BuWaZ3Y4.js → dist-Dpet39Yp.js} +30 -30
  250. package/editor-web/assets/dist-Dre4Cwpz.js +1 -0
  251. package/editor-web/assets/dist-RkxskWGK.js +5 -0
  252. package/editor-web/assets/dist-aANR6S2I.js +3 -0
  253. package/editor-web/assets/{dist-Gz6NDS0J.js → dist-qSuFWuVB.js} +3 -3
  254. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-Cs4YRvDD.js → ebnfDiagram-V4P3TTPT-D-1x27Eh.js} +1 -1
  255. package/editor-web/assets/{elk-QONTBCTQ-Bh3LZ9WI.js → elk-QONTBCTQ-BJSCxiTH.js} +1 -1
  256. package/editor-web/assets/{erDiagram-KYQIGQAA-C4vYTYXp.js → erDiagram-KYQIGQAA-C7Q357iD.js} +1 -1
  257. package/editor-web/assets/{eventmodeling-K75KTNOO-BN1kkHWS.js → eventmodeling-K75KTNOO-kXrQLSF5.js} +1 -1
  258. package/editor-web/assets/flowDiagram-IUGLLWBU-GSC4btef.js +1 -0
  259. package/editor-web/assets/{ganttDiagram-R7GPNTJY-CA1LkkC5.js → ganttDiagram-R7GPNTJY-Bt3SRgK7.js} +1 -1
  260. package/editor-web/assets/{gitGraph-VSP46ZUC-Dy5tA7dG.js → gitGraph-VSP46ZUC-DS4CkhfK.js} +1 -1
  261. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-hJIB8EkH.js → gitGraphDiagram-PDYL7XHY-BgfmSVdI.js} +1 -1
  262. package/editor-web/assets/group-pebHQTdP.js +1 -0
  263. package/editor-web/assets/{hint-B8JpEypy.js → hint-BmRKl2nL.js} +1 -1
  264. package/editor-web/assets/index-D8qc_ipi.js +28 -0
  265. package/editor-web/assets/index-DDtZpLDF.css +2 -0
  266. package/editor-web/assets/{info-OHQRW6UA-DvzSf7rQ.js → info-OHQRW6UA-BZjctF3x.js} +1 -1
  267. package/editor-web/assets/{infoDiagram-MVDRKAX5-BjIMm4Af.js → infoDiagram-MVDRKAX5-BAp5oUXk.js} +1 -1
  268. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-Bpz71S40.js → ishikawaDiagram-HPEHV2GE-DGL7ZfUu.js} +1 -1
  269. package/editor-web/assets/{italic-D10w8n6C.js → italic-CtlNOXN9.js} +1 -1
  270. package/editor-web/assets/{journeyDiagram-BOSHW7O7-DAB-pZjD.js → journeyDiagram-BOSHW7O7-DOOoBGx-.js} +1 -1
  271. package/editor-web/assets/{kanban-definition-FNSA4HC5-cYeyh3P6.js → kanban-definition-FNSA4HC5-lbLuUiMW.js} +1 -1
  272. package/editor-web/assets/katex-UWCZofcd.js +257 -0
  273. package/editor-web/assets/{link-BC5xK1-1.js → link-CW2KxKT_.js} +1 -1
  274. package/editor-web/assets/{mermaid-parser.core-req5LE0X.js → mermaid-parser.core-RkCFmJcg.js} +3 -3
  275. package/editor-web/assets/{mermaid.core-zFwZug4C.js → mermaid.core-BVUl-afX.js} +4 -4
  276. package/editor-web/assets/{mindmap-definition-6OY57UG3-TStWb7DG.js → mindmap-definition-6OY57UG3-C3DC4T1J.js} +1 -1
  277. package/editor-web/assets/minus-D1tgAHbU.js +1 -0
  278. package/editor-web/assets/{packet-JDAUHWVQ-smFhVKcB.js → packet-JDAUHWVQ-Bkd6YpX8.js} +1 -1
  279. package/editor-web/assets/{palette-BIOudGkm.js → palette-INFK0Zsr.js} +1 -1
  280. package/editor-web/assets/{pegDiagram-ECIUJNBX-DvSNRv0-.js → pegDiagram-ECIUJNBX-B5Seh4Oe.js} +1 -1
  281. package/editor-web/assets/{pie-XZMESJXO-qjaGsBZG.js → pie-XZMESJXO-BNbb4Q8k.js} +1 -1
  282. package/editor-web/assets/{pieDiagram-GNMPY74T-Dd9P-Pdc.js → pieDiagram-GNMPY74T-_hnbUloZ.js} +1 -1
  283. package/editor-web/assets/play-DvMyq5xW.js +1 -0
  284. package/editor-web/assets/{progress-DE4C5_3x.js → progress-D6wSFdpY.js} +1 -1
  285. package/editor-web/assets/props-form-BfwEi6jW.js +1 -0
  286. package/editor-web/assets/{quadrantDiagram-D57K4MC3-h2IIKUUA.js → quadrantDiagram-D57K4MC3-1rbqW-KO.js} +1 -1
  287. package/editor-web/assets/{radar-ABXABTNO-DlVrSA1d.js → radar-ABXABTNO-BWSnhBSp.js} +1 -1
  288. package/editor-web/assets/{railroad-I3PHUGI6-nFbuLAtc.js → railroad-I3PHUGI6-BNB-OKs1.js} +1 -1
  289. package/editor-web/assets/{railroad-abnf-LNEFI6M7-Daj8h2iV.js → railroad-abnf-LNEFI6M7-BKgidf_B.js} +1 -1
  290. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-eYJyl5PH.js → railroad-ebnf-DWYD2UWJ-CNCnxtHp.js} +1 -1
  291. package/editor-web/assets/{railroad-peg-JR7BVNR7-BTRhKZQq.js → railroad-peg-JR7BVNR7-CyBW6_0o.js} +1 -1
  292. package/editor-web/assets/{railroadDiagram-Y72NRBL7-CeLGUjdp.js → railroadDiagram-Y72NRBL7-Cud3SJ7O.js} +1 -1
  293. package/editor-web/assets/{react-WA6wlt8S.js → react-Bk7NnOLX.js} +1 -1
  294. package/editor-web/assets/{repeat-2-VQP1EVOZ.js → repeat-2-DfPmKp4w.js} +1 -1
  295. package/editor-web/assets/{requirementDiagram-EQYSW5RA-Dmk9XRM5.js → requirementDiagram-EQYSW5RA-BrSCcpqV.js} +1 -1
  296. package/editor-web/assets/{row-BRlEWRrK.js → row-VwyPfa1b.js} +1 -1
  297. package/editor-web/assets/{sankeyDiagram-SY24JHO5-Yn4zlrAM.js → sankeyDiagram-SY24JHO5-rJV4dJFn.js} +1 -1
  298. package/editor-web/assets/scissors-D9WmgvNP.js +1 -0
  299. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-BTRnp_PW.js → sequenceDiagram-BLEHNHQU-CEUuD2n6.js} +1 -1
  300. package/editor-web/assets/{session-Do9AqS38.js → session-DE0fvAcs.js} +1 -1
  301. package/editor-web/assets/sigma-CY2Chbro.js +1 -0
  302. package/editor-web/assets/slides-BgacyjJW.js +1 -0
  303. package/editor-web/assets/{snapshots-BUGlKQIB.js → snapshots-D8TtZp1x.js} +1 -1
  304. package/editor-web/assets/{sound-Bj3o9_Fa.js → sound-DUCxe9eC.js} +1 -1
  305. package/editor-web/assets/split-Cx2MMnC_.js +3 -0
  306. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-kstrRKv2.js → stateDiagram-v2-A6IESKWZ-BRE_C2he.js} +1 -1
  307. package/editor-web/assets/sticky-note-C5qUDHhC.js +1 -0
  308. package/editor-web/assets/{strikethrough-CfXx6IYH.js → strikethrough-DP-7tMz0.js} +1 -1
  309. package/editor-web/assets/svg-nJtFNJ-7.js +1 -0
  310. package/editor-web/assets/{swatch-WeJD41aW.js → swatch-lxK4C8fD.js} +1 -1
  311. package/editor-web/assets/{swimlanes-B3ENRKFQ-DaZsZkeP.js → swimlanes-B3ENRKFQ-BEPqWgVe.js} +1 -1
  312. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-DAcNszZ6.js +8 -0
  313. package/editor-web/assets/{switch-N0G_sbqt.js → switch-DaG6OuAi.js} +1 -1
  314. package/editor-web/assets/{syntax-oWsKBWFw.js → syntax-9LD8MzGy.js} +1 -1
  315. package/editor-web/assets/{syntax-BVsgRJ4I.js → syntax-CLaCSmoi.js} +1 -1
  316. package/editor-web/assets/{table-B6hVZAMi.js → table-CTjNpE4W.js} +1 -1
  317. package/editor-web/assets/tabs-DjhzblAG.js +1 -0
  318. package/editor-web/assets/{textarea-tEWvBY9p.js → textarea-DBwRbOyF.js} +1 -1
  319. package/editor-web/assets/{timeline-definition-JXYKGLGB-CLCvY-Yf.js → timeline-definition-JXYKGLGB-p8Qeg4pS.js} +1 -1
  320. package/editor-web/assets/{trash-2-BP6nqpg2.js → trash-2-DrnRa91l.js} +1 -1
  321. package/editor-web/assets/{treeView-D4JQ5SDB-BmN0gwdC.js → treeView-D4JQ5SDB-C9FTdXKq.js} +1 -1
  322. package/editor-web/assets/{treemap-SAJKECNS-DN29G_E_.js → treemap-SAJKECNS-XAeLVOtI.js} +1 -1
  323. package/editor-web/assets/{undo-2-CHR0nvWL.js → undo-2-DUGGyBdX.js} +1 -1
  324. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-DTRS54cB.js → usecaseDiagram-WPOLBNNX-BV3AMRuH.js} +1 -1
  325. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-DAAc11Hx.js → vennDiagram-Q3Y3IDCW-CJdKcYyA.js} +1 -1
  326. package/editor-web/assets/{video-BlvmR8BK.js → video-He8p6dr6.js} +1 -1
  327. package/editor-web/assets/{wardley-7MLQ67FV-B-UYkmdB.js → wardley-7MLQ67FV-DZh6Mf22.js} +1 -1
  328. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-BmbwCaky.js → wardleyDiagram-IVAIDKWA-XtvKSX-m.js} +1 -1
  329. package/editor-web/assets/{words-D_4T9Adq.js → words-CPHp_0tt.js} +1 -1
  330. package/editor-web/assets/{words-WgdEQdYP.js → words-CjW-1tZI.js} +1 -1
  331. package/editor-web/assets/{xychartDiagram-4URNHDU4-ChAfAq1U.js → xychartDiagram-4URNHDU4-CGkL42sz.js} +1 -1
  332. package/editor-web/assets/zoom-in-C4lxmIDE.js +1 -0
  333. package/editor-web/index.html +6 -6
  334. package/package.json +2 -2
  335. package/editor-web/assets/arrow-up-B5rJbBv0.js +0 -1
  336. package/editor-web/assets/article-DNioBb3p.js +0 -7
  337. package/editor-web/assets/calc-worker-D2pGis6e.js +0 -45
  338. package/editor-web/assets/channel-TNPgFDrw.js +0 -1
  339. package/editor-web/assets/chart-C37xvZT2.js +0 -1
  340. package/editor-web/assets/dist-BGRwhCQO.js +0 -1
  341. package/editor-web/assets/dist-BW4X7BrF.js +0 -1
  342. package/editor-web/assets/dist-BgDRE85b.js +0 -2
  343. package/editor-web/assets/dist-Blq5nJnU.js +0 -24
  344. package/editor-web/assets/dist-C1emZ9wX.js +0 -37
  345. package/editor-web/assets/dist-CX-fiPSn.js +0 -38
  346. package/editor-web/assets/dist-C_VvG-_9.js +0 -5
  347. package/editor-web/assets/dist-Ce7HrBxv.js +0 -3
  348. package/editor-web/assets/dist-D2k6w-_a.js +0 -1
  349. package/editor-web/assets/dist-DEoEO4zs.js +0 -1
  350. package/editor-web/assets/dist-DlDxxPIP.js +0 -16
  351. package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +0 -1
  352. package/editor-web/assets/index-CgB5osVc.js +0 -28
  353. package/editor-web/assets/index-Daytem9N.css +0 -2
  354. package/editor-web/assets/katex-5Z2zF-9g.js +0 -257
  355. package/editor-web/assets/minus-DaWs5i8B.js +0 -1
  356. package/editor-web/assets/play-CrMmPghG.js +0 -1
  357. package/editor-web/assets/props-form-CsmDBqzy.js +0 -1
  358. package/editor-web/assets/schemas-VikZYZIK.js +0 -1
  359. package/editor-web/assets/slides-diTEQ3C5.js +0 -1
  360. package/editor-web/assets/split-CNU1RHcX.js +0 -3
  361. package/editor-web/assets/svg-Cx50MpxK.js +0 -1
  362. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +0 -8
  363. package/editor-web/assets/tabs-DIFDqj-l.js +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Feature highlights from each AllyHub release.
4
4
 
5
+ ## 0.13.0
6
+
7
+ - **Decks and sheets work like PowerPoint and Excel.** The deck editor has PowerPoint's ribbon and every animation effect; the sheet editor has Excel's everyday commands, from filters by colour to Paste Special, and rich text in a cell. An export says what it leaves out.
8
+ - **A provenance record is `<file>.provenance`.** The record beside a file a tool made no longer ends in `.json`, so reading a folder's data skips it.
9
+ - **Choose how hard AllyHub's own agent thinks.** Studio offers each model's Effort, starting at medium.
10
+ - **More of each cloud tool's options**, such as the country TikTok is seen from or YouTube's counts and descriptions in search.
11
+ - **A new account starts with 200 credits**, and uploads and tools' results are let go 2 hours after they were used.
12
+
5
13
  ## 0.12.0
6
14
 
7
15
  - **AllyHub learns what is used and what fails.** The CLI and Studio tell AllyHub which commands run, how long agents take and the errors they meet, never what you make or say. Studio's Settings or `ALLYHUB_TELEMETRY=off` turns it off; the list of what is told is public.
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{createHash as d}from"node:crypto";import{dirname as m,join as c,relative as a}from"node:path";import{REPORT_DEFAULTS as f,reportPicture as u}from"@allyhub/report-extension/cli";import{webp as h}from"@allyhub/image-render/webp";import{EXIT as l}from"@allyhub/protocol";import{CommandError as w}from"../../command.js";import{picturePath as g,save as E,workPath as $}from"./common.js";export function selectorName(t){const r=t.replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,40),e=d("sha256").update(t).digest("hex").slice(0,6);return r===""?e:`${r}-${e}`}export async function reportFrames(t){const r=a(t.root,m(t.file)),e=t.width??f.width;let i;try{i=await u({root:t.root,file:a(t.root,t.file).split("\\").join("/"),width:e,dark:t.dark,print:t.print,at:t.at})}catch(o){throw o instanceof Error&&o.name==="ReportPictureError"?new w("no-element",o.message,{exit:l.notFound,hint:"Write --at as a CSS selector of an element the page draws."}):o}const s=[`w${String(e)}`,...t.dark?["dark"]:[],...t.print?["print"]:[],...t.at===void 0?[]:[`at-${selectorName(t.at)}`]].join("-"),p=await E(g(t.cwd,t.out,c($(t.root,"frames",r),`${s}.png`)),await h(i.png,90)),n=i.findings;return{mode:"frame",source:"report",report:r,out:p,width:e,pageHeight:i.pageHeight,bands:i.bands,missing:n.missing,outside:n.outside,thrown:n.thrown,...n.unsettled===void 0?{}:{unsettled:n.unsettled}}}
2
+ import{createHash as d}from"node:crypto";import{dirname as m,join as c,relative as o}from"node:path";import{REPORT_DEFAULTS as f,reportPicture as u}from"@allyhub/report-extension/cli";import{webp as l}from"@allyhub/image-render/webp";import{EXIT as h}from"@allyhub/protocol";import{CommandError as w}from"../../command.js";import{picturePath as g,save as k,workPath as E}from"./common.js";export function selectorName(t){const n=t.replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,40),e=d("sha256").update(t).digest("hex").slice(0,6);return n===""?e:`${n}-${e}`}export async function reportFrames(t){const n=o(t.root,m(t.file)),e=t.width??f.width;let r;try{r=await u({root:t.root,file:o(t.root,t.file).split("\\").join("/"),width:e,dark:t.dark,print:t.print,at:t.at})}catch(i){throw i instanceof Error&&i.name==="ReportPictureError"?new w("no-element",i.message,{exit:h.notFound,hint:"Write --at as a CSS selector of an element the page draws."}):i}const s=[`w${String(e)}`,...t.dark?["dark"]:[],...t.print?["print"]:[],...t.at===void 0?[]:[`at-${selectorName(t.at)}`]].join("-"),p=await k(g(t.cwd,t.out,c(E(t.root,"frames",n),`${s}.png`)),await l(r.png,90)),a=r.findings;return{mode:"frame",source:"report",report:n,out:p,width:e,pageHeight:r.pageHeight,bands:r.bands,missing:a.missing,outside:a.outside,thrown:a.thrown,...a.unsettled===void 0?{}:{unsettled:a.unsettled},blankCanvases:r.blankCanvases}}
@@ -1,12 +1,12 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{relative as _,sep as G}from"node:path";import{z as r}from"zod";import{formatConsole as H,formatProblem as N}from"../text/index.js";import{sizeOf as B}from"@allyhub/build";import{COMPARE_DEFAULTS as U}from"@allyhub/measure";import{CUT_REVIEW_DEFAULTS as J,cutLine as V,dbText as x,silenceText as q}from"@allyhub/video-measure";import{consoleJson as T}from"@allyhub/project";import{PAGE_CAPTURE_DEFAULTS as j}from"@allyhub/browser";import{itemIdOf as X}from"@allyhub/formats";import{EXIT as O}from"@allyhub/protocol";import{defineCommand as w}from"../command.js";import{dir as C}from"../fields.js";import{parameters as D}from"../parameters.js";import{tellPresence as E}from"../presence.js";import{projectRoot as $}from"../project.js";import{VERSION_FIELDS as k,commandError as P,withVersion as y}from"../version.js";import{compareText as W,comparePictures as z}from"./frames/compare.js";import{isPicture as A,isVideo as M,usage as m}from"./frames/common.js";import{cutSheets as K}from"./frames/cuts.js";import{fileFrames as Q}from"./frames/file.js";import{pageShot as Y}from"./frames/page.js";import{pieceMoments as Z,stillsSheet as ee}from"./frames/piece.js";import{docPicture as te}from"./frames/doc.js";import{findDoc as re}from"@allyhub/doc-extension/cli";import{sheetPicture as oe}from"./frames/sheet.js";import{findSheet as I}from"@allyhub/sheet-extension/cli";import{reportFrames as ae}from"./frames/report.js";import{findReport as ne}from"@allyhub/report-extension/cli";function v(e){return[...e.problems.filter(a=>a.level==="error").map(N),...H(T(e.console))]}const S=e=>({problems:e.problems,...T(e.console)}),F=(e,i)=>$(e,i),ie=r.strictObject({...k,item:r.string().optional().describe("The piece (its id, its file without its extension, or its file; default the project's only one), a sheet, a doc, a report, or a video file: a path ending in .mp4, .mov, .webm, .m4v, .qt, .mkv or .avi is a file"),range:r.string().optional().describe("A sheet's: what to draw, a sheet (Summary), a range (Summary!B3:D9, or B3:D9 on the first sheet), columns (A:C) or rows (1:20); default its sheets, from A1"),page:r.string().optional().describe("A doc's: the pages to draw large, counted from 1 (2, 2-4, 1,5); default every page, small, tiled"),at:r.array(r.string()).optional().describe("Moments: seconds (from the start of --part when given) or anchors (@press, @/map a stretch's end, @press+0.2); a video file's are seconds. One is written as the frame itself, several are tiled. Without it, --part's still, or every part's still on one sheet. A report's: a CSS selector, that element alone"),width:r.number().int().min(200).max(3840).optional().describe("A report's: the page's width, CSS pixels (default 1440; 375 a phone's)"),dark:r.boolean().default(!1).describe("A report's: drawn as a reader who asks for dark sees it"),print:r.boolean().default(!1).describe("A report's: laid out for paper (@media print) at the width given, as one long picture"),part:r.string().optional().describe("The part --at, --from and --to count from; alone, its still"),from:r.number().optional().describe("A stretch of consecutive frames from this second (with --to), instead of --at"),to:r.number().optional().describe("The stretch's last second"),clip:r.string().optional().describe("Write the stretch as a small silent video, .gif, .mp4 or .webm by its extension; with --out, the grid too"),overlay:r.boolean().default(!1).describe("Draw over each tile the face boxes with ids, the person matte's outline, the covered areas and the text boxes (a deck's: each shape's box and name, and the lines nearly in line); places nothing. Alone, over every part's still"),beside:r.string().optional().describe("Another video file (a reference) whose frame at the same time goes on each tile's left"),grid:r.number().int().min(4).optional().describe("A video file at one --at: the frame at its own size with numbered lines every this many pixels"),out:r.string().optional().describe("Where the picture goes, always a WebP whatever the extension; default under .allyhub/work/frames/")});function se(e){const i=[["--combo",e.combo!==void 0],["--part",e.part!==void 0],["--beside",e.beside!==void 0],["--overlay",e.overlay]].filter(([,a])=>a).map(([a])=>a);if(i.length>0)throw m("bad-option",`${i.join(" and ")} ${i.length===1?"is":"are"} a piece's: a video file has no combos or parts.`)}function de(e){const i=[["--at",e.at!==void 0],["--part",e.part!==void 0],["--from",e.from!==void 0],["--to",e.to!==void 0],["--clip",e.clip!==void 0],["--overlay",e.overlay],["--beside",e.beside!==void 0],["--range",e.range!==void 0],["--combo",e.combo!==void 0]].filter(([,a])=>a).map(([a])=>a);if(i.length>0)throw m("bad-option",`${i.join(" and ")} ${i.length===1?"is":"are"} not a doc's: a doc has pages (--page), not moments.`)}function le(e){const i=[["--part",e.part!==void 0],["--from",e.from!==void 0],["--to",e.to!==void 0],["--clip",e.clip!==void 0],["--overlay",e.overlay],["--beside",e.beside!==void 0],["--range",e.range!==void 0],["--page",e.page!==void 0],["--combo",e.combo!==void 0],["--at with more than one selector",(e.at?.length??0)>1]].filter(([,a])=>a).map(([a])=>a);if(i.length>0)throw m("bad-option",`${i.join(" and ")} ${i.length===1?"is":"are"} not a report's: a report is one page (--width, --dark, --print, --at <selector>).`)}export const frames=w({name:"frames",summary:"Pictures of a piece over time, drawn as the render draws them: every part's still on a sheet (default), a moment, a stretch tiled or as a clip, overlays; a sheet's cells, or a range of them; a doc's pages as they print, with how many; a report's page at a width, light or dark, or laid out for print; or any video file's frames",input:ie,positional:["item"],output:r.looseObject({mode:r.enum(["sheet","frame","grid","clip"])}),examples:["allyhub frames launch/film","allyhub frames launch/film --at 2.5","allyhub frames launch/film --part hook --from 0 --to 1 --clip hook.gif","allyhub frames launch/film --at 1,2,3 --overlay","allyhub frames reference.mp4 --at 0,1,2","allyhub frames reference.mp4 --at 3 --grid 50","allyhub frames finance/budget --range 'Summary!A1:F20'","allyhub frames launch/plan","allyhub frames launch/plan --page 2-3","allyhub frames research/channels/channels --width 375","allyhub frames research/channels/channels --at '#tiers'"]},async(e,i)=>{const a=i.cwd;if(e.item!==void 0&&M(e.item)){se(e);const t=await Q({cwd:a,root:await F(a,e.dir),file:e.item,at:e.at,from:e.from,to:e.to,clip:e.clip,out:e.out,grid:e.grid}).catch(b=>{throw P(b)}),n=t.video,c=`${t.file} · ${n.duration.toFixed(2)} s · ${String(n.width)}×${String(n.height)} · ${String(n.fps)} fps`,g="clip"in t&&t.clip?`${t.clip.out} (${t.clip.type}, ${String(t.clip.frames)} frames at ${String(t.clip.fps)} fps, no sound)`:void 0;return{value:t,text:[c,..."out"in t?[`${t.out}${"tiles"in t?` (${String(t.tiles.length)} moments in ${String(t.cols)} columns)`:""}`]:[],...g?[g]:[]].join(`
3
- `)}}if(e.grid!==void 0)throw m("bad-option","--grid draws a video file's frame at its own size: give the file.");const d=await $(a,e.dir);if(e.item!==void 0&&await I(d,a,e.item)!==void 0){const t=await oe({cwd:a,root:d,item:e.item,range:e.range,out:e.out}),n=await I(d,a,e.item);return n!==void 0&&Object.keys(t.at).length>0&&await E(d,{doing:"looking",item:X(_(d,n).split(G).join("/")),place:t.at}),{value:t,text:[t.out,...t.cut].join(`
4
- `)}}const l=e.item===void 0?void 0:await ne(d,a,e.item);if(l!==void 0){le(e);const t=await ae({cwd:a,root:d,file:l,width:e.width,dark:e.dark,print:e.print,at:e.at?.[0],out:e.out}),n=[...t.missing.map(c=>`asks for ${c.path}, not in the project`),...t.outside.map(c=>`asks for ${c}, outside the project: refused`),...t.thrown.map(c=>`threw ${c.text.split(`
5
- `)[0]??""}`),...t.unsettled===void 0?[]:[t.unsettled]];return{value:t,text:[t.out,`${t.report}: ${String(t.width)} px wide, ${String(t.pageHeight)} px tall${t.bands>1?`, in ${String(t.bands)} bands side by side`:""}`,...n.map(c=>`${t.report}: ${c}`)].join(`
6
- `)}}if(e.width!==void 0||e.dark||e.print)throw m("bad-option","--width, --dark and --print are a report's: name the report.");const s=e.item===void 0?void 0:await re(d,a,e.item);if(s!==void 0){de(e);const t=await te({cwd:a,root:d,file:s,page:e.page,out:e.out,progress:c=>{i.progress(c)}}),n=t.drawn.length===t.pages?"every page":`page${t.drawn.length===1?"":"s"} ${t.drawn.join(", ")}`;return{value:t,text:[t.out,`${t.doc}: ${String(t.pages)} page${t.pages===1?"":"s"} on ${String(t.paper.width)} × ${String(t.paper.height)} mm paper; ${n} drawn`].join(`
7
- `)}}if(e.page!==void 0)throw m("bad-option","--page is a doc's: name the doc.");if(e.range!==void 0)throw m("bad-option","--range is a sheet's: name the sheet.");const h=e.at!==void 0||e.part!==void 0||e.from!==void 0||e.to!==void 0;if(!h&&(e.clip!==void 0||e.beside!==void 0))throw m("bad-option","--clip and --beside draw moments: give --at, --part, or --from and --to.");if(!h&&!e.overlay){const{result:t,...n}=await y(e,i,"render",b=>ee(b,{cwd:a,root:d,out:e.out})),{unit:c,...g}=t;return{value:{...g,...S(n)},text:[`${t.out} (${t.piece} · ${t.format} · ${String(t.parts.length)} ${t.parts.length===1?c.noun:c.plural})`,...v(n)].join(`
8
- `)}}const f=!h&&e.overlay,{result:o,...p}=await y(e,i,"render",async t=>{const n=await Z(t,{cwd:a,root:d,at:f?t.timeline.parts.map(L=>String(L.still)):e.at,part:e.part,from:e.from,to:e.to,clip:e.clip,out:e.out,overlay:e.overlay,beside:e.beside}),c="tiles"in n?n.tiles[0]:void 0,g=n.mode==="frame"?n.t:n.stretch?.from??c?.t,b=n.mode==="frame"?n.part:c?.part;return g!==void 0&&!f&&await E(d,{doing:"looking",item:t.piece.place,place:{t:g,...b===void 0?{}:{part:b}}}),n}),u=[];if(o.mode==="frame"&&u.push(`${o.out} (${o.piece} · ${o.format} · ${o.part} · ${o.t.toFixed(2)} s)`),o.mode==="grid"){u.push(`${o.out} (${o.piece} · ${String(o.tiles.length)} moments in ${String(o.cols)} columns)`,` ${o.tiles.map(n=>`${n.t.toFixed(o.stretch?3:2)} ${n.part}`).join(" · ")}`);const t=[...new Set(o.tiles.flatMap(n=>n.overlay?.missing??[]))];t.length>0&&u.push(` Not measured: ${t.join(", ")}.`)}return o.stretch&&u.push(` Stretch ${o.stretch.from.toFixed(3)}–${o.stretch.to.toFixed(3)} s, one frame in ${String(o.stretch.every)}: ${String(o.stretch.frames)} frames.`),"clip"in o&&o.clip&&u.push(`${o.clip.out} (${o.clip.type}, ${String(o.clip.frames)} frames at ${String(o.clip.fps)} fps, no sound)`),{value:{...o,...S(p)},text:[...u,...v(p)].join(`
9
- `)}}),framesCuts=w({name:"frames cuts",summary:"A review sheet per cut of a video (a cut take's jumps, part joins, a scenery camera's cuts): frames around it, waveform and level, the words each side, the sound at it",input:r.strictObject({...k,part:r.string().optional().describe("Only this part's cuts and its joins"),out:r.string().optional().describe("The folder the sheets go in; default .allyhub/work/cuts/"),params:D({span:r.number().positive().max(10).default(J.span).describe("Seconds shown on each side of a cut")})}),positional:["item"],output:r.looseObject({out:r.string(),cuts:r.array(r.looseObject({sheet:r.string()}))}),examples:["allyhub frames cuts launch/film","allyhub frames cuts launch/film --part hook"]},async(e,i)=>{const a=i.cwd,d=await $(a,e.dir),{result:l,...s}=await y(e,i,"render",o=>K(o,{cwd:a,root:d,part:e.part,out:e.out,review:{span:e.params.span}})),h=l.part===void 0?`${String(l.cuts.length)} cut${l.cuts.length===1?"":"s"}`:`${String(l.cuts.length)} of ${String(l.total)} cuts (part ${l.part} and its joins)`,f=[`${l.piece} · ${l.format} · ${h}; silence is sound under ${String(l.threshold)} dBFS`];for(const o of l.cuts){const p=o.sound?`level ${x(o.sound.levelDb)} / around ${x(o.sound.aroundDb)} dBFS, peak ${x(o.sound.peakDb)}, step ${o.sound.jumpDb<0?"−":"+"}${Math.abs(o.sound.jumpDb).toFixed(1)} dB`:"no sound";f.push(`${String(o.index).padStart(3)} ${o.t.toFixed(3).padStart(7)} s ${o.kind.padEnd(6)} ${V(o)}`,` silence at the cut: ${q(o.silence)} · ${p}`,` “${o.said.before}” | “${o.said.after}”${o.across?` · across the cut: “${o.across}”`:""}`,` ${o.sheet}`)}return{value:{...l,...S(s)},text:[...f,...v(s)].join(`
10
- `)}});const R=U;export const framesCompare=w({name:"frames compare",summary:"How a candidate picture differs from a reference, as numbers (ΔE, channels, SSIM, levels, grain, edges, regions) with a heatmap and a side-by-side: a piece's moment, a picture file or a video file's frame",input:r.strictObject({reference:r.string().describe("The reference picture (PNG, WebP, JPEG…)"),candidate:r.string().optional().describe("A piece (its id, its file without its extension, or its file; default the project's only one) at --at or --part's still; or a file by its extension: a picture (.png, .jpg, .webp…), or a video file's frame at --at (.mp4, .mov, .webm…)"),combo:k.combo,dir:C,at:r.string().optional().describe("The moment: seconds (from the start of --part when given) or an anchor of the piece; a video file's are seconds (default 0)"),part:r.string().optional().describe("The piece's part --at counts from; alone, its still"),refCrop:r.string().optional().describe("Cut the reference to x,y,width,height, or to an element of the elements.json beside it (frames web writes one)"),crop:r.string().optional().describe("Cut the candidate to x,y,width,height before any resize"),encode:r.string().optional().describe("Draw the candidate through this encode first, as a platform serves it: codec:kbps, h264 or hevc (hevc:618)"),out:r.string().optional().describe("Where its files go, a path without extension; default under .allyhub/work/compare/"),params:D({resize:r.enum(["stretch","width","none"]).default(R.resize).describe("When sizes differ: stretch the candidate to the reference, scale it to its width, or compare the common area"),shift:r.number().int().min(0).max(32).default(R.shift).describe("Search the best offset within this many pixels each way")})}),positional:["reference","candidate"],output:r.looseObject({reference:r.string(),files:r.looseObject({side:r.string(),heatmap:r.string()})}),examples:["allyhub frames compare reference.png launch/film --at 2.5 --encode hevc:618","allyhub frames compare reference.png shot.webp --ref-crop cta","allyhub frames compare reference.png theirs.mp4 --at 3"]},async(e,i)=>{const a=i.cwd,d=e.params;if(!A(e.reference))throw m("bad-reference",`${e.reference} is not a picture: the reference comes first, a picture file (PNG, WebP, JPEG…), then the piece or file to compare with it.`,`For example: allyhub frames compare ${e.candidate!==void 0&&A(e.candidate)?e.candidate:"reference.png"} ${e.reference}`);const l=e.candidate!==void 0&&(A(e.candidate)||M(e.candidate))?e.candidate:void 0,s=p=>({cwd:a,root:p,reference:e.reference,file:l,at:e.at===void 0?void 0:[e.at],part:e.part,refCrop:e.refCrop,crop:e.crop,encode:e.encode,out:e.out,options:{shift:d.shift,resize:d.resize}});if(l!==void 0){if(e.combo!==void 0||e.part!==void 0)throw m("bad-option","--combo and --part are a piece's: the candidate is a file.");const p=await z(s(await F(a,e.dir)),void 0).catch(u=>{throw P(u)});return{value:p,text:W(p)}}const h=await $(a,e.dir),{result:f,...o}=await y({...e,item:e.candidate},i,"render",p=>z(s(h),p));return{value:{...f,...S(o)},text:[W(f),...v(o)].join(`
11
- `)}}),framesWeb=w({name:"frames web",summary:"A web page's screenshot with its named elements' boxes in the image's pixels, for a screen demo",input:r.strictObject({url:r.string().describe("The page: an address, or an HTML file on this computer"),el:r.array(r.string()).optional().describe("An element to locate, name=selector (CSS, or text=<words>); [data-el] elements are found too"),click:r.array(r.string()).optional().describe("Selectors clicked in order before the shot (close a banner, open a dialog)"),full:r.boolean().default(!1).describe("The whole page, not one viewport"),out:r.string().optional().describe("Where the picture goes (a WebP), its boxes in <out>.elements.json beside it; default under .allyhub/work/pages/"),dir:C,size:r.string().default(`${String(j.width)}x${String(j.height)}`).describe("The viewport, WIDTHxHEIGHT in CSS pixels"),scale:r.number().min(1).max(4).default(j.scale).describe("Image pixels per CSS pixel; 2 draws a high-density screen, sharp when a camera goes in"),wait:r.number().int().min(0).optional().describe("Milliseconds to wait after loading and clicking")}),positional:["url"],output:r.looseObject({out:r.string(),elementsFile:r.string()}),examples:["allyhub frames web https://example.com --el cta=text=Sign\\ up --scale 2 --out assets/media/home","allyhub frames web page.html --click '#accept' --full"]},async(e,i)=>{const a=i.cwd,[d,l]=B(e.size),s=await Y({cwd:a,root:await F(a,e.dir),url:e.url,out:e.out,el:e.el,click:e.click,width:d,height:l,scale:e.scale,full:e.full,wait:e.wait});return{value:s,text:[`${s.out}: ${String(s.width)}×${String(s.height)}${s.scale===1?"":` (${String(s.scale)} image pixels per CSS pixel)`}, ${String(Object.keys(s.elements).length)} elements (${Object.keys(s.elements).join(", ")||"none"}) in ${s.elementsFile}`,...s.missing.length>0?[`Not found: ${s.missing.join(", ")} (the selector is wrong, or something must be opened with --click first).`]:[]].join(`
12
- `),exit:s.missing.length>0?O.failed:O.ok}}),FRAMES_COMMANDS=[frames,framesCuts,framesCompare,framesWeb];
2
+ import{relative as _,sep as G}from"node:path";import{z as r}from"zod";import{formatConsole as H,formatProblem as N}from"../text/index.js";import{sizeOf as B}from"@allyhub/build";import{COMPARE_DEFAULTS as U}from"@allyhub/measure";import{CUT_REVIEW_DEFAULTS as J,cutLine as V,dbText as x,silenceText as q}from"@allyhub/video-measure";import{consoleJson as T}from"@allyhub/project";import{PAGE_CAPTURE_DEFAULTS as j}from"@allyhub/browser";import{itemIdOf as X}from"@allyhub/formats";import{EXIT as C}from"@allyhub/protocol";import{defineCommand as w}from"../command.js";import{dir as O}from"../fields.js";import{parameters as D}from"../parameters.js";import{tellPresence as E}from"../presence.js";import{projectRoot as $}from"../project.js";import{VERSION_FIELDS as k,commandError as P,withVersion as y}from"../version.js";import{compareText as W,comparePictures as z}from"./frames/compare.js";import{isPicture as A,isVideo as M,usage as m}from"./frames/common.js";import{cutSheets as K}from"./frames/cuts.js";import{fileFrames as Q}from"./frames/file.js";import{pageShot as Y}from"./frames/page.js";import{pieceMoments as Z,stillsSheet as ee}from"./frames/piece.js";import{docPicture as te}from"./frames/doc.js";import{findDoc as re}from"@allyhub/doc-extension/cli";import{sheetPicture as oe}from"./frames/sheet.js";import{findSheet as I}from"@allyhub/sheet-extension/cli";import{reportFrames as ae}from"./frames/report.js";import{findReport as ne}from"@allyhub/report-extension/cli";function v(e){return[...e.problems.filter(a=>a.level==="error").map(N),...H(T(e.console))]}const S=e=>({problems:e.problems,...T(e.console)}),F=(e,i)=>$(e,i),ie=r.strictObject({...k,item:r.string().optional().describe("The piece (its id, its file without its extension, or its file; default the project's only one), a sheet, a doc, a report, or a video file: a path ending in .mp4, .mov, .webm, .m4v, .qt, .mkv or .avi is a file"),range:r.string().optional().describe("A sheet's: what to draw, a sheet (Summary), a range (Summary!B3:D9, or B3:D9 on the first sheet), columns (A:C) or rows (1:20); default its sheets, from A1"),page:r.string().optional().describe("A doc's: the pages to draw large, counted from 1 (2, 2-4, 1,5); default every page, small, tiled"),at:r.array(r.string()).optional().describe("Moments: seconds (from the start of --part when given) or anchors (@press, @/map a stretch's end, @press+0.2); a video file's are seconds. One is written as the frame itself, several are tiled. Without it, --part's still, or every part's still on one sheet. A report's: a CSS selector, that element alone"),width:r.number().int().min(200).max(3840).optional().describe("A report's: the page's width, CSS pixels (default 1440; 375 a phone's)"),dark:r.boolean().default(!1).describe("A report's: drawn as a reader who asks for dark sees it"),print:r.boolean().default(!1).describe("A report's: laid out for paper (@media print) at the width given, as one long picture"),part:r.string().optional().describe("The part --at, --from and --to count from; alone, its still"),from:r.number().optional().describe("A stretch of consecutive frames from this second (with --to), instead of --at"),to:r.number().optional().describe("The stretch's last second"),clip:r.string().optional().describe("Write the stretch as a small silent video, .gif, .mp4 or .webm by its extension; with --out, the grid too"),overlay:r.boolean().default(!1).describe("Draw over each tile the face boxes with ids, the person matte's outline, the covered areas and the text boxes (a deck's: each shape's box and name, and the lines nearly in line); places nothing. Alone, over every part's still"),beside:r.string().optional().describe("Another video file (a reference) whose frame at the same time goes on each tile's left"),grid:r.number().int().min(4).optional().describe("A video file at one --at: the frame at its own size with numbered lines every this many pixels"),out:r.string().optional().describe("Where the picture goes, always a WebP whatever the extension; default under .allyhub/work/frames/")});function se(e){const i=[["--combo",e.combo!==void 0],["--part",e.part!==void 0],["--beside",e.beside!==void 0],["--overlay",e.overlay]].filter(([,a])=>a).map(([a])=>a);if(i.length>0)throw m("bad-option",`${i.join(" and ")} ${i.length===1?"is":"are"} a piece's: a video file has no combos or parts.`)}function de(e){const i=[["--at",e.at!==void 0],["--part",e.part!==void 0],["--from",e.from!==void 0],["--to",e.to!==void 0],["--clip",e.clip!==void 0],["--overlay",e.overlay],["--beside",e.beside!==void 0],["--range",e.range!==void 0],["--combo",e.combo!==void 0]].filter(([,a])=>a).map(([a])=>a);if(i.length>0)throw m("bad-option",`${i.join(" and ")} ${i.length===1?"is":"are"} not a doc's: a doc has pages (--page), not moments.`)}function le(e){const i=[["--part",e.part!==void 0],["--from",e.from!==void 0],["--to",e.to!==void 0],["--clip",e.clip!==void 0],["--overlay",e.overlay],["--beside",e.beside!==void 0],["--range",e.range!==void 0],["--page",e.page!==void 0],["--combo",e.combo!==void 0],["--at with more than one selector",(e.at?.length??0)>1]].filter(([,a])=>a).map(([a])=>a);if(i.length>0)throw m("bad-option",`${i.join(" and ")} ${i.length===1?"is":"are"} not a report's: a report is one page (--width, --dark, --print, --at <selector>).`)}export const frames=w({name:"frames",summary:"Pictures of a piece over time, drawn as the render draws them: every part's still on a sheet (default), a moment, a stretch tiled or as a clip, overlays; a sheet's cells, or a range of them; a doc's pages as they print, with how many; a report's page at a width, light or dark, or laid out for print; or any video file's frames",input:ie,positional:["item"],output:r.looseObject({mode:r.enum(["sheet","frame","grid","clip"])}),examples:["allyhub frames launch/film","allyhub frames launch/film --at 2.5","allyhub frames launch/film --part hook --from 0 --to 1 --clip hook.gif","allyhub frames launch/film --at 1,2,3 --overlay","allyhub frames reference.mp4 --at 0,1,2","allyhub frames reference.mp4 --at 3 --grid 50","allyhub frames finance/budget --range 'Summary!A1:F20'","allyhub frames launch/plan","allyhub frames launch/plan --page 2-3","allyhub frames research/channels/channels --width 375","allyhub frames research/channels/channels --at '#tiers'"]},async(e,i)=>{const a=i.cwd;if(e.item!==void 0&&M(e.item)){se(e);const t=await Q({cwd:a,root:await F(a,e.dir),file:e.item,at:e.at,from:e.from,to:e.to,clip:e.clip,out:e.out,grid:e.grid}).catch(b=>{throw P(b)}),n=t.video,d=`${t.file} · ${n.duration.toFixed(2)} s · ${String(n.width)}×${String(n.height)} · ${String(n.fps)} fps`,g="clip"in t&&t.clip?`${t.clip.out} (${t.clip.type}, ${String(t.clip.frames)} frames at ${String(t.clip.fps)} fps, no sound)`:void 0;return{value:t,text:[d,..."out"in t?[`${t.out}${"tiles"in t?` (${String(t.tiles.length)} moments in ${String(t.cols)} columns)`:""}`]:[],...g?[g]:[]].join(`
3
+ `)}}if(e.grid!==void 0)throw m("bad-option","--grid draws a video file's frame at its own size: give the file.");const l=await $(a,e.dir);if(e.item!==void 0&&await I(l,a,e.item)!==void 0){const t=await oe({cwd:a,root:l,item:e.item,range:e.range,out:e.out}),n=await I(l,a,e.item);return n!==void 0&&Object.keys(t.at).length>0&&await E(l,{doing:"looking",item:X(_(l,n).split(G).join("/")),place:t.at}),{value:t,text:[t.out,...t.cut].join(`
4
+ `)}}const c=e.item===void 0?void 0:await ne(l,a,e.item);if(c!==void 0){le(e);const t=await ae({cwd:a,root:l,file:c,width:e.width,dark:e.dark,print:e.print,at:e.at?.[0],out:e.out}),n=[...t.missing.map(d=>`asks for ${d.path}, not in the project`),...t.outside.map(d=>`asks for ${d}, outside the project: refused`),...t.thrown.map(d=>`threw ${d.text.split(`
5
+ `)[0]??""}`),...t.unsettled===void 0?[]:[t.unsettled],...t.blankCanvases.map(d=>`${d.canvas} (${String(d.width)} × ${String(d.height)} px) has nothing drawn on it`)];return{value:t,text:[t.out,`${t.report}: ${String(t.width)} px wide, ${String(t.pageHeight)} px tall${t.bands>1?`, in ${String(t.bands)} bands side by side`:""}`,...n.map(d=>`${t.report}: ${d}`)].join(`
6
+ `)}}if(e.width!==void 0||e.dark||e.print)throw m("bad-option","--width, --dark and --print are a report's: name the report.");const s=e.item===void 0?void 0:await re(l,a,e.item);if(s!==void 0){de(e);const t=await te({cwd:a,root:l,file:s,page:e.page,out:e.out,progress:d=>{i.progress(d)}}),n=t.drawn.length===t.pages?"every page":`page${t.drawn.length===1?"":"s"} ${t.drawn.join(", ")}`;return{value:t,text:[t.out,`${t.doc}: ${String(t.pages)} page${t.pages===1?"":"s"} on ${String(t.paper.width)} × ${String(t.paper.height)} mm paper; ${n} drawn`].join(`
7
+ `)}}if(e.page!==void 0)throw m("bad-option","--page is a doc's: name the doc.");if(e.range!==void 0)throw m("bad-option","--range is a sheet's: name the sheet.");const h=e.at!==void 0||e.part!==void 0||e.from!==void 0||e.to!==void 0;if(!h&&(e.clip!==void 0||e.beside!==void 0))throw m("bad-option","--clip and --beside draw moments: give --at, --part, or --from and --to.");if(!h&&!e.overlay){const{result:t,...n}=await y(e,i,"render",b=>ee(b,{cwd:a,root:l,out:e.out})),{unit:d,...g}=t;return{value:{...g,...S(n)},text:[`${t.out} (${t.piece} · ${t.format} · ${String(t.parts.length)} ${t.parts.length===1?d.noun:d.plural})`,...v(n)].join(`
8
+ `)}}const f=!h&&e.overlay,{result:o,...p}=await y(e,i,"render",async t=>{const n=await Z(t,{cwd:a,root:l,at:f?t.timeline.parts.map(L=>String(L.still)):e.at,part:e.part,from:e.from,to:e.to,clip:e.clip,out:e.out,overlay:e.overlay,beside:e.beside}),d="tiles"in n?n.tiles[0]:void 0,g=n.mode==="frame"?n.t:n.stretch?.from??d?.t,b=n.mode==="frame"?n.part:d?.part;return g!==void 0&&!f&&await E(l,{doing:"looking",item:t.piece.place,place:{t:g,...b===void 0?{}:{part:b}}}),n}),u=[];if(o.mode==="frame"&&u.push(`${o.out} (${o.piece} · ${o.format} · ${o.part} · ${o.t.toFixed(2)} s)`),o.mode==="grid"){u.push(`${o.out} (${o.piece} · ${String(o.tiles.length)} moments in ${String(o.cols)} columns)`,` ${o.tiles.map(n=>`${n.t.toFixed(o.stretch?3:2)} ${n.part}`).join(" · ")}`);const t=[...new Set(o.tiles.flatMap(n=>n.overlay?.missing??[]))];t.length>0&&u.push(` Not measured: ${t.join(", ")}.`)}return o.stretch&&u.push(` Stretch ${o.stretch.from.toFixed(3)}–${o.stretch.to.toFixed(3)} s, one frame in ${String(o.stretch.every)}: ${String(o.stretch.frames)} frames.`),"clip"in o&&o.clip&&u.push(`${o.clip.out} (${o.clip.type}, ${String(o.clip.frames)} frames at ${String(o.clip.fps)} fps, no sound)`),{value:{...o,...S(p)},text:[...u,...v(p)].join(`
9
+ `)}}),framesCuts=w({name:"frames cuts",summary:"A review sheet per cut of a video (a cut take's jumps, part joins, a scenery camera's cuts): frames around it, waveform and level, the words each side, the sound at it",input:r.strictObject({...k,part:r.string().optional().describe("Only this part's cuts and its joins"),out:r.string().optional().describe("The folder the sheets go in; default .allyhub/work/cuts/"),params:D({span:r.number().positive().max(10).default(J.span).describe("Seconds shown on each side of a cut")})}),positional:["item"],output:r.looseObject({out:r.string(),cuts:r.array(r.looseObject({sheet:r.string()}))}),examples:["allyhub frames cuts launch/film","allyhub frames cuts launch/film --part hook"]},async(e,i)=>{const a=i.cwd,l=await $(a,e.dir),{result:c,...s}=await y(e,i,"render",o=>K(o,{cwd:a,root:l,part:e.part,out:e.out,review:{span:e.params.span}})),h=c.part===void 0?`${String(c.cuts.length)} cut${c.cuts.length===1?"":"s"}`:`${String(c.cuts.length)} of ${String(c.total)} cuts (part ${c.part} and its joins)`,f=[`${c.piece} · ${c.format} · ${h}; silence is sound under ${String(c.threshold)} dBFS`];for(const o of c.cuts){const p=o.sound?`level ${x(o.sound.levelDb)} / around ${x(o.sound.aroundDb)} dBFS, peak ${x(o.sound.peakDb)}, step ${o.sound.jumpDb<0?"−":"+"}${Math.abs(o.sound.jumpDb).toFixed(1)} dB`:"no sound";f.push(`${String(o.index).padStart(3)} ${o.t.toFixed(3).padStart(7)} s ${o.kind.padEnd(6)} ${V(o)}`,` silence at the cut: ${q(o.silence)} · ${p}`,` “${o.said.before}” | “${o.said.after}”${o.across?` · across the cut: “${o.across}”`:""}`,` ${o.sheet}`)}return{value:{...c,...S(s)},text:[...f,...v(s)].join(`
10
+ `)}});const R=U;export const framesCompare=w({name:"frames compare",summary:"How a candidate picture differs from a reference, as numbers (ΔE, channels, SSIM, levels, grain, edges, regions) with a heatmap and a side-by-side: a piece's moment, a picture file or a video file's frame",input:r.strictObject({reference:r.string().describe("The reference picture (PNG, WebP, JPEG…)"),candidate:r.string().optional().describe("A piece (its id, its file without its extension, or its file; default the project's only one) at --at or --part's still; or a file by its extension: a picture (.png, .jpg, .webp…), or a video file's frame at --at (.mp4, .mov, .webm…)"),combo:k.combo,dir:O,at:r.string().optional().describe("The moment: seconds (from the start of --part when given) or an anchor of the piece; a video file's are seconds (default 0)"),part:r.string().optional().describe("The piece's part --at counts from; alone, its still"),refCrop:r.string().optional().describe("Cut the reference to x,y,width,height, or to an element of the elements.json beside it (frames web writes one)"),crop:r.string().optional().describe("Cut the candidate to x,y,width,height before any resize"),encode:r.string().optional().describe("Draw the candidate through this encode first, as a platform serves it: codec:kbps, h264 or hevc (hevc:618)"),out:r.string().optional().describe("Where its files go, a path without extension; default under .allyhub/work/compare/"),params:D({resize:r.enum(["stretch","width","none"]).default(R.resize).describe("When sizes differ: stretch the candidate to the reference, scale it to its width, or compare the common area"),shift:r.number().int().min(0).max(32).default(R.shift).describe("Search the best offset within this many pixels each way")})}),positional:["reference","candidate"],output:r.looseObject({reference:r.string(),files:r.looseObject({side:r.string(),heatmap:r.string()})}),examples:["allyhub frames compare reference.png launch/film --at 2.5 --encode hevc:618","allyhub frames compare reference.png shot.webp --ref-crop cta","allyhub frames compare reference.png theirs.mp4 --at 3"]},async(e,i)=>{const a=i.cwd,l=e.params;if(!A(e.reference))throw m("bad-reference",`${e.reference} is not a picture: the reference comes first, a picture file (PNG, WebP, JPEG…), then the piece or file to compare with it.`,`For example: allyhub frames compare ${e.candidate!==void 0&&A(e.candidate)?e.candidate:"reference.png"} ${e.reference}`);const c=e.candidate!==void 0&&(A(e.candidate)||M(e.candidate))?e.candidate:void 0,s=p=>({cwd:a,root:p,reference:e.reference,file:c,at:e.at===void 0?void 0:[e.at],part:e.part,refCrop:e.refCrop,crop:e.crop,encode:e.encode,out:e.out,options:{shift:l.shift,resize:l.resize}});if(c!==void 0){if(e.combo!==void 0||e.part!==void 0)throw m("bad-option","--combo and --part are a piece's: the candidate is a file.");const p=await z(s(await F(a,e.dir)),void 0).catch(u=>{throw P(u)});return{value:p,text:W(p)}}const h=await $(a,e.dir),{result:f,...o}=await y({...e,item:e.candidate},i,"render",p=>z(s(h),p));return{value:{...f,...S(o)},text:[W(f),...v(o)].join(`
11
+ `)}}),framesWeb=w({name:"frames web",summary:"A web page's screenshot with its named elements' boxes in the image's pixels, for a screen demo",input:r.strictObject({url:r.string().describe("The page: an address, or an HTML file on this computer"),el:r.array(r.string()).optional().describe("An element to locate, name=selector (CSS, or text=<words>); [data-el] elements are found too"),click:r.array(r.string()).optional().describe("Selectors clicked in order before the shot (close a banner, open a dialog)"),full:r.boolean().default(!1).describe("The whole page, not one viewport"),out:r.string().optional().describe("Where the picture goes (a WebP), its boxes in <out>.elements.json beside it; default under .allyhub/work/pages/"),dir:O,size:r.string().default(`${String(j.width)}x${String(j.height)}`).describe("The viewport, WIDTHxHEIGHT in CSS pixels"),scale:r.number().min(1).max(4).default(j.scale).describe("Image pixels per CSS pixel; 2 draws a high-density screen, sharp when a camera goes in"),wait:r.number().int().min(0).optional().describe("Milliseconds to wait after loading and clicking")}),positional:["url"],output:r.looseObject({out:r.string(),elementsFile:r.string()}),examples:["allyhub frames web https://example.com --el cta=text=Sign\\ up --scale 2 --out assets/media/home","allyhub frames web page.html --click '#accept' --full"]},async(e,i)=>{const a=i.cwd,[l,c]=B(e.size),s=await Y({cwd:a,root:await F(a,e.dir),url:e.url,out:e.out,el:e.el,click:e.click,width:l,height:c,scale:e.scale,full:e.full,wait:e.wait});return{value:s,text:[`${s.out}: ${String(s.width)}×${String(s.height)}${s.scale===1?"":` (${String(s.scale)} image pixels per CSS pixel)`}, ${String(Object.keys(s.elements).length)} elements (${Object.keys(s.elements).join(", ")||"none"}) in ${s.elementsFile}`,...s.missing.length>0?[`Not found: ${s.missing.join(", ")} (the selector is wrong, or something must be opened with --click first).`]:[]].join(`
12
+ `),exit:s.missing.length>0?C.failed:C.ok}}),FRAMES_COMMANDS=[frames,framesCuts,framesCompare,framesWeb];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/3d-extension",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./tools": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{clipSource as x}from"./decode.js";import{equalPower as z,gainAt as A}from"./envelope.js";import{playMusic as B}from"./music.js";import{shapes as C,shapeSound as H,soundLevel as q}from"./shape.js";import{synthSfx as J}from"./sfx.js";import{playVoice as K,voiceGroups as N}from"./voice.js";function Q(o,r,n){if(r.length===0)return;const s=o[0].length;for(let i=0;i<s;i++){const t=10**(A(r,i/n)/20);t!==1&&(o[0][i]=(o[0][i]??0)*t,o[1][i]=(o[1][i]??0)*t)}}function E(o,r,n,s,i,t){const m=Math.round(n.dur*s),y=Math.round(n.at*s),v=10**(n.gainDb/20),p=Math.min(Math.round(.01*s),Math.floor(m/4)),e=l=>l===void 0||l<=0?0:Math.min(Math.round(l*s),Math.floor(m/2)),f=e(n.fadeIn),a=e(n.fadeOut),c=(l,g)=>g>0?z(l/g):p>0&&l<p?l/p:1,u=[...n.envelope??[]],b=o[0].length,h=r[0].length,d=i===void 0?n.speed??1:1,S=i===void 0?n.from*s:n.from/i*s;for(let l=0;l<m;l++){const g=y+l;if(g<0||g>=b)continue;const F=d===1?Math.round(S)+l:S+l*d,M=Math.floor(F);if(M<0||M>=h)continue;const I=F-M,O=Math.min(M+1,h-1),w=g/s,V=u.length>0||t.length>0?10**((A(u,w)+A(t,w))/20):1,j=v*V*c(l,f)*c(m-1-l,a);for(let D=0;D<2;D++){const G=r[D]??r[0],L=G[M]??0,k=G[O]??0,P=o[D]??o[0];P[g]=(P[g]??0)+(L+(k-L)*I)*j}}}export function playSfx(o,r,n){if(!o.shape||!(C(o.shape)||o.shape.filter!==void 0))return{src:r,gainDb:o.gainDb};const s=q(r,n)?.lufs,i=[Float32Array.from(r[0]),Float32Array.from(r[1])];H(i,o.shape,n,0);const t=q(i,n)?.lufs;return t===void 0?{src:i,gainDb:o.gainDb}:o.level?{src:i,gainDb:o.level.target-t+o.level.gainDb}:{src:i,gainDb:o.gainDb+(s===void 0?0:s-t)}}function R(o,r,n){const s=J(o,r,n);return[s,s]}export function renderMix(o,r,n,s={}){const i=Math.round(o.duration*n),t=[new Float32Array(i),new Float32Array(i)],m=o.speechGain??[],y=x(r),{groups:v,dry:p}=N(o);for(const e of v){const[f,a]=K(e,o.duration,n,y);Q([f,a],m,n);for(let c=0;c<i;c++)t[0][c]=(t[0][c]??0)+(f[c]??0),t[1][c]=(t[1][c]??0)+(a[c]??0)}for(const e of p){const f=y(e);f&&E(t,f.src,e,n,f.stretched,m)}if(s.only==="voice")return t;for(const e of o.footage){const f=r(e.file,{});f&&E(t,f.src,e,n,void 0,[])}if(o.music){const e=o.music,f=r(e.file,e.shape?.filter?{filter:e.shape.filter}:{});if(f){const[a,c]=B(e,f.src,o.duration,n);for(let u=0;u<i;u++)t[0][u]=(t[0][u]??0)+(a[u]??0),t[1][u]=(t[1][u]??0)+(c[u]??0)}}for(const e of o.sfx){let f;if(e.file!==void 0?f=r(e.file,e.shape?.filter?{filter:e.shape.filter}:{})?.src:f=R(e.sound,n,e.seed),!f)continue;const a=playSfx(e,f,n),c=10**(a.gainDb/20),u=Math.round(e.at*n),b=a.src[0].length;for(let h=0;h<b;h++){const d=u+h;d<0||d>=i||(t[0][d]=(t[0][d]??0)+(a.src[0][h]??0)*c,t[1][d]=(t[1][d]??0)+(a.src[1][h]??0)*c)}}return t}
2
+ import{clipSource as k}from"./decode.js";import{equalPower as z,gainAt as A}from"./envelope.js";import{playMusic as B}from"./music.js";import{shapes as C,shapeSound as H,soundLevel as q}from"./shape.js";import{synthSfx as J}from"./sfx.js";import{playVoice as K,voiceGroups as N}from"./voice.js";function Q(n,r,o){if(r.length===0)return;const s=n[0].length;for(let f=0;f<s;f++){const e=10**(A(r,f/o)/20);e!==1&&(n[0][f]=(n[0][f]??0)*e,n[1][f]=(n[1][f]??0)*e)}}function x(n,r,o,s,f,e){const m=Math.round(o.dur*s),y=Math.round(o.at*s),b=10**(o.gainDb/20),p=Math.min(Math.round(.01*s),Math.floor(m/4)),t=l=>l===void 0||l<=0?0:Math.min(Math.round(l*s),Math.floor(m/2)),i=t(o.fadeIn),h=t(o.fadeOut),c=(l,g)=>g>0?z(l/g):p>0&&l<p?l/p:1,a=[...o.envelope??[]],v=n[0].length,u=r[0].length,d=f===void 0?o.speed??1:1,S=f===void 0?o.from*s:o.from/f*s;for(let l=0;l<m;l++){const g=y+l;if(g<0||g>=v)continue;const F=d===1?Math.round(S)+l:S+l*d,M=Math.floor(F);if(M<0||M>=u)continue;const E=F-M,I=Math.min(M+1,u-1),w=g/s,O=a.length>0||e.length>0?10**((A(a,w)+A(e,w))/20):1,V=b*O*c(l,i)*c(m-1-l,h);for(let D=0;D<2;D++){const G=r[D]??r[0],L=G[M]??0,j=G[I]??0,P=n[D]??n[0];P[g]=(P[g]??0)+(L+(j-L)*E)*V}}}export function playSfx(n,r,o){if(!n.shape||!(C(n.shape)||n.shape.filter!==void 0))return{src:r,gainDb:n.gainDb};const s=q(r,o)?.lufs,f=[Float32Array.from(r[0]),Float32Array.from(r[1])];H(f,n.shape,o,0);const e=q(f,o)?.lufs;return e===void 0?{src:f,gainDb:n.gainDb}:n.level?{src:f,gainDb:n.level.target-e+n.level.gainDb}:{src:f,gainDb:n.gainDb+(s===void 0?0:s-e)}}function R(n,r,o){const s=J(n,r,o);return[s,s]}export function renderMix(n,r,o,s={}){const f=Math.round(n.duration*o),e=[new Float32Array(f),new Float32Array(f)],m=n.speechGain??[],y=k(r),{groups:b,dry:p}=N(n);for(const t of b){const[i,h]=K(t,n.duration,o,y);Q([i,h],m,o);for(let c=0;c<f;c++)e[0][c]=(e[0][c]??0)+(i[c]??0),e[1][c]=(e[1][c]??0)+(h[c]??0)}for(const t of p){const i=y(t);i&&x(e,i.src,t,o,i.stretched,m)}if(s.only==="voice")return e;for(const t of n.footage){const i=r(t.file,{});i&&x(e,i.src,t,o,void 0,[])}if(n.music){const t=n.music,i=r(t.file,t.shape?.filter?{filter:t.shape.filter}:{});if(i){const[h,c]=B(t,i.src,n.duration,o);for(let a=0;a<f;a++)e[0][a]=(e[0][a]??0)+(h[a]??0),e[1][a]=(e[1][a]??0)+(c[a]??0)}}for(const t of n.sfx){let i;if(t.file!==void 0?i=r(t.file,t.shape?.filter?{filter:t.shape.filter}:{})?.src:i=R(t.sound,o,t.seed),!i)continue;if(t.from!==void 0||t.length!==void 0){const u=Math.max(0,Math.round((t.from??0)*o)),d=t.length===void 0?i[0].length:Math.min(i[0].length,u+Math.round(t.length*o));i=[i[0].subarray(u,d),i[1].subarray(u,d)]}const h=playSfx(t,i,o),c=10**(h.gainDb/20),a=Math.round(t.at*o),v=h.src[0].length;for(let u=0;u<v;u++){const d=a+u;d<0||d>=f||(e[0][d]=(e[0][d]??0)+(h.src[0][u]??0)*c,e[1][d]=(e[1][d]??0)+(h.src[1][u]??0)*c)}}return e}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/audio",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/browser",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readFile as y}from"node:fs/promises";import{missingFiles as F,modelInfo as O}from"./model-info.js";import{takeVoice as $}from"./takes.js";import{join as h}from"node:path";import{readDataFile as S}from"@allyhub/formats";import{ONSET_RATE as j,cached as k,decodeMono as N,estimateTempo as M,hasMatte as T,mediaKindOf as D,onsetNovelty as E,probeMedia as I,readFaceTrack as J}from"@allyhub/media";import{mediaGen as K}from"@allyhub/piece";import{unheardSounds as x}from"@allyhub/piece";const A=new Set(["image","audio","video","font","model","environment"]),w=e=>e.replace(/\.[^./]+$/u,"");async function g(e){try{return JSON.parse(await y(e,"utf8"))}catch{return}}async function G(e){const d=S("words",await g(e));if(d.ok)return d.value.words.map(({confidence:s,...r})=>s===void 0?r:{...r,confidence:s})}async function R(e,d,s){return await k(e,"tempo",{version:1},{root:d},async()=>{const c=M(E(await N(e,j,s),j));return c?{bpm:c.bpm,confidence:c.confidence,beat:c.beats[0]??0}:null}).catch(()=>null)??void 0}export async function readMedia(e,d,s={}){const r=new Set(d),c={},p=s.runtimes?{runtimes:s.runtimes}:{};for(const a of d){const o=D(a);if(!o||!A.has(o))continue;const u=h(e,a);s.onFile?.(a);const t=await I(u,{root:e,...p}),i={path:a,sha256:t.sha256,kind:o,url:"",bytes:t.bytes,...t.width===void 0?{}:{width:t.width},...t.height===void 0?{}:{height:t.height},...t.duration===void 0?{}:{duration:t.duration},...t.rotation===void 0?{}:{rotation:t.rotation},...o==="video"?{audio:(t.audio??[]).length>0}:{}},v=`${w(a)}.words.json`;if((o==="audio"||o==="video")&&r.has(v)){const n=await G(h(e,v));if(n){i.words=n;const f=n.at(-1);i.duration===void 0&&f&&(i.duration=f.end);const m=n.length>0?await $(u,e,p):void 0;if(m){const b=x(n,{hop:m.hop,db:m.db,voicing:m.voicing});i.envelope=m.base64,i.speechDb=b.speech,i.sounds=b.sounds}}}else if(o==="audio"){const n=await R(u,e,p);n&&(i.tempo=n)}const l=`${a}.gen.json`;if(r.has(l)){const n=await g(h(e,l)),f=n===void 0?{error:"not JSON"}:K(l,n,t.sha256);"gen"in f?i.gen=f.gen:i.genUnread={record:l,error:f.error}}if(o==="video"){const n=await J(e,t.sha256);n&&(i.faces=n),await T(e,t.sha256)&&(i.matte=!0)}if(o==="model"&&/\.(glb|gltf)$/iu.test(a)){const n=await k(u,"model",{version:1},{root:e},async()=>O(e,a,await y(u)));i.model=n.container==="gltf"?{...n,missing:await F(e,a)}:n}if(o==="image"&&r.has(`${w(a)}.elements.json`)){const n=S("elements",await g(h(e,`${w(a)}.elements.json`)));n.ok&&(i.elements=n.value)}c[a]=i}return c}
2
+ import{readFile as y}from"node:fs/promises";import{missingFiles as O,modelInfo as j}from"./model-info.js";import{takeVoice as N}from"./takes.js";import{join as h}from"node:path";import{genFileFor as $,readDataFile as F}from"@allyhub/formats";import{ONSET_RATE as S,cached as k,decodeMono as M,estimateTempo as T,hasMatte as D,mediaKindOf as E,onsetNovelty as I,probeMedia as J,readFaceTrack as K}from"@allyhub/media";import{mediaGen as x}from"@allyhub/piece";import{unheardSounds as A}from"@allyhub/piece";const G=new Set(["image","audio","video","font","model","environment"]),w=e=>e.replace(/\.[^./]+$/u,"");async function g(e){try{return JSON.parse(await y(e,"utf8"))}catch{return}}async function R(e){const d=F("words",await g(e));if(d.ok)return d.value.words.map(({confidence:s,...r})=>s===void 0?r:{...r,confidence:s})}async function U(e,d,s){return await k(e,"tempo",{version:1},{root:d},async()=>{const c=T(I(await M(e,S,s),S));return c?{bpm:c.bpm,confidence:c.confidence,beat:c.beats[0]??0}:null}).catch(()=>null)??void 0}export async function readMedia(e,d,s={}){const r=new Set(d),c={},p=s.runtimes?{runtimes:s.runtimes}:{};for(const a of d){const o=E(a);if(!o||!G.has(o))continue;const u=h(e,a);s.onFile?.(a);const t=await J(u,{root:e,...p}),i={path:a,sha256:t.sha256,kind:o,url:"",bytes:t.bytes,...t.width===void 0?{}:{width:t.width},...t.height===void 0?{}:{height:t.height},...t.duration===void 0?{}:{duration:t.duration},...t.rotation===void 0?{}:{rotation:t.rotation},...o==="video"?{audio:(t.audio??[]).length>0}:{}},v=`${w(a)}.words.json`;if((o==="audio"||o==="video")&&r.has(v)){const n=await R(h(e,v));if(n){i.words=n;const f=n.at(-1);i.duration===void 0&&f&&(i.duration=f.end);const m=n.length>0?await N(u,e,p):void 0;if(m){const b=A(n,{hop:m.hop,db:m.db,voicing:m.voicing});i.envelope=m.base64,i.speechDb=b.speech,i.sounds=b.sounds}}}else if(o==="audio"){const n=await U(u,e,p);n&&(i.tempo=n)}const l=$(a);if(r.has(l)){const n=await g(h(e,l)),f=n===void 0?{error:"not JSON"}:x(l,n,t.sha256);"gen"in f?i.gen=f.gen:i.genUnread={record:l,error:f.error}}if(o==="video"){const n=await K(e,t.sha256);n&&(i.faces=n),await D(e,t.sha256)&&(i.matte=!0)}if(o==="model"&&/\.(glb|gltf)$/iu.test(a)){const n=await k(u,"model",{version:1},{root:e},async()=>j(e,a,await y(u)));i.model=n.container==="gltf"?{...n,missing:await O(e,a)}:n}if(o==="image"&&r.has(`${w(a)}.elements.json`)){const n=F("elements",await g(h(e,`${w(a)}.elements.json`)));n.ok&&(i.elements=n.value)}c[a]=i}return c}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/build",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/canvas-extension",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/canvas-model",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{colorOfFile as j}from"@allyhub/formats";import{isScatter as O,labelPositionsOf as v}from"./chart.js";const u=e=>j(e)??"dk1";function S(e,n){if(n.startsWith("/"))return n.slice(1);const o=e===""?[]:e.split("/");for(const s of n.split("/"))s===""||s==="."||(s===".."?o.pop():o.push(s));return o.join("/")}const w=e=>e&&{...e.min===void 0?{}:{minimum_scale:e.min},...e.max===void 0?{}:{maximum_scale:e.max},...e.major===void 0?{}:{major_unit:e.major},...e.gridlines===void 0?{}:{has_major_gridlines:e.gridlines},...e.visible===void 0?{}:{visible:e.visible},...e.format===void 0?{}:{number_format:e.format},...e.reverse===void 0?{}:{reverse_order:e.reverse},...e.gridline_color===void 0?{}:{gridline_color:u(e.gridline_color)},...e.line_color===void 0?{}:{line_color:u(e.line_color)}},F=e=>{if(!(e===void 0||e===!1))return e===!0?{show_value:!0}:{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...e.color===void 0?{}:{color:u(e.color)}}};function $(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e==null)return null;if(typeof e!="string")return;const n=e.trim();if(n==="")return null;const o=Number(n);return Number.isFinite(o)?o:void 0}export function chartOfFile(e,n){const o=F(e.labels),s=O(e.type);let l,m;const g=r=>({...r.color===void 0?{}:{color:u(r.color)},...r.format===void 0?{}:{number_format:r.format},...r.smooth===void 0?{}:{smooth:r.smooth},...r.line_width===void 0?{}:{line_width:r.line_width},...r.marker_size===void 0?{}:{marker_size:r.marker_size}});if(e.data!==void 0){let r;try{r=n.rows(e.data)}catch(t){n.problem(`${e.data} cannot be read: ${t instanceof Error?t.message:String(t)}`);return}if(!Array.isArray(r)||r.length===0){n.problem(`${e.data} holds no rows.`);return}const i=r,d=e.categories;if(typeof d!="string"){n.problem("with data, categories names its column.");return}const h=Object.keys(i[0]??{}),y=[d,...e.series.map(t=>typeof t=="string"?t:t.name)].filter(t=>!h.includes(t));if(y.length>0){n.problem(`${e.data} has no column ${y.join(", ")} (it has ${h.join(", ")}).`);return}l=i.map(t=>{const a=t[d];return typeof a=="string"||typeof a=="number"?String(a):""}),m=e.series.map(t=>{const a=typeof t=="string"?t:t.name,x=i.map((c,z)=>{const b=$(c[a]);return b===void 0?(n.problem(`${String(e.data)} row ${String(z+1)}: ${JSON.stringify(c[a])} in ${a} is not a number.`),null):b});return{name:a,values:x,...s?{x:i.map(c=>$(c[d])??null)}:{},...typeof t=="string"?{}:g(t)}})}else{if(typeof e.categories=="string"){n.problem("categories names a column, and there is no data to read.");return}if(e.categories===void 0&&!s){n.problem(`a ${e.type} chart has categories.`);return}l=e.categories??[];const r=[];for(const i of e.series){if(typeof i=="string"||!i.values){const d=typeof i=="string"?i:i.name;n.problem(`series ${d} has no values, and there is no data to read.`);return}if(s){if(i.x?.length!==i.values.length){n.problem(`series ${i.name} has an x for each of its values.`);return}}else i.values.length!==l.length&&n.problem(`series ${i.name} has ${String(i.values.length)} values for ${String(l.length)} categories.`);r.push({name:i.name,values:i.values,...s&&i.x?{x:i.x}:{},...g(i)})}m=r}const f=o?.position;f!==void 0&&!v(e.type).includes(f)&&n.problem(`a ${e.type} chart has no label position ${f}, which PowerPoint would repair (it has ${v(e.type).join(", ")||"none"}).`);const p=w(e.value_axis),_=w(e.category_axis);return{type:e.type,categories:l,series:m,...n.title===void 0?{}:{title:n.title},...e.legend===void 0?{}:{legend:e.legend},...o?{labels:o}:{},...e.gap_width===void 0?{}:{gap_width:e.gap_width},...e.overlap===void 0?{}:{overlap:e.overlap},...e.vary_by_categories===void 0?{}:{vary_by_categories:e.vary_by_categories},...e.category_colors===void 0?{}:{category_colors:e.category_colors.map(u)},...e.hole_size===void 0?{}:{hole_size:e.hole_size},...p?{value_axis:p}:{},..._?{category_axis:_}:{},...e.size===void 0?{}:{font_size:e.size},...e.title_size===void 0?{}:{title_size:e.title_size},...e.color===void 0?{}:{font_color:u(e.color)},...e.data===void 0?{}:{source:S(n.base,e.data)}}}
2
+ import{colorOfFile as O}from"@allyhub/formats";import{isCombinable as S,isScatter as k,labelPositionsOf as w}from"./chart.js";const u=e=>O(e)??"dk1";function F(e,n){if(n.startsWith("/"))return n.slice(1);const i=e===""?[]:e.split("/");for(const s of n.split("/"))s===""||s==="."||(s===".."?i.pop():i.push(s));return i.join("/")}function p(e,n){if(e===void 0&&n===void 0)return;const i=e??{};return{...n===void 0?{}:{title:n},...i.min===void 0?{}:{minimum_scale:i.min},...i.max===void 0?{}:{maximum_scale:i.max},...i.major===void 0?{}:{major_unit:i.major},...i.gridlines===void 0?{}:{has_major_gridlines:i.gridlines},...i.visible===void 0?{}:{visible:i.visible},...i.format===void 0?{}:{number_format:i.format},...i.reverse===void 0?{}:{reverse_order:i.reverse},...i.gridline_color===void 0?{}:{gridline_color:u(i.gridline_color)},...i.line_color===void 0?{}:{line_color:u(i.line_color)}}}const A=e=>{if(!(e===void 0||e===!1))return e===!0?{show_value:!0}:{...e.value===void 0?{}:{show_value:e.value},...e.percentage===void 0?{}:{show_percentage:e.percentage},...e.category===void 0?{}:{show_category_name:e.category},...e.series===void 0?{}:{show_series_name:e.series},...e.format===void 0?{}:{number_format:e.format},...e.position===void 0?{}:{position:e.position},...e.size===void 0?{}:{size:e.size},...e.color===void 0?{}:{color:u(e.color)}}};function $(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(e==null)return null;if(typeof e!="string")return;const n=e.trim();if(n==="")return null;const i=Number(n);return Number.isFinite(i)?i:void 0}export function chartOfFile(e,n){const i=A(e.labels),s=k(e.type);let l,m;const g=r=>({...r.color===void 0?{}:{color:u(r.color)},...r.format===void 0?{}:{number_format:r.format},...r.smooth===void 0?{}:{smooth:r.smooth},...r.line_width===void 0?{}:{line_width:r.line_width},...r.marker_size===void 0?{}:{marker_size:r.marker_size},...r.type===void 0?{}:{type:r.type},...r.secondary===void 0?{}:{secondary:r.secondary}});if(e.data!==void 0){let r;try{r=n.rows(e.data)}catch(o){n.problem(`${e.data} cannot be read: ${o instanceof Error?o.message:String(o)}`);return}if(!Array.isArray(r)||r.length===0){n.problem(`${e.data} holds no rows.`);return}const t=r,d=e.categories;if(typeof d!="string"){n.problem("with data, categories names its column.");return}const b=Object.keys(t[0]??{}),v=[d,...e.series.map(o=>typeof o=="string"?o:o.name)].filter(o=>!b.includes(o));if(v.length>0){n.problem(`${e.data} has no column ${v.join(", ")} (it has ${b.join(", ")}).`);return}l=t.map(o=>{const a=o[d];return typeof a=="string"||typeof a=="number"?String(a):""}),m=e.series.map(o=>{const a=typeof o=="string"?o:o.name,z=t.map((c,j)=>{const x=$(c[a]);return x===void 0?(n.problem(`${String(e.data)} row ${String(j+1)}: ${JSON.stringify(c[a])} in ${a} is not a number.`),null):x});return{name:a,values:z,...s?{x:t.map(c=>$(c[d])??null)}:{},...typeof o=="string"?{}:g(o)}})}else{if(typeof e.categories=="string"){n.problem("categories names a column, and there is no data to read.");return}if(e.categories===void 0&&!s){n.problem(`a ${e.type} chart has categories.`);return}l=e.categories??[];const r=[];for(const t of e.series){if(typeof t=="string"||!t.values){const d=typeof t=="string"?t:t.name;n.problem(`series ${d} has no values, and there is no data to read.`);return}if(s){if(t.x?.length!==t.values.length){n.problem(`series ${t.name} has an x for each of its values.`);return}}else t.values.length!==l.length&&n.problem(`series ${t.name} has ${String(t.values.length)} values for ${String(l.length)} categories.`);r.push({name:t.name,values:t.values,...s&&t.x?{x:t.x}:{},...g(t)})}m=r}!S(e.type)&&e.series.some(r=>typeof r!="string"&&(r.type!==void 0||r.secondary===!0))&&n.problem(`a ${e.type} chart combines with no other kind and has no second axis: only columns, lines and areas do.`);const f=i?.position;f!==void 0&&!w(e.type).includes(f)&&n.problem(`a ${e.type} chart has no label position ${f}, which PowerPoint would repair (it has ${w(e.type).join(", ")||"none"}).`);const _=p(e.value_axis,n.axisTitles?.value_axis),y=p(e.category_axis,n.axisTitles?.category_axis),h=p(e.secondary_axis,n.axisTitles?.secondary_axis);return{type:e.type,categories:l,series:m,...n.title===void 0?{}:{title:n.title},...e.legend===void 0?{}:{legend:e.legend},...i?{labels:i}:{},...e.gap_width===void 0?{}:{gap_width:e.gap_width},...e.overlap===void 0?{}:{overlap:e.overlap},...e.vary_by_categories===void 0?{}:{vary_by_categories:e.vary_by_categories},...e.category_colors===void 0?{}:{category_colors:e.category_colors.map(u)},...e.hole_size===void 0?{}:{hole_size:e.hole_size},..._?{value_axis:_}:{},...y?{category_axis:y}:{},...h?{secondary_axis:h}:{},...e.size===void 0?{}:{font_size:e.size},...e.title_size===void 0?{}:{title_size:e.title_size},...e.color===void 0?{}:{font_color:u(e.color)},...e.data===void 0?{}:{source:F(n.base,e.data)}}}
@@ -1,3 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{lumOf as V}from"@allyhub/ooxml/brightness";import{accentOf as I,CHART_DEFAULTS as m,chartDrawing as B,groupingOf as A,groupsOf as R,hasLines as W,hasMarkers as Z,isArea as O,isBar as L,isHorizontal as G,isLine as S,isRound as g,isScatter as w,labelPositionOf as H,variesOf as M}from"./chart.js";const Y="http://schemas.openxmlformats.org/drawingml/2006/chart",q="http://schemas.openxmlformats.org/drawingml/2006/main",K="http://schemas.openxmlformats.org/officeDocument/2006/relationships",J=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
- `,b="2118791784",y="2140495176",j="2118791785",T="2140495177",Q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},ee=e=>{const n=e.charCodeAt(0);return n<32&&n!==9&&n!==10&&n!==13||n===65534||n===65535},d=e=>Array.from(e,n=>ee(n)?"":Q[n]??n).join("");function r(e,n={},...c){const a=Object.entries(n).filter(([,s])=>s!==void 0).map(([s,i])=>` ${s}="${d(typeof i=="boolean"?i?"1":"0":String(i))}"`).join(""),o=c.join("");return o===""?`<${e}${a}/>`:`<${e}${a}>${o}</${e}>`}const te=e=>{if(typeof e=="string")return r("a:schemeClr",{val:e});if("rgb"in e)return r("a:srgbClr",{val:e.rgb.replace("#","").toUpperCase()});const{lumMod:n,lumOff:c}=V(e.brightness);return r("a:schemeClr",{val:e.theme_color},t("a:lumMod",n),...c===void 0?[]:[t("a:lumOff",c)])},h=e=>e===null?r("a:noFill"):r("a:solidFill",{},te(e)),t=(e,n)=>r(e,{val:typeof n=="boolean"?n?1:0:n}),f=(e,n)=>r("a:ln",n===void 0?{}:{w:Math.round(n*12700)},h(e)),X=(e,n)=>r("c:txPr",{},r("a:bodyPr"),r("a:lstStyle"),r("a:p",{},r("a:pPr",{},r("a:defRPr",e===void 0?{}:{sz:Math.round(e*100)},n===void 0?"":h(n))),r("a:endParaRPr",{lang:"en-US"}))),$=e=>r("c:strCache",{},t("c:ptCount",e.length),...e.map((n,c)=>r("c:pt",{idx:c},`<c:v>${d(n)}</c:v>`))),F=(e,n)=>r("c:numCache",{},`<c:formatCode>${d(e??"General")}</c:formatCode>`,t("c:ptCount",n.length),...n.flatMap((c,a)=>c===null?[]:[r("c:pt",{idx:a},`<c:v>${String(c)}</c:v>`)])),ne=(e,n)=>r("c:tx",{},n===void 0?`<c:v>${d(e.name)}</c:v>`:r("c:strRef",{},`<c:f>${d(n)}</c:f>`,$([e.name]))),re=(e,n)=>n===void 0?"":r("c:xVal",{},r("c:numRef",{},`<c:f>${d(n)}</c:f>`,F("General",e.x??[])));function oe(e,n,c,a){const o=n.color??I(c),s=g(e.type),i=w(e.type),l=S(e.type)||i,u=Z(e.type),z=l?r("c:spPr",{},W(e.type)?f(o,n.line_width??m.lineWidth):r("a:ln",{w:19050},h(null))):r("c:spPr",{},h(o),s?f("lt1",1):""),v=a.categories;return r("c:ser",{},t("c:idx",c),t("c:order",c),ne(n,a.name(c)),z,L(e.type)?t("c:invertIfNegative",!1):"",l?r("c:marker",{},t("c:symbol",u?"circle":"none"),u?t("c:size",n.marker_size??m.marker):"",u?r("c:spPr",{},h(o),f(o)):""):"",...M(e)&&!l&&!O(e.type)?e.categories.map((P,p)=>r("c:dPt",{},t("c:idx",p),L(e.type)?t("c:invertIfNegative",!1):"",t("c:bubble3D",!1),r("c:spPr",{},h(e.category_colors?.[p]??I(p)),s?f("lt1",1):""))):[],i?re(n,a.x?.(c)):v===void 0?"":r("c:cat",{},a.numeric===!0?r("c:numRef",{},`<c:f>${d(v)}</c:f>`,F(a.categoryFormat??"General",a.categoryNumbers??e.categories.map(P=>{const p=Number(P);return P===""||!Number.isFinite(p)?null:p}))):r("c:strRef",{},`<c:f>${d(v)}</c:f>`,$(e.categories))),r(i?"c:yVal":"c:val",{},r("c:numRef",{},`<c:f>${d(a.values(c))}</c:f>`,F(n.number_format,n.values))),l?t("c:smooth",n.smooth===!0||e.type==="scatter-smooth"):"")}function _(e){const n=e.labels;if(!n)return"";const c=n.show_percentage===!0,a=H(e);return r("c:dLbls",{},n.number_format===void 0?"":r("c:numFmt",{formatCode:n.number_format,sourceLinked:0}),n.size===void 0&&n.color===void 0&&!g(e.type)?"":X(n.size,n.color??(g(e.type)?"lt1":void 0)),a===void 0?"":t("c:dLblPos",a),t("c:showLegendKey",!1),t("c:showVal",n.show_value??!c),t("c:showCatName",n.show_category_name===!0),t("c:showSerName",n.show_series_name===!0),t("c:showPercent",c),t("c:showBubbleSize",!1))}function ce(e,n){const c=R(e),[a]=c;return c.length<=1&&a?.secondary!==!0?E(e,e.series.map((o,s)=>s),n,!1):c.map(o=>E({...e,type:o.kind},o.series,n,o.secondary)).join("")}function E(e,n,c,a){const o=n.map(l=>{const u=e.series[l];return u?oe(e,u,l,c):""}).join(""),s=A(e.type),i=a?t("c:axId",j)+t("c:axId",T):t("c:axId",b)+t("c:axId",y);if(g(e.type)){const l=e.type==="pie";return r(l?"c:pieChart":"c:doughnutChart",{},t("c:varyColors",M(e)),o,_(e),t("c:firstSliceAng",0),l?"":t("c:holeSize",e.hole_size??50))}if(w(e.type))return r("c:scatterChart",{},t("c:scatterStyle","lineMarker"),t("c:varyColors",!1),o,_(e),i);if(L(e.type)){const l=s!=="clustered";return r("c:barChart",{},t("c:barDir",G(e.type)?"bar":"col"),t("c:grouping",s),t("c:varyColors",M(e)),o,_(e),t("c:gapWidth",e.gap_width??150),e.overlap!==void 0||l?t("c:overlap",e.overlap??100):"",i)}return r(S(e.type)?"c:lineChart":"c:areaChart",{},t("c:grouping",s),t("c:varyColors",!1),o,_(e),S(e.type)?t("c:marker",!0):"",i)}const x=e=>r("c:scaling",{},t("c:orientation",e.reverse_order===!0?"maxMin":"minMax"),e.maximum_scale===void 0?"":t("c:max",e.maximum_scale),e.minimum_scale===void 0?"":t("c:min",e.minimum_scale)),N=e=>r("c:spPr",{},f(e.line_color??{rgb:m.axisLine},m.gridWidth)),k=e=>e.has_major_gridlines===!0?r("c:majorGridlines",{},r("c:spPr",{},f(e.gridline_color??{rgb:m.gridline},m.gridWidth))):"",U=(e,n)=>r("c:rich",{},r("a:bodyPr"),r("a:lstStyle"),r("a:p",{},r("a:pPr",{},r("a:defRPr",{sz:n,b:0})),r("a:r",{},r("a:rPr",{lang:"en-US",sz:n,b:0}),`<a:t>${d(e)}</a:t>`))),C=(e,n)=>e===void 0||e===""?"":r("c:title",{},r("c:tx",{},U(e,n)),t("c:overlay",!1));function ae(e,n){if(g(e.type))return"";const c=w(e.type),a=G(e.type),o=e.category_axis??{},s={has_major_gridlines:!0,...e.value_axis},i=A(e.type)==="percentStacked",l=s.number_format??(i?"0%":e.series[0]?.number_format??"General"),u=Math.round((e.font_size??m.fontSize)*100);return(c?r("c:valAx",{},t("c:axId",b),x(o),t("c:delete",o.visible===!1),t("c:axPos","b"),k(o),C(o.title,u),r("c:numFmt",{formatCode:o.number_format??"General",sourceLinked:o.number_format===void 0?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),N(o),t("c:crossAx",y),t("c:crosses","autoZero"),t("c:crossBetween","midCat"),o.major_unit===void 0?"":t("c:majorUnit",o.major_unit)):r("c:catAx",{},t("c:axId",b),x(o),t("c:delete",o.visible===!1),t("c:axPos",a?"l":"b"),k(o),C(o.title,u),n?.numeric===!0?r("c:numFmt",{formatCode:o.number_format??n.categoryFormat??"General",sourceLinked:o.number_format===void 0?1:0}):r("c:numFmt",{formatCode:"General",sourceLinked:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),N(o),t("c:crossAx",y),t("c:crosses","autoZero"),t("c:auto",!0),t("c:lblAlgn","ctr"),t("c:lblOffset",100),t("c:noMultiLvlLbl",!1)))+r("c:valAx",{},t("c:axId",y),x(s),t("c:delete",s.visible===!1),t("c:axPos",a?"b":"l"),k(s),C(s.title,u),r("c:numFmt",{formatCode:l,sourceLinked:s.number_format===void 0&&!i?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),r("c:spPr",{},f(null)),t("c:crossAx",b),t("c:crosses","autoZero"),t("c:crossBetween",O(e.type)||c?"midCat":"between"),s.major_unit===void 0?"":t("c:majorUnit",s.major_unit))+se(e,u)}function se(e,n){const c=R(e).find(i=>i.secondary);if(!c)return"";const a=e.secondary_axis??{},o=A(c.kind)==="percentStacked",s=a.number_format??(o?"0%":e.series[c.series[0]??0]?.number_format??"General");return r("c:catAx",{},t("c:axId",j),x({}),t("c:delete",!0),t("c:axPos","b"),r("c:numFmt",{formatCode:"General",sourceLinked:1}),t("c:majorTickMark","out"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),t("c:crossAx",T),t("c:crosses","autoZero"),t("c:auto",!0),t("c:lblAlgn","ctr"),t("c:lblOffset",100),t("c:noMultiLvlLbl",!1))+r("c:valAx",{},t("c:axId",T),x(a),t("c:delete",a.visible===!1),t("c:axPos","r"),k(a),C(a.title,n),r("c:numFmt",{formatCode:s,sourceLinked:a.number_format===void 0&&!o?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),r("c:spPr",{},f(null)),t("c:crossAx",j),t("c:crosses","max"),t("c:crossBetween","between"),a.major_unit===void 0?"":t("c:majorUnit",a.major_unit))}const ie={bottom:"b",top:"t",left:"l",right:"r"};function le(e,n){const c=n.width,a=n.height,{plot:o}=B(e,c,a),s=i=>Number(i.toFixed(5));return r("c:layout",{},r("c:manualLayout",{},t("c:layoutTarget","inner"),t("c:xMode","edge"),t("c:yMode","edge"),t("c:x",s(o.x/c)),t("c:y",s(o.y/a)),t("c:w",s(o.width/c)),t("c:h",s(o.height/a))))}const D=r("c:spPr",{},r("a:noFill"),r("a:ln",{},r("a:noFill")));export function chartSpaceXml(e,n){const c=e.title!==void 0&&e.title!==""?e.title:void 0,a=e.font_size??m.fontSize,o=Math.round((e.title_size??a*m.titleScale)*100);return J+r("c:chartSpace",{"xmlns:c":Y,"xmlns:a":q,"xmlns:r":K},t("c:date1904",!1),t("c:roundedCorners",!1),r("c:chart",{},c===void 0?"":r("c:title",{},r("c:tx",{},n.titleRef===void 0?U(c,o):r("c:strRef",{},`<c:f>${d(n.titleRef)}</c:f>`,$([c]))),t("c:overlay",!1)),t("c:autoTitleDeleted",c===void 0),r("c:plotArea",{},n.frame?le(e,n.frame):r("c:layout"),ce(e,n.refs),ae(e,n.refs),n.frameless===!0?D:""),e.legend===void 0?"":r("c:legend",{},t("c:legendPos",ie[e.legend]),t("c:overlay",e.legend_overlay===!0)),t("c:plotVisOnly",n.plotVisible??!0),t("c:dispBlanksAs","gap")),n.frameless===!0?D:"",X(a,e.font_color??"dk1"),n.tail??"")}
2
+ import{colorXml as V}from"./color.js";import{accentOf as I,CHART_DEFAULTS as m,chartDrawing as B,groupingOf as A,groupsOf as R,hasLines as W,hasMarkers as Z,isArea as X,isBar as L,isHorizontal as G,isLine as S,isRound as h,isScatter as w,labelPositionOf as H,variesOf as j}from"./chart.js";const Y="http://schemas.openxmlformats.org/drawingml/2006/chart",q="http://schemas.openxmlformats.org/drawingml/2006/main",K="http://schemas.openxmlformats.org/officeDocument/2006/relationships",J=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3
+ `,b="2118791784",y="2140495176",M="2118791785",T="2140495177",Q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},ee=e=>{const n=e.charCodeAt(0);return n<32&&n!==9&&n!==10&&n!==13||n===65534||n===65535},d=e=>Array.from(e,n=>ee(n)?"":Q[n]??n).join("");function o(e,n={},...a){const r=Object.entries(n).filter(([,s])=>s!==void 0).map(([s,i])=>` ${s}="${d(typeof i=="boolean"?i?"1":"0":String(i))}"`).join(""),c=a.join("");return c===""?`<${e}${r}/>`:`<${e}${r}>${c}</${e}>`}const te=e=>V(e),x=e=>e===null?o("a:noFill"):o("a:solidFill",{},te(e)),t=(e,n)=>o(e,{val:typeof n=="boolean"?n?1:0:n}),f=(e,n)=>o("a:ln",n===void 0?{}:{w:Math.round(n*12700)},x(e)),O=(e,n)=>o("c:txPr",{},o("a:bodyPr"),o("a:lstStyle"),o("a:p",{},o("a:pPr",{},o("a:defRPr",e===void 0?{}:{sz:Math.round(e*100)},n===void 0?"":x(n))),o("a:endParaRPr",{lang:"en-US"}))),$=e=>o("c:strCache",{},t("c:ptCount",e.length),...e.map((n,a)=>o("c:pt",{idx:a},`<c:v>${d(n)}</c:v>`))),F=(e,n)=>o("c:numCache",{},`<c:formatCode>${d(e??"General")}</c:formatCode>`,t("c:ptCount",n.length),...n.flatMap((a,r)=>a===null?[]:[o("c:pt",{idx:r},`<c:v>${String(a)}</c:v>`)])),ne=(e,n)=>o("c:tx",{},n===void 0?`<c:v>${d(e.name)}</c:v>`:o("c:strRef",{},`<c:f>${d(n)}</c:f>`,$([e.name]))),oe=(e,n)=>n===void 0?"":o("c:xVal",{},o("c:numRef",{},`<c:f>${d(n)}</c:f>`,F("General",e.x??[])));function re(e,n,a,r){const c=n.color??I(a),s=h(e.type),i=w(e.type),l=S(e.type)||i,u=Z(e.type),z=l?o("c:spPr",{},W(e.type)?f(c,n.line_width??m.lineWidth):o("a:ln",{w:19050},x(null))):o("c:spPr",{},x(c),s?f("lt1",1):""),v=r.categories;return o("c:ser",{},t("c:idx",a),t("c:order",a),ne(n,r.name(a)),z,L(e.type)?t("c:invertIfNegative",!1):"",l?o("c:marker",{},t("c:symbol",u?"circle":"none"),u?t("c:size",n.marker_size??m.marker):"",u?o("c:spPr",{},x(c),f(c)):""):"",...j(e)&&!l&&!X(e.type)?e.categories.map((C,p)=>o("c:dPt",{},t("c:idx",p),L(e.type)?t("c:invertIfNegative",!1):"",t("c:bubble3D",!1),o("c:spPr",{},x(e.category_colors?.[p]??I(p)),s?f("lt1",1):""))):[],i?oe(n,r.x?.(a)):v===void 0?"":o("c:cat",{},r.numeric===!0?o("c:numRef",{},`<c:f>${d(v)}</c:f>`,F(r.categoryFormat??"General",r.categoryNumbers??e.categories.map(C=>{const p=Number(C);return C===""||!Number.isFinite(p)?null:p}))):o("c:strRef",{},`<c:f>${d(v)}</c:f>`,$(e.categories))),o(i?"c:yVal":"c:val",{},o("c:numRef",{},`<c:f>${d(r.values(a))}</c:f>`,F(n.number_format,n.values))),l?t("c:smooth",n.smooth===!0||e.type==="scatter-smooth"):"")}function _(e){const n=e.labels;if(!n)return"";const a=n.show_percentage===!0,r=H(e);return o("c:dLbls",{},n.number_format===void 0?"":o("c:numFmt",{formatCode:n.number_format,sourceLinked:0}),n.size===void 0&&n.color===void 0&&!h(e.type)?"":O(n.size,n.color??(h(e.type)?"lt1":void 0)),r===void 0?"":t("c:dLblPos",r),t("c:showLegendKey",!1),t("c:showVal",n.show_value??!a),t("c:showCatName",n.show_category_name===!0),t("c:showSerName",n.show_series_name===!0),t("c:showPercent",a),t("c:showBubbleSize",!1))}function ce(e,n){const a=R(e);return a.length<=1?E(e,e.series.map((r,c)=>c),n,!1):a.map(r=>E({...e,type:r.kind},r.series,n,r.secondary)).join("")}function E(e,n,a,r){const c=n.map(l=>{const u=e.series[l];return u?re(e,u,l,a):""}).join(""),s=A(e.type),i=r?t("c:axId",M)+t("c:axId",T):t("c:axId",b)+t("c:axId",y);if(h(e.type)){const l=e.type==="pie";return o(l?"c:pieChart":"c:doughnutChart",{},t("c:varyColors",j(e)),c,_(e),t("c:firstSliceAng",0),l?"":t("c:holeSize",e.hole_size??50))}if(w(e.type))return o("c:scatterChart",{},t("c:scatterStyle","lineMarker"),t("c:varyColors",!1),c,_(e),i);if(L(e.type)){const l=s!=="clustered";return o("c:barChart",{},t("c:barDir",G(e.type)?"bar":"col"),t("c:grouping",s),t("c:varyColors",j(e)),c,_(e),t("c:gapWidth",e.gap_width??150),e.overlap!==void 0||l?t("c:overlap",e.overlap??100):"",i)}return o(S(e.type)?"c:lineChart":"c:areaChart",{},t("c:grouping",s),t("c:varyColors",!1),c,_(e),S(e.type)?t("c:marker",!0):"",i)}const g=e=>o("c:scaling",{},t("c:orientation",e.reverse_order===!0?"maxMin":"minMax"),e.maximum_scale===void 0?"":t("c:max",e.maximum_scale),e.minimum_scale===void 0?"":t("c:min",e.minimum_scale)),N=e=>o("c:spPr",{},f(e.line_color??{rgb:m.axisLine},m.gridWidth)),k=e=>e.has_major_gridlines===!0?o("c:majorGridlines",{},o("c:spPr",{},f(e.gridline_color??{rgb:m.gridline},m.gridWidth))):"",U=(e,n)=>o("c:rich",{},o("a:bodyPr"),o("a:lstStyle"),...e.split(`
4
+ `).map(a=>o("a:p",{},o("a:pPr",{},o("a:defRPr",{sz:n,b:0})),o("a:r",{},o("a:rPr",{lang:"en-US",sz:n,b:0}),`<a:t>${d(a)}</a:t>`)))),P=(e,n)=>e===void 0||e===""?"":o("c:title",{},o("c:tx",{},U(e,n)),t("c:overlay",!1));function ae(e,n){if(h(e.type))return"";const a=w(e.type),r=G(e.type),c=e.category_axis??{},s={has_major_gridlines:!0,...e.value_axis},i=A(e.type)==="percentStacked",l=s.number_format??(i?"0%":e.series[0]?.number_format??"General"),u=Math.round((e.font_size??m.fontSize)*100);return(a?o("c:valAx",{},t("c:axId",b),g(c),t("c:delete",c.visible===!1),t("c:axPos","b"),k(c),P(c.title,u),o("c:numFmt",{formatCode:c.number_format??"General",sourceLinked:c.number_format===void 0?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),N(c),t("c:crossAx",y),t("c:crosses","autoZero"),t("c:crossBetween","midCat"),c.major_unit===void 0?"":t("c:majorUnit",c.major_unit)):o("c:catAx",{},t("c:axId",b),g(c),t("c:delete",c.visible===!1),t("c:axPos",r?"l":"b"),k(c),P(c.title,u),n?.numeric===!0?o("c:numFmt",{formatCode:c.number_format??n.categoryFormat??"General",sourceLinked:c.number_format===void 0?1:0}):o("c:numFmt",{formatCode:"General",sourceLinked:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),N(c),t("c:crossAx",y),t("c:crosses","autoZero"),t("c:auto",!0),t("c:lblAlgn","ctr"),t("c:lblOffset",100),t("c:noMultiLvlLbl",!1)))+o("c:valAx",{},t("c:axId",y),g(s),t("c:delete",s.visible===!1),t("c:axPos",r?"b":"l"),k(s),P(s.title,u),o("c:numFmt",{formatCode:l,sourceLinked:s.number_format===void 0&&!i?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),o("c:spPr",{},f(null)),t("c:crossAx",b),t("c:crosses","autoZero"),t("c:crossBetween",X(e.type)||a?"midCat":"between"),s.major_unit===void 0?"":t("c:majorUnit",s.major_unit))+se(e,u)}function se(e,n){const a=R(e).find(i=>i.secondary);if(!a)return"";const r=e.secondary_axis??{},c=A(a.kind)==="percentStacked",s=r.number_format??(c?"0%":e.series[a.series[0]??0]?.number_format??"General");return o("c:catAx",{},t("c:axId",M),g({}),t("c:delete",!0),t("c:axPos","b"),o("c:numFmt",{formatCode:"General",sourceLinked:1}),t("c:majorTickMark","out"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),t("c:crossAx",T),t("c:crosses","autoZero"),t("c:auto",!0),t("c:lblAlgn","ctr"),t("c:lblOffset",100),t("c:noMultiLvlLbl",!1))+o("c:valAx",{},t("c:axId",T),g(r),t("c:delete",r.visible===!1),t("c:axPos","r"),k(r),P(r.title,n),o("c:numFmt",{formatCode:s,sourceLinked:r.number_format===void 0&&!c?1:0}),t("c:majorTickMark","none"),t("c:minorTickMark","none"),t("c:tickLblPos","nextTo"),o("c:spPr",{},f(null)),t("c:crossAx",M),t("c:crosses","max"),t("c:crossBetween","between"),r.major_unit===void 0?"":t("c:majorUnit",r.major_unit))}const ie={bottom:"b",top:"t",left:"l",right:"r"};function le(e,n){const a=n.width,r=n.height,{plot:c}=B(e,a,r),s=i=>Number(i.toFixed(5));return o("c:layout",{},o("c:manualLayout",{},t("c:layoutTarget","inner"),t("c:xMode","edge"),t("c:yMode","edge"),t("c:x",s(c.x/a)),t("c:y",s(c.y/r)),t("c:w",s(c.width/a)),t("c:h",s(c.height/r))))}const D=o("c:spPr",{},o("a:noFill"),o("a:ln",{},o("a:noFill")));export function chartSpaceXml(e,n){const a=e.title!==void 0&&e.title!==""?e.title:void 0,r=e.font_size??m.fontSize,c=Math.round((e.title_size??r*m.titleScale)*100);return J+o("c:chartSpace",{"xmlns:c":Y,"xmlns:a":q,"xmlns:r":K},t("c:date1904",!1),t("c:roundedCorners",!1),o("c:chart",{},a===void 0?"":o("c:title",{},o("c:tx",{},n.titleRef===void 0?U(a,c):o("c:strRef",{},`<c:f>${d(n.titleRef)}</c:f>`,$([a]))),t("c:overlay",!1)),t("c:autoTitleDeleted",a===void 0),o("c:plotArea",{},n.frame?le(e,n.frame):o("c:layout"),ce(e,n.refs),ae(e,n.refs),n.frameless===!0?D:""),e.legend===void 0?"":o("c:legend",{},t("c:legendPos",ie[e.legend]),t("c:overlay",e.legend_overlay===!0)),t("c:plotVisOnly",n.plotVisible??!0),t("c:dispBlanksAs","gap")),n.frameless===!0?D:"",O(r,e.font_color??"dk1"),n.tail??"")}
@@ -1,2 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{format as Vt,isValidFormat as Rt}from"numfmt";import{brightened as Zt}from"@allyhub/ooxml/brightness";export const themeColor=(t,s=0)=>s===0?t:{theme_color:t,brightness:s},themeColorOf=t=>typeof t=="string"?t:"theme_color"in t?t.theme_color:void 0;export function colorRgb(t,s){return typeof t=="string"?s[t]:"rgb"in t?t.rgb:Zt(s[t.theme_color],t.brightness)}export const CHART_DEFAULTS={fontSize:12,titleScale:1.2,gapWidth:150,holeSize:50,margin:6,gridline:"#D9D9D9",axisLine:"#BFBFBF",letter:.55,lineWidth:2.25,gridWidth:.75,marker:5};const Ft=["accent1","accent2","accent3","accent4","accent5","accent6"];export const accentOf=t=>Ft[t%Ft.length]??"accent1",isBar=t=>t.startsWith("column")||t.startsWith("bar"),isHorizontal=t=>t.startsWith("bar"),isLine=t=>t.startsWith("line"),isArea=t=>t.startsWith("area"),isRound=t=>t==="pie"||t==="doughnut",isScatter=t=>t.startsWith("scatter"),hasLines=t=>!isScatter(t)||t!=="scatter",hasMarkers=t=>t==="line-markers"||t==="scatter"||t==="scatter-lines",groupingOf=t=>t.endsWith("-100")?"percentStacked":t.endsWith("-stacked")?"stacked":isBar(t)?"clustered":"standard";export function labelPositionsOf(t){return isArea(t)||t==="doughnut"?[]:t==="pie"?["bestFit","outEnd","inEnd","ctr"]:isLine(t)||isScatter(t)?["t","b","l","r","ctr"]:groupingOf(t)==="clustered"?["outEnd","inEnd","ctr","inBase"]:["inEnd","ctr","inBase"]}export function labelPositionOf(t){const s=labelPositionsOf(t.type),h=t.labels?.position;if(h!==void 0&&s.includes(h))return h;if(s.length!==0)return t.type==="pie"?"ctr":isLine(t.type)||isScatter(t.type)?"t":groupingOf(t.type)==="clustered"?"outEnd":"ctr"}export const isCombinable=t=>t.startsWith("column")||isLine(t)||isArea(t);export function groupsOf(t){const s=isCombinable(t.type),h=[];t.series.forEach((o,c)=>{const n=o.type!==void 0&&s&&isCombinable(o.type)?o.type??t.type:t.type,S=s&&o.secondary===!0,_=h.find(O=>O.kind===n&&O.secondary===S);_?_.series.push(c):h.push({kind:n,secondary:S,series:[c]})});const r=o=>(o.secondary?3:0)+(isArea(o.kind)?0:isBar(o.kind)?1:2);return h.sort((o,c)=>r(o)-r(c))}export const variesOf=t=>t.vary_by_categories??isRound(t.type);export function formatValue(t,s="General"){return s==="General"||!Rt(s)?String(Number(t.toPrecision(10))):Vt(s,t)}const Ut=[1,2,5,10];export function chartScale(t,s,h,r,o={}){const c=t>0&&(s-t)/s<.16666666666666666?t:Math.min(t,0),a=s<=0&&t<0?0:s,n=o.minimum_scale??c,S=o.maximum_scale??a,_=S>n?S-n:1,O=Math.max(1,Math.floor(h/r)),k=_/O,P=10**Math.floor(Math.log10(k)),N=o.major_unit??(Ut.find(v=>v*P>=k)??10)*P,z=(v,j)=>Number((j(Number((v/N).toFixed(9)))*N).toPrecision(12)),q=a>0?a+_*.05:a===c?_:a,x=o.maximum_scale??z(q,Math.ceil),Z=c<0?c-_*.05:c,V=o.minimum_scale??z(Z,Math.floor),D=[],y=Math.round((x-V)/N);for(let v=0;v<=y;v++)D.push(Number((V+v*N).toPrecision(12)));return{min:V,max:x,major:N,ticks:D}}const it=(t,s)=>{let h=0;for(const r of t)h+=(r.codePointAt(0)??0)>11903?1:CHART_DEFAULTS.letter;return h*s},m=t=>String(Number(t.toFixed(3)));function jt(t){const s=h=>t[Math.max(0,Math.min(t.length-1,h))]??[0,0];return t.map(([h,r],o)=>{if(o===0)return`M${m(h)} ${m(r)}`;const[c,a]=s(o-2),[n,S]=s(o-1),[_,O]=s(o+1),k=`${m(n+(h-c)/6)} ${m(S+(r-a)/6)}`,P=`${m(h-(_-n)/6)} ${m(r-(O-S)/6)}`;return`C${k} ${P} ${m(h)} ${m(r)}`}).join(" ")}const gt=t=>t.map(([s,h],r)=>`${r===0?"M":"L"}${m(s)} ${m(h)}`).join(" ");function qt(t,s,h,r,o,c){const a=(O,k)=>`${m(t+O*Math.sin(k))} ${m(s-O*Math.cos(k))}`,n=c-o>=Math.PI*2?o+Math.PI*2-1e-4:c,S=n-o>Math.PI?1:0,_=`M${a(h,o)} A${m(h)} ${m(h)} 0 ${String(S)} 1 ${a(h,n)}`;return r<=0?`${_} L${m(t)} ${m(s)} Z`:`${_} L${a(r,n)} A${m(r)} ${m(r)} 0 ${String(S)} 0 ${a(r,o)} Z`}function Nt(t,s,h,r){const o=r*1.5;return s!==void 0&&s!==""&&(t.bottom-=o),h!==void 0&&h!==""&&(t.left+=o),{x:t.left-o/2,y:t.bottom+o/2}}function Bt(t,s,h,r,o,c,a){r!==void 0&&r!==""&&t.words.push({x:s.x+s.width/2,y:h.y,text:r,size:c,anchor:"middle",color:a}),o!==void 0&&o!==""&&t.words.push({x:h.x,y:s.y+s.height/2,text:o,size:c,anchor:"middle",color:a,rotate:-90})}const xt=(t,s,h,r,o)=>{const c=t.labels;if(!c)return"";const a=isRound(t.type),n=[];return c.show_series_name&&n.push(r.name),c.show_category_name&&n.push(o),(c.show_value??!(c.show_percentage??!1))&&n.push(formatValue(s,c.number_format??r.number_format)),c.show_percentage&&a&&n.push(formatValue(h,c.number_format??"0%")),n.join(", ")};function Jt(t,s,h,r,o){const c=CHART_DEFAULTS,a=t.category_axis??{},n=t.value_axis??{},S=Nt(h,a.title,n.title,r),_=t.series.map(f=>f.values.flatMap((W,B)=>{const I=f.x?.[B]??(f.x?null:B+1);return I===null||W===null?[]:[[I,W]]})),O=_.flat().map(f=>f[0]),k=_.flat().map(f=>f[1]),P=f=>f.length>0?Math.min(...f):0,N=f=>f.length>0?Math.max(...f):1,z=n.number_format??t.series[0]?.number_format??"General",q=a.number_format??"General",x=r*.5,Z=chartScale(P(k),N(k),h.bottom-h.top,r*2.4,n),V=n.visible===!1?0:Math.max(0,...Z.ticks.map(f=>it(formatValue(f,z),r)))+x,D=a.visible===!1?0:r*1.2+x,y={x:h.left+V,y:h.top,width:h.right-h.left-V,height:h.bottom-h.top-D};s.plot=y,Bt(s,y,S,a.title,n.title,r,o);const v=chartScale(P(O),N(O),y.width,r*5,a),j=chartScale(P(k),N(k),y.height,r*2.4,n),U=f=>y.x+(Math.min(v.max,Math.max(v.min,f))-v.min)/(v.max-v.min)*y.width,G=f=>y.y+y.height-(Math.min(j.max,Math.max(j.min,f))-j.min)/(j.max-j.min)*y.height;for(const f of j.ticks){const W=G(f);(n.has_major_gridlines??!0)&&s.grid.push({d:`M${m(y.x)} ${m(W)} H${m(y.x+y.width)}`,color:n.gridline_color??{rgb:c.gridline},width:c.gridWidth}),n.visible!==!1&&s.words.push({x:y.x-x,y:W,text:formatValue(f,z),size:r,anchor:"end",color:o})}for(const f of v.ticks){const W=U(f);a.has_major_gridlines===!0&&s.grid.push({d:`M${m(W)} ${m(y.y)} V${m(y.y+y.height)}`,color:a.gridline_color??{rgb:c.gridline},width:c.gridWidth}),a.visible!==!1&&s.words.push({x:W,y:y.y+y.height+x+r*.6,text:formatValue(f,q),size:r,anchor:"middle",color:o})}s.axes.push({d:`M${m(y.x)} ${m(G(Math.max(j.min,Math.min(j.max,0))))} H${m(y.x+y.width)}`,color:a.line_color??{rgb:c.axisLine},width:c.gridWidth}),t.series.forEach((f,W)=>{const B=f.color??accentOf(W),I=(_[W]??[]).map(([J,R])=>[U(J),G(R)]);if(I.length!==0&&(hasLines(t.type)&&s.lines.push({d:t.type==="scatter-smooth"||f.smooth===!0?jt(I):gt(I),color:B,width:f.line_width??c.lineWidth,series:W}),hasMarkers(t.type)))for(const[J,R]of I)s.dots.push({x:J,y:R,r:(f.marker_size??c.marker)/2,color:B})})}export function chartDrawing(t,s,h){const r=CHART_DEFAULTS,o=t.font_size??r.fontSize,c=t.font_color??"dk1",a={grid:[],shapes:[],boxes:[],lines:[],axes:[],dots:[],keys:[],words:[],plot:{x:0,y:0,width:0,height:0}},n={left:r.margin,top:r.margin,right:s-r.margin,bottom:h-r.margin};if(t.title!==void 0&&t.title!==""){const e=t.title_size??o*r.titleScale;a.words.push({x:s/2,y:n.top+e*.7,text:t.title,size:e,anchor:"middle",color:c}),n.top+=e*1.6}const S=isRound(t.type),_=variesOf(t),O=(e,i)=>_?t.category_colors?.[i]??accentOf(i):t.series[e]?.color??accentOf(e);if(t.legend!==void 0){const e=_?t.categories:t.series.map(d=>d.name),i=o*.6,g=o*.4,l=o*1.5,b=e.map(d=>i+g+it(d,o)),F=(d,w,u)=>{a.keys.push({x:w,y:u-i/2,width:i,height:i,color:_?t.category_colors?.[d]??accentOf(d):t.series[d]?.color??accentOf(d),series:_?0:d,category:_?d:0}),a.words.push({x:w+i+g,y:u,text:e[d]??"",size:o,anchor:"start",color:c})};if(t.legend==="top"||t.legend==="bottom"){const d=b.reduce((E,M)=>E+M,0)+o*(e.length-1),w=t.legend==="top"?n.top+l/2:n.bottom-l/2;let u=(s-d)/2;e.forEach((E,M)=>{F(M,u,w),u+=(b[M]??0)+o}),t.legend_overlay!==!0&&(t.legend==="top"?n.top+=l:n.bottom-=l)}else{const d=Math.max(0,...b),w=t.legend==="left"?n.left:n.right-d,u=(n.top+n.bottom-l*e.length)/2+l/2;e.forEach((E,M)=>{F(M,w,u+M*l)}),t.legend_overlay!==!0&&(t.legend==="left"?n.left+=d+o:n.right-=d+o)}}const k=t.labels,P=k?.size??o,N=k?.color??c,z=(e,i,g,l,b=N)=>{g!==""&&a.words.push({x:e,y:i,text:g,size:P,anchor:l,color:b})};if(S){const e=t.series[0],i=(e?.values??[]).map(u=>Math.max(0,u??0)),g=i.reduce((u,E)=>u+E,0),l=Math.max(0,Math.min(n.right-n.left,n.bottom-n.top)/2),b=(n.left+n.right)/2,F=(n.top+n.bottom)/2,d=t.type==="doughnut"?l*((t.hole_size??r.holeSize)/100):0;a.plot={x:b-l,y:F-l,width:l*2,height:l*2};let w=0;return i.forEach((u,E)=>{const M=g>0?u/g:0,$=w+M*Math.PI*2;if(M>0){a.shapes.push({d:qt(b,F,l,d,w,$),color:"lt1",width:1,fill:O(0,E),series:0,category:E});const A=(w+$)/2,T=d>0?(l+d)/2:labelPositionOf(t)==="inEnd"?l*.85:l*.6;e&&z(b+T*Math.sin(A),F-T*Math.cos(A),xt(t,u,M,e,t.categories[E]??""),"middle",k?.color??"lt1")}w=$}),a}if(isScatter(t.type))return Jt(t,a,n,o,c),a;const q=Math.max(1,t.categories.length),x=isHorizontal(t.type),Z=groupsOf(t),V=Z.every(e=>e.secondary)?Z.map(e=>({...e,secondary:!1})):Z,D=t.series.map(e=>t.categories.map((i,g)=>e.values[g]??null)),y=V.map(e=>{const i=groupingOf(e.kind),g=i!=="clustered"&&i!=="standard",l=i==="percentStacked",b=t.categories.map((F,d)=>e.series.reduce((w,u)=>w+Math.abs(D[u]?.[d]??0),0));return{...e,stacked:g,percent:l,totals:b}}),v=(e,i,g)=>{const l=D[i]?.[g];if(l==null)return null;const b=e.totals[g]??0;return e.percent?b>0?l/b:0:l},j=e=>{let i=0,g=0,l=1/0,b=!1;for(const u of y)if(u.secondary===e&&(b||=u.percent,t.categories.forEach((E,M)=>{let $=0,A=0;for(const T of u.series){const C=v(u,T,M)??0;u.stacked?C>=0?$+=C:A+=C:($=Math.max($,C),A=Math.min(A,C))}g=Math.max(g,$),i=Math.min(i,A)}),!u.stacked))for(const E of u.series)for(const M of D[E]??[])M!==null&&(l=Math.min(l,M));y.every(u=>u.secondary!==e||!u.stacked)&&Number.isFinite(l)&&l>0&&(i=l),b&&(g=1,i=Math.min(i,0));const d=y.find(u=>u.secondary===e),w=d===void 0?void 0:d.series[0];return{low:i,high:g,percent:b,format:w===void 0?void 0:t.series[w]?.number_format}},U=j(!1),G=y.some(e=>e.secondary)?j(!0):void 0,f=t.value_axis??{},W=t.secondary_axis??{},B=t.category_axis??{},I=f.number_format??(U.percent?"0%":U.format??"General"),J=W.number_format??(G?.percent===!0?"0%":G?.format??"General"),R=(e,i,g,l)=>chartScale(e.low,e.high,g,l,{...i,...e.percent?{maximum_scale:i.maximum_scale??1}:{}}),yt=x?n.right-n.left:n.bottom-n.top,at=x?o*5:o*2.4,It=R(U,f,yt,at),bt=f.visible===!1?[]:It.ticks.map(e=>formatValue(e,I)),Mt=Math.max(0,...bt.map(e=>it(e,o))),wt=G===void 0||W.visible===!1?0:Math.max(0,...R(G,W,yt,at).ticks.map(e=>it(formatValue(e,J),o))),ct=B.visible!==!1,_t=ct?Math.max(0,...t.categories.map(e=>it(e,o))):0,H=o*.5,$t=x?f.title:B.title,kt=x?B.title:f.title,zt=Nt(n,$t,kt,o),p=x?{x:n.left+(ct?_t+H:0),y:n.top,width:0,height:n.bottom-n.top-(f.visible===!1?0:o*1.2+H)}:{x:n.left+(f.visible===!1?0:Mt+H),y:n.top,width:0,height:n.bottom-n.top-(ct?o*1.2+H:0)};p.width=n.right-p.x-(x&&bt.length>0?Mt/2:0)-(wt>0?wt+H:0),a.plot=p,Bt(a,p,zt,$t,kt,o,c);const ft=x?p.width:p.height,et=R(U,f,ft,at),ot=G===void 0?void 0:R(G,W,ft,at),vt=(e,i)=>(Math.min(e.max,Math.max(e.min,i))-e.min)/(e.max-e.min)*ft,ut=(e,i)=>x?p.x+vt(e,i):p.y+p.height-vt(e,i),Wt=e=>ut(et,e),Et=y.every(e=>isArea(e.kind)),St=B.reverse_order===!0,Ot=x?!St:St,mt=(x?p.height:p.width)/q,Pt=Et?(x?p.height:p.width)/Math.max(1,q-1):mt,pt=e=>{const i=Et?e*Pt:(e+.5)*mt,g=x?p.height:p.width,l=Ot?g-i:i;return(x?p.y:p.x)+l},At=Wt(Math.max(et.min,Math.min(et.max,0)));for(const e of et.ticks){const i=Wt(e);(f.has_major_gridlines??!0)&&a.grid.push({d:x?`M${m(i)} ${m(p.y)} V${m(p.y+p.height)}`:`M${m(p.x)} ${m(i)} H${m(p.x+p.width)}`,color:f.gridline_color??{rgb:r.gridline},width:r.gridWidth}),f.visible!==!1&&a.words.push(x?{x:i,y:p.y+p.height+H+o*.6,text:formatValue(e,I),size:o,anchor:"middle",color:c}:{x:p.x-H,y:i,text:formatValue(e,I),size:o,anchor:"end",color:c})}if(ot&&W.visible!==!1)for(const e of ot.ticks)a.words.push({x:p.x+p.width+H,y:ut(ot,e),text:formatValue(e,J),size:o,anchor:"start",color:c});if(a.axes.push({d:x?`M${m(At)} ${m(p.y)} V${m(p.y+p.height)}`:`M${m(p.x)} ${m(At)} H${m(p.x+p.width)}`,color:B.line_color??{rgb:r.axisLine},width:r.gridWidth}),ct){const e=x?o*1.3:_t+o,i=Math.max(1,Math.ceil(e/Math.max(1,Pt)));t.categories.forEach((g,l)=>{if(l%i!==0)return;const b=pt(l);a.words.push(x?{x:p.x-H,y:b,text:g,size:o,anchor:"end",color:c}:{x:b,y:p.y+p.height+H+o*.6,text:g,size:o,anchor:"middle",color:c})})}for(const e of y){const i=e.secondary&&ot?ot:et,g=b=>ut(i,b),l={type:e.kind,...t.labels===void 0?{}:{labels:t.labels}};isBar(e.kind)?Dt(e,g,l):Gt(e,g,l)}return a;function Dt(e,i,g){const l=(t.gap_width??r.gapWidth)/100,b=e.stacked?1:e.series.length,F=e.stacked?1:(t.overlap??0)/100,d=mt/(Math.max(1,b-(b-1)*F)+l),w=d*(1-F),u=d+w*(b-1);t.categories.forEach((E,M)=>{const $=pt(M);let A=0,T=0;e.series.forEach((C,nt)=>{const K=t.series[C],L=v(e,C,M);if(L===null||!K)return;const lt=e.stacked?L>=0?A:T:0,st=lt+L;e.stacked&&(L>=0?A=st:T=st);const Q=i(lt),X=i(st),ht=(e.stacked?$-d/2:$-u/2+nt*w)+(x&&Ot&&!e.stacked?u-d-2*nt*w:0),Ht=x?{x:Math.min(Q,X),y:ht,width:Math.abs(X-Q),height:d}:{x:ht,y:Math.min(Q,X),width:d,height:Math.abs(X-Q)};if(a.boxes.push({...Ht,color:O(C,M),series:C,category:M}),!k)return;const Ct=xt(t,D[C]?.[M]??0,0,K,t.categories[M]??""),dt=labelPositionOf(g),Y=P*.8,Tt=L>=0?1:-1,Lt=(rt,tt)=>dt==="ctr"?(rt+tt)/2:dt==="inBase"?rt+(tt>rt?Y:-Y):dt==="inEnd"?tt-(tt>rt?Y:-Y):tt+(tt>=rt?Y:-Y);x?z(Lt(Q,X),ht+d/2,Ct,dt==="outEnd"?Tt>0?"start":"end":"middle"):z(ht+d/2,Lt(Q,X),Ct,"middle")})})}function Gt(e,i,g){const l=t.categories.map(()=>0),b=e.series.map(d=>{const w=t.series[d],u=[],E=[];return t.categories.forEach((M,$)=>{const A=v(e,d,$);if(A===null||!w)return;const T=e.stacked?l[$]??0:0,C=T+A;e.stacked&&(l[$]=C);const nt=pt($),K=L=>x?[i(L),nt]:[nt,i(L)];if(u.push(K(C)),E.push(K(T)),isLine(e.kind)&&k){const L=labelPositionOf(g),[lt,st]=K(C);z(lt+(L==="r"?P:L==="l"?-P:0),st+(L==="t"?-P:L==="b"?P:0),xt(t,D[d]?.[$]??0,0,w,t.categories[$]??""),L==="r"?"start":L==="l"?"end":"middle")}}),{series:w,s:d,points:u,base:E}}),F=[];for(const{series:d,s:w,points:u,base:E}of b){if(!d)continue;const M=d.color??accentOf(w);if(isArea(e.kind)&&u.length>0)F.push({d:`${gt([...u,...[...E].reverse()])} Z`,color:M,width:0,fill:M,series:w});else if(u.length>0&&(a.lines.push({d:d.smooth===!0?jt(u):gt(u),color:M,width:d.line_width??r.lineWidth,series:w}),hasMarkers(e.kind)))for(const[$,A]of u)a.dots.push({x:$,y:A,r:(d.marker_size??r.marker)/2,color:M})}a.shapes.push(...F.reverse())}}
2
+ import{format as Zt,isValidFormat as Ut}from"numfmt";export const CHART_DEFAULTS={fontSize:12,titleScale:1.2,gapWidth:150,holeSize:50,margin:6,gridline:"#D9D9D9",axisLine:"#BFBFBF",letter:.55,lineWidth:2.25,gridWidth:.75,marker:5};const jt=["accent1","accent2","accent3","accent4","accent5","accent6"];export const accentOf=t=>jt[t%jt.length]??"accent1",isBar=t=>t.startsWith("column")||t.startsWith("bar"),isHorizontal=t=>t.startsWith("bar"),isLine=t=>t.startsWith("line"),isArea=t=>t.startsWith("area"),isRound=t=>t==="pie"||t==="doughnut",isScatter=t=>t.startsWith("scatter"),hasLines=t=>!isScatter(t)||t!=="scatter",hasMarkers=t=>t==="line-markers"||t==="scatter"||t==="scatter-lines",groupingOf=t=>t.endsWith("-100")?"percentStacked":t.endsWith("-stacked")?"stacked":isBar(t)?"clustered":"standard";export function labelPositionsOf(t){return isArea(t)||t==="doughnut"?[]:t==="pie"?["bestFit","outEnd","inEnd","ctr"]:isLine(t)||isScatter(t)?["t","b","l","r","ctr"]:groupingOf(t)==="clustered"?["outEnd","inEnd","ctr","inBase"]:["inEnd","ctr","inBase"]}export function labelPositionOf(t){const c=labelPositionsOf(t.type),h=t.labels?.position;if(h!==void 0&&c.includes(h))return h;if(c.length!==0)return t.type==="pie"?"ctr":isLine(t.type)||isScatter(t.type)?"t":groupingOf(t.type)==="clustered"?"outEnd":"ctr"}export const isCombinable=t=>t.startsWith("column")||isLine(t)||isArea(t);export function groupsOf(t){const c=isCombinable(t.type),h=[];if(t.series.forEach((n,i)=>{const o=n.type!==void 0&&c&&isCombinable(n.type)?n.type??t.type:t.type,S=c&&n.secondary===!0,_=h.find(A=>A.kind===o&&A.secondary===S);_?_.series.push(i):h.push({kind:o,secondary:S,series:[i]})}),h.every(n=>n.secondary))for(const n of h)n.secondary=!1;const r=n=>(n.secondary?3:0)+(isArea(n.kind)?0:isBar(n.kind)?1:2);return h.sort((n,i)=>r(n)-r(i))}export const variesOf=t=>t.vary_by_categories??isRound(t.type);export function formatValue(t,c="General"){return c==="General"||!Ut(c)?String(Number(t.toPrecision(10))):Zt(c,t)}const qt=[1,2,5,10];export function chartScale(t,c,h,r,n={}){const i=t>0&&(c-t)/c<.16666666666666666?t:Math.min(t,0),a=c<=0&&t<0?0:c,o=n.minimum_scale??i,S=n.maximum_scale??a,_=S>o?S-o:1,A=Math.max(1,Math.floor(h/r)),k=_/A,O=10**Math.floor(Math.log10(k)),T=n.major_unit??(qt.find(E=>E*O>=k)??10)*O,D=(E,P)=>Number((P(Number((E/T).toFixed(9)))*T).toPrecision(12)),U=a>0?a+_*.05:a===i?_:a,x=n.maximum_scale??D(U,Math.ceil),tt=i<0?i-_*.05:i,N=n.minimum_scale??D(tt,Math.floor),B=[],M=Math.round((x-N)/T);for(let E=0;E<=M;E++)B.push(Number((N+E*T).toPrecision(12)));return{min:N,max:x,major:T,ticks:B}}const Jt=[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],it=(t,c)=>{let h=0;for(const r of t){const n=r.codePointAt(0)??0,i=Jt[n-32];h+=i!==void 0?i/1e3:n>11903?1:CHART_DEFAULTS.letter}return h*c},m=t=>String(Number(t.toFixed(3)));function Nt(t){const c=h=>t[Math.max(0,Math.min(t.length-1,h))]??[0,0];return t.map(([h,r],n)=>{if(n===0)return`M${m(h)} ${m(r)}`;const[i,a]=c(n-2),[o,S]=c(n-1),[_,A]=c(n+1),k=`${m(o+(h-i)/6)} ${m(S+(r-a)/6)}`,O=`${m(h-(_-o)/6)} ${m(r-(A-S)/6)}`;return`C${k} ${O} ${m(h)} ${m(r)}`}).join(" ")}const xt=t=>t.map(([c,h],r)=>`${r===0?"M":"L"}${m(c)} ${m(h)}`).join(" ");function Kt(t,c,h,r,n,i){const a=(A,k)=>`${m(t+A*Math.sin(k))} ${m(c-A*Math.cos(k))}`,o=i-n>=Math.PI*2?n+Math.PI*2-1e-4:i,S=o-n>Math.PI?1:0,_=`M${a(h,n)} A${m(h)} ${m(h)} 0 ${String(S)} 1 ${a(h,o)}`;return r<=0?`${_} L${m(t)} ${m(c)} Z`:`${_} L${a(r,o)} A${m(r)} ${m(r)} 0 ${String(S)} 0 ${a(r,n)} Z`}function Tt(t,c,h,r){const n=r*1.5;return c!==void 0&&c!==""&&(t.bottom-=n),h!==void 0&&h!==""&&(t.left+=n),{x:t.left-n/2,y:t.bottom+n/2}}function Bt(t,c,h,r,n,i,a){r!==void 0&&r!==""&&t.words.push({x:c.x+c.width/2,y:h.y,text:r,size:i,anchor:"middle",color:a}),n!==void 0&&n!==""&&t.words.push({x:h.x,y:c.y+c.height/2,text:n,size:i,anchor:"middle",color:a,rotate:-90})}const yt=(t,c,h,r,n)=>{const i=t.labels;if(!i)return"";const a=isRound(t.type),o=[];return i.show_series_name&&o.push(r.name),i.show_category_name&&o.push(n),(i.show_value??!(i.show_percentage??!1))&&o.push(formatValue(c,i.number_format??r.number_format)),i.show_percentage&&a&&o.push(formatValue(h,i.number_format??"0%")),o.join(", ")};function Qt(t,c,h,r,n){const i=CHART_DEFAULTS,a=t.category_axis??{},o=t.value_axis??{},S=Tt(h,a.title,o.title,r),_=t.series.map(p=>p.values.flatMap((v,R)=>{const z=p.x?.[R]??(p.x?null:R+1);return z===null||v===null?[]:[[z,v]]})),A=_.flat().map(p=>p[0]),k=_.flat().map(p=>p[1]),O=p=>p.length>0?Math.min(...p):0,T=p=>p.length>0?Math.max(...p):1,D=o.number_format??t.series[0]?.number_format??"General",U=a.number_format??"General",x=r*.5,tt=chartScale(O(k),T(k),h.bottom-h.top,r*2.4,o),N=o.visible===!1?0:Math.max(0,...tt.ticks.map(p=>it(formatValue(p,D),r)))+x,B=a.visible===!1?0:r*1.2+x,M={x:h.left+N,y:h.top,width:h.right-h.left-N,height:h.bottom-h.top-B};c.plot=M,Bt(c,M,S,a.title,o.title,r,n);const E=chartScale(O(A),T(A),M.width,r*5,a),P=chartScale(O(k),T(k),M.height,r*2.4,o),H=p=>M.x+(Math.min(E.max,Math.max(E.min,p))-E.min)/(E.max-E.min)*M.width,C=p=>M.y+M.height-(Math.min(P.max,Math.max(P.min,p))-P.min)/(P.max-P.min)*M.height;for(const p of P.ticks){const v=C(p);(o.has_major_gridlines??!0)&&c.grid.push({d:`M${m(M.x)} ${m(v)} H${m(M.x+M.width)}`,color:o.gridline_color??{rgb:i.gridline},width:i.gridWidth}),o.visible!==!1&&c.words.push({x:M.x-x,y:v,text:formatValue(p,D),size:r,anchor:"end",color:n})}for(const p of E.ticks){const v=H(p);a.has_major_gridlines===!0&&c.grid.push({d:`M${m(v)} ${m(M.y)} V${m(M.y+M.height)}`,color:a.gridline_color??{rgb:i.gridline},width:i.gridWidth}),a.visible!==!1&&c.words.push({x:v,y:M.y+M.height+x+r*.6,text:formatValue(p,U),size:r,anchor:"middle",color:n})}c.axes.push({d:`M${m(M.x)} ${m(C(Math.max(P.min,Math.min(P.max,0))))} H${m(M.x+M.width)}`,color:a.line_color??{rgb:i.axisLine},width:i.gridWidth}),t.series.forEach((p,v)=>{const R=p.color??accentOf(v),z=(_[v]??[]).map(([Z,q])=>[H(Z),C(q)]);if(z.length!==0&&(hasLines(t.type)&&c.lines.push({d:t.type==="scatter-smooth"||p.smooth===!0?Nt(z):xt(z),color:R,width:p.line_width??i.lineWidth,series:v}),hasMarkers(t.type)))for(const[Z,q]of z)c.dots.push({x:Z,y:q,r:(p.marker_size??i.marker)/2,color:R})})}export function chartDrawing(t,c,h){const r=CHART_DEFAULTS,n=t.font_size??r.fontSize,i=t.font_color??"dk1",a={grid:[],shapes:[],boxes:[],lines:[],axes:[],dots:[],keys:[],words:[],plot:{x:0,y:0,width:0,height:0}},o={left:r.margin,top:r.margin,right:c-r.margin,bottom:h-r.margin};if(t.title!==void 0&&t.title!==""){const e=t.title_size??n*r.titleScale,s=t.title.split(`
3
+ `);s.forEach((g,l)=>{a.words.push({x:c/2,y:o.top+e*(.7+l*1.2),text:g,size:e,anchor:"middle",color:i})}),o.top+=e*(1.6+(s.length-1)*1.2)}const S=isRound(t.type),_=variesOf(t),A=(e,s)=>_?t.category_colors?.[s]??accentOf(s):t.series[e]?.color??accentOf(e);if(t.legend!==void 0){const e=_?t.categories:t.series.map(d=>d.name),s=n*.6,g=n*.4,l=n*1.5,y=e.map(d=>s+g+it(d,n)),j=(d,w,f)=>{a.keys.push({x:w,y:f-s/2,width:s,height:s,color:_?t.category_colors?.[d]??accentOf(d):t.series[d]?.color??accentOf(d),series:_?0:d,category:_?d:0}),a.words.push({x:w+s+g,y:f,text:e[d]??"",size:n,anchor:"start",color:i})};if(t.legend==="top"||t.legend==="bottom"){const d=y.reduce((W,b)=>W+b,0)+n*(e.length-1),w=t.legend==="top"?o.top+l/2:o.bottom-l/2;let f=(c-d)/2;e.forEach((W,b)=>{j(b,f,w),f+=(y[b]??0)+n}),t.legend_overlay!==!0&&(t.legend==="top"?o.top+=l:o.bottom-=l)}else{const d=Math.max(0,...y),w=t.legend==="left"?o.left:o.right-d,f=(o.top+o.bottom-l*e.length)/2+l/2;e.forEach((W,b)=>{j(b,w,f+b*l)}),t.legend_overlay!==!0&&(t.legend==="left"?o.left+=d+n:o.right-=d+n)}}const k=t.labels,O=k?.size??n,T=k?.color??i,D=(e,s,g,l,y=T)=>{g!==""&&a.words.push({x:e,y:s,text:g,size:O,anchor:l,color:y})};if(S){const e=t.series[0],s=(e?.values??[]).map(f=>Math.max(0,f??0)),g=s.reduce((f,W)=>f+W,0),l=Math.max(0,Math.min(o.right-o.left,o.bottom-o.top)/2),y=(o.left+o.right)/2,j=(o.top+o.bottom)/2,d=t.type==="doughnut"?l*((t.hole_size??r.holeSize)/100):0;a.plot={x:y-l,y:j-l,width:l*2,height:l*2};let w=0;return s.forEach((f,W)=>{const b=g>0?f/g:0,$=w+b*Math.PI*2;if(b>0){a.shapes.push({d:Kt(y,j,l,d,w,$),color:"lt1",width:1,fill:A(0,W),series:0,category:W});const I=(w+$)/2,V=d>0?(l+d)/2:labelPositionOf(t)==="inEnd"?l*.85:l*.6;e&&D(y+V*Math.sin(I),j-V*Math.cos(I),yt(t,f,b,e,t.categories[W]??""),"middle",k?.color??"lt1")}w=$}),a}if(isScatter(t.type))return Qt(t,a,o,n,i),a;const U=Math.max(1,t.categories.length),x=isHorizontal(t.type),tt=groupsOf(t),N=t.series.map(e=>t.categories.map((s,g)=>e.values[g]??null)),B=tt.map(e=>{const s=groupingOf(e.kind),g=s!=="clustered"&&s!=="standard",l=s==="percentStacked",y=t.categories.map((j,d)=>e.series.reduce((w,f)=>w+Math.abs(N[f]?.[d]??0),0));return{...e,stacked:g,percent:l,totals:y}}),M=(e,s,g)=>{const l=N[s]?.[g];if(l==null)return null;const y=e.totals[g]??0;return e.percent?y>0?l/y:0:l},E=e=>{let s=0,g=0,l=1/0,y=!1;for(const f of B)if(f.secondary===e&&(y||=f.percent,t.categories.forEach((W,b)=>{let $=0,I=0;for(const V of f.series){const L=M(f,V,b)??0;f.stacked?L>=0?$+=L:I+=L:($=Math.max($,L),I=Math.min(I,L))}g=Math.max(g,$),s=Math.min(s,I)}),!f.stacked))for(const W of f.series)for(const b of N[W]??[])b!==null&&(l=Math.min(l,b));B.every(f=>f.secondary!==e||!f.stacked)&&Number.isFinite(l)&&l>0&&(s=l),y&&(g=1,s=Math.min(s,0));const d=B.find(f=>f.secondary===e),w=d===void 0?void 0:d.series[0];return{low:s,high:g,percent:y,format:w===void 0?void 0:t.series[w]?.number_format}},P=E(!1),H=B.some(e=>e.secondary)?E(!0):void 0,C=t.value_axis??{},p=t.secondary_axis??{},v=t.category_axis??{},R=C.number_format??(P.percent?"0%":P.format??"General"),z=p.number_format??(H?.percent===!0?"0%":H?.format??"General"),Z=(e,s,g,l)=>chartScale(e.low,e.high,g,l,{...s,...e.percent?{maximum_scale:s.maximum_scale??1}:{}}),q=x?o.right-o.left:o.bottom-o.top,at=x?n*5:n*2.4,Dt=Z(P,C,q,at),bt=C.visible===!1?[]:Dt.ticks.map(e=>formatValue(e,R)),wt=Math.max(0,...bt.map(e=>it(e,n))),Mt=H===void 0||p.visible===!1?0:Math.max(0,...Z(H,p,q,at).ticks.map(e=>it(formatValue(e,z),n))),ct=v.visible!==!1,_t=ct?Math.max(0,...t.categories.map(e=>it(e,n))):0,G=n*.5,$t=x?C.title:v.title,kt=x?v.title:C.title,Ht=Tt(o,$t,kt,n),lt=H===void 0?void 0:p.title,vt=n*1.5,Wt=lt!==void 0&&lt!==""?(o.right-=vt)+vt/2:void 0,u=x?{x:o.left+(ct?_t+G:0),y:o.top,width:0,height:o.bottom-o.top-(C.visible===!1?0:n*1.2+G)}:{x:o.left+(C.visible===!1?0:wt+G),y:o.top,width:0,height:o.bottom-o.top-(ct?n*1.2+G:0)};u.width=o.right-u.x-(x&&bt.length>0?wt/2:0)-(Mt>0?Mt+G:0),a.plot=u,Bt(a,u,Ht,$t,kt,n,i),Wt!==void 0&&lt!==void 0&&a.words.push({x:Wt,y:u.y+u.height/2,text:lt,size:n,anchor:"middle",color:i,rotate:-90});const ut=x?u.width:u.height,et=Z(P,C,ut,at),nt=H===void 0?void 0:Z(H,p,ut,at),Et=(e,s)=>(Math.min(e.max,Math.max(e.min,s))-e.min)/(e.max-e.min)*ut,mt=(e,s)=>x?u.x+Et(e,s):u.y+u.height-Et(e,s),St=e=>mt(et,e),At=B.every(e=>isArea(e.kind)),Ot=v.reverse_order===!0,Pt=x?!Ot:Ot,pt=(x?u.height:u.width)/U,Ct=At?(x?u.height:u.width)/Math.max(1,U-1):pt,gt=e=>{const s=At?e*Ct:(e+.5)*pt,g=x?u.height:u.width,l=Pt?g-s:s;return(x?u.y:u.x)+l},It=St(Math.max(et.min,Math.min(et.max,0)));for(const e of et.ticks){const s=St(e);(C.has_major_gridlines??!0)&&a.grid.push({d:x?`M${m(s)} ${m(u.y)} V${m(u.y+u.height)}`:`M${m(u.x)} ${m(s)} H${m(u.x+u.width)}`,color:C.gridline_color??{rgb:r.gridline},width:r.gridWidth}),C.visible!==!1&&a.words.push(x?{x:s,y:u.y+u.height+G+n*.6,text:formatValue(e,R),size:n,anchor:"middle",color:i}:{x:u.x-G,y:s,text:formatValue(e,R),size:n,anchor:"end",color:i})}if(nt&&p.visible!==!1)for(const e of nt.ticks)a.words.push({x:u.x+u.width+G,y:mt(nt,e),text:formatValue(e,z),size:n,anchor:"start",color:i});if(a.axes.push({d:x?`M${m(It)} ${m(u.y)} V${m(u.y+u.height)}`:`M${m(u.x)} ${m(It)} H${m(u.x+u.width)}`,color:v.line_color??{rgb:r.axisLine},width:r.gridWidth}),ct){const e=x?n*1.3:_t+n,s=Math.max(1,Math.ceil(e/Math.max(1,Ct)));t.categories.forEach((g,l)=>{if(l%s!==0)return;const y=gt(l);a.words.push(x?{x:u.x-G,y,text:g,size:n,anchor:"end",color:i}:{x:y,y:u.y+u.height+G+n*.6,text:g,size:n,anchor:"middle",color:i})})}for(const e of B){const s=e.secondary&&nt?nt:et,g=y=>mt(s,y),l={type:e.kind,...t.labels===void 0?{}:{labels:t.labels}};isBar(e.kind)?zt(e,g,l):Gt(e,g,l)}return a;function zt(e,s,g){const l=(t.gap_width??r.gapWidth)/100,y=e.stacked?1:e.series.length,j=e.stacked?1:(t.overlap??0)/100,d=pt/(Math.max(1,y-(y-1)*j)+l),w=d*(1-j),f=d+w*(y-1);t.categories.forEach((W,b)=>{const $=gt(b);let I=0,V=0;e.series.forEach((L,ot)=>{const J=t.series[L],F=M(e,L,b);if(F===null||!J)return;const ht=e.stacked?F>=0?I:V:0,st=ht+F;e.stacked&&(F>=0?I=st:V=st);const K=s(ht),Q=s(st),dt=(e.stacked?$-d/2:$-f/2+ot*w)+(x&&Pt&&!e.stacked?f-d-2*ot*w:0),Vt=x?{x:Math.min(K,Q),y:dt,width:Math.abs(Q-K),height:d}:{x:dt,y:Math.min(K,Q),width:d,height:Math.abs(Q-K)};if(a.boxes.push({...Vt,color:A(L,b),series:L,category:b}),!k)return;const Lt=yt(t,N[L]?.[b]??0,0,J,t.categories[b]??""),ft=labelPositionOf(g),X=O*.8,Rt=F>=0?1:-1,Ft=(rt,Y)=>ft==="ctr"?(rt+Y)/2:ft==="inBase"?rt+(Y>rt?X:-X):ft==="inEnd"?Y-(Y>rt?X:-X):Y+(Y>=rt?X:-X);x?D(Ft(K,Q),dt+d/2,Lt,ft==="outEnd"?Rt>0?"start":"end":"middle"):D(dt+d/2,Ft(K,Q),Lt,"middle")})})}function Gt(e,s,g){const l=t.categories.map(()=>0),y=e.series.map(d=>{const w=t.series[d],f=[],W=[];return t.categories.forEach((b,$)=>{const I=M(e,d,$);if(I===null||!w)return;const V=e.stacked?l[$]??0:0,L=V+I;e.stacked&&(l[$]=L);const ot=gt($),J=F=>x?[s(F),ot]:[ot,s(F)];if(f.push(J(L)),W.push(J(V)),isLine(e.kind)&&k){const F=labelPositionOf(g),[ht,st]=J(L);D(ht+(F==="r"?O:F==="l"?-O:0),st+(F==="t"?-O:F==="b"?O:0),yt(t,N[d]?.[$]??0,0,w,t.categories[$]??""),F==="r"?"start":F==="l"?"end":"middle")}}),{series:w,s:d,points:f,base:W}}),j=[];for(const{series:d,s:w,points:f,base:W}of y){if(!d)continue;const b=d.color??accentOf(w);if(isArea(e.kind)&&f.length>0)j.push({d:`${xt([...f,...[...W].reverse()])} Z`,color:b,width:0,fill:b,series:w});else if(f.length>0&&(a.lines.push({d:d.smooth===!0?Nt(f):xt(f),color:b,width:d.line_width??r.lineWidth,series:w}),hasMarkers(e.kind)))for(const[$,I]of f)a.dots.push({x:$,y:I,r:(d.marker_size??r.marker)/2,color:b})}a.shapes.push(...j.reverse())}}
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{brightened as u,hexOfRgb as h,lumOf as p,rgbOfHex as b}from"@allyhub/ooxml/brightness";import{transformed as d}from"@allyhub/ooxml/transform";export const DEFAULT_MAPPED={tx1:"dk1",bg1:"lt1",tx2:"dk2",bg2:"lt2"};export function mappedColors(t,r){if(!r||Object.keys(r).length===0)return t;const e={...t};for(const[o,n]of Object.entries(r))e[o]=t[n];return e}export const themeColor=(t,r=0)=>r===0?t:{theme_color:t,brightness:r},themeColorOf=t=>typeof t=="string"?t:"theme_color"in t?t.theme_color:void 0;const f=(t,r)=>r[t]??(t in DEFAULT_MAPPED?r[DEFAULT_MAPPED[t]]:"#000000"),x=new Set(["hue","hueOff"]);export const transformVal=t=>Math.round(t.value*(x.has(t.name)?6e4:1e5));export function colorRgba(t,r){const e=typeof t=="string"?f(t,r):"rgb"in t?t.rgb:"brightness"in t?u(f(t.theme_color,r),t.brightness):f(t.theme_color,r),o=typeof t=="string"||"brightness"in t?[]:t.transforms;let n={rgb:b(e),alpha:1};for(const a of o??[])n=d(n,a.name,transformVal(a));return n}export function colorRgb(t,r){if(typeof t=="string")return f(t,r);if("rgb"in t&&!t.transforms?.length)return t.rgb;if("brightness"in t)return u(f(t.theme_color,r),t.brightness);const{rgb:e,alpha:o}=colorRgba(t,r),n=h(e);return o>=1?n:`${n}${Math.round(o*255).toString(16).padStart(2,"0").toUpperCase()}`}const g=t=>Object.entries(t).map(([r,e])=>` ${r}="${String(e)}"`).join("");export function colorXml(t,r=""){const e=(s,i,m)=>m===""?`<${s}${g(i)}/>`:`<${s}${g(i)}>${m}</${s}>`,o=(s,i)=>`<a:${s} val="${String(i)}"/>`;if(typeof t=="string")return e("a:schemeClr",{val:t},r);const n=s=>(s??[]).map(i=>o(i.name,transformVal(i))).join("");if("rgb"in t)return e("a:srgbClr",{val:t.rgb.replace("#","").toUpperCase()},n(t.transforms)+r);if("transforms"in t)return e("a:schemeClr",{val:t.theme_color},n(t.transforms)+r);const{lumMod:a,lumOff:l}=p(t.brightness);return e("a:schemeClr",{val:t.theme_color},o("lumMod",a)+(l===void 0?"":o("lumOff",l))+r)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export*from"./chart.js";export*from"./chart-file.js";export*from"./chart-xml.js";export*from"./embedded.js";export*from"./svg.js";
2
+ export*from"./color.js";export*from"./chart.js";export*from"./chart-file.js";export*from"./chart-xml.js";export*from"./embedded.js";export*from"./svg.js";
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartDrawing as u,colorRgb as F}from"./chart.js";export const OFFICE_COLORS={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6",accent1:"#4472C4",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#5B9BD5",accent6:"#70AD47",hlink:"#0563C1",folHlink:"#954F72"};const w={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},i=n=>n.replace(/[&<>"]/gu,r=>w[r]??r),o=n=>String(Number(n.toFixed(3)));function k(n,r){const l=t=>{const c=t.fill===void 0?"none":r(t.fill),s=t.width>0?r(t.color):"none";return`<path d="${i(t.d)}" fill="${c}" stroke="${s}" stroke-width="${o(t.width)}" stroke-linejoin="round"/>`},e=[];for(const t of[...n.grid,...n.shapes])e.push(l(t));for(const t of[...n.boxes,...n.keys])e.push(`<rect x="${o(t.x)}" y="${o(t.y)}" width="${o(t.width)}" height="${o(t.height)}" fill="${r(t.color)}"/>`);for(const t of[...n.axes,...n.lines])e.push(l(t));for(const t of n.dots)e.push(`<circle cx="${o(t.x)}" cy="${o(t.y)}" r="${o(t.r)}" fill="${r(t.color)}"/>`);for(const t of n.words){const c=t.rotate===void 0?"":` transform="rotate(${o(t.rotate)} ${o(t.x)} ${o(t.y)})"`;e.push(`<text x="${o(t.x)}" y="${o(t.y)}" font-size="${o(t.size)}" text-anchor="${t.anchor}" dominant-baseline="central" fill="${r(t.color)}"${c}>${i(t.text)}</text>`)}return e.join("")}export function chartSvg(n,r,l,e={}){const t=e.pointsPerPixel??.75,c=r*t,s=l*t,f=e.colors??OFFICE_COLORS,h=p=>F(p,f),d=e.font??"Carlito, Calibri, Arial, sans-serif",$=e.paper??"#FFFFFF",a=e.edge??"#D9D9D9",x=e.label===void 0?"":` role="img" aria-label="${i(e.label)}"`,g=$==="none"&&a==="none"?"":`<rect x="0.375" y="0.375" width="${o(c-.75)}" height="${o(s-.75)}" fill="${i($)}" stroke="${i(a)}" stroke-width="${a==="none"?"0":"0.75"}"/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o(c)} ${o(s)}" width="${o(r)}" height="${o(l)}" font-family="${i(d)}"${x}>${g}${k(u(n,c,s),h)}</svg>`}
2
+ import{colorRgb as u}from"./color.js";import{chartDrawing as F}from"./chart.js";export const OFFICE_COLORS={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6",accent1:"#4472C4",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#5B9BD5",accent6:"#70AD47",hlink:"#0563C1",folHlink:"#954F72"};const w={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},i=n=>n.replace(/[&<>"]/gu,r=>w[r]??r),o=n=>String(Number(n.toFixed(3)));function k(n,r){const l=t=>{const c=t.fill===void 0?"none":r(t.fill),s=t.width>0?r(t.color):"none";return`<path d="${i(t.d)}" fill="${c}" stroke="${s}" stroke-width="${o(t.width)}" stroke-linejoin="round"/>`},e=[];for(const t of[...n.grid,...n.shapes])e.push(l(t));for(const t of[...n.boxes,...n.keys])e.push(`<rect x="${o(t.x)}" y="${o(t.y)}" width="${o(t.width)}" height="${o(t.height)}" fill="${r(t.color)}"/>`);for(const t of[...n.axes,...n.lines])e.push(l(t));for(const t of n.dots)e.push(`<circle cx="${o(t.x)}" cy="${o(t.y)}" r="${o(t.r)}" fill="${r(t.color)}"/>`);for(const t of n.words){const c=t.rotate===void 0?"":` transform="rotate(${o(t.rotate)} ${o(t.x)} ${o(t.y)})"`;e.push(`<text x="${o(t.x)}" y="${o(t.y)}" font-size="${o(t.size)}" text-anchor="${t.anchor}" dominant-baseline="central" fill="${r(t.color)}"${c}>${i(t.text)}</text>`)}return e.join("")}export function chartSvg(n,r,l,e={}){const t=e.pointsPerPixel??.75,c=r*t,s=l*t,f=e.colors??OFFICE_COLORS,h=g=>u(g,f),d=e.font??"Carlito, Calibri, Arial, sans-serif",$=e.paper??"#FFFFFF",a=e.edge??"#D9D9D9",p=e.label===void 0?"":` role="img" aria-label="${i(e.label)}"`,x=$==="none"&&a==="none"?"":`<rect x="0.375" y="0.375" width="${o(c-.75)}" height="${o(s-.75)}" fill="${i($)}" stroke="${i(a)}" stroke-width="${a==="none"?"0":"0.75"}"/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o(c)} ${o(s)}" width="${o(r)}" height="${o(l)}" font-family="${i(d)}"${p}>${x}${k(F(n,c,s),h)}</svg>`}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/chart",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/check",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -2,4 +2,4 @@
2
2
  import{randomUUID as X}from"node:crypto";import{mkdir as D,readdir as Y,readFile as E,rm as q,writeFile as A}from"node:fs/promises";import{basename as $,dirname as k,extname as S,join as j}from"node:path";import{EXIT as p,FileContentResponseSchema as Q,ToolCallSchema as _,callPath as V,fileContentPath as tt,parseAllyFilePath as I,toolCallsPath as et}from"@allyhub/protocol";import{genFileFor as U}from"@allyhub/formats";import{CloudError as d}from"./errors.js";import{genRecord as H,inputHash as nt,namedFile as it,readGen as at,toolWords as ot,writeGen as M,writeWords as rt}from"./records.js";import{withKnownUploads as st}from"./uploads.js";export const WAIT_SECONDS=900,POLL_SECONDS={least:1,most:60},RETRY_SECONDS={least:1,most:30},READ_SECONDS=120;const lt=new Set([408,429,500,502,503,504]),ut=t=>t instanceof d&&(t.code==="network"||t.status!==void 0&&lt.has(t.status));function ft(t){if(!/^https?:\/\//iu.test(t))return t;let e;try{e=new URL(t)}catch{return t}if(e.search==="")return t.replace(/^https?:\/\//iu,"");const i=/filename\*?=(?:UTF-8'')?"?([^";]+)/iu.exec(e.searchParams.get("response-content-disposition")??"")?.[1];return i===void 0?void 0:decodeURIComponent(i)}export function inputSlug(t){return Object.values(t).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>typeof e=="string").flatMap(e=>ft(e)??[]).join("-").replace(/[^\p{L}\p{N}._]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,40).replace(/-+$/u,"")}const L=t=>t.replace(/[^A-Za-z0-9_-]/gu,"_").slice(0,8),W=(t,e)=>{const i=S(t);return`${$(t,i)}-${L(e)}${i}`};async function ct(t,e,i,n,o){await D(t,{recursive:!0});const s=[e,inputSlug(i),L(n)].filter(Boolean).join("-"),r=j(t,`${s}.output.json`);return await A(r,`${JSON.stringify(o,null,2)}
3
3
  `),r}async function dt(t,e){const i=S(t)===""?`${t}.json`:t;return await D(k(i),{recursive:!0}),await A(i,`${JSON.stringify(e,null,2)}
4
4
  `),i}const T=t=>j(t.config.cacheDir,"jobs"),C=(t,e)=>j(T(t),`${e.replace(/[^A-Za-z0-9_-]/gu,"_")}.json`);async function wt(t,e,i){await D(k(C(t,e)),{recursive:!0}),await A(C(t,e),`${JSON.stringify(i,null,2)}
5
- `)}const P=(t,e)=>q(C(t,e),{force:!0});async function ht(t,e,i){const n=await Y(T(t)).catch(()=>[]);for(const o of n.filter(s=>s.endsWith(".json")).sort()){const s=await E(j(T(t),o),"utf8").then(r=>JSON.parse(r)).catch(()=>{});if(s?.jobId!==void 0&&s.file===e&&s.inputHash===i)return s.jobId}}async function pt(t,e){try{return JSON.parse(await E(C(t,e),"utf8"))}catch{throw new d("unknown-job",`No job ${e} was started on this computer.`,{exit:p.notFound,hint:"Call the tool again: that is a new call."})}}async function B(t,e,i,n,o){const{url:s}=Q.parse(await t.json(tt(e,"attachment"),{signal:v(o)}));let r;try{const f=await t.config.fetch(s,o?{signal:o}:{});if(!f.ok)throw new d("download-failed",`Downloading ${i} answered ${String(f.status)}.`,{exit:p.platform,status:f.status});r=Buffer.from(await f.arrayBuffer())}catch(f){throw f instanceof d||o?.aborted===!0?f:new d("network",`Downloading ${i} failed: ${f instanceof Error?f.message:String(f)}`,{exit:p.platform,cause:f})}const w="dir"in n?j(n.dir,$(n.name??i)):S(n.file)?n.file:`${n.file}${S(i)}`;return await D(k(w),{recursive:!0}),await A(w,r),w}const v=t=>t?AbortSignal.any([t,AbortSignal.timeout(READ_SECONDS*1e3)]):AbortSignal.timeout(READ_SECONDS*1e3),z=(t,e)=>new Promise((i,n)=>{const o=setTimeout(i,t*1e3);e?.addEventListener("abort",()=>{clearTimeout(o),n(e.reason instanceof Error?e.reason:new Error("Stopped."))},{once:!0})});export async function callTool(t,e,i,n){const o=n.file,s=await st(t,i,n.base),r=nt(e,s);let w=n.jobId,f=!1;if(o!==void 0&&w===void 0){w=await ht(t,o,r);const u=w===void 0?await it(o):void 0,l=u?await at(u):void 0;if(n.force===!0)f=l!==void 0;else{if(u&&!l)throw new d("file-exists",`${u} is there, without a record (${$(U(u))}) saying a tool call made it.`,{exit:p.conflict,hint:"Choose another --file, or pass --force to replace it."});if(u&&l){if(l.tool===e&&l.inputHash===r)return{tool:e,output:typeof l.output?.allyFilePath=="string"?l.output:JSON.parse(await E(u,"utf8")),file:u,gen:U(u),kept:{at:l.at}};throw new d("file-exists",`${u} was made by ${l.tool??"another tool"} from another input on ${l.at}.`,{exit:p.conflict,hint:"Choose another --file to keep it, or pass --force to make it again over it (charged again)."})}}}const m=Date.now()+(n.timeoutSeconds??WAIT_SECONDS)*1e3,g=n.signal;let a=w===void 0?_.parse(await t.json(et(e),{method:"POST",body:{input:i},idempotencyKey:X(),...g?{signal:g}:{}})):await G(t,w,m,n);a.status==="working"&&w===void 0&&await wt(t,a.id,{jobId:a.id,tool:e,input:{...i},inputHash:r,outDir:n.outDir,...o===void 0?{}:{file:o}});const K=()=>({tool:e,jobId:a.id,status:"running",elapsedSeconds:(Date.now()-Date.parse(a.createdAt))/1e3,...o===void 0?{}:{file:o}});for(;a.status==="working";){if(n.wait===!1||Date.now()>m)return K();n.onRunning?.(a),await z(Math.min(Math.max((a.pollAfterMs??0)/1e3,POLL_SECONDS.least),POLL_SECONDS.most),g),a=await G(t,a.id,m,n)}if(a.status==="failed")throw await P(t,a.id),new d(`tool-${(a.error?.kind??"failed").replaceAll("_","-")}`,a.error?.message??"The tool failed.",{exit:a.error?.kind==="input"?p.usage:p.platform,hint:a.error?.kind==="input"||a.error?.kind==="not_found"?"A failed call is not charged. Change the input and call again.":a.error?.kind==="unavailable"?"A failed call is not charged. Calling it again will not help until AllyHub sets it up.":"A failed call is not charged. Call it again; a supplier's failure often passes."});if(a.status!=="completed")throw new d("tool-state",`The call ${a.id} is ${a.status}, a state this version of allyhub does not know.`,{exit:p.platform,hint:"Update allyhub in the project (npm install allyhub@latest) and call it again."});const h=typeof a.output=="object"&&a.output!==null?a.output:{value:a.output},R=h.allyFilePath,y=typeof R=="string"?I(R):void 0,b=!y&&o!==void 0?await dt(o,h):void 0,c={tool:e,output:h,outputFile:b??await ct(n.outputDir??n.outDir,e,i,a.id,h),...a.credits===void 0?{}:{credits:a.credits}};if(y){const u=a.id,l=await J(u,()=>B(t,y.id,y.name,o!==void 0?{file:o}:{dir:n.outDir,name:W(y.name,u)},g),m,n);c.file=l,c.gen=await M(l,await H(l,{tool:e,input:s,output:h,credits:a.credits}));const x=ot(h),N=h.durationSeconds;x&&(c.words=await rt(l,x,typeof N=="number"&&N>=0?N:void 0)),f&&(c.replaced=!0)}else b!==void 0&&(c.file=b,c.gen=await M(b,await H(b,{tool:e,input:s,output:h,credits:a.credits})),f&&(c.replaced=!0));const O={},Z=c.file===void 0?n.outDir:k(c.file),F=c.file;for(const u of mt(h)){const l=I(u);if(!l)continue;const x=F===void 0?W(l.name,a.id):`${$(F,S(F))}.${$(l.name)}`;O[u]=await J(a.id,()=>B(t,l.id,l.name,{dir:Z,name:x},g),m,n)}return Object.keys(O).length>0&&(c.more=O),await P(t,a.id),c}function mt(t){const e=[],i=(n,o)=>{if(Array.isArray(n))for(const s of n)i(s,!1);else if(typeof n=="object"&&n!==null)for(const[s,r]of Object.entries(n))s==="allyFilePath"&&!o&&typeof r=="string"?e.push(r):i(r,!1)};return i(t,!0),e}async function G(t,e,i,n){try{return await J(e,async()=>_.parse(await t.json(V(e),{signal:v(n.signal)})),i,n)}catch(o){throw o instanceof d&&o.status===404&&await P(t,e),o}}async function J(t,e,i,n){const o=n.retrySeconds??RETRY_SECONDS;for(let s=o.least;;)try{return await e()}catch(r){if(!ut(r)||n.signal?.aborted===!0)throw r;if(Date.now()+s*1e3>i)throw new d(r.code,r.message,{exit:r.exit,...r.status===void 0?{}:{status:r.status},hint:`Call ${t} goes on at AllyHub, charged once when it works: --resume ${t} waits for it again (so does the same call to the same --file).`,cause:r});n.onRetry?.(t,r,s),await z(s,n.signal),s=Math.min(s*2,o.most)}}export async function resumeJob(t,e,i){const n=await pt(t,e);if(i.tool!==void 0&&i.tool!==n.tool)throw new d("wrong-job",`Job ${e} is ${n.tool}'s, not ${i.tool}'s.`,{exit:p.usage,hint:`Resume it with ${n.tool}.`});return await callTool(t,n.tool,n.input,{...i,outDir:n.outDir,...n.file===void 0?{}:{file:n.file},jobId:e})}
5
+ `)}const P=(t,e)=>q(C(t,e),{force:!0});async function ht(t,e,i){const n=await Y(T(t)).catch(()=>[]);for(const o of n.filter(s=>s.endsWith(".json")).sort()){const s=await E(j(T(t),o),"utf8").then(r=>JSON.parse(r)).catch(()=>{});if(s?.jobId!==void 0&&s.file===e&&s.inputHash===i)return s.jobId}}async function pt(t,e){try{return JSON.parse(await E(C(t,e),"utf8"))}catch{throw new d("unknown-job",`No job ${e} was started on this computer.`,{exit:p.notFound,hint:"Call the tool again: that is a new call."})}}async function B(t,e,i,n,o){const{url:s}=Q.parse(await t.json(tt(e,"attachment"),{signal:v(o)}));let r;try{const f=await t.config.fetch(s,o?{signal:o}:{});if(!f.ok)throw new d("download-failed",`Downloading ${i} answered ${String(f.status)}.`,{exit:p.platform,status:f.status});r=Buffer.from(await f.arrayBuffer())}catch(f){throw f instanceof d||o?.aborted===!0?f:new d("network",`Downloading ${i} failed: ${f instanceof Error?f.message:String(f)}`,{exit:p.platform,cause:f})}const w="dir"in n?j(n.dir,$(n.name??i)):S(n.file)?n.file:`${n.file}${S(i)}`;return await D(k(w),{recursive:!0}),await A(w,r),w}const v=t=>t?AbortSignal.any([t,AbortSignal.timeout(READ_SECONDS*1e3)]):AbortSignal.timeout(READ_SECONDS*1e3),z=(t,e)=>new Promise((i,n)=>{const o=setTimeout(i,t*1e3);e?.addEventListener("abort",()=>{clearTimeout(o),n(e.reason instanceof Error?e.reason:new Error("Stopped."))},{once:!0})});export async function callTool(t,e,i,n){const o=n.file,s=await st(t,i,n.base),r=nt(e,s);let w=n.jobId,f=!1;if(o!==void 0&&w===void 0){w=await ht(t,o,r);const u=w===void 0?await it(o):void 0,l=u?await at(u):void 0;if(n.force===!0)f=l!==void 0;else{if(u&&!l)throw new d("file-exists",`${u} is there, without a record (${$(U(u))}) saying a tool call made it.`,{exit:p.conflict,hint:"Choose another --file, or pass --force to replace it."});if(u&&l){if(l.tool===e&&l.inputHash===r)return{tool:e,output:typeof l.output?.allyFilePath=="string"?l.output:JSON.parse(await E(u,"utf8")),file:u,gen:U(u),kept:{at:l.at}};throw new d("file-exists",`${u} was made by ${l.tool??"another tool"} from another input on ${l.at}.`,{exit:p.conflict,hint:"Choose another --file to keep it, or pass --force to make it again over it (charged again)."})}}}const m=Date.now()+(n.timeoutSeconds??WAIT_SECONDS)*1e3,g=n.signal;let a=w===void 0?_.parse(await t.json(et(e),{method:"POST",body:{input:i},idempotencyKey:X(),...g?{signal:g}:{}})):await G(t,w,m,n);a.status==="working"&&w===void 0&&await wt(t,a.id,{jobId:a.id,tool:e,input:{...i},inputHash:r,outDir:n.outDir,...o===void 0?{}:{file:o}});const K=()=>({tool:e,jobId:a.id,status:"running",elapsedSeconds:(Date.now()-Date.parse(a.createdAt))/1e3,...o===void 0?{}:{file:o}});for(;a.status==="working";){if(n.wait===!1||Date.now()>m)return K();n.onRunning?.(a),await z(Math.min(Math.max((a.pollAfterMs??0)/1e3,POLL_SECONDS.least),POLL_SECONDS.most),g),a=await G(t,a.id,m,n)}if(a.status==="failed")throw await P(t,a.id),new d(`tool-${(a.error?.kind??"failed").replaceAll("_","-")}`,a.error?.message??"The tool failed.",{exit:a.error?.kind==="input"?p.usage:p.platform,hint:a.error?.kind==="input"||a.error?.kind==="not_found"?"A failed call is not charged. Change the input and call again.":a.error?.kind==="unavailable"?"A failed call is not charged. Calling it again will not help until AllyHub sets it up or fixes it.":"A failed call is not charged. Call it again; a supplier's failure often passes."});if(a.status!=="completed")throw new d("tool-state",`The call ${a.id} is ${a.status}, a state this version of allyhub does not know.`,{exit:p.platform,hint:"Update allyhub in the project (npm install allyhub@latest) and call it again."});const h=typeof a.output=="object"&&a.output!==null?a.output:{value:a.output},R=h.allyFilePath,y=typeof R=="string"?I(R):void 0,b=!y&&o!==void 0?await dt(o,h):void 0,c={tool:e,output:h,outputFile:b??await ct(n.outputDir??n.outDir,e,i,a.id,h),...a.credits===void 0?{}:{credits:a.credits}};if(y){const u=a.id,l=await J(u,()=>B(t,y.id,y.name,o!==void 0?{file:o}:{dir:n.outDir,name:W(y.name,u)},g),m,n);c.file=l,c.gen=await M(l,await H(l,{tool:e,input:s,output:h,credits:a.credits}));const x=ot(h),N=h.durationSeconds;x&&(c.words=await rt(l,x,typeof N=="number"&&N>=0?N:void 0)),f&&(c.replaced=!0)}else b!==void 0&&(c.file=b,c.gen=await M(b,await H(b,{tool:e,input:s,output:h,credits:a.credits})),f&&(c.replaced=!0));const O={},Z=c.file===void 0?n.outDir:k(c.file),F=c.file;for(const u of mt(h)){const l=I(u);if(!l)continue;const x=F===void 0?W(l.name,a.id):`${$(F,S(F))}.${$(l.name)}`;O[u]=await J(a.id,()=>B(t,l.id,l.name,{dir:Z,name:x},g),m,n)}return Object.keys(O).length>0&&(c.more=O),await P(t,a.id),c}function mt(t){const e=[],i=(n,o)=>{if(Array.isArray(n))for(const s of n)i(s,!1);else if(typeof n=="object"&&n!==null)for(const[s,r]of Object.entries(n))s==="allyFilePath"&&!o&&typeof r=="string"?e.push(r):i(r,!1)};return i(t,!0),e}async function G(t,e,i,n){try{return await J(e,async()=>_.parse(await t.json(V(e),{signal:v(n.signal)})),i,n)}catch(o){throw o instanceof d&&o.status===404&&await P(t,e),o}}async function J(t,e,i,n){const o=n.retrySeconds??RETRY_SECONDS;for(let s=o.least;;)try{return await e()}catch(r){if(!ut(r)||n.signal?.aborted===!0)throw r;if(Date.now()+s*1e3>i)throw new d(r.code,r.message,{exit:r.exit,...r.status===void 0?{}:{status:r.status},hint:`Call ${t} goes on at AllyHub, charged once when it works: --resume ${t} waits for it again (so does the same call to the same --file).`,cause:r});n.onRetry?.(t,r,s),await z(s,n.signal),s=Math.min(s*2,o.most)}}export async function resumeJob(t,e,i){const n=await pt(t,e);if(i.tool!==void 0&&i.tool!==n.tool)throw new d("wrong-job",`Job ${e} is ${n.tool}'s, not ${i.tool}'s.`,{exit:p.usage,hint:`Resume it with ${n.tool}.`});return await callTool(t,n.tool,n.input,{...i,outDir:n.outDir,...n.file===void 0?{}:{file:n.file},jobId:e})}
@@ -32,7 +32,7 @@ export declare function readGen(file: string): Promise<GenFile | undefined>;
32
32
  /**
33
33
  * The file a name stands for. A name with an extension is that file; one
34
34
  * without takes the result's extension, so before the call it is found by
35
- * its record (`<name>.<ext>.gen.json`), else any `<name>.<ext>`.
35
+ * its record (`<name>.<ext>.provenance`), else any `<name>.<ext>`.
36
36
  */
37
37
  export declare function namedFile(name: string): Promise<string | undefined>;
38
38
  /** The words of a voice tool's output (`words`: text, start and end in seconds); undefined when it returned none. */
@@ -2,7 +2,7 @@ import type { Cloud } from "./client.js";
2
2
  import { CloudError } from "./errors.js";
3
3
  /** The media types an upload is sent as, by extension: what media tools take. */
4
4
  export declare const UPLOAD_TYPES: Readonly<Record<string, string>>;
5
- /** A URL this computer got for a file is given again while it has this much time left. */
5
+ /** A URL this computer got for a file is given again while it has this much time left: an hour of the two AllyHub gives it, which keeps the file as long. */
6
6
  export declare const REUSE_LEFT_MS: number;
7
7
  /** How many files of a batch are sent at once. */
8
8
  export declare const UPLOAD_CONCURRENCY = 4;
@@ -1,3 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{createHash as b}from"node:crypto";import{chmod as U,mkdir as F,readFile as x,realpath as S,stat as P,writeFile as C}from"node:fs/promises";import{basename as D,dirname as N,extname as _,isAbsolute as L,join as R,relative as A,resolve as g}from"node:path";import{EXIT as $,FILES_PATH as M,FILE_MAX_BYTES as O,FileContentResponseSchema as z,FileCreatedSchema as v,UploadedFileSchema as X,fileContentPath as q,fileDonePath as H}from"@allyhub/protocol";import{CloudError as p}from"./errors.js";export const UPLOAD_TYPES={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",ogg:"audio/ogg",oga:"audio/ogg",flac:"audio/flac",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm"},REUSE_LEFT_MS=7200*1e3;const K=720*60*60*1e3;export const UPLOAD_CONCURRENCY=4;const Y=Object.keys(UPLOAD_TYPES).map(e=>`.${e}`).join(", ");async function j(e){const t=(await e.key())?.account??"",i=b("sha256").update(`${e.url}
2
+ import{createHash as b}from"node:crypto";import{chmod as U,mkdir as F,readFile as x,realpath as S,stat as P,writeFile as C}from"node:fs/promises";import{basename as D,dirname as N,extname as _,isAbsolute as L,join as R,relative as A,resolve as g}from"node:path";import{EXIT as $,FILES_PATH as M,FILE_MAX_BYTES as O,FileContentResponseSchema as z,FileCreatedSchema as v,UploadedFileSchema as X,fileContentPath as q,fileDonePath as H}from"@allyhub/protocol";import{CloudError as p}from"./errors.js";export const UPLOAD_TYPES={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",ogg:"audio/ogg",oga:"audio/ogg",flac:"audio/flac",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm"},REUSE_LEFT_MS=3600*1e3;const K=720*60*60*1e3;export const UPLOAD_CONCURRENCY=4;const Y=Object.keys(UPLOAD_TYPES).map(e=>`.${e}`).join(", ");async function j(e){const t=(await e.key())?.account??"",i=b("sha256").update(`${e.url}
3
3
  ${t}`).digest("hex").slice(0,12);return R(e.config.cacheDir,`uploads-${i}.json`)}async function E(e){try{const t=JSON.parse(await x(e,"utf8"));return{files:t.files??{},urls:t.urls??{}}}catch{return{files:{},urls:{}}}}async function J(e,t){const i=Date.now();for(const[c,o]of Object.entries(t.urls))i-Date.parse(o.expiresAt??o.at)>K&&Reflect.deleteProperty(t.urls,c);await F(N(e),{recursive:!0}),await C(e,JSON.stringify(t),{mode:384}),await U(e,384)}export function urlExpiry(e){let t;try{t=new URL(e).searchParams}catch{return}const i=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/u.exec(t.get("X-Amz-Date")??""),c=Number(t.get("X-Amz-Expires"));if(!i||!Number.isFinite(c)||c<=0)return;const[o,r,l,a,n,u]=i.slice(1).map(Number);return new Date(Date.UTC(o,r-1,l,a,n,u)+c*1e3).toISOString()}const T=async e=>await S(g(e)).catch(()=>g(e)),y=(e,t)=>{const i=A(e,t);return i.startsWith("..")||L(i)},w=(e,t)=>new p("bad-input",e,{exit:$.usage,...t===void 0?{}:{hint:t}});async function W(e,t){const i=g(t.base,e),c=()=>w(`${e} is not inside ${String(t.inside)}.`,"Upload a file of the project.");if(t.inside!==void 0&&y(g(t.inside),i))throw c();const o=await P(i).catch(()=>{});if(!o?.isFile())throw w(`There is no file ${i}.`,"A relative path is read from the folder it is run in.");const r=await S(i);if(t.inside!==void 0&&y(await T(t.inside),r))throw c();const l=_(r).slice(1).toLowerCase(),a=UPLOAD_TYPES[l];if(a===void 0)throw w(`${e} is a${l?` .${l}`:"n unnamed"} file; an upload is one of ${Y}.`,"Convert it first, for example with ffmpeg.");if(o.size>O)throw w(`${e} is ${String(o.size)} bytes; AllyHub keeps files of at most ${String(O)}.`,"Make it smaller first, for example with ffmpeg.");const n=await x(r);return{given:e,path:r,type:a,sha256:b("sha256").update(n).digest("hex"),bytes:n}}async function B(e,t,i){const c=new Array(e.length);let o=0;const r=async()=>{for(;o<e.length;){const l=o++;c[l]=await i(e[l])}};return await Promise.all(Array.from({length:Math.min(t,e.length)},r)),c}async function k(e,t,i,c){const o=i.files[t.sha256];if(o&&!c)return{fileId:o.fileId,known:!0};const r={name:D(t.path),size:t.bytes.length,sha256:t.sha256,contentType:t.type},l=v.parse(await e.json(M,{method:"POST",body:r}));if(l.upload!==null){const n=await e.config.fetch(l.upload.url,{method:"PUT",headers:l.upload.headers,body:new Uint8Array(t.bytes),signal:AbortSignal.timeout(3e5)});if(!n.ok)throw new p("upload-failed",`Storage refused ${t.given}: ${String(n.status)} ${(await n.text()).slice(0,200)}`,{exit:$.platform})}const a=X.parse(await e.json(H(l.id),{method:"POST"}));return i.files[t.sha256]={fileId:a.id,path:t.path,bytes:t.bytes.length},{fileId:a.id,known:!1}}const I=async(e,t)=>z.parse(await e.json(q(t,"inline"))).url;export async function uploadFiles(e,t,i){if(t.length===0)throw w("Name at least one file to upload.");const c=[];for(const a of t)c.push(await W(a,{base:i.base,...i.inside===void 0?{}:{inside:i.inside}}));await e.requireKey();const o=await j(e),r=await E(o),l=await B(c,i.concurrency??UPLOAD_CONCURRENCY,async a=>{const n=(s,d,f,m,h)=>({ok:!0,file:a.given,path:a.path,fileId:s,url:d,...f===void 0?{}:{expiresAt:f},sha256:a.sha256,bytes:a.bytes.length,contentType:a.type,known:m,reused:h}),u=r.files[a.sha256];if(u){const s=Date.now(),d=Object.entries(r.urls).find(([,f])=>f.sha256===a.sha256&&f.expiresAt!==void 0&&Date.parse(f.expiresAt)-s>=REUSE_LEFT_MS);if(d)return u.path=a.path,n(u.fileId,d[0],d[1].expiresAt,!0,!0)}try{let s=await k(e,a,r,!1),d;try{d=await I(e,s.fileId)}catch(h){if(!s.known||!(h instanceof p)||h.status!==404)throw h;s=await k(e,a,r,!0),d=await I(e,s.fileId)}const f=urlExpiry(d);r.urls[d]={sha256:a.sha256,...f===void 0?{}:{expiresAt:f},at:new Date().toISOString()};const m=r.files[a.sha256];return m&&(m.path=a.path),n(s.fileId,d,f,s.known,!1)}catch(s){if(!(s instanceof p)||s.code==="not-signed-in")throw s;return{ok:!1,file:a.given,error:new p(s.code==="api-error"?"upload-failed":s.code,`Uploading ${a.given} failed. ${s.message}`,{exit:s.exit,...s.hint?{hint:s.hint}:{}})}}});return await J(o,r),l}export async function withKnownUploads(e,t,i){const c=await E(await j(e)),o=await T(i),r=n=>y(o,n)?n:A(o,n),l=new Map;for(const[n,u]of Object.entries(c.urls)){const s=c.files[u.sha256];s&&l.set(n,{uploaded:r(s.path),sha256:u.sha256,bytes:s.bytes})}const a=n=>typeof n=="string"?l.get(n)??n:Array.isArray(n)?n.map(a):typeof n=="object"&&n!==null?Object.fromEntries(Object.entries(n).map(([u,s])=>[u,a(s)])):n;return a(t)}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/cloud",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/components",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",