allyhub 0.15.2 → 0.17.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.
- package/CHANGELOG.md +24 -0
- package/dist/commands/add.js +1 -1
- package/dist/commands/cloud-tools.js +1 -1
- package/dist/commands/dev.js +6 -2
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/frames/doc.js +1 -1
- package/dist/commands/inspect/common.js +3 -3
- package/dist/commands/inspect/facts.js +2 -2
- package/dist/commands/inspect/index.js +1 -1
- package/dist/commands/inspect/layout.js +1 -1
- package/dist/commands/inspect/uses.js +3 -0
- package/dist/commands/mail.js +6 -6
- package/dist/commands/render.js +1 -1
- package/dist/main.js +8 -8
- package/dist/node_modules/@allyhub/3d-extension/dist/cli/scenery-text.js +2 -2
- package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/audio/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/place.js +2 -0
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/browser/package.json +1 -1
- package/dist/node_modules/@allyhub/build/dist/content.d.ts +7 -0
- package/dist/node_modules/@allyhub/build/dist/file-check.d.ts +2 -2
- package/dist/node_modules/@allyhub/build/dist/imports.d.ts +17 -0
- package/dist/node_modules/@allyhub/build/dist/imports.js +2 -0
- package/dist/node_modules/@allyhub/build/dist/index.d.ts +3 -2
- package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/inspect-view.d.ts +1 -1
- package/dist/node_modules/@allyhub/build/dist/inspect-view.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +19 -3
- package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
- package/dist/node_modules/@allyhub/build/dist/uses.d.ts +27 -6
- package/dist/node_modules/@allyhub/build/dist/uses.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/work.d.ts +9 -1
- package/dist/node_modules/@allyhub/build/dist/work.js +3 -3
- package/dist/node_modules/@allyhub/build/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/skills/allyhub/references/canvas.md +2 -2
- package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/check/package.json +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/client.d.ts +12 -3
- package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/index.d.ts +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/cloud/package.json +1 -1
- package/dist/node_modules/@allyhub/components/package.json +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/deletion.js +2 -0
- package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/inputs.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/writer.js +3 -2
- package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/doc/dist/docx.js +4 -4
- package/dist/node_modules/@allyhub/doc/dist/html.js +40 -40
- package/dist/node_modules/@allyhub/doc/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/markdown.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/parse.js +4 -4
- package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
- package/dist/node_modules/@allyhub/doc/dist/write.js +26 -26
- package/dist/node_modules/@allyhub/doc/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/build.js +2 -2
- package/dist/node_modules/@allyhub/doc-extension/dist/inspect.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
- package/dist/node_modules/@allyhub/export/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/export/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
- package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +15 -3
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +70 -11
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +15 -4
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +4 -0
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/i18n/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/i18n/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/dist/stage.js +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/image-extension/dist/workspace.js +1 -1
- package/dist/node_modules/@allyhub/image-extension/package.json +2 -2
- package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +3 -3
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
- package/dist/node_modules/@allyhub/image-render/package.json +1 -1
- package/dist/node_modules/@allyhub/image-runtime/dist/load.js +2 -2
- package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/jobs/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-extension/package.json +3 -1
- package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +1 -1
- package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/package.json +1 -1
- package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/model/package.json +1 -1
- package/dist/node_modules/@allyhub/office-extension/LICENSE +241 -0
- package/dist/node_modules/@allyhub/office-extension/markup/csv/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/csv/data/leads.csv +5 -0
- package/dist/node_modules/@allyhub/office-extension/markup/csv/markup.json +19 -0
- package/dist/node_modules/@allyhub/office-extension/markup/document/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/document/briefs/launch.docx +0 -0
- package/dist/node_modules/@allyhub/office-extension/markup/document/markup.json +11 -0
- package/dist/node_modules/@allyhub/office-extension/markup/presentation/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/presentation/decks/pitch.pptx +0 -0
- package/dist/node_modules/@allyhub/office-extension/markup/presentation/markup.json +11 -0
- package/dist/node_modules/@allyhub/office-extension/markup/workbook/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/office-extension/markup/workbook/data/plans.xlsx +0 -0
- package/dist/node_modules/@allyhub/office-extension/markup/workbook/markup.json +10 -0
- package/dist/node_modules/@allyhub/office-extension/package.json +124 -0
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +9 -0
- package/dist/node_modules/@allyhub/piece/dist/page/runtimes.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +53 -10
- package/dist/node_modules/@allyhub/piece/dist/source.js +1 -1
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/project/dist/digest.js +1 -1
- package/dist/node_modules/@allyhub/project/dist/part-keys.js +1 -1
- package/dist/node_modules/@allyhub/project/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +10 -11
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +7 -0
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/blobs.d.ts +9 -0
- package/dist/node_modules/@allyhub/protocol/dist/blobs.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.d.ts +77 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud-computer.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +39 -9
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +15 -15
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +441 -5
- package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -2
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +4 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +5 -5
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +45 -0
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/paywall.d.ts +134 -0
- package/dist/node_modules/@allyhub/protocol/dist/paywall.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +3 -3
- package/dist/node_modules/@allyhub/protocol/dist/purposes.d.ts +47 -0
- package/dist/node_modules/@allyhub/protocol/dist/purposes.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +52 -5
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.d.ts +34 -0
- package/dist/node_modules/@allyhub/protocol/dist/sidebar-deletion.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/sites.d.ts +1 -0
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +21 -52
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.d.ts +264 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-server.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.d.ts +18 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-tool-calls.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.d.ts +97 -0
- package/dist/node_modules/@allyhub/protocol/dist/studio-window-requests.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +3 -2
- package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +26 -20
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/turns.d.ts +71 -0
- package/dist/node_modules/@allyhub/protocol/dist/turns.js +2 -0
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/package.json +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/embed.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/film.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/piece.js +2 -2
- package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
- package/dist/node_modules/@allyhub/runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scaffold/dist/index.js +4 -4
- package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/dynamic.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/logical.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/cli/sheet.js +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/package.json +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/components.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/build.js +2 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/cli/slides.js +2 -2
- package/dist/node_modules/@allyhub/slides-extension/dist/deck-pptx.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/evaluate.js +2 -2
- package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/package.json +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/dist/audio-icon.js +1 -1
- package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
- package/dist/node_modules/@allyhub/slides-pptx/package.json +5 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/component.js +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
- package/dist/node_modules/@allyhub/slides-runtime/dist/item.js +2 -0
- package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
- package/dist/node_modules/@allyhub/slides-runtime/dist/slide-css.js +20 -0
- package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/stage/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.html +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.js +2 -2
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +20 -20
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/telemetry/dist/doc.js +17 -2
- package/dist/node_modules/@allyhub/telemetry/dist/level.js +2 -2
- package/dist/node_modules/@allyhub/telemetry/dist/levels.js +2 -0
- package/dist/node_modules/@allyhub/telemetry/dist/scrub.js +1 -1
- package/dist/node_modules/@allyhub/telemetry/package.json +5 -1
- package/dist/node_modules/@allyhub/text-extension/markup/markup.json +1 -1
- package/dist/node_modules/@allyhub/text-extension/markup-file/allyhub.yaml +2 -0
- package/dist/node_modules/@allyhub/text-extension/markup-file/archive/assets.zip +0 -0
- package/dist/node_modules/@allyhub/text-extension/markup-file/markup.json +10 -0
- package/dist/node_modules/@allyhub/text-extension/package.json +35 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-extension/dist/build.js +1 -1
- package/dist/node_modules/@allyhub/video-extension/dist/cli/reference-text.js +3 -3
- package/dist/node_modules/@allyhub/video-extension/package.json +2 -2
- package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/website/package.json +1 -1
- package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-extension/package.json +3 -1
- package/dist/node_modules/@allyhub/x-extension/skills/allyhub/references/x.md +1 -1
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/package.json +13 -12
- package/dist/project.js +1 -1
- package/dist/telemetry.js +3 -3
- package/dist/text/console-text.js +2 -2
- package/dist/works.js +1 -1
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-9z0ZEYUq.js → abnfDiagram-WEYOIA3C-CHNpVSPv.js} +1 -1
- package/editor-web/assets/{architecture-WOLXFQ4H-ELMO_PA6.js → architecture-WOLXFQ4H-gPsJqQwV.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-C0yuCWU3.js → architectureDiagram-ZHVYKT53-CEIDcC6r.js} +1 -1
- package/editor-web/assets/arrow-down-B8VUPCGi.js +1 -0
- package/editor-web/assets/arrow-up-Ds4juY8X.js +1 -0
- package/editor-web/assets/article-BHTjq0_Y.js +3 -0
- package/editor-web/assets/article-DfELjJ2o.js +7 -0
- package/editor-web/assets/{audio-lines-1s1eRs4Q.js → audio-lines-PZj77e7t.js} +1 -1
- package/editor-web/assets/bar-button-J9vbfzTx.js +1 -0
- package/editor-web/assets/{blockDiagram-RJAE7QA3-vi6JOg4o.js → blockDiagram-RJAE7QA3-CUzEGVet.js} +4 -4
- package/editor-web/assets/browser-C1XuTMlp.js +1 -0
- package/editor-web/assets/{c4Diagram-XDPPPE54-Agf_H8uS.js → c4Diagram-XDPPPE54-CB94NR9s.js} +1 -1
- package/editor-web/assets/calc-worker-BdHh5LXM.js +45 -0
- package/editor-web/assets/channel-DCDCx5Es.js +1 -0
- package/editor-web/assets/chart-amT4lgX3.js +2 -0
- package/editor-web/assets/chart-file-CfbWK9l1.js +1 -0
- package/editor-web/assets/{chart-no-axes-column-CJmeYOSo.js → chart-no-axes-column-Be0lFcGF.js} +1 -1
- package/editor-web/assets/{chunk-2E7WHVMD-XalaZaha.js → chunk-2E7WHVMD-DFYo_Boi.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-DUlRZkCS.js → chunk-4EMNKR2T-CLLjmweX.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-DTa7whGr.js → chunk-55XCU76K-CkwQ_3m1.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-85zCPzj0.js → chunk-7S6XSTFO-V-AvHpAB.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-CWBseIyh.js → chunk-AQDTSKZB-PjHyYpb8.js} +1 -1
- package/editor-web/assets/chunk-DSNLSHJZ-QaczBS3J.js +127 -0
- package/editor-web/assets/{chunk-HAGFOTED-DFWda2Rk.js → chunk-HAGFOTED-aLaQB5Xu.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-aXibFitC.js → chunk-HNE4Q36P-De3ftDQR.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-CtJUuFdN.js → chunk-NQOKRVIF-CrhVQyvP.js} +17 -17
- package/editor-web/assets/{chunk-UHW7PFBP-B6QKSKWE.js → chunk-UHW7PFBP-BFmZ5ZLn.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-CF6Al55P.js → chunk-VQ5W62QI-CzppUHLA.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-w2TKLkyw.js → chunk-WQQL4CDK-BrAU7V6v.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-DVGOATM3.js → chunk-YZO67HFG-BSiF71qj.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-Cq7MMjDP.js → chunk-ZAUX2LTX-BJc4r5b1.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-GMW_lBh4.js → chunk-ZCHMQSOR-CkGTuehB.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-C7AK5Bkj.js → classDiagram-v2-4MYWR3UA-Byxc7J88.js} +7 -7
- package/editor-web/assets/code-CD-CbJG9.js +1 -0
- package/editor-web/assets/collaborator-BU4qU7O3.js +1 -0
- package/editor-web/assets/{copy-DvOiv9Ra.js → copy-CuJSs0nI.js} +1 -1
- package/editor-web/assets/{createLucideIcon-REX213UO.js → createLucideIcon-lm_6n8YT.js} +1 -1
- package/editor-web/assets/csv-Bwre9FdI.js +11 -0
- package/editor-web/assets/{cynefin-EF2NZ3EQ-ZnDieQsN.js → cynefin-EF2NZ3EQ-BSxkVbdf.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-BrukKIBF.js → cynefinDiagram-WF24UDRP-IkCgARNs.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-DfO0S2p_.js → dagre-NK4GIZVX-9PgeH6nY.js} +1 -1
- package/editor-web/assets/deck-tTzKONci.js +1 -0
- package/editor-web/assets/{diagram-CBK3MWTC-D43RLesi.js → diagram-CBK3MWTC-DRzeg3Ds.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-bA1B1QQG.js → diagram-I5XIIV2D-B_zeKMN6.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-DAdXBD2K.js → diagram-ODIL2UCW-FFm0O8SN.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-C_KyEaws.js → diagram-PFBEJUXE-DrtCT8OA.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-oXTtENF7.js → diagram-RJA3I4VV-DtxJ3V0q.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-Czupe6mO.js → diagram-TYUNFSNR-DmxF_8H_.js} +16 -16
- package/editor-web/assets/dist-BEpzsYn_.js +6 -0
- package/editor-web/assets/dist-BUD4ywMB.js +18 -0
- package/editor-web/assets/{dist-BrGYx10E.js → dist-Bd8IxQPP.js} +1 -1
- package/editor-web/assets/dist-C21CkR7Z.js +531 -0
- package/editor-web/assets/dist-C56mWAec.js +5 -0
- package/editor-web/assets/dist-CAb3W9_P.js +43 -0
- package/editor-web/assets/dist-CEknsRDd.js +24 -0
- package/editor-web/assets/dist-CbZAznNW.js +19 -0
- package/editor-web/assets/{dist-2lNSE-G_.js → dist-D3C6FyrO.js} +1 -1
- package/editor-web/assets/dist-DDzjbKIg.js +4 -0
- package/editor-web/assets/dist-DaEbElXI.js +3 -0
- package/editor-web/assets/dist-Dr3o4vee.js +1 -0
- package/editor-web/assets/{dist-BtRMClDw.js → dist-DruvDNQe.js} +1 -1
- package/editor-web/assets/dist-JLyDtl9X.js +1 -0
- package/editor-web/assets/dist-PBbWAsrV.js +17 -0
- package/editor-web/assets/dist-ZZlQa66J.js +1 -0
- package/editor-web/assets/dist-bQKpw3Zz.js +16 -0
- package/editor-web/assets/dist-d4dayaWE.js +17 -0
- package/editor-web/assets/docx-draw-9Q_fArBC.js +4 -0
- package/editor-web/assets/docx-preview-pcg9ioe3.js +21 -0
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-BOhNZmtp.js → ebnfDiagram-V4P3TTPT-DSX1Aoty.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-DoZH3OoE.js → elk-QONTBCTQ-C7gy9q56.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-Bv0KDJi4.js → erDiagram-KYQIGQAA-CKx_HoY4.js} +2 -2
- package/editor-web/assets/esm-BZb5QMQf.js +21 -0
- package/editor-web/assets/{eventmodeling-K75KTNOO-C-_xzqfj.js → eventmodeling-K75KTNOO-DL4HvSrd.js} +1 -1
- package/editor-web/assets/{file-exclamation-point-C_fX4fpI.js → file-exclamation-point-_L3ElCJ5.js} +1 -1
- package/editor-web/assets/file-question-mark-DlIjUK37.js +1 -0
- package/editor-web/assets/flowDiagram-IUGLLWBU-BUnRtJ8q.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-CAuJlaZX.js → ganttDiagram-R7GPNTJY-N-AP4slN.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-Dx2xLi5C.js → gitGraph-VSP46ZUC-BKRGJKWm.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-DHsk_UOT.js → gitGraphDiagram-PDYL7XHY-ClwL7w2_.js} +1 -1
- package/editor-web/assets/{group-pebHQTdP.js → group-BdrTp7gi.js} +1 -1
- package/editor-web/assets/hint-rlht0uxG.js +1 -0
- package/editor-web/assets/index-BedbINE5.css +2 -0
- package/editor-web/assets/index-DG2nHq4D.js +28 -0
- package/editor-web/assets/{info-OHQRW6UA-CnKQHx5m.js → info-OHQRW6UA-DpcY8t23.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-ibAVFw_2.js → infoDiagram-MVDRKAX5-ChtmtWni.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-C1OCHt3y.js → ishikawaDiagram-HPEHV2GE-BZNTuG_F.js} +1 -1
- package/editor-web/assets/iso-ahTwmFwH.js +56 -0
- package/editor-web/assets/{italic-CtlNOXN9.js → italic-zw4_eUNF.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-BDdqMOM1.js → journeyDiagram-BOSHW7O7-C3uVmZbL.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-CSAS_zGn.js → kanban-definition-FNSA4HC5-puEhftGG.js} +4 -4
- package/editor-web/assets/{link-CW2KxKT_.js → link-DopSU3aa.js} +1 -1
- package/editor-web/assets/{mermaid-parser.core-DTLyYXbn.js → mermaid-parser.core-Bw8re-WE.js} +3 -3
- package/editor-web/assets/mermaid.core-Cc2GIqBr.js +44 -0
- package/editor-web/assets/{mindmap-definition-6OY57UG3-DSWHcglH.js → mindmap-definition-6OY57UG3-C6MUl_S_.js} +3 -3
- package/editor-web/assets/minus-CbPnUIOy.js +1 -0
- package/editor-web/assets/{packet-JDAUHWVQ-_k1BF29s.js → packet-JDAUHWVQ-C75RnvC5.js} +1 -1
- package/editor-web/assets/{pegDiagram-ECIUJNBX-B22YyWAa.js → pegDiagram-ECIUJNBX-ChjmsdV4.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-CSwV32hj.js → pie-XZMESJXO-BaKxJQpj.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-rSFNeWnq.js → pieDiagram-GNMPY74T-CT2ez8pr.js} +1 -1
- package/editor-web/assets/progress-CwKcXARv.js +6 -0
- package/editor-web/assets/props-form-D5oKHfpk.js +1 -0
- package/editor-web/assets/purify.es-B9ve_eFf.js +3 -0
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-Xrntfg4j.js → quadrantDiagram-D57K4MC3-BJItlTfk.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-Dwq5qiNw.js → radar-ABXABTNO-DnLzBlTo.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-sIUGWcZh.js → railroad-I3PHUGI6-D5hj6Yv3.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-1rWlT9BX.js → railroad-abnf-LNEFI6M7-DUZlZoPu.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-DWdkzEHc.js → railroad-ebnf-DWYD2UWJ-CDyyDC6d.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-CME0JBbV.js → railroad-peg-JR7BVNR7-CC3ImNnT.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-Ch4BpP22.js → railroadDiagram-Y72NRBL7-Bjw-8Se5.js} +1 -1
- package/editor-web/assets/{react-Bk7NnOLX.js → react-Edyoga_4.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-CgE-x3wN.js → requirementDiagram-EQYSW5RA-CDFnuEIO.js} +1 -1
- package/editor-web/assets/row-C_svyL8o.js +1 -0
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-DBf4G6n3.js → sankeyDiagram-SY24JHO5-CQPVLY1w.js} +1 -1
- package/editor-web/assets/schemas-moE_A7Nj.js +1 -0
- package/editor-web/assets/{scissors-BURkYWPv.js → scissors-B_xOiUhd.js} +1 -1
- package/editor-web/assets/{search-jKDvFIEU.js → search-Ba2BbT6T.js} +1 -1
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-Bz07CoUS.js → sequenceDiagram-BLEHNHQU-BQzuLmBX.js} +1 -1
- package/editor-web/assets/{session-CUCSWPTE.js → session-s1I85rox.js} +1 -1
- package/editor-web/assets/{sigma-CY2Chbro.js → sigma-DSUsJhMn.js} +1 -1
- package/editor-web/assets/slides-oQ_C0SVJ.js +1 -0
- package/editor-web/assets/snapshots-BPJKywuN.js +1 -0
- package/editor-web/assets/{sound-DUCxe9eC.js → sound-bTlco_K3.js} +1 -1
- package/editor-web/assets/split-7CVjIkSU.js +3 -0
- package/editor-web/assets/square-arrow-out-up-right-DF5dvsSp.js +1 -0
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-DuqAmDPP.js → stateDiagram-v2-A6IESKWZ-DOuageUf.js} +7 -7
- package/editor-web/assets/{sticky-note-C5qUDHhC.js → sticky-note-BdkIu5_D.js} +1 -1
- package/editor-web/assets/{strikethrough-DP-7tMz0.js → strikethrough-BwXWi4zg.js} +1 -1
- package/editor-web/assets/surface-DtCjIlrq.js +1 -0
- package/editor-web/assets/svg-CWIBMIQ9.js +1 -0
- package/editor-web/assets/swatch-DhztHwPU.js +1 -0
- package/editor-web/assets/{swimlanes-B3ENRKFQ-C7sOL6rB.js → swimlanes-B3ENRKFQ-CXKkok7X.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-C3Car2M0.js +8 -0
- package/editor-web/assets/switch-8MU4Nfxe.js +1 -0
- package/editor-web/assets/{syntax-DSsHrzWF.js → syntax-CU_WPKxt.js} +1 -1
- package/editor-web/assets/{table-CTjNpE4W.js → table-DRbddzx0.js} +1 -1
- package/editor-web/assets/tabs-CiF1N-pL.js +1 -0
- package/editor-web/assets/tag-CIfWT8B_.js +1 -0
- package/editor-web/assets/text-align-start-Cic2-TLh.js +1 -0
- package/editor-web/assets/textarea-D7TnPwv1.js +1 -0
- package/editor-web/assets/{timeline-definition-JXYKGLGB-CaLYz9mc.js → timeline-definition-JXYKGLGB-DgAjAeZp.js} +3 -3
- package/editor-web/assets/{treeView-D4JQ5SDB-D1P1Kyxc.js → treeView-D4JQ5SDB-C0Xvnhck.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-2YaFL53t.js → treemap-SAJKECNS-aXfKAeSX.js} +1 -1
- package/editor-web/assets/{undo-2-DUGGyBdX.js → undo-2-C47jrRp5.js} +1 -1
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-uYdbUhUS.js → usecaseDiagram-WPOLBNNX-CvUlBa-L.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-DHepmX4t.js → vennDiagram-Q3Y3IDCW-qMJ1iCxs.js} +3 -3
- package/editor-web/assets/{video-Xl-OaXRc.js → video-DQrjo1TI.js} +1 -1
- package/editor-web/assets/{wardley-7MLQ67FV-Dx0MOPV1.js → wardley-7MLQ67FV-DEdnH0by.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-BX8ElwDW.js → wardleyDiagram-IVAIDKWA-Bt-B2hQ5.js} +1 -1
- package/editor-web/assets/{whole-word-6DliXke2.js → whole-word-D3ZAtnkw.js} +1 -1
- package/editor-web/assets/{words-B2FXYyeZ.js → words-0Ww2RyT4.js} +1 -1
- package/editor-web/assets/{words-DFIhHhHF.js → words-XlXG79Ur.js} +1 -1
- package/editor-web/assets/workbook-FSSUiIp9.js +45 -0
- package/editor-web/assets/x-DlhyIKuu.js +41 -0
- package/editor-web/assets/{xychartDiagram-4URNHDU4-DoWQRJUS.js → xychartDiagram-4URNHDU4-DV4bSzTb.js} +1 -1
- package/editor-web/assets/{zoom-in-C4lxmIDE.js → zoom-in-PgsC94hP.js} +1 -1
- package/editor-web/index.html +8 -6
- package/package.json +2 -2
- package/editor-web/assets/arrow-down-DzZjFrBL.js +0 -1
- package/editor-web/assets/arrow-up-hdmh9LVD.js +0 -1
- package/editor-web/assets/article-DHFgHYjv.js +0 -3
- package/editor-web/assets/article-Dt9id9Y9.js +0 -7
- package/editor-web/assets/button-BVQH7zxz.js +0 -41
- package/editor-web/assets/calc-worker-jImBXoeb.js +0 -45
- package/editor-web/assets/channel-Dkg198L0.js +0 -1
- package/editor-web/assets/chart-BC3kUUDD.js +0 -2
- package/editor-web/assets/chunk-DSNLSHJZ-BFnyvrWg.js +0 -129
- package/editor-web/assets/code-BID_OoRp.js +0 -1
- package/editor-web/assets/collaborator-2qfw-8OJ.js +0 -1
- package/editor-web/assets/dist-5HNrQ9AU.js +0 -45
- package/editor-web/assets/dist-BPecIPz6.js +0 -530
- package/editor-web/assets/dist-BXJKASX4.js +0 -24
- package/editor-web/assets/dist-BeDRTqQ8.js +0 -38
- package/editor-web/assets/dist-BlL-4sl3.js +0 -43
- package/editor-web/assets/dist-BuqBg8k8.js +0 -1
- package/editor-web/assets/dist-BwW08gSh.js +0 -1
- package/editor-web/assets/dist-C30Thvb3.js +0 -1
- package/editor-web/assets/dist-Cj5AmpVb.js +0 -5
- package/editor-web/assets/dist-CjjnDOa8.js +0 -3
- package/editor-web/assets/dist-D7ur8721.js +0 -6
- package/editor-web/assets/dist-DOHhp09C.js +0 -4
- package/editor-web/assets/dist-LhFEYZza.js +0 -16
- package/editor-web/assets/flowDiagram-IUGLLWBU-C7ZmHJZW.js +0 -1
- package/editor-web/assets/hint-mQB8slJ2.js +0 -1
- package/editor-web/assets/index-BGAXezRR.js +0 -28
- package/editor-web/assets/index-Br4a-QEv.css +0 -2
- package/editor-web/assets/mermaid.core-B8478wZ1.js +0 -44
- package/editor-web/assets/minus-D1tgAHbU.js +0 -1
- package/editor-web/assets/progress-udl4pNsP.js +0 -6
- package/editor-web/assets/props-form-B6mYjTgZ.js +0 -1
- package/editor-web/assets/row-dgHEAE7h.js +0 -1
- package/editor-web/assets/schemas-B89k2jEC.js +0 -1
- package/editor-web/assets/slides-BdaWgL_N.js +0 -1
- package/editor-web/assets/snapshots-CTS2iez5.js +0 -56
- package/editor-web/assets/split-mDSkdQkd.js +0 -3
- package/editor-web/assets/surface-D9qJjJQL.js +0 -1
- package/editor-web/assets/svg-nJtFNJ-7.js +0 -1
- package/editor-web/assets/swatch-S8YuBYyj.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CQ2aWYP-.js +0 -8
- package/editor-web/assets/switch-D5kPl2jO.js +0 -1
- package/editor-web/assets/tabs-C0AHyuE5.js +0 -1
- package/editor-web/assets/textarea-mzr9Kfuf.js +0 -1
|
@@ -4,5 +4,5 @@ import{existsSync as ie}from"node:fs";import{mkdir as ce,readFile as V,stat as h
|
|
|
4
4
|
`)}}});function Ie(e,s){return te(e,s.trim()).flatMap(n=>n.rows.flat().map(t=>({...t,address:t.address===""?s.trim():`${n.sheet}!${t.address}`})))}async function Re(e,s,n,t){const o=await j(e,s,n),a=G(o.workbook);if(a.length===0)throw new g("not-found",`${o.file} has no scenarios.`,{exit:y.notFound,hint:`${v(o.file)}'s scenarios: { high: { growth: 0.2 } } names some.`});const r=new Set(a.flatMap(d=>Object.keys(o.workbook.file.scenarios?.[d]??{}).map(p=>p.toLowerCase()))),i=t?.split(",")??[...o.workbook.names.values()].map(d=>d.name).filter(d=>!r.has(d.toLowerCase()));if(i.length===0)throw new g("bad-input","Say what to compare: names, cells or ranges, apart by commas.",{exit:y.usage});const c=["Base case",...a],l=[o,...await Promise.all(a.map(d=>j(e,s,n,d)))],$=i.map(d=>l.map(p=>Ie(p.calc,d))).flatMap(d=>(d[0]??[]).map((p,m)=>({output:p.address,values:Object.fromEntries(c.map((x,b)=>[x,d[b]?.[m]?.value??null])),shown:Object.fromEntries(c.map((x,b)=>[x,d[b]?.[m]?.shown??""]))})));return{value:{file:o.file,scenarios:c,outputs:$},text:[...P([["",...c],...$.map(d=>[d.output,...c.map(p=>d.shown[p]??"")])]),..._(o.problems)].join(`
|
|
5
5
|
`)}}const Le=(e,s)=>`${e.sheet===s?"":`${e.sheet.name}!`}${q({top:e.top,left:e.left,bottom:Math.min(e.bottom,Math.max(e.top,e.sheet.lastRow)),right:e.right})}`;export const sheetTrace=k({input:h.strictObject({sheet:h.string().describe("The sheet, by its file or its id in allyhub.yaml"),cell:h.string().describe("The cell: Summary!B5, or B5 on the first sheet"),all:h.boolean().default(!1).describe(`Every cell that reads it, not the first ${String(TRACE_CELLS)}`),dir:E}),positional:["sheet","cell"],output:h.looseObject({}),examples:["allyhub sheet trace finance/budget 'Summary!B1'"],run:async(e,s)=>{const n=await O(s.cwd,e.dir),{file:t,workbook:o,calc:a}=await j(n,s,e.sheet),{sheet:r,address:i}=ee(o,e.cell),c=Ee(i);if(!c)throw new g("bad-input",`${e.cell} is not a cell.`,{exit:y.usage});const{row:l,col:u}=c,$=a.value(r,l,u),d=r.lookAt(l,u).format,p=r.at(l,u),m=o.sourceOf(r,l,u),x=p instanceof T?a.precedents(p).map(f=>{const le=f.single?S(a.value(f.sheet,f.top,f.left),f.sheet.lookAt(f.top,f.left).format):`${w(f.cols)} × ${w(Math.max(0,Math.min(f.bottom,f.sheet.lastRow)-f.top+1))}`,H=f.single?f.sheet.at(f.top,f.left):void 0,J=H instanceof T?H.text:void 0;return{address:Le(f,r),shown:le,...J===void 0?{}:{formula:J}}}):[],b=a.readers(r,l,u),B=e.all?b:b.slice(0,TRACE_CELLS),U=B.map(f=>({address:`${f.sheet===r?"":`${f.sheet.name}!`}${M(f)}`,shown:S(f.value,f.sheet.lookAt(f.row,f.col).format),formula:f.text})),W=f=>[` ${f.address}`,f.shown,f.formula].filter(Boolean).join(" "),z=m===void 0?void 0:m.file===I||m.file===""?t:F.join(ue(t),m.file),C=m?.line===void 0?z:`${z??""}:${String(m.line)}`;return{value:{file:t,cell:`${r.name}!${M(c)}`,value:D($,d),shown:S($,d),...$ instanceof be?{error:$.code}:{},...p instanceof T?{formula:p.text}:{},...C===void 0?{}:{written:C},reads:x,readBy:U,readers:b.length},text:[`${r.name}!${M(c)} ${S($,d)}`,...p instanceof T?[` ${p.text}`]:[],...C===void 0?[]:[` written in ${C}`],...x.length>0?["reads:",...x.map(W)]:[],...b.length>0?[`read by ${w(b.length)}:`,...U.map(W),...b.length>B.length?[` … ${w(b.length-B.length)} more (--all)`]:[]]:["read by nothing"]].join(`
|
|
6
6
|
`)}}}),sheetCapabilities=k({input:h.strictObject({}),output:h.looseObject({}),examples:["allyhub sheet capabilities"],run:()=>Promise.resolve({value:{...Z},text:JSON.stringify(Z,null,2)})});const se=new Set([".xlsx",".xlsm",".xltx",".xltm"]);export const DIFF_ROWS=50;const ne={value:"Value changed, formula the same",formula:"Formula changed, value the same",both:"Formula and value changed",added:"Added",removed:"Removed"},Be=e=>{const s=(e.now??e.was)?.cell??"",n=e.table===void 0?s:`${e.table}[${e.key??s}]`,t=e.column===void 0?"":` ${e.column}`;return`${e.sheet}!${n}${t}`},Ne=e=>{const s=e.was?.formula??"",n=e.now?.formula??"";return[Be(e),e.was?.shown??"","→",e.now?.shown??"",e.kind==="value"?n:e.kind==="formula"||e.kind==="both"?`${s} → ${n}`:n===""?s:n]};function De(e,s){const n=[];for(const t of e.sheets)n.push(`Sheet ${t.name} ${t.added?"added":"removed"}`);for(const t of e.tables){const o=[t.rowsAdded.length>0?`rows added: ${t.rowsAdded.slice(0,20).join(", ")}`:"",t.rowsRemoved.length>0?`rows removed: ${t.rowsRemoved.slice(0,20).join(", ")}`:"",t.columnsAdded.length>0?`columns added: ${t.columnsAdded.join(", ")}`:"",t.columnsRemoved.length>0?`columns removed: ${t.columnsRemoved.join(", ")}`:""].filter(Boolean);n.push(`Table ${t.name}, rows lined up by ${t.by==="key"?t.key??"its key":"their place"}${o.length>0?`: ${o.join("; ")}`:""}`)}for(const t of e.names)n.push(`Name ${t.name}: ${t.was??"(none)"} → ${t.now??"(none)"}`);for(const t of e.parts)n.push(`${t.sheet??"Workbook"} ${t.part}${t.key===void 0?"":` ${t.key}`}: ${t.was??"(none)"} → ${t.now??"(none)"}`);for(const t of e.charts)n.push(`Charts of ${t} changed`);for(const t of Object.keys(ne)){const o=e.cells.filter(r=>r.kind===t);if(o.length===0)continue;const a=s?o:o.slice(0,DIFF_ROWS);n.push("",`${ne[t]}: ${w(o.length)}`,...P(a.map(Ne)).map(r=>` ${r}`),...o.length>a.length?[` … ${w(o.length-a.length)} more (--all)`]:[])}return n}async function oe(e,s,n){const t=X(s.cwd,n);if(se.has(A(t).toLowerCase())){const r=await V(t).catch(()=>{throw new g("not-found",`There is no file ${t}.`,{exit:y.notFound})}),i=K(new Uint8Array(r),{name:v(t,A(t))}),{calc:c}=ve({text:i.files.get(I)??"",read:l=>i.files.get(l)});if(!c)throw new g("bad-file",`${n} cannot be read.`,{exit:y.usage});return{calc:c,file:n}}const{calc:o,file:a}=await j(e,s,n);return{calc:o,file:a}}export const sheetDiff=k({input:h.strictObject({was:h.string().describe("The version before: a sheet (its file or its id) or an .xlsx"),now:h.string().describe("The version after: a sheet (its file or its id) or an .xlsx"),tolerance:h.number().min(0).default(pe.tolerance).describe("How far apart two numbers may be, as a share of the larger, and be the same"),all:h.boolean().default(!1).describe(`Every cell, not the first ${String(DIFF_ROWS)} of each kind`),dir:E}),positional:["was","now"],output:h.looseObject({}),examples:["allyhub sheet diff finance/budget finance/budget-v2","allyhub sheet diff finance/budget ~/Downloads/budget.xlsx --json"],run:async(e,s)=>{const n=await O(s.cwd,e.dir),t=await oe(n,s,e.was),o=await oe(n,s,e.now),a=ke(t.calc,o.calc,{tolerance:e.tolerance}),{counts:r}=a,i=a.cells.length;return{value:{was:t.file,now:o.file,...a},text:[`${t.file} → ${o.file}: ${w(i)} cell${i===1?"":"s"} differ (${w(r.value)} value, ${w(r.formula)} formula, ${w(r.both)} both, ${w(r.added)} added, ${w(r.removed)} removed); ${w(a.names.length+a.parts.length)} other thing${a.names.length+a.parts.length===1?"":"s"} differ${a.names.length+a.parts.length===1?"s":""}`,...De(a,e.all)].join(`
|
|
7
|
-
`)}}});const _e=h.string().transform(e=>e.replace(/^\/+/gu,"")).refine(e=>e.endsWith(".yaml")&&!e.split("/").some(s=>s===""||s==="."||s===".."),{message:"a .yaml file from the project's root, such as research/leads.yaml"});export const IMPORT_DIFFERENCES=50;const ae=e=>e===null?"empty":typeof e=="string"?JSON.stringify(e):String(e);function Pe(e,s){const{formulas:n,same:t,uncached:o,moving:a,differences:r}=e,i=[`${w(t)} of ${w(n)} formulas compute what the file holds`,...a>0?[`${w(a)} read the clock or a random number, not compared`]:[],...o>0?[`${w(o)} have no value in the file`]:[]],c=s?r:r.slice(0,IMPORT_DIFFERENCES);return[`Computed here against the file: ${i.join("; ")}.`,...r.length>0?[`${w(r.length)} differ${r.length===1?"s":""}:`,...c.map(l=>` ${l.sheet}!${l.cell} ${l.formula} file ${ae(l.file)} here ${ae(l.engine)}`),...r.length>c.length?[` … ${w(r.length-c.length)} more (--all)`]:[]]:[]]}async function re(e,s,n){const t=F.dirname(s),o=[...n].map(([a,r])=>({path:a===I?s:t==="."?a:`${t}/${a}`,content:r}));for(const{path:a}of o)if(await he(N(e,a)).catch(()=>{}))throw new g("place-taken",`${a} is already there.`,{exit:y.conflict,hint:"Name another file with --to."});for(const{path:a,content:r}of o){const i=N(e,a);await ce(de(i),{recursive:!0}),await fe(i,r,{flag:"wx"})}return o.map(a=>a.path)}export const sheetImport=k({input:h.strictObject({file:h.string().describe("The file to make a sheet of: .xlsx, .xlsm, .csv or .tsv"),to:_e.optional().describe("The sheet's file, from the project's root (default <the file's name>.yaml); its tables' CSV files go beside it, under names no file there has"),maxUnzipped:h.number().positive().default(me.bytes/1024/1024).describe("MB the file may unzip to
|
|
7
|
+
`)}}});const _e=h.string().transform(e=>e.replace(/^\/+/gu,"")).refine(e=>e.endsWith(".yaml")&&!e.split("/").some(s=>s===""||s==="."||s===".."),{message:"a .yaml file from the project's root, such as research/leads.yaml"});export const IMPORT_DIFFERENCES=50;const ae=e=>e===null?"empty":typeof e=="string"?JSON.stringify(e):String(e);function Pe(e,s){const{formulas:n,same:t,uncached:o,moving:a,differences:r}=e,i=[`${w(t)} of ${w(n)} formulas compute what the file holds`,...a>0?[`${w(a)} read the clock or a random number, not compared`]:[],...o>0?[`${w(o)} have no value in the file`]:[]],c=s?r:r.slice(0,IMPORT_DIFFERENCES);return[`Computed here against the file: ${i.join("; ")}.`,...r.length>0?[`${w(r.length)} differ${r.length===1?"s":""}:`,...c.map(l=>` ${l.sheet}!${l.cell} ${l.formula} file ${ae(l.file)} here ${ae(l.engine)}`),...r.length>c.length?[` … ${w(r.length-c.length)} more (--all)`]:[]]:[]]}async function re(e,s,n){const t=F.dirname(s),o=[...n].map(([a,r])=>({path:a===I?s:t==="."?a:`${t}/${a}`,content:r}));for(const{path:a}of o)if(await he(N(e,a)).catch(()=>{}))throw new g("place-taken",`${a} is already there.`,{exit:y.conflict,hint:"Name another file with --to."});for(const{path:a,content:r}of o){const i=N(e,a);await ce(de(i),{recursive:!0}),await fe(i,r,{flag:"wx"})}return o.map(a=>a.path)}export const sheetImport=k({input:h.strictObject({file:h.string().describe("The file to make a sheet of: .xlsx, .xlsm, .csv or .tsv"),to:_e.optional().describe("The sheet's file, from the project's root (default <the file's name>.yaml); its tables' CSV files go beside it, under names no file there has"),maxUnzipped:h.number().positive().default(me.bytes/1024/1024).describe("The most MB the file may unzip to"),tolerance:h.number().min(0).default(Te).describe("How far apart a computed number and the file's may be, as a share of the larger, and count as the same; 0 lists every difference"),all:h.boolean().default(!1).describe(`Every difference, not the first ${String(IMPORT_DIFFERENCES)}`),dir:E}),positional:["file"],output:h.looseObject({}),examples:["allyhub sheet import ~/Downloads/forecast.xlsx --to finance/forecast.yaml","allyhub sheet import ~/Downloads/leads.csv --to research/leads.yaml"],run:async(e,s)=>{const n=await O(s.cwd,e.dir),t=X(s.cwd,e.file),o=A(t).toLowerCase(),a=se.has(o);if(o===".xls"||o===".xlsb")throw new g("bad-file",`${v(t)} is Excel's binary format.`,{exit:y.usage,hint:"Save it as .xlsx, then import that."});if(!a&&o!==".csv"&&o!==".tsv")throw new g("bad-file",`${v(t)} is not an .xlsx, .xlsm, .csv or .tsv file.`,{exit:y.usage});const r=await V(t).catch(()=>{throw new g("not-found",`There is no file ${t}.`,{exit:y.notFound})}),i=v(t,A(t)),c=e.to??`${i}.yaml`,l=F.basename(c,".yaml"),u=we(c),$=m=>ie(N(n,F.dirname(c),m));if(a){let m;try{m=K(new Uint8Array(r),{name:l,tolerance:e.tolerance,zip:{bytes:e.maxUnzipped*1024*1024},taken:$})}catch(b){throw new g("bad-file",`${v(t)} cannot be read: ${b.message}`,{exit:y.usage})}const x=await re(n,c,new Map([...m.files,...m.assets]));return await Y(n,{kind:"sheet",file:c}),{value:{id:u,files:x,sheets:m.sheets,tables:m.tables,lost:m.lost,problems:m.problems,compared:m.compared},text:[`Made ${x.join(", ")}; listed in allyhub.yaml as ${u}.`,...m.lost.length>0?["Not carried over:",...m.lost.map(b=>` ${b}`)]:["Nothing was left out."],...Pe(m.compared,e.all),...m.problems.length>0?["Problems:",...m.problems.map(b=>` ${b.file}${b.line===void 0?"":`:${String(b.line)}`}: ${b.message}`)]:[],`allyhub sheet calc ${u}, then allyhub frames ${u}, to see it.`].join(`
|
|
8
8
|
`)}}let d;try{d=Se(l,r.toString("utf8"),o===".tsv"?" ":",",$)}catch(m){throw new g("bad-file",m.message,{exit:y.usage})}const p=await re(n,c,new Map([[I,d.text],[d.path,d.csv]]));return await Y(n,{kind:"sheet",file:c}),{value:{id:u,files:p,rows:d.rows,lost:[]},text:`Made ${p.join(" and ")}, listed in allyhub.yaml as ${u}: ${w(d.rows)} row${d.rows===1?"":"s"}`}}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allyhub/sheet-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./code": {
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"inspectViews": [
|
|
161
161
|
{
|
|
162
162
|
"name": "sheet",
|
|
163
|
-
"summary": "A workbook's facts, for you to judge
|
|
163
|
+
"summary": "A workbook's facts, for you to judge: error values by cell, numbers written into formulas, a cell unlike its neighbours, what nothing reads, exceptions in calculated columns, values under a validation that breaks them, the rounds iterative calculation ran",
|
|
164
164
|
"module": "./dist/inspect.js"
|
|
165
165
|
}
|
|
166
166
|
],
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
"name": "sheet import",
|
|
200
|
-
"summary": "Makes a sheet of an Excel, CSV or TSV file: its sheets, tables, formulas, names and looks as a sheet file and CSV files, listed in allyhub.yaml,
|
|
200
|
+
"summary": "Makes a sheet of an Excel, CSV or TSV file: its sheets, tables, formulas, names and looks as a sheet file and CSV files, listed in allyhub.yaml, with each difference from the file listed and each formula computed here and compared with the value the file holds; writes new files alone (--to names another place)",
|
|
201
201
|
"work": "sheets",
|
|
202
202
|
"module": "./dist/cli/index.js"
|
|
203
203
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{pathSteps as E}from"./path.js";import{EMU_PER_PT as h}from"./units.js";export const ANIMATION_DURATIONS={appear:0,fade:.5,"fly-in":.5,"float-in":1,split:.5,wipe:.5,zoom:.5,disappear:0,"fade-out":.5,"fly-out":.5,"float-out":1,"split-out":.5,"wipe-out":.5,"zoom-out":.5,pulse:.5,"grow-shrink":2,spin:2,transparency:.5,path:2};const I=new Set(["disappear","fade-out","fly-out","float-out","split-out","wipe-out","zoom-out"]),A=new Set(["appear","fade","fly-in","float-in","split","wipe","zoom"]);export const isExit=t=>I.has(t),isEntrance=t=>A.has(t),TRANSITION_DURATIONS={fade:.7,push:1,wipe:1,split:1.5,reveal:2,cut:0,cover:1,uncover:1,zoom:1,morph:2};const x=["from-right","from-top","from-left","from-bottom"],w=[...x,"from-top-right","from-bottom-right","from-top-left","from-bottom-left"];export const TRANSITION_OPTIONS={fade:{directions:[],throughBlack:!0},push:{directions:x,throughBlack:!1},wipe:{directions:x,throughBlack:!1},split:{directions:["vertical-out","vertical-in","horizontal-out","horizontal-in"],throughBlack:!1},reveal:{directions:["from-right","from-left"],throughBlack:!0},cut:{directions:[],throughBlack:!0},cover:{directions:w,throughBlack:!1},uncover:{directions:w,throughBlack:!1},zoom:{directions:["in","out","rotate"],throughBlack:!1},morph:{directions:[],throughBlack:!1}};const S=["vertical-out","vertical-in","horizontal-out","horizontal-in"];export const EFFECT_OPTIONS={appear:{directions:[]},fade:{directions:[]},"fly-in":{directions:["from-bottom","from-top","from-left","from-right"]},"float-in":{directions:["up","down"]},split:{directions:S},wipe:{directions:["from-bottom","from-top","from-left","from-right"]},zoom:{directions:[]},disappear:{directions:[]},"fade-out":{directions:[]},"fly-out":{directions:["from-bottom","from-top","from-left","from-right"]},"float-out":{directions:["up","down"]},"split-out":{directions:S},"wipe-out":{directions:["from-bottom","from-top","from-left","from-right"]},"zoom-out":{directions:[]},pulse:{directions:[]},"grow-shrink":{directions:["both","horizontal","vertical"],amounts:[1.1,.5,1.5,4],amount:1.5},spin:{directions:["clockwise","counterclockwise"],amounts:[90,180,360,720],amount:360},transparency:{directions:[],amounts:[.25,.5,.75,1],amount:.5},path:{directions:[]}},effectTakes=(t,e)=>EFFECT_OPTIONS[t].directions.includes(e),transitionTakes=(t,e)=>TRANSITION_OPTIONS[t].directions.includes(e),resolveTransition=t=>{const e=TRANSITION_OPTIONS[t.type];return{type:t.type,direction:t.direction!==void 0&&e.directions.includes(t.direction)?t.direction:e.directions[0]??"from-right",throughBlack:t.through_black===!0&&e.throughBlack,duration:t.duration??TRANSITION_DURATIONS[t.type]}};const B={"from-left":{x:-1,y:0},"from-right":{x:1,y:0},"from-top":{x:0,y:-1},"from-bottom":{x:0,y:1},"from-top-right":{x:1,y:-1},"from-bottom-right":{x:1,y:1},"from-top-left":{x:-1,y:-1},"from-bottom-left":{x:-1,y:1}},m=t=>B[t]??{x:0,y:1},l={opacity:1,x:0,y:0,scale:1,rotate:0};export function barn(t,e){const n=t==="vertical-out"||t==="vertical-in";if(t==="vertical-out"||t==="horizontal-out"){const s=(1-e)/2;return{clip:n?{top:0,right:s,bottom:0,left:s}:{top:s,right:0,bottom:s,left:0}}}const f=e/2,i=1-f,r=[[0,0],[f,0],[f,1],[i,1],[i,0],[1,0],[1,1],[0,1]];return{polygon:n?r:r.map(([s,c])=>[c,s])}}export function transitionAt(t,e){const o={incoming:{...l},outgoing:{...l},outgoingOver:!1,black:!1},f=e<.5;switch(t.type){case"fade":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:f?1-2*e:0},incoming:{...l,opacity:f?0:2*e-1}}:{...o,incoming:{...l,opacity:e}};case"cut":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:0},incoming:{...l,opacity:e>=1?1:0}}:o;case"push":{const i=m(t.direction);return{...o,incoming:{...l,x:i.x*(1-e),y:i.y*(1-e)},outgoing:{...l,x:-i.x*e,y:-i.y*e}}}case"cover":{const i=m(t.direction);return{...o,incoming:{...l,x:i.x*(1-e),y:i.y*(1-e)}}}case"uncover":{const i=m(t.direction);return{...o,outgoingOver:!0,outgoing:{...l,x:-i.x*e,y:-i.y*e}}}case"reveal":{const i=m(t.direction);return t.throughBlack?{...o,outgoingOver:!0,black:!0,outgoing:{...l,x:-i.x*Math.min(1,2*e),opacity:f?1-2*e:0},incoming:{...l,opacity:f?0:2*e-1}}:{...o,outgoingOver:!0,outgoing:{...l,x:-i.x*e,opacity:1-e}}}case"wipe":return{...o,incoming:{...l,clip:O(t.direction,1-e)}};case"split":return{...o,incoming:{...l,...barn(t.direction,e)}};case"zoom":return t.direction==="out"?{...o,outgoingOver:!0,outgoing:{...l,scale:1-e,opacity:1-e}}:{...o,incoming:{...l,scale:e,opacity:t.direction==="rotate"?1:e,rotate:t.direction==="rotate"?-720*(1-e):0}};case"morph":return o}}export function morphFrame(t,e,n){const o=n*n*(3-2*n),f=(i,r)=>i+(r-i)*o;return{left:f(t.left,e.left),top:f(t.top,e.top),width:f(t.width,e.width),height:f(t.height,e.height)}}export const TEXT_DELAY=.1;const T=new Intl.Segmenter(void 0,{granularity:"grapheme"});export function textUnits(t,e){return e==="word"?t.split(/\s+/u).filter(n=>n!==""):[...T.segment(t)].map(n=>n.segment).filter(n=>!/^\s+$/u.test(n))}export function unitsAcross(t,e){const n=[];let o=[];return t.forEach((f,i)=>{if(e==="letter"){for(const r of T.segment(f))/^\s+$/u.test(r.segment)||n.push([{piece:i,start:r.index,end:r.index+r.segment.length}]);return}for(const r of f.matchAll(/\s+|\S+/gu))/^\s/u.test(r[0])?(o.length>0&&n.push(o),o=[]):o.push({piece:i,start:r.index,end:r.index+r[0].length})}),o.length>0&&n.push(o),n}export const roundOf=t=>t.iterate?t.duration*(1+Math.max(0,t.iterate.units-1)*t.iterate.delay):t.duration,spanOf=t=>roundOf(t)*(typeof t.repeat=="number"?t.repeat:1);export function resolveAnimation(t,e=1){const n=t.path===void 0?void 0:E(t.path);if(t.path!==void 0&&!n||t.effect==="path"&&!n)return;const o=EFFECT_OPTIONS[t.effect],f=o.amount===void 0?void 0:t.amount??o.amount;return{shape:t.shape,...t.paragraph===void 0?{}:{paragraph:t.paragraph},effect:t.effect,direction:t.direction!==void 0&&o.directions.includes(t.direction)?t.direction:o.directions[0]??"from-bottom",...f===void 0?{}:{amount:t.effect==="transparency"?Math.min(1,f):f},start:t.start??"on-click",duration:t.duration??ANIMATION_DURATIONS[t.effect],delay:t.delay??0,...t.animate_text===void 0?{}:{iterate:{by:t.animate_text,delay:t.text_delay??TEXT_DELAY,units:Math.max(1,e)}},...t.repeat===void 0||t.repeat===1?{}:{repeat:t.repeat},...t.rewind?{rewind:!0}:{},...n?{path:n.map(i=>i.op==="close"?i:i.op!=="curve"?{...i,x:i.x*h,y:i.y*h}:{op:"curve",x1:i.x1*h,y1:i.y1*h,x2:i.x2*h,y2:i.y2*h,x:i.x*h,y:i.y*h})}:{}}}export function slideClock(t,e,n,o=0,f=0){const i=new Set(t.filter(a=>isEntrance(a.effect)).map(a=>a.shape)),r=[...e].filter(([a])=>!i.has(a)).map(([,a])=>a);let s=f+Math.max(0,...r);if(t.length===0)return{timed:[],rests:[Math.max(n,f,...r)]};const c=[],d=[];let u=0,p=f;for(const a of t){a.start==="on-click"?(c.push(s),u++,s+=o,p=s):a.start==="after-previous"&&(p=s);const g=p+a.delay,v=g+spanOf(a);d.push({...a,step:u,from:g,to:v}),s=Math.max(s,v);const b=e.get(a.shape);b!==void 0&&isEntrance(a.effect)&&(s=Math.max(s,g+b))}c.push(s);for(const a of d)a.repeat==="until-next-click"?a.stop=c[a.step]??s:a.repeat==="until-end-of-slide"&&(a.stop=s);return{timed:d,rests:c}}export const SLIDE_SECONDS=4,componentSeconds=t=>t.dur??SLIDE_SECONDS,DECK_FPS=30;const M=t=>Math.ceil(t*DECK_FPS-1e-6)/DECK_FPS;export const inTransition=(t,e)=>t<e-1e-6;export function clockOf(t,e){const n=e?0:t.transition?.duration??0,o=slideClock(t.animations,new Map(t.shapes.flatMap(s=>s.component?[[s.name,componentSeconds(s.component)-1/DECK_FPS]]:[])),SLIDE_SECONDS-1/DECK_FPS,1/DECK_FPS,n),f=o.rests.map(M),i=s=>o.timed.find(c=>c.shape===s&&isEntrance(c.effect))?.from??n,r=new Map;for(const s of t.shapes){if(s.media?.playback?.start!=="on-click")continue;const c=f.at(-1)??n;r.set(s.name,c),f.push(M(c+1/DECK_FPS))}return{timed:o.timed,rests:f,lead:n,comesOn:i,goesOff:s=>o.timed.find(c=>c.shape===s&&isExit(c.effect))?.to,playsAt:s=>r.get(s)??i(s)}}const k=1e-6,y={hidden:!1,opacity:1,x:0,y:0,scale:1,sx:1,sy:1,rotate:0},N=t=>1-(1-t)*(1-t);function _(t){const e=[];let n={x:0,y:0};for(const o of t){if(o.op==="close")continue;if(o.op!=="curve"){n={x:o.x,y:o.y},e.push(n);continue}const f=n;for(let i=1;i<=24;i++){const r=i/24,s=1-r,c=(d,u,p,a)=>s*s*s*d+3*s*s*r*u+3*s*r*r*p+r*r*r*a;e.push({x:c(f.x,o.x1,o.x2,o.x),y:c(f.y,o.y1,o.y2,o.y)})}n={x:o.x,y:o.y}}return e}export function pathPoint(t,e){const n=_(t),[o]=n;if(!o)return{x:0,y:0};let f=0;for(let r=1;r<n.length;r++){const[s,c]=[n[r-1]??o,n[r]??o];f+=Math.hypot(c.x-s.x,c.y-s.y)}let i=f*e;for(let r=1;r<n.length;r++){const[s,c]=[n[r-1]??o,n[r]??o],d=Math.hypot(c.x-s.x,c.y-s.y);if(i<=d&&d>0){const u=i/d;return{x:s.x+(c.x-s.x)*u,y:s.y+(c.y-s.y)*u}}i-=d}return n.at(-1)??o}function P(t,e,n){return t==="from-left"?{x:-(e.left+e.width),y:0}:t==="from-right"?{x:n.width-e.left,y:0}:t==="from-top"?{x:0,y:-(e.top+e.height)}:{x:0,y:n.height-e.top}}function O(t,e){const n={top:0,right:0,bottom:0,left:0};return t==="from-left"?n.right=e:t==="from-right"?n.left=e:t==="from-top"?n.bottom=e:n.top=e,n}const D={"vertical-out":"vertical-in","vertical-in":"vertical-out","horizontal-out":"horizontal-in","horizontal-in":"horizontal-out"};function z(t,e,n,o){if(t.effect==="fade"||t.effect==="fade-out")return{opacity:e};if(t.effect==="zoom"||t.effect==="zoom-out")return{scale:e,opacity:e};if(t.effect==="wipe"||t.effect==="wipe-out")return{clip:O(t.direction,1-e)};if(t.effect==="split")return barn(t.direction,e);if(t.effect==="split-out")return barn(D[t.direction]??"vertical-in",e);if(t.effect==="float-in"||t.effect==="float-out"){const f=.1*o.height*(1-e),i=t.effect==="float-in"==(t.direction==="down")?-1:1;return{opacity:e,y:i*f}}if(t.effect==="fly-in"||t.effect==="fly-out"){const f=P(t.direction,n,o);return{x:f.x*(1-e),y:f.y*(1-e)}}return{}}export function drawnAt(t,e,n,o,f){const[i]=t;let r=i&&isEntrance(i.effect)?{...y,hidden:!0}:{...y};const s=c=>e<c-k;for(const c of t){const d=f!==void 0&&c.iterate?f*c.iterate.delay*c.duration:0;if(s(c.from+d))break;const u=R(c,e,d);if(u!==void 0)if(c.effect==="path"&&c.path){const p=pathPoint(c.path,u);r={...r,x:p.x,y:p.y}}else if(c.effect==="pulse")r={...r,scale:1+.05*Math.sin(u*Math.PI)};else if(c.effect==="grow-shrink"){const p=1+((c.amount??1.5)-1)*u;r={...r,sx:r.sx*(c.direction==="vertical"?1:p),sy:r.sy*(c.direction==="horizontal"?1:p)}}else if(c.effect==="spin"){const p=(c.amount??360)*u;r={...r,rotate:r.rotate+(c.direction==="counterclockwise"?-p:p)}}else c.effect==="transparency"?r={...r,opacity:r.opacity*(1-(c.amount??.5)*u)}:isExit(c.effect)?r=u>=1?{...y,hidden:!0}:{...r,...z(c,1-(c.effect==="fly-out"?u*u:u),n,o)}:r={...y,...u<1?z(c,c.effect==="fly-in"?N(u):u,n,o):{}}}return r}function R(t,e,n){const o=roundOf(t),f=r=>t.duration>0?Math.min(1,Math.max(0,(r-n)/t.duration)):1,i=typeof t.repeat=="string"?t.stop??1/0:t.to;if(e>=i-k){if(t.rewind)return;const r=typeof t.repeat=="number"?t.repeat%1:0;return r>k?f(o*r):1}return o<=0?1:f((e-t.from)%o)}export function animationTargets(t){const e=new Map;for(const n of t){const o=JSON.stringify([n.shape,n.paragraph??null]),f=e.get(o);f?f.animations.push(n):e.set(o,{shape:n.shape,...n.paragraph===void 0?{}:{paragraph:n.paragraph},animations:[n]})}return[...e.values()]}
|
|
2
|
+
import{pathSteps as E}from"./path.js";import{EMU_PER_PT as m}from"./units.js";export const ANIMATION_DURATIONS={appear:0,fade:.5,"fly-in":.5,"float-in":1,split:.5,wipe:.5,zoom:.5,disappear:0,"fade-out":.5,"fly-out":.5,"float-out":1,"split-out":.5,"wipe-out":.5,"zoom-out":.5,pulse:.5,"grow-shrink":2,spin:2,transparency:.5,path:2};const I=new Set(["disappear","fade-out","fly-out","float-out","split-out","wipe-out","zoom-out"]),A=new Set(["appear","fade","fly-in","float-in","split","wipe","zoom"]);export const isExit=t=>I.has(t),isEntrance=t=>A.has(t),TRANSITION_DURATIONS={fade:.7,push:1,wipe:1,split:1.5,reveal:2,cut:0,cover:1,uncover:1,zoom:1,morph:2};const x=["from-right","from-top","from-left","from-bottom"],w=[...x,"from-top-right","from-bottom-right","from-top-left","from-bottom-left"];export const TRANSITION_OPTIONS={fade:{directions:[],throughBlack:!0},push:{directions:x,throughBlack:!1},wipe:{directions:x,throughBlack:!1},split:{directions:["vertical-out","vertical-in","horizontal-out","horizontal-in"],throughBlack:!1},reveal:{directions:["from-right","from-left"],throughBlack:!0},cut:{directions:[],throughBlack:!0},cover:{directions:w,throughBlack:!1},uncover:{directions:w,throughBlack:!1},zoom:{directions:["in","out","rotate"],throughBlack:!1},morph:{directions:[],throughBlack:!1}};const S=["vertical-out","vertical-in","horizontal-out","horizontal-in"];export const EFFECT_OPTIONS={appear:{directions:[]},fade:{directions:[]},"fly-in":{directions:["from-bottom","from-top","from-left","from-right"]},"float-in":{directions:["up","down"]},split:{directions:S},wipe:{directions:["from-bottom","from-top","from-left","from-right"]},zoom:{directions:[]},disappear:{directions:[]},"fade-out":{directions:[]},"fly-out":{directions:["from-bottom","from-top","from-left","from-right"]},"float-out":{directions:["up","down"]},"split-out":{directions:S},"wipe-out":{directions:["from-bottom","from-top","from-left","from-right"]},"zoom-out":{directions:[]},pulse:{directions:[]},"grow-shrink":{directions:["both","horizontal","vertical"],amounts:[1.1,.5,1.5,4],amount:1.5},spin:{directions:["clockwise","counterclockwise"],amounts:[90,180,360,720],amount:360},transparency:{directions:[],amounts:[.25,.5,.75,1],amount:.5},path:{directions:[]}},effectTakes=(t,e)=>EFFECT_OPTIONS[t].directions.includes(e),transitionTakes=(t,e)=>TRANSITION_OPTIONS[t].directions.includes(e),resolveTransition=t=>{const e=TRANSITION_OPTIONS[t.type];return{type:t.type,direction:t.direction!==void 0&&e.directions.includes(t.direction)?t.direction:e.directions[0]??"from-right",throughBlack:t.through_black===!0&&e.throughBlack,duration:t.duration??TRANSITION_DURATIONS[t.type]}};const B={"from-left":{x:-1,y:0},"from-right":{x:1,y:0},"from-top":{x:0,y:-1},"from-bottom":{x:0,y:1},"from-top-right":{x:1,y:-1},"from-bottom-right":{x:1,y:1},"from-top-left":{x:-1,y:-1},"from-bottom-left":{x:-1,y:1}},h=t=>B[t]??{x:0,y:1},l={opacity:1,x:0,y:0,scale:1,rotate:0};export function barn(t,e){const n=t==="vertical-out"||t==="vertical-in";if(t==="vertical-out"||t==="horizontal-out"){const f=(1-e)/2;return{clip:n?{top:0,right:f,bottom:0,left:f}:{top:f,right:0,bottom:f,left:0}}}const s=e/2,c=1-s,r=[[0,0],[s,0],[s,1],[c,1],[c,0],[1,0],[1,1],[0,1]];return{polygon:n?r:r.map(([f,i])=>[i,f])}}export function transitionAt(t,e){const o={incoming:{...l},outgoing:{...l},outgoingOver:!1,black:!1},s=e<.5;switch(t.type){case"fade":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:s?1-2*e:0},incoming:{...l,opacity:s?0:2*e-1}}:{...o,incoming:{...l,opacity:e}};case"cut":return t.throughBlack?{...o,black:!0,outgoing:{...l,opacity:0},incoming:{...l,opacity:e>=1?1:0}}:o;case"push":{const c=h(t.direction);return{...o,incoming:{...l,x:c.x*(1-e),y:c.y*(1-e)},outgoing:{...l,x:-c.x*e,y:-c.y*e}}}case"cover":{const c=h(t.direction);return{...o,incoming:{...l,x:c.x*(1-e),y:c.y*(1-e)}}}case"uncover":{const c=h(t.direction);return{...o,outgoingOver:!0,outgoing:{...l,x:-c.x*e,y:-c.y*e}}}case"reveal":{const c=h(t.direction);return t.throughBlack?{...o,outgoingOver:!0,black:!0,outgoing:{...l,x:-c.x*Math.min(1,2*e),opacity:s?1-2*e:0},incoming:{...l,opacity:s?0:2*e-1}}:{...o,outgoingOver:!0,outgoing:{...l,x:-c.x*e,opacity:1-e}}}case"wipe":return{...o,incoming:{...l,clip:O(t.direction,1-e)}};case"split":return{...o,incoming:{...l,...barn(t.direction,e)}};case"zoom":return t.direction==="out"?{...o,outgoingOver:!0,outgoing:{...l,scale:1-e,opacity:1-e}}:{...o,incoming:{...l,scale:e,opacity:t.direction==="rotate"?1:e,rotate:t.direction==="rotate"?-720*(1-e):0}};case"morph":return o}}export function morphFrame(t,e,n){const o=n*n*(3-2*n),s=(c,r)=>c+(r-c)*o;return{left:s(t.left,e.left),top:s(t.top,e.top),width:s(t.width,e.width),height:s(t.height,e.height)}}export const TEXT_DELAY=.1;const T=new Intl.Segmenter(void 0,{granularity:"grapheme"});export function textUnits(t,e){return e==="word"?t.split(/\s+/u).filter(n=>n!==""):[...T.segment(t)].map(n=>n.segment).filter(n=>!/^\s+$/u.test(n))}export function unitsAcross(t,e){const n=[];let o=[];return t.forEach((s,c)=>{if(e==="letter"){for(const r of T.segment(s))/^\s+$/u.test(r.segment)||n.push([{piece:c,start:r.index,end:r.index+r.segment.length}]);return}for(const r of s.matchAll(/\s+|\S+/gu))/^\s/u.test(r[0])?(o.length>0&&n.push(o),o=[]):o.push({piece:c,start:r.index,end:r.index+r[0].length})}),o.length>0&&n.push(o),n}export const roundOf=t=>t.iterate?t.duration*(1+Math.max(0,t.iterate.units-1)*t.iterate.delay):t.duration,spanOf=t=>roundOf(t)*(typeof t.repeat=="number"?t.repeat:1);export function resolveAnimation(t,e=1){const n=t.path===void 0?void 0:E(t.path);if(t.path!==void 0&&!n||t.effect==="path"&&!n)return;const o=EFFECT_OPTIONS[t.effect],s=o.amount===void 0?void 0:t.amount??o.amount;return{shape:t.shape,...t.paragraph===void 0?{}:{paragraph:t.paragraph},effect:t.effect,direction:t.direction!==void 0&&o.directions.includes(t.direction)?t.direction:o.directions[0]??"from-bottom",...s===void 0?{}:{amount:t.effect==="transparency"?Math.min(1,s):s},start:t.start??"on-click",duration:t.duration??ANIMATION_DURATIONS[t.effect],delay:t.delay??0,...t.animate_text===void 0?{}:{iterate:{by:t.animate_text,delay:t.text_delay??TEXT_DELAY,units:Math.max(1,e)}},...t.repeat===void 0||t.repeat===1?{}:{repeat:t.repeat},...t.rewind?{rewind:!0}:{},...n?{path:n.map(c=>c.op==="close"?c:c.op!=="curve"?{...c,x:c.x*m,y:c.y*m}:{op:"curve",x1:c.x1*m,y1:c.y1*m,x2:c.x2*m,y2:c.y2*m,x:c.x*m,y:c.y*m})}:{}}}export function slideClock(t,e,n,o=0,s=0){const c=new Set(t.filter(a=>isEntrance(a.effect)).map(a=>a.shape)),r=[...e].filter(([a])=>!c.has(a)).map(([,a])=>a);let f=s+Math.max(0,...r);if(t.length===0)return{timed:[],rests:[Math.max(n,s,...r)]};const i=[],d=[];let u=0,p=s;for(const a of t){a.start==="on-click"?(i.push(f),u++,f+=o,p=f):a.start==="after-previous"&&(p=f);const g=p+a.delay,v=g+spanOf(a);d.push({...a,step:u,from:g,to:v}),f=Math.max(f,v);const b=e.get(a.shape);b!==void 0&&isEntrance(a.effect)&&(f=Math.max(f,g+b))}i.push(f);for(const a of d)a.repeat==="until-next-click"?a.stop=i[a.step]??f:a.repeat==="until-end-of-slide"&&(a.stop=f);return{timed:d,rests:i}}export const SLIDE_SECONDS=4,componentSeconds=t=>t.dur??SLIDE_SECONDS,DECK_FPS=30;const M=t=>Math.ceil(t*DECK_FPS-1e-6)/DECK_FPS;export const inTransition=(t,e)=>t<e-1e-6;export function clockOf(t,e){const n=e?0:t.transition?.duration??0,o=slideClock(t.animations,new Map(t.shapes.flatMap(f=>{if(f.component)return[[f.name,componentSeconds(f.component)-1/DECK_FPS]];const i=f.item?.playback?.trim;return i?.end===void 0?[]:[[f.name,Math.max(0,i.end-(i.start??0))-1/DECK_FPS]]})),SLIDE_SECONDS-1/DECK_FPS,1/DECK_FPS,n),s=o.rests.map(M),c=f=>o.timed.find(i=>i.shape===f&&isEntrance(i.effect))?.from??n,r=new Map;for(const f of t.shapes){if((f.media??f.item)?.playback?.start!=="on-click")continue;const i=s.at(-1)??n;r.set(f.name,i),s.push(M(i+1/DECK_FPS))}return{timed:o.timed,rests:s,lead:n,comesOn:c,goesOff:f=>o.timed.find(i=>i.shape===f&&isExit(i.effect))?.to,playsAt:f=>r.get(f)??c(f)}}const k=1e-6,y={hidden:!1,opacity:1,x:0,y:0,scale:1,sx:1,sy:1,rotate:0},N=t=>1-(1-t)*(1-t);function _(t){const e=[];let n={x:0,y:0};for(const o of t){if(o.op==="close")continue;if(o.op!=="curve"){n={x:o.x,y:o.y},e.push(n);continue}const s=n;for(let c=1;c<=24;c++){const r=c/24,f=1-r,i=(d,u,p,a)=>f*f*f*d+3*f*f*r*u+3*f*r*r*p+r*r*r*a;e.push({x:i(s.x,o.x1,o.x2,o.x),y:i(s.y,o.y1,o.y2,o.y)})}n={x:o.x,y:o.y}}return e}export function pathPoint(t,e){const n=_(t),[o]=n;if(!o)return{x:0,y:0};let s=0;for(let r=1;r<n.length;r++){const[f,i]=[n[r-1]??o,n[r]??o];s+=Math.hypot(i.x-f.x,i.y-f.y)}let c=s*e;for(let r=1;r<n.length;r++){const[f,i]=[n[r-1]??o,n[r]??o],d=Math.hypot(i.x-f.x,i.y-f.y);if(c<=d&&d>0){const u=c/d;return{x:f.x+(i.x-f.x)*u,y:f.y+(i.y-f.y)*u}}c-=d}return n.at(-1)??o}function P(t,e,n){return t==="from-left"?{x:-(e.left+e.width),y:0}:t==="from-right"?{x:n.width-e.left,y:0}:t==="from-top"?{x:0,y:-(e.top+e.height)}:{x:0,y:n.height-e.top}}function O(t,e){const n={top:0,right:0,bottom:0,left:0};return t==="from-left"?n.right=e:t==="from-right"?n.left=e:t==="from-top"?n.bottom=e:n.top=e,n}const D={"vertical-out":"vertical-in","vertical-in":"vertical-out","horizontal-out":"horizontal-in","horizontal-in":"horizontal-out"};function z(t,e,n,o){if(t.effect==="fade"||t.effect==="fade-out")return{opacity:e};if(t.effect==="zoom"||t.effect==="zoom-out")return{scale:e,opacity:e};if(t.effect==="wipe"||t.effect==="wipe-out")return{clip:O(t.direction,1-e)};if(t.effect==="split")return barn(t.direction,e);if(t.effect==="split-out")return barn(D[t.direction]??"vertical-in",e);if(t.effect==="float-in"||t.effect==="float-out"){const s=.1*o.height*(1-e),c=t.effect==="float-in"==(t.direction==="down")?-1:1;return{opacity:e,y:c*s}}if(t.effect==="fly-in"||t.effect==="fly-out"){const s=P(t.direction,n,o);return{x:s.x*(1-e),y:s.y*(1-e)}}return{}}export function drawnAt(t,e,n,o,s){const[c]=t;let r=c&&isEntrance(c.effect)?{...y,hidden:!0}:{...y};const f=i=>e<i-k;for(const i of t){const d=s!==void 0&&i.iterate?s*i.iterate.delay*i.duration:0;if(f(i.from+d))break;const u=R(i,e,d);if(u!==void 0)if(i.effect==="path"&&i.path){const p=pathPoint(i.path,u);r={...r,x:p.x,y:p.y}}else if(i.effect==="pulse")r={...r,scale:1+.05*Math.sin(u*Math.PI)};else if(i.effect==="grow-shrink"){const p=1+((i.amount??1.5)-1)*u;r={...r,sx:r.sx*(i.direction==="vertical"?1:p),sy:r.sy*(i.direction==="horizontal"?1:p)}}else if(i.effect==="spin"){const p=(i.amount??360)*u;r={...r,rotate:r.rotate+(i.direction==="counterclockwise"?-p:p)}}else i.effect==="transparency"?r={...r,opacity:r.opacity*(1-(i.amount??.5)*u)}:isExit(i.effect)?r=u>=1?{...y,hidden:!0}:{...r,...z(i,1-(i.effect==="fly-out"?u*u:u),n,o)}:r={...y,...u<1?z(i,i.effect==="fly-in"?N(u):u,n,o):{}}}return r}function R(t,e,n){const o=roundOf(t),s=r=>t.duration>0?Math.min(1,Math.max(0,(r-n)/t.duration)):1,c=typeof t.repeat=="string"?t.stop??1/0:t.to;if(e>=c-k){if(t.rewind)return;const r=typeof t.repeat=="number"?t.repeat%1:0;return r>k?s(o*r):1}return o<=0?1:s((e-t.from)%o)}export function animationTargets(t){const e=new Map;for(const n of t){const o=JSON.stringify([n.shape,n.paragraph??null]),s=e.get(o);s?s.animations.push(n):e.set(o,{shape:n.shape,...n.paragraph===void 0?{}:{paragraph:n.paragraph},animations:[n]})}return[...e.values()]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
2
|
import{themeColor as P,themeColorOf as T}from"@allyhub/chart";import{presetAdjustments as te}from"@allyhub/ooxml/geometry";import{connectorBetween as re,connectorEnds as se,siteOn as ie,sitesOf as ne}from"./connect.js";import{framedComponent as oe}from"@allyhub/piece";import{COLOR_TRANSFORMS as F,colorOfFile as ae,GRADIENT_PATHS as z,inGroup as I,THEME_COLORS as A}from"@allyhub/formats";import{MSO_ARROWHEAD as C,MSO_ARROWHEAD_SIZE as S,MSO_CONNECTOR as he,MSO_LINE as de,MSO_LINE_CAP as le,MSO_LINE_COMPOUND as fe,MSO_LINE_JOIN as ce,MSO_PATTERN_TYPE as ue,TILE_ALIGNMENT as pe,MSO_SHAPE as D,MSO_SHAPE_TYPE as _e,MSO_TEXT_ORIENTATION as G,PP_PLACEHOLDER as H}from"./enums.js";import{Chart as ge}from"./chart-api.js";import{AUTOSHAPE_STYLE as g,SHADOW_DEFAULTS as U,LINE_DEFAULTS as x,PATTERN_DEFAULTS as O,TILE_DEFAULTS as B,INNER_SHADOW_DEFAULTS as me,GLOW_DEFAULTS as v,REFLECTION_DEFAULTS as we,PLAYBACK_DEFAULTS as W,CONNECTOR_GEOMETRIES as be,CONNECTOR_STYLE as Y,FOOTER_IDX as ye,isConnectorGeometry as M,OFFICE_TEXT_STYLES as xe,placeholderLevels as Ee,TEXT_INSETS as w,TEXTBOX_FRAME as Se}from"./office.js";import{masterPlaceholder as X}from"./placeholders.js";import{strict as a}from"./strict.js";import{DEFAULT_TABLE_STYLE as Oe,TABLE_STYLES as $e,tableStyleOf as Z}from"./table-style.js";import{EMU_PER_PT as R,SLIDE_SIZES as j,length as l,lengthOr as $}from"./units.js";class ke extends Error{constructor(e){super(`${e} (allyhub slides capabilities lists what the API holds).`),this.name="Unsupported"}}export const refuse=i=>{throw new ke(i)};const Te=/^#?[0-9a-f]{6}$/iu,J=i=>{if(!Te.test(i))throw new Error(`rgb ${i} is not RRGGBB.`);return`#${i.replace("#","").toUpperCase()}`};function N(i,e){if(typeof i!="string")return i;const t=ae(i);if(t===void 0)throw new Error(`${e} is a theme colour (accent1), one lighter or darker (accent1 lighter 40%) or #RRGGBB, not ${i}.`);return t}export const OFFICE_COLOR_MAP={...Object.fromEntries(A.map(i=>[i,i])),tx1:"dk1",bg1:"lt1",tx2:"dk2",bg2:"lt2"};const Ae=["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function K(i){const e={};for(const[t,r]of Object.entries(i))if(r!==void 0){if(!Ae.includes(t))throw new Error(`A colour map maps bg1, tx1, bg2, tx2, accent1 to accent6, hlink and folHlink, not ${t}.`);if(!A.includes(r))throw new Error(`A colour map's ${t} is one of the theme's colours (${A.join(", ")}), not ${r}.`);e[t]=r}return e}export const RGBColor=Object.assign(function(e,t,r){for(const o of[e,t,r])if(!Number.isInteger(o)||o<0||o>255)throw new Error(`RGBColor(${String(e)}, ${String(t)}, ${String(r)}): each is 0 to 255.`);const s=`#${[e,t,r].map(o=>o.toString(16).padStart(2,"0")).join("").toUpperCase()}`;return new.target===void 0?s:new String(s)},{from_string:i=>J(i)});export class ColorFormat{read;write;constructor(e,t){return this.read=e,this.write=t,a(this,"ColorFormat")}get theme_color(){const e=this.read();return e===void 0?void 0:T(e)}set theme_color(e){const t=this.read();e!==void 0&&typeof t=="object"&&"transforms"in t?this.write(t.transforms.length>0?{theme_color:e,transforms:t.transforms}:e):this.write(e===void 0?void 0:P(e,this.brightness))}get transforms(){const e=this.read();return typeof e=="object"&&"transforms"in e?[...e.transforms??[]]:[]}set transforms(e){const t=this.read();if(t===void 0)throw new TypeError("There is no colour to transform: set theme_color or rgb first.");for(const s of e)if(!F.includes(s.name))throw new Error(`A colour's transform is one of ${F.join(", ")}, not ${s.name}.`);const r=e.map(s=>({name:s.name,value:s.value}));if(typeof t=="object"&&"rgb"in t)this.write(r.length>0?{rgb:t.rgb,transforms:r}:{rgb:t.rgb});else{const s=T(t)??"dk1";this.write(r.length>0?{theme_color:s,transforms:r}:s)}}get brightness(){const e=this.read();return typeof e=="object"&&"brightness"in e?e.brightness:0}set brightness(e){if(!(e>=-1&&e<=1))throw new RangeError(`brightness ${String(e)} is not a number from -1.0 to 1.0.`);const t=this.read();if(t===void 0)throw new TypeError("There is no colour to set the brightness of: set theme_color first.");const r=T(t);if(r!==void 0)this.write(P(r,e));else if(e!==0)throw new TypeError("Only a theme colour has a brightness here, so an RGB colour does not: set theme_color first, or rgb to the colour it makes.")}get rgb(){const e=this.read();return typeof e=="object"&&"rgb"in e?e.rgb:void 0}set rgb(e){this.write(e===void 0?void 0:{rgb:J(e)})}}export class Font{def;constructor(e){return this.def=e,a(this,"Font")}_set(e,t){t===void 0?Reflect.deleteProperty(this.def,e):this.def[e]=t}get strike(){const e=this.def.strike;return e==="sngStrike"?!0:e}set strike(e){this._set("strike",e==="noStrike"?!1:e==="sngStrike"?!0:e)}get caps(){return this.def.caps}set caps(e){this._set("caps",e)}get baseline(){return this.def.baseline}set baseline(e){this._set("baseline",e)}get highlight(){return this.def.highlight}set highlight(e){this._set("highlight",e)}get name(){return this.def.name}set name(e){this._set("name",e)}get size(){return $(this.def.size)}set size(e){if(e!==void 0&&e<12700)throw new Error(`A font size is a Length of Pt(1) and over: Pt(${String(e)}) for ${String(e)} points; ${String(e)} alone is ${String(e)} EMU.`);this._set("size",e)}get bold(){return this.def.bold}set bold(e){this._set("bold",e)}get italic(){return this.def.italic}set italic(e){this._set("italic",e)}get underline(){const e=this.def.underline;return e==="sng"?!0:e}set underline(e){this._set("underline",e==="none"?!1:e==="sng"?!0:e)}get spacing(){return $(this.def.spacing)}set spacing(e){this._set("spacing",e)}get color(){return new ColorFormat(()=>this.def.color,e=>{this._set("color",e)})}}export class Hyperlink{def;constructor(e){return this.def=e,a(this,"_Hyperlink")}get address(){return this.def.font?.link}set address(e){this.def.font??={},e===void 0?Reflect.deleteProperty(this.def.font,"link"):this.def.font.link=e}}export class Run{def;constructor(e){return this.def=e,a(this,"_Run")}get text(){return this.def.text}set text(e){this.def.text=e}get font(){return this.def.font??={},new Font(this.def.font)}get hyperlink(){return new Hyperlink(this.def)}}const Me=i=>{if(!Number.isFinite(i)||i<=0)throw new Error(`line_spacing ${String(i)} is not over 0.`);return Number.isInteger(i)&&i>=R?{fixed:i}:{lines:i}},Re=i=>i===void 0?void 0:"lines"in i?i.lines:l(i.fixed),q=i=>{if(!Number.isFinite(i)||i<0)throw new Error(`A paragraph's space ${String(i)} is under 0.`);return i===0||Number.isInteger(i)&&i>=R?i:{lines:i}},Q=i=>i===void 0?void 0:typeof i=="number"?l(i):i.lines,V=i=>i.split(/\n|\v/u).flatMap((e,t)=>[...t>0?[{text:"\v"}]:[],...e===""?[]:[{text:e}]]);class ee{_set(e,t){t===void 0?Reflect.deleteProperty(this.fmt,e):this.fmt[e]=t}get alignment(){return this.fmt.alignment}set alignment(e){this._set("alignment",e)}get line_spacing(){return Re(this.fmt.line_spacing)}set line_spacing(e){this._set("line_spacing",e===void 0?void 0:Me(e))}get space_before(){return Q(this.fmt.space_before)}set space_before(e){this._set("space_before",e===void 0?void 0:q(e))}get space_after(){return Q(this.fmt.space_after)}set space_after(e){this._set("space_after",e===void 0?void 0:q(e))}get font(){return this.fmt.font??={},new Font(this.fmt.font)}}export class Paragraph extends ee{fmt;constructor(e){return super(),this.fmt=e,a(this,"_Paragraph")}get text(){return this.fmt.runs.map(e=>e.text).join("")}set text(e){this.fmt.runs=V(e)}get runs(){return this.fmt.runs.filter(e=>e.text!=="\v").map(e=>new Run(e))}add_run(){const e={text:""};return this.fmt.runs.push(e),new Run(e)}add_line_break(){this.fmt.runs.push({text:"\v"})}clear(){return this.fmt.runs=[],this}get level(){return this.fmt.level}set level(e){if(!Number.isInteger(e)||e<0||e>8)throw new Error(`level ${String(e)} is not 0 to 8.`);this.fmt.level=e}}export class ListLevel extends ee{fmt;constructor(e){return super(),this.fmt=e,a(this,"ListLevel")}get numbered(){return this.fmt.numbered}set numbered(e){this._set("numbered",e)}get bullet(){return this.fmt.bullet}set bullet(e){this._set("bullet",e)}get bullet_font(){return this.fmt.bullet_font}set bullet_font(e){this._set("bullet_font",e)}get bullet_color(){return this.fmt.bullet_color}set bullet_color(e){this._set("bullet_color",e==null?e:N(e,"bullet_color"))}get bullet_size(){return this.fmt.bullet_size}set bullet_size(e){if(typeof e=="number"&&!(e>=.25&&e<=4))throw new Error(`bullet_size is a share of the text's size, 0.25 to 4, not ${String(e)}.`);this._set("bullet_size",e)}get start_at(){return this.fmt.start_at}set start_at(e){if(e!==void 0&&!(Number.isInteger(e)&&e>=1&&e<=32767))throw new Error(`start_at is a whole number from 1 to 32767, not ${String(e)}.`);this._set("start_at",e)}get margin_left(){return $(this.fmt.margin_left)}set margin_left(e){this._set("margin_left",e)}get indent(){return $(this.fmt.indent)}set indent(e){this._set("indent",e)}}const k=i=>Object.freeze(i.map(e=>new ListLevel(e))),je=()=>Array.from({length:9},()=>({})),E=()=>({paragraphs:[],levels:je()});export class TextFrame{def;constructor(e){return this.def=e,a(this,"TextFrame")}_set(e,t){t===void 0?Reflect.deleteProperty(this.def,e):this.def[e]=t}get text(){return this.def.paragraphs.map(e=>e.runs.map(t=>t.text).join("")).join(`
|
|
3
3
|
`)}set text(e){this.def.paragraphs=e.split(`
|
|
4
|
-
`).map(t=>({runs:V(t),level:0}))}get paragraphs(){return this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0}),this.def.paragraphs.map(e=>new Paragraph(e))}add_paragraph(){this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0});const e={runs:[],level:0};return this.def.paragraphs.push(e),new Paragraph(e)}clear(){const e=this.def.paragraphs[0];this.def.paragraphs=e?[{...e,runs:[]}]:[]}fit_text(e,t=18,r,s){this.def.auto_size="text",this.def.word_wrap=!0;for(const n of this.def.paragraphs)for(const o of n.runs)o.font={...o.font,size:Math.trunc(t*R),...e===void 0?{}:{name:e},...r===void 0?{}:{bold:r},...s===void 0?{}:{italic:s}}}get list_style(){return k(this.def.levels)}get vertical_anchor(){return this.def.vertical_anchor}set vertical_anchor(e){this._set("vertical_anchor",e)}get orientation(){return this.def.orientation}set orientation(e){if(e!==void 0&&!Object.values(G).includes(e))throw new Error(`orientation is one of MSO_TEXT_ORIENTATION's ${Object.values(G).join(", ")}, not ${e}.`);this._set("orientation",e)}get auto_size(){return this.def.auto_size}set auto_size(e){this._set("auto_size",e)}get word_wrap(){return this.def.word_wrap}set word_wrap(e){this._set("word_wrap",e)}get margin_left(){return l(this.def.margin_left??w.left)}set margin_left(e){this.def.margin_left=e}get margin_top(){return l(this.def.margin_top??w.top)}set margin_top(e){this.def.margin_top=e}get margin_right(){return l(this.def.margin_right??w.right)}set margin_right(e){this.def.margin_right=e}get margin_bottom(){return l(this.def.margin_bottom??w.bottom)}set margin_bottom(e){this.def.margin_bottom=e}}export class FillFormat{read;write;start;shape;base;constructor(e,t,r="lt1",s,n=""){return this.read=e,this.write=t,this.start=r,this.shape=s,this.base=n,a(this,"FillFormat")}_only(e){if(this.shape)for(const t of["gradient","pattern","picture_fill"])t!==e&&Reflect.deleteProperty(this.shape,t)}solid(){const e=this.read();this._only("solid"),e==null&&this.write(this.start)}background(){this._only("solid"),this.write(null)}patterned(){const e=this._shape("a pattern");this._only("pattern"),e.pattern??={preset:"pct5",fg:O.fg,bg:O.bg}}get pattern(){return this._pattern().preset}set pattern(e){this._pattern().preset=p(ue,"MSO_PATTERN_TYPE","pattern",e)}_pattern(){const{pattern:e}=this._shape("a pattern");if(!e)throw new TypeError("This fill is no pattern: call fill.patterned() first.");return e}get back_color(){const e=this._pattern();return new ColorFormat(()=>e.bg,t=>{e.bg=t??O.bg})}picture(e,t={}){const r=this._shape("a picture");this._only("picture_fill"),r.picture_fill={path:e,base:this.base,...t.tile?{tile:{...B,...t.tile,align:p(pe,"TILE_ALIGNMENT","tile.align",t.tile.align??B.align)}}:{},...t.transparency===void 0?{}:{transparency:t.transparency}}}_shape(e){if(!this.shape)throw new TypeError(`Only a shape's fill has ${e}.`);return this.shape}gradient(){this._only("gradient"),this._shape("a gradient").gradient??={angle:90,stops:[{at:0,color:"accent1"},{at:1,color:"accent2"}]}}get gradient_path(){return this._gradient().path??"linear"}set gradient_path(e){const t=this._gradient();e==="linear"?delete t.path:z.includes(e)?t.path=e:refuse(`gradient_path is "linear", ${z.map(r=>`"${r}"`).join(", ")}, not ${e}.`)}get gradient_focus(){return{...this._gradient().focus??{left:.5,top:.5,right:.5,bottom:.5}}}set gradient_focus(e){this._gradient().focus={...e}}get gradient_angle(){return this._gradient().angle}set gradient_angle(e){this._gradient().angle=e}get gradient_stops(){return this._gradient().stops.map(e=>new GradientStop(e))}set gradient_stops(e){if(e.length<2)throw new Error("A gradient has two stops at least.");this._gradient().stops=e.map(t=>t instanceof GradientStop?GradientStop.defOf(t):{...t,color:N(t.color,"A gradient stop's colour")})}_gradient(){const{gradient:e}=this._shape("a gradient");if(!e)throw new TypeError("This fill is no gradient: call fill.gradient() first.");return e}get transparency(){return this._shape("a transparency").fill_transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);this._shape("a transparency").fill_transparency=e}get type(){if(this.shape?.picture_fill)return"picture";if(this.shape?.pattern)return"patterned";if(this.shape?.gradient)return"gradient";const e=this.read();return e===void 0?void 0:e===null?"background":"solid"}get fore_color(){const e=this.shape?.pattern;if(e)return new ColorFormat(()=>e.fg,r=>{e.fg=r??O.fg});const t=this.read();if(t==null)throw new TypeError("This fill is not solid, so it has no fore_color: call fill.solid() first.");return new ColorFormat(()=>this.read()??void 0,r=>{this.write(r??this.start)})}}export class GradientStop{stop;constructor(e){return this.stop=e,a(this,"GradientStop")}static defOf(e){return{...e.stop}}get color(){return new ColorFormat(()=>this.stop.color,e=>{e!==void 0&&(this.stop.color=e)})}get position(){return this.stop.at}set position(e){if(!(e>=0&&e<=1))throw new Error(`A stop's position is a share, 0 to 1, not ${String(e)}.`);this.stop.at=e}get transparency(){return this.stop.transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);e===0?Reflect.deleteProperty(this.stop,"transparency"):this.stop.transparency=e}}export class ShadowFormat{def;inner;constructor(e,t=!1){return this.def=e,this.inner=t,a(this,"ShadowFormat")}_shadow(){return this.inner?(this.def.inner_shadow??={...me},this.def.inner_shadow):(this.def.shadow??={...U},this.def.shadow)}get visible(){return this.inner?this.def.inner_shadow!==void 0:this.def.shadow!==void 0&&this.def.shadow!==null}set visible(e){e?this._shadow():this.inner?Reflect.deleteProperty(this.def,"inner_shadow"):this.def.shadow=null}get inherit(){return this.def.shadow===void 0}set inherit(e){e?Reflect.deleteProperty(this.def,"shadow"):this.def.shadow??=null}get blur_radius(){return l(this._shadow().blur)}set blur_radius(e){this._shadow().blur=e}get distance(){return l(this._shadow().distance)}set distance(e){this._shadow().distance=e}get angle(){return this._shadow().angle}set angle(e){this._shadow().angle=e}get transparency(){return this._shadow().transparency}set transparency(e){this._shadow().transparency=e}get color(){const e=this._shadow();return new ColorFormat(()=>e.color,t=>{e.color=t??U.color})}}export class GlowFormat{def;constructor(e){return this.def=e,a(this,"GlowFormat")}_glow(){return this.def.glow??={...v},this.def.glow}get visible(){return this.def.glow!==void 0}set visible(e){e?this._glow():Reflect.deleteProperty(this.def,"glow")}get radius(){return l(this.def.glow?.size??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"glow"):this._glow().size=e}get transparency(){return this._glow().transparency}set transparency(e){this._glow().transparency=e}get color(){const e=this._glow();return new ColorFormat(()=>e.color,t=>{e.color=t??v.color})}}export class SoftEdgeFormat{def;constructor(e){return this.def=e,a(this,"SoftEdgeFormat")}get radius(){return l(this.def.soft_edges??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"soft_edges"):this.def.soft_edges=e}}export class ReflectionFormat{def;constructor(e){return this.def=e,a(this,"ReflectionFormat")}_reflection(){return this.def.reflection??={...we},this.def.reflection}get visible(){return this.def.reflection!==void 0}set visible(e){e?this._reflection():Reflect.deleteProperty(this.def,"reflection")}get transparency(){return this._reflection().transparency}set transparency(e){this._reflection().transparency=e}get size(){return this._reflection().size}set size(e){this._reflection().size=e}get offset(){return l(this._reflection().distance)}set offset(e){this._reflection().distance=e}get blur(){return l(this._reflection().blur)}set blur(e){this._reflection().blur=e}}export class LineFormat{def;constructor(e){return this.def=e,a(this,"LineFormat")}get color(){return new ColorFormat(()=>this.def.line??void 0,e=>{this.def.line=e??null})}get fill(){return new FillFormat(()=>this.def.line,e=>{this.def.line=e},"dk1")}get width(){return l(this.def.line_width??0)}set width(e){this.def.line_width=e}get dash_style(){return this.def.line_dash??null}set dash_style(e){e===null?delete this.def.line_dash:this.def.line_dash=p(de,"MSO_LINE","dash_style",e)}get cap_type(){return this.def.line_cap??x.cap}set cap_type(e){const t=p(le,"MSO_LINE_CAP","cap_type",e);t===x.cap?delete this.def.line_cap:this.def.line_cap=t}get join_type(){return this.def.line_join??x.join}set join_type(e){const t=p(ce,"MSO_LINE_JOIN","join_type",e);t===x.join?delete this.def.line_join:this.def.line_join=t}get compound_type(){return this.def.line_compound??x.compound}set compound_type(e){const t=p(fe,"MSO_LINE_COMPOUND","compound_type",e);t===x.compound?delete this.def.line_compound:this.def.line_compound=t}get begin_arrow(){return this.def.line_begin??"none"}set begin_arrow(e){this.def.line_begin=p(C,"MSO_ARROWHEAD","begin_arrow",e)}get end_arrow(){return this.def.line_end??"none"}set end_arrow(e){this.def.line_end=p(C,"MSO_ARROWHEAD","end_arrow",e)}get begin_arrow_width(){return this.def.line_begin_size?.w??"med"}set begin_arrow_width(e){this.def.line_begin_size={...this.def.line_begin_size,w:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_width",e)}}get begin_arrow_length(){return this.def.line_begin_size?.len??"med"}set begin_arrow_length(e){this.def.line_begin_size={...this.def.line_begin_size,len:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_length",e)}}get end_arrow_width(){return this.def.line_end_size?.w??"med"}set end_arrow_width(e){this.def.line_end_size={...this.def.line_end_size,w:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_width",e)}}get end_arrow_length(){return this.def.line_end_size?.len??"med"}set end_arrow_length(e){this.def.line_end_size={...this.def.line_end_size,len:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_length",e)}}}function p(i,e,t,r){if(Object.values(i).includes(r))return r;throw new Error(`${t}: ${String(r)} is not one of ${e}'s ${Object.keys(i).join(", ")}.`)}export class Background{holder;constructor(e){return this.holder=e,a(this,"_Background")}get fill(){return new FillFormat(()=>this.holder.background,e=>{this.holder.background=e??"bg1"})}}export const adjustmentDefaults=i=>te(i).map(e=>e.value/1e5);export class Adjustments{def;constructor(e){return this.def=e,a(this,"Adjustments",{index:t=>this._values()[t],setIndex:(t,r)=>{this._set(t,Number(r))}})}_values(){return this.def.adjustments??adjustmentDefaults(this.def.geometry??"rect")}get length(){return this._values().length}_set(e,t){const r=this._values();if(e<0||e>=r.length)throw new RangeError(`adjustments[${String(e)}]: ${this.def.geometry??"this shape"} has ${String(r.length)}.`);if(!Number.isFinite(t))throw new Error(`adjustments[${String(e)}] = ${String(t)} is not a number.`);r[e]=t,this.def.adjustments=r}}const Ne={left:0,top:0,width:0,height:0};export class Shape{def;inherit;base;constructor(e,t=()=>{},r=""){return this.def=e,this.inherit=t,this.base=r,a(this,"Shape")}get _def(){return this.def}_frame(){return this.def.frame??this.inherit()??Ne}_own(){return this.def.frame??={...this._frame()},this.def.frame}get name(){return this.def.name}set name(e){this.def.name=e}get shape_type(){return this.def.path?"freeform":this.def.kind==="audio"?"movie":M(this.def.geometry)?"line":this.def.kind}get is_placeholder(){return this.def.kind==="placeholder"}get has_table(){return this.def.table!==void 0}get has_chart(){return this.def.chart!==void 0}get chart(){if(!this.def.chart)throw new Error(`${this.def.name} is not a chart.`);return new ge(this.def.chart)}get table(){if(!this.def.table)throw new Error(`${this.def.name} is not a table.`);return new Table(this.def.table)}get placeholder_format(){if(!this.def.placeholder)throw new Error(`${this.def.name} is not a placeholder.`);return a({...this.def.placeholder},"_PlaceholderFormat")}get left(){return l(this._frame().left)}set left(e){this._own().left=e}get top(){return l(this._frame().top)}set top(e){this._own().top=e}get width(){return l(this._frame().width)}set width(e){this._own().width=e}get height(){return l(this._frame().height)}set height(e){this._own().height=e}get rotation(){return this.def.rotation??0}set rotation(e){if(!Number.isFinite(e))throw new Error(`${this.def.name}: rotation is a number of degrees.`);const t=(Math.trunc(e*6e4)%216e5+216e5)%216e5/6e4;t===0?Reflect.deleteProperty(this.def,"rotation"):this.def.rotation=t}get flip_h(){return this.def.flip?.h===!0}set flip_h(e){this._flip("h",e)}get flip_v(){return this.def.flip?.v===!0}set flip_v(e){this._flip("v",e)}_flip(e,t){const r={...this.def.flip};t?r[e]=!0:Reflect.deleteProperty(r,e),Object.keys(r).length===0?Reflect.deleteProperty(this.def,"flip"):this.def.flip=r}get has_text_frame(){return this.def.text!==void 0}get text_frame(){if(!this.def.text)throw new Error(`${this.def.name} (a ${this.shape_type}) has no text frame: has_text_frame is false.`);return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e},"lt1",this.def,this.base)}get line(){return new LineFormat(this.def)}get shadow(){return new ShadowFormat(this.def)}get inner_shadow(){return new ShadowFormat(this.def,!0)}get glow(){return new GlowFormat(this.def)}get soft_edge(){return new SoftEdgeFormat(this.def)}get reflection(){return new ReflectionFormat(this.def)}get adjustments(){return new Adjustments(this.def)}_ends(e){if(this.def.path||!M(this.def.geometry))throw new Error(`${this.def.name}.${e}: it is not a connector (add_connector makes one).`);return se(this._frame(),this.def.flip,this.def.rotation)}_move(e,t){const r=re(e,t,this.def.rotation);this.def.frame=r.frame,r.flip?this.def.flip=r.flip:Reflect.deleteProperty(this.def,"flip")}get begin_x(){return l(Math.round(this._ends("begin_x")[0][0]))}set begin_x(e){const[t,r]=this._ends("begin_x");this._move([e,t[1]],r)}get begin_y(){return l(Math.round(this._ends("begin_y")[0][1]))}set begin_y(e){const[t,r]=this._ends("begin_y");this._move([t[0],e],r)}get end_x(){return l(Math.round(this._ends("end_x")[1][0]))}set end_x(e){const[t,r]=this._ends("end_x");this._move(t,[e,r[1]])}get end_y(){return l(Math.round(this._ends("end_y")[1][1]))}set end_y(e){const[t,r]=this._ends("end_y");this._move(t,[r[0],e])}begin_connect(e,t){this._connect("begin",e,t)}end_connect(e,t){this._connect("end",e,t)}_connect(e,t,r){const s=`${e}_connect`,[n,o]=this._ends(s);if(!(t instanceof Shape))throw new Error(`${this.def.name}.${s}(): its shape is a Shape.`);const h=t._def,f={frame:t._frame(),geometry:h.geometry,adjustments:h.adjustments,flip:h.flip,rotation:h.rotation,path:h.path},c=ne(f).length;if(!Number.isInteger(r)||r<0||r>=c)throw new Error(`${this.def.name}.${s}(): ${h.name} has connection sites 0 to ${String(c-1)}; ${String(r)} is not one.`);const u=ie(f,r)??(e==="begin"?n:o);this.def.connect={...this.def.connect,[e]:{shape:h.name,site:r}},this._move(e==="begin"?u:n,e==="begin"?o:u)}}const Le=i=>typeof i=="number"&&Number.isFinite(i),_=(i,e,t,r)=>{for(const[s,n]of Object.entries({left:i,top:e,width:t,height:r}))if(!Le(n))throw new Error(`${s} ${String(n)} is not a length (Emu, Inches, Pt, Cm, Mm).`);if(t<0||r<0)throw new Error("A shape's width and height are 0 or more.");return{left:Math.trunc(i),top:Math.trunc(e),width:Math.trunc(t),height:Math.trunc(r)}},Pe=new Set(Object.values(D));export class FreeformBuilder{steps;sx;sy;make;constructor(e,t,r){return this.steps=[{op:"move",x:e[0],y:e[1]}],[this.sx,this.sy]=typeof t=="number"?[t,t]:t,this.make=r,a(this,"FreeformBuilder")}add_line_segments(e,t=!0){for(const[r,s]of e)this.steps.push({op:"line",x:r,y:s});return t&&this.steps.push({op:"close"}),this}add_curve_segment(e,t,r,s,n,o){if(![e,t,r,s,n,o].every(h=>Number.isFinite(h)))throw new Error("add_curve_segment(x1, y1, x2, y2, x, y) takes six numbers in local units: its two control points and the point it ends at.");return this.steps.push({op:"curve",x1:e,y1:t,x2:r,y2:s,x:n,y:o}),this}move_to(e,t){return this.steps.push({op:"move",x:e,y:t}),this}convert_to_shape(e=0,t=0){this.steps.length<2&&refuse("convert_to_shape(): a freeform needs a segment.");const r=this.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),s=r.map(d=>d[0]),n=r.map(d=>d[1]),o=Math.min(...s),h=Math.min(...n),f=Math.max(...s)-o,c=Math.max(...n)-h;f===0&&c===0&&refuse("convert_to_shape(): a freeform's points are all one point.");const u=(d,m)=>({x:d-o,y:m-h});return this.make({w:f,h:c,steps:this.steps.map(d=>{if(d.op==="close")return d;if(d.op!=="curve")return{op:d.op,...u(d.x,d.y)};const m=u(d.x1,d.y1),y=u(d.x2,d.y2);return{op:"curve",x1:m.x,y1:m.y,x2:y.x,y2:y.y,...u(d.x,d.y)}})},_(Math.round(o*this.sx)+e,Math.round(h*this.sy)+t,Math.round(f*this.sx),Math.round(c*this.sy)))}}export class GroupShape{list;_name;make;constructor(e,t,r){return this.list=e,this._name=t,this.make=r,a(this,"GroupShape")}members(){return this.list.filter(e=>I(e.group,this._name))}box(){const e=this.members().flatMap(s=>s.frame?[s.frame]:[]),t=Math.min(...e.map(s=>s.left)),r=Math.min(...e.map(s=>s.top));return{left:e.length>0?t:0,top:e.length>0?r:0,right:Math.max(0,...e.map(s=>s.left+s.width)),bottom:Math.max(0,...e.map(s=>s.top+s.height))}}get shapes(){return this.make(this._name)}get shape_type(){return _e.GROUP}get name(){return this._name.split("/").pop()??this._name}set name(e){const t=this._name.lastIndexOf("/"),r=t<0?e:`${this._name.slice(0,t)}/${e}`;for(const s of this.members())s.group=`${r}${(s.group??"").slice(this._name.length)}`;this._name=r}get left(){return l(this.box().left)}set left(e){const t=e-this.box().left;for(const r of this.members())r.frame&&(r.frame.left+=t)}get top(){return l(this.box().top)}set top(e){const t=e-this.box().top;for(const r of this.members())r.frame&&(r.frame.top+=t)}get width(){const e=this.box();return l(e.right-e.left)}get height(){const e=this.box();return l(e.bottom-e.top)}}export class Cell{def;table;row;col;constructor(e,t,r,s){return this.def=e,this.table=t,this.row=r,this.col=s,a(this,"_Cell")}get text_frame(){return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e})}get borders(){return this.def.borders??{}}set borders(e){this.def.borders=Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r,color:N(r.color,`A cell's ${t} border`)}]))}get margin_left(){return l(this.def.text.margin_left??w.left)}set margin_left(e){this.def.text.margin_left=e}get margin_right(){return l(this.def.text.margin_right??w.right)}set margin_right(e){this.def.text.margin_right=e}get margin_top(){return l(this.def.text.margin_top??w.top)}set margin_top(e){this.def.text.margin_top=e}get margin_bottom(){return l(this.def.text.margin_bottom??w.bottom)}set margin_bottom(e){this.def.text.margin_bottom=e}get vertical_anchor(){return this.def.text.vertical_anchor}set vertical_anchor(e){e===void 0?delete this.def.text.vertical_anchor:this.def.text.vertical_anchor=e}get is_merge_origin(){return(this.def.span_width??1)>1||(this.def.span_height??1)>1}get is_spanned(){return this.def.spanned===!0}get span_width(){return this.def.span_width??1}get span_height(){return this.def.span_height??1}merge(e){const t=[this.row,e.row].sort((f,c)=>f-c),r=[this.col,e.col].sort((f,c)=>f-c),[s=0,n=0]=t,[o=0,h=0]=r;for(let f=s;f<=n;f++)for(let c=o;c<=h;c++){const u=this.table.rows[f]?.cells[c];u&&(f===s&&c===o?(h>o&&(u.span_width=h-o+1),n>s&&(u.span_height=n-s+1)):u.spanned=!0)}}split(){const e=this.span_width,t=this.span_height;delete this.def.span_width,delete this.def.span_height;for(let r=this.row;r<this.row+t;r++)for(let s=this.col;s<this.col+e;s++){const n=this.table.rows[r]?.cells[s];n&&delete n.spanned}}}export class Column{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Column")}get width(){return l(this.def.columns[this.at]??0)}set width(e){this.def.columns[this.at]=e}}export class Row{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Row")}get row(){const e=this.def.rows[this.at];if(!e)throw new Error(`The table has no row ${String(this.at)}.`);return e}get height(){return l(this.row.height)}set height(e){this.row.height=e}}export class Table{def;constructor(e){return this.def=e,a(this,"Table")}cell(e,t){const r=this.def.rows[e]?.cells[t];if(!r)throw new Error(`cell(): the table has ${String(this.def.rows.length)} rows and ${String(this.def.columns.length)} columns.`);return new Cell(r,this.def,e,t)}*iter_cells(){for(let e=0;e<this.def.rows.length;e++)for(let t=0;t<this.def.columns.length;t++)yield this.cell(e,t)}get columns(){return this.def.columns.map((e,t)=>new Column(this.def,t))}get rows(){return this.def.rows.map((e,t)=>new Row(this.def,t))}get style(){return Z(this.def.style)?.name??null}set style(e){if(e===null){delete this.def.style;return}const t=Z(e)??refuse(`Table.style: ${e} is none of PowerPoint's built-in table styles (${$e.slice(0,3).map(r=>r.name).join(", ")}…).`);this.def.style=t.id}flag(e){return this.def[e]===!0}get first_row(){return this.flag("first_row")}set first_row(e){this.def.first_row=e}get first_col(){return this.flag("first_col")}set first_col(e){this.def.first_col=e}get last_row(){return this.flag("last_row")}set last_row(e){this.def.last_row=e}get last_col(){return this.flag("last_col")}set last_col(e){this.def.last_col=e}get horz_banding(){return this.flag("horz_banding")}set horz_banding(e){this.def.horz_banding=e}get vert_banding(){return this.flag("vert_banding")}set vert_banding(e){this.def.vert_banding=e}}function Fe(i,e,t=[]){const r=new Set([...i,...t].map(n=>n.name));let s=1;for(;r.has(`${e}-${String(s)}`);)s++;return`${e}-${String(s)}`}export class ShapeCollection{list;base;components;inherit;group;under;constructor(e,t,r,s=()=>{},n=()=>[],o){return this.list=e,this.base=t,this.components=r,this.inherit=s,this.under=n,this.group=o,a(this,"SlideShapes",{index:h=>this._at(h)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}_at(e){const t=this.list[e];return t?this._wrap(t):void 0}*[Symbol.iterator](){for(const e of this.list)yield this._wrap(e)}get length(){return this.list.length}get(e){const t=this.list.find(r=>r.name===e);return t?this._wrap(t):void 0}get title(){const e=this.list.find(t=>t.placeholder?.type==="title"||t.placeholder?.type==="ctrTitle");return e?this._wrap(e):void 0}get placeholders(){return new Placeholders(this.list,this.inherit)}_add(e,t){const r={name:Fe(this.list,e,this.under()),...t,...this.group===void 0?{}:{group:this.group}};return this.list.push(r),this._wrap(r)}add_textbox(e,t,r,s){return this._add("textbox",{kind:"textbox",frame:_(e,t,r,s),text:{...E(),...Se}})}add_picture(e,t,r,s,n){return(s===void 0||n===void 0)&&refuse("add_picture() takes a width and a height here: a picture's own size is not read while a deck's code runs"),this._add("picture",{kind:"picture",frame:_(t,r,s??0,n??0),media:{path:e,base:this.base}})}add_movie(e,t,r,s,n,o={}){return this._add("movie",{kind:"movie",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.poster_frame_time===void 0?{}:{poster:o.poster_frame_time},...o.playback?{playback:{...o.playback}}:{}}})}add_audio(e,t,r,s=W.icon,n=W.icon,o={}){return this._add("audio",{kind:"audio",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.playback?{playback:{...o.playback}}:{}}})}add_shape(e,t,r,s,n){Pe.has(e)||refuse(`add_shape(): ${e} is not one of MSO_SHAPE's ${Object.keys(D).join(", ")}`);const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("shape",{kind:"autoshape",frame:_(t,r,s,n),geometry:e,fill:g.fill,line:g.line,line_width:g.line_width,text:o})}add_table(e,t,r,s,n,o){(e<1||t<1)&&refuse("add_table(): a table has at least a row and a column.");const h=Math.floor(n/t),f=Math.floor(o/e);return this._add("table",{kind:"table",frame:_(r,s,n,o),table:{style:Oe,first_row:!0,horz_banding:!0,columns:Array.from({length:t},()=>h),rows:Array.from({length:e},()=>({height:f,cells:Array.from({length:t},()=>({text:E()}))}))}})}add_chart(e,t,r,s,n,o){return this._add("chart",{kind:"chart",frame:_(t,r,s,n),chart:{type:e,categories:[...o.categories],series:o._series()}})}add_group_shape(){const e=this.group===void 0?"":`${this.group}/`;let t=1;for(;this.list.some(r=>I(r.group,`${e}group-${String(t)}`));)t++;return new GroupShape(this.list,`${e}group-${String(t)}`,r=>new ShapeCollection(this.list,this.base,this.components,this.inherit,this.under,r))}build_freeform(e=0,t=0,r=1){return new FreeformBuilder([e,t],r,(s,n)=>{const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("freeform",{kind:"autoshape",frame:n,path:s,fill:g.fill,line:g.line,line_width:g.line_width,text:o})})}add_connector(e,t,r,s,n){M(e)||refuse(`add_connector(): ${e} is not one of MSO_CONNECTOR's ${Object.keys(he).join(", ")}, nor a connector's preset (${be.join(", ")})`);const o=_(Math.min(t,s),Math.min(r,n),Math.abs(s-t),Math.abs(n-r)),h=s<t,f=n<r;return this._add("connector",{kind:"autoshape",frame:o,geometry:e,...h||f?{flip:{...h?{h}:{},...f?{v:f}:{}}}:{},line:Y.line,line_width:Y.line_width})}add_component(e,t,r,s,n,o={},h={}){if(!Object.hasOwn(this.components(),e))throw new Error(`add_component(): the presentation has no component ${e}; add it with prs.components.add("${e}", { … }) first.`);if(h.dur!==void 0&&!(Number.isFinite(h.dur)&&h.dur>0))throw new Error(`add_component(): dur is how long ${e} moves, seconds over 0; it was ${String(h.dur)}.`);return this._add(e,{kind:"component",frame:_(t,r,s,n),component:{name:e,props:o,...h.dur===void 0?{}:{dur:h.dur}}})}}export const NAME_OF_TYPE={title:"title",ctrTitle:"title",subTitle:"subtitle",body:"body",pic:"picture",media:"media",obj:"content",dt:"date",ftr:"footer",sldNum:"slide-number"};export class Placeholders{list;inherit;constructor(e,t=()=>{}){return this.list=e,this.inherit=t,a(this,"placeholders",{index:r=>this.get(r)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}*[Symbol.iterator](){for(const e of this.list)e.kind==="placeholder"&&(yield this._wrap(e))}get length(){return this.list.filter(e=>e.kind==="placeholder").length}get(e){const t=this.list.find(r=>r.kind==="placeholder"&&(typeof e=="number"?r.placeholder?.idx===e:r.name===e||r.placeholder?.type===e));return t?this._wrap(t):void 0}add(e,t,r,s,n,o={}){const h=typeof t=="object"?t:o,f=typeof t=="object"?void 0:t;Object.values(H).includes(e)||refuse(`placeholders.add(): ${e} is not one of PP_PLACEHOLDER's ${Object.keys(H).join(", ")}`);const c=this.list.filter(b=>b.kind==="placeholder"),u=new Set(c.map(b=>b.placeholder?.idx));let d=e==="title"||e==="ctrTitle"?0:ye[e]??1;for(u.has(d)&&d===0&&(d=1);u.has(d);)d++;const m=h.name??NAME_OF_TYPE[e];if(this.list.some(b=>b.name===m))throw new Error(`Two shapes are ${m}: give the placeholder a name ({ name }).`);const y=[f,r,s,n].filter(b=>b!==void 0);if(y.length!==0&&y.length!==4)throw new Error("placeholders.add(type, left, top, width, height): give all four, or none to take the master's frame.");const L={name:m,kind:"placeholder",placeholder:{type:e,idx:d,...h.orient==="vert"?{orient:"vert"}:{}},...y.length===4?{frame:_(f??0,r??0,s??0,n??0)}:{},text:{paragraphs:[],levels:Ee(e)}};return this.list.push(L),this._wrap(L)}}export class SlideLayout{def;master;ctx;constructor(e,t,r){return this.def=e,this.master=t,this.ctx=r,a(this,"SlideLayout")}get _def(){return this.def}inherit=e=>e.placeholder?X(this.master._def,e.placeholder.type)?.frame:void 0;get name(){return this.def.name}get slide_master(){return this.master}get display_master_shapes(){return this.def.display_master_shapes??!0}set display_master_shapes(e){e?delete this.def.display_master_shapes:this.def.display_master_shapes=!1}get color_map(){return this.def.color_map&&{...this.def.color_map}}set color_map(e){e===void 0?delete this.def.color_map:this.def.color_map=K(e)}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes,this.inherit)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components,this.inherit,()=>this.master._def.shapes)}}export class SlideLayouts{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideLayouts",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}get_by_name(e,t){return this.list.find(r=>r.name===e)??t}index(e){const t=this.list.indexOf(e);if(t<0)throw new Error(`${e.name} is not among these layouts.`);return t}add(e,t){if(!this.make)throw new Error("A layout is added to a master: master.slide_layouts.add(name).");const r=this.make(e);return t?.(r),r}}export class TextStyles{def;constructor(e){return this.def=e,a(this,"text_styles")}get title_style(){return k(this.def.title)}get body_style(){return k(this.def.body)}get other_style(){return k(this.def.other)}}export class SlideMaster{def;layouts=[];ctx;allLayouts;constructor(e,t,r){return this.def=e,this.ctx=t,this.allLayouts=r,a(this,"SlideMaster")}get _def(){return this.def}get name(){return this.def.name}get color_map(){return{...OFFICE_COLOR_MAP,...this.def.color_map}}set color_map(e){const t=K(e),r=Object.fromEntries(Object.entries(t).filter(([s,n])=>OFFICE_COLOR_MAP[s]!==n));Object.keys(r).length===0?delete this.def.color_map:this.def.color_map=r}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components)}get text_styles(){return new TextStyles(this.def.text_styles)}get slide_layouts(){return new SlideLayouts(this.layouts,e=>{if(this.allLayouts.some(s=>s.name===e))throw new Error(`Two layouts are "${e}": a layout's name is unique in the deck, as its slides file names it.`);const t={name:e,master:this.def.name,shapes:[]};this.def.layouts.push(t);const r=new SlideLayout(t,this,this.ctx);return this.layouts.push(r),this.allLayouts.push(r),r})}}export class SlideMasters{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideMasters",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}index(e){return this.list.indexOf(e)}add(e,t){const r=this.make(e);return t?.(r),r}}export class GeneratedSlide{own;def;layout;constructor(e,t,r){this.def=e,this.layout=t,this.own=t._def.shapes.filter(n=>n.kind==="placeholder").map(n=>({name:n.name,kind:"placeholder",...n.placeholder?{placeholder:{...n.placeholder}}:{},text:E()}));const s=n=>{const o=t._def.shapes.find(h=>h.kind==="placeholder"&&h.placeholder?.idx===n.placeholder?.idx);return o?o.frame??(o.placeholder?X(t.slide_master._def,o.placeholder.type)?.frame:void 0):void 0};return this._shapes=new ShapeCollection(this.own,r.base,r.components,s,()=>[...t.slide_master._def.shapes,...t._def.shapes]),this._placeholders=new Placeholders(this.own,s),a(this,"Slide")}_shapes;_placeholders;get shapes(){return this._shapes}get placeholders(){return this._placeholders}get slide_id(){return this.def.id}get slide_layout(){return this.layout}get has_notes_slide(){return this.def.notes!==void 0}get notes_slide(){const e=this.def;return a({notes_text_frame:a({get text(){return e.notes??""},set text(t){e.notes=t}},"TextFrame")},"NotesSlide")}get transition(){return this.def.transition}set transition(e){e===void 0?delete this.def.transition:this.def.transition=e}get animations(){return new Animations(this.def.animations??=[])}_done(){const e={},t=[];for(const r of this.own)r.kind==="placeholder"&&r.placeholder?(r.text?.paragraphs.some(s=>s.runs.length>0)&&(e[r.placeholder.idx]=r.text.paragraphs),r.frame&&t.push({...r,text:E()})):t.push(r);return{...this.def,shapes:t,text:e}}}export class Animations{list;constructor(e){return this.list=e,a(this,"Animations")}add(e,t,r={}){this.list.push({shape:typeof e=="string"?e:e.name,effect:t,...r})}get length(){return this.list.length}}class ze{gen;constructor(e){return this.gen=e,a(this,"slides")}add_slide(e,t){return this.gen._add(e,t)}}export class Generator{list=[];prs;ctx;constructor(e,t){return this.prs=e,this.ctx=t,a(this,"Generator")}data(e){return this.ctx.data(e)}get slides(){return new ze(this)}_add(e,t){const r=typeof e=="string"?this.prs._layout(e):e;if(!r)throw new Error(`add_slide(): the presentation has no layout ${typeof e=="string"?e:e.name}.`);if(!/^[A-Za-z0-9_-]+$/u.test(t))throw new Error(`add_slide(): ${t} is not an id of letters, digits, _ and -.`);if(this.list.some(n=>n.slide_id===t))throw new Error(`add_slide(): two slides are ${t}.`);const s=new GeneratedSlide({id:t,layout:r.name,shapes:[],text:{}},r,this.prs._ctx);return this.list.push(s),s}_made(){return this.list.map(e=>e._done())}}const Ie=()=>JSON.parse(JSON.stringify(xe));export class Presentation{masters=[];layouts=[];def;_ctx;constructor(e,t){return this.def={slide_width:e[0],slide_height:e[1],masters:[],components:{},generators:{}},this._ctx={base:t,components:()=>this.def.components},a(this,"Presentation")}get _def(){return this.def}get slide_width(){return l(this.def.slide_width)}set slide_width(e){this.def.slide_width=e}get slide_height(){return l(this.def.slide_height)}set slide_height(e){this.def.slide_height=e}get slide_masters(){return new SlideMasters(this.masters,e=>{if(this.masters.some(s=>s.name===e))throw new Error(`Two masters are "${e}".`);const t={name:e,background:"bg1",text_styles:Ie(),shapes:[],layouts:[]};this.def.masters.push(t);const r=new SlideMaster(t,this._ctx,this.layouts);return this.masters.push(r),r})}get slide_master(){const e=this.masters[0];if(!e)throw new Error("The presentation has no master yet: prs.slide_masters.add(name) makes one.");return e}get slide_layouts(){const e=this.masters[0];return e?e.slide_layouts:new SlideLayouts([])}get slides(){return refuse("A deck's slides are in the slides file presentation({ slides }) names, in order, each on a layout, and their words in its script; slides made from data are a generator's (prs.generators.add)")}save(){return refuse("A deck is not saved by its code: allyhub render writes its PDF, pictures and PPTX")}get theme(){return this.def.theme??={},this.def.theme}set theme(e){this.def.theme=e}get components(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.components,e))throw new Error(`Two components are "${e}".`);const r=oe(e,t);if(!r)throw new Error(`Component ${e} is not a component: give what defineComponent makes, or { props, layers }.`);this.def.components[e]=r}},"components")}get generators(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.generators,e))throw new Error(`Two generators are "${e}".`);this.def.generators[e]={name:e,make:r=>{const s=new Generator(this,r);return t(s),s._made()}}}},"generators")}_layout(e){return this.layouts.find(t=>t.name===e)}}export const DECK_BRAND="__allyhubDeck";export function isDeck(i){return typeof i=="object"&&i!==null&&DECK_BRAND in i}export const presentationFor=i=>(e,t)=>{const[r,s]=typeof e=="function"?[{},e]:[e,t];if(typeof s!="function")throw new Error(`A deck's module exports one deck: export default presentation({ slides: "./deck.yaml", script: "./deck.{locale}.yaml", size }, (prs) => { … masters, layouts, components … }), its slides and its script named from its folder.`);if(r.script!==void 0&&!r.script.includes("{locale}"))throw new Error(`presentation(): script ${r.script} names one file: write {locale} in its name for each language (./deck.{locale}.yaml).`);if(typeof r.size=="string"&&!Object.hasOwn(j,r.size))throw new Error(`presentation(): size ${r.size} is not one of ${Object.keys(j).join(", ")}, or { width, height } in EMU.`);return{[DECK_BRAND]:!0,kind:"slides",options:r,build:s,written:{file:i}}};export function evaluateDeck(i){const e=i.options.size??"16:9",t=typeof e=="string"?j[e]:[e.width,e.height],r=i.written.file.split("/").slice(0,-1).join("/"),s=new Presentation(t,r);return i.options.theme&&(s.theme=JSON.parse(JSON.stringify(i.options.theme))),i.build(s),s._def}
|
|
4
|
+
`).map(t=>({runs:V(t),level:0}))}get paragraphs(){return this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0}),this.def.paragraphs.map(e=>new Paragraph(e))}add_paragraph(){this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0});const e={runs:[],level:0};return this.def.paragraphs.push(e),new Paragraph(e)}clear(){const e=this.def.paragraphs[0];this.def.paragraphs=e?[{...e,runs:[]}]:[]}fit_text(e,t=18,r,s){this.def.auto_size="text",this.def.word_wrap=!0;for(const n of this.def.paragraphs)for(const o of n.runs)o.font={...o.font,size:Math.trunc(t*R),...e===void 0?{}:{name:e},...r===void 0?{}:{bold:r},...s===void 0?{}:{italic:s}}}get list_style(){return k(this.def.levels)}get vertical_anchor(){return this.def.vertical_anchor}set vertical_anchor(e){this._set("vertical_anchor",e)}get orientation(){return this.def.orientation}set orientation(e){if(e!==void 0&&!Object.values(G).includes(e))throw new Error(`orientation is one of MSO_TEXT_ORIENTATION's ${Object.values(G).join(", ")}, not ${e}.`);this._set("orientation",e)}get auto_size(){return this.def.auto_size}set auto_size(e){this._set("auto_size",e)}get word_wrap(){return this.def.word_wrap}set word_wrap(e){this._set("word_wrap",e)}get margin_left(){return l(this.def.margin_left??w.left)}set margin_left(e){this.def.margin_left=e}get margin_top(){return l(this.def.margin_top??w.top)}set margin_top(e){this.def.margin_top=e}get margin_right(){return l(this.def.margin_right??w.right)}set margin_right(e){this.def.margin_right=e}get margin_bottom(){return l(this.def.margin_bottom??w.bottom)}set margin_bottom(e){this.def.margin_bottom=e}}export class FillFormat{read;write;start;shape;base;constructor(e,t,r="lt1",s,n=""){return this.read=e,this.write=t,this.start=r,this.shape=s,this.base=n,a(this,"FillFormat")}_only(e){if(this.shape)for(const t of["gradient","pattern","picture_fill"])t!==e&&Reflect.deleteProperty(this.shape,t)}solid(){const e=this.read();this._only("solid"),e==null&&this.write(this.start)}background(){this._only("solid"),this.write(null)}patterned(){const e=this._shape("a pattern");this._only("pattern"),e.pattern??={preset:"pct5",fg:O.fg,bg:O.bg}}get pattern(){return this._pattern().preset}set pattern(e){this._pattern().preset=p(ue,"MSO_PATTERN_TYPE","pattern",e)}_pattern(){const{pattern:e}=this._shape("a pattern");if(!e)throw new TypeError("This fill is no pattern: call fill.patterned() first.");return e}get back_color(){const e=this._pattern();return new ColorFormat(()=>e.bg,t=>{e.bg=t??O.bg})}picture(e,t={}){const r=this._shape("a picture");this._only("picture_fill"),r.picture_fill={path:e,base:this.base,...t.tile?{tile:{...B,...t.tile,align:p(pe,"TILE_ALIGNMENT","tile.align",t.tile.align??B.align)}}:{},...t.transparency===void 0?{}:{transparency:t.transparency}}}_shape(e){if(!this.shape)throw new TypeError(`Only a shape's fill has ${e}.`);return this.shape}gradient(){this._only("gradient"),this._shape("a gradient").gradient??={angle:90,stops:[{at:0,color:"accent1"},{at:1,color:"accent2"}]}}get gradient_path(){return this._gradient().path??"linear"}set gradient_path(e){const t=this._gradient();e==="linear"?delete t.path:z.includes(e)?t.path=e:refuse(`gradient_path is "linear", ${z.map(r=>`"${r}"`).join(", ")}, not ${e}.`)}get gradient_focus(){return{...this._gradient().focus??{left:.5,top:.5,right:.5,bottom:.5}}}set gradient_focus(e){this._gradient().focus={...e}}get gradient_angle(){return this._gradient().angle}set gradient_angle(e){this._gradient().angle=e}get gradient_stops(){return this._gradient().stops.map(e=>new GradientStop(e))}set gradient_stops(e){if(e.length<2)throw new Error("A gradient has two stops at least.");this._gradient().stops=e.map(t=>t instanceof GradientStop?GradientStop.defOf(t):{...t,color:N(t.color,"A gradient stop's colour")})}_gradient(){const{gradient:e}=this._shape("a gradient");if(!e)throw new TypeError("This fill is no gradient: call fill.gradient() first.");return e}get transparency(){return this._shape("a transparency").fill_transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);this._shape("a transparency").fill_transparency=e}get type(){if(this.shape?.picture_fill)return"picture";if(this.shape?.pattern)return"patterned";if(this.shape?.gradient)return"gradient";const e=this.read();return e===void 0?void 0:e===null?"background":"solid"}get fore_color(){const e=this.shape?.pattern;if(e)return new ColorFormat(()=>e.fg,r=>{e.fg=r??O.fg});const t=this.read();if(t==null)throw new TypeError("This fill is not solid, so it has no fore_color: call fill.solid() first.");return new ColorFormat(()=>this.read()??void 0,r=>{this.write(r??this.start)})}}export class GradientStop{stop;constructor(e){return this.stop=e,a(this,"GradientStop")}static defOf(e){return{...e.stop}}get color(){return new ColorFormat(()=>this.stop.color,e=>{e!==void 0&&(this.stop.color=e)})}get position(){return this.stop.at}set position(e){if(!(e>=0&&e<=1))throw new Error(`A stop's position is a share, 0 to 1, not ${String(e)}.`);this.stop.at=e}get transparency(){return this.stop.transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);e===0?Reflect.deleteProperty(this.stop,"transparency"):this.stop.transparency=e}}export class ShadowFormat{def;inner;constructor(e,t=!1){return this.def=e,this.inner=t,a(this,"ShadowFormat")}_shadow(){return this.inner?(this.def.inner_shadow??={...me},this.def.inner_shadow):(this.def.shadow??={...U},this.def.shadow)}get visible(){return this.inner?this.def.inner_shadow!==void 0:this.def.shadow!==void 0&&this.def.shadow!==null}set visible(e){e?this._shadow():this.inner?Reflect.deleteProperty(this.def,"inner_shadow"):this.def.shadow=null}get inherit(){return this.def.shadow===void 0}set inherit(e){e?Reflect.deleteProperty(this.def,"shadow"):this.def.shadow??=null}get blur_radius(){return l(this._shadow().blur)}set blur_radius(e){this._shadow().blur=e}get distance(){return l(this._shadow().distance)}set distance(e){this._shadow().distance=e}get angle(){return this._shadow().angle}set angle(e){this._shadow().angle=e}get transparency(){return this._shadow().transparency}set transparency(e){this._shadow().transparency=e}get color(){const e=this._shadow();return new ColorFormat(()=>e.color,t=>{e.color=t??U.color})}}export class GlowFormat{def;constructor(e){return this.def=e,a(this,"GlowFormat")}_glow(){return this.def.glow??={...v},this.def.glow}get visible(){return this.def.glow!==void 0}set visible(e){e?this._glow():Reflect.deleteProperty(this.def,"glow")}get radius(){return l(this.def.glow?.size??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"glow"):this._glow().size=e}get transparency(){return this._glow().transparency}set transparency(e){this._glow().transparency=e}get color(){const e=this._glow();return new ColorFormat(()=>e.color,t=>{e.color=t??v.color})}}export class SoftEdgeFormat{def;constructor(e){return this.def=e,a(this,"SoftEdgeFormat")}get radius(){return l(this.def.soft_edges??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"soft_edges"):this.def.soft_edges=e}}export class ReflectionFormat{def;constructor(e){return this.def=e,a(this,"ReflectionFormat")}_reflection(){return this.def.reflection??={...we},this.def.reflection}get visible(){return this.def.reflection!==void 0}set visible(e){e?this._reflection():Reflect.deleteProperty(this.def,"reflection")}get transparency(){return this._reflection().transparency}set transparency(e){this._reflection().transparency=e}get size(){return this._reflection().size}set size(e){this._reflection().size=e}get offset(){return l(this._reflection().distance)}set offset(e){this._reflection().distance=e}get blur(){return l(this._reflection().blur)}set blur(e){this._reflection().blur=e}}export class LineFormat{def;constructor(e){return this.def=e,a(this,"LineFormat")}get color(){return new ColorFormat(()=>this.def.line??void 0,e=>{this.def.line=e??null})}get fill(){return new FillFormat(()=>this.def.line,e=>{this.def.line=e},"dk1")}get width(){return l(this.def.line_width??0)}set width(e){this.def.line_width=e}get dash_style(){return this.def.line_dash??null}set dash_style(e){e===null?delete this.def.line_dash:this.def.line_dash=p(de,"MSO_LINE","dash_style",e)}get cap_type(){return this.def.line_cap??x.cap}set cap_type(e){const t=p(le,"MSO_LINE_CAP","cap_type",e);t===x.cap?delete this.def.line_cap:this.def.line_cap=t}get join_type(){return this.def.line_join??x.join}set join_type(e){const t=p(ce,"MSO_LINE_JOIN","join_type",e);t===x.join?delete this.def.line_join:this.def.line_join=t}get compound_type(){return this.def.line_compound??x.compound}set compound_type(e){const t=p(fe,"MSO_LINE_COMPOUND","compound_type",e);t===x.compound?delete this.def.line_compound:this.def.line_compound=t}get begin_arrow(){return this.def.line_begin??"none"}set begin_arrow(e){this.def.line_begin=p(C,"MSO_ARROWHEAD","begin_arrow",e)}get end_arrow(){return this.def.line_end??"none"}set end_arrow(e){this.def.line_end=p(C,"MSO_ARROWHEAD","end_arrow",e)}get begin_arrow_width(){return this.def.line_begin_size?.w??"med"}set begin_arrow_width(e){this.def.line_begin_size={...this.def.line_begin_size,w:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_width",e)}}get begin_arrow_length(){return this.def.line_begin_size?.len??"med"}set begin_arrow_length(e){this.def.line_begin_size={...this.def.line_begin_size,len:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_length",e)}}get end_arrow_width(){return this.def.line_end_size?.w??"med"}set end_arrow_width(e){this.def.line_end_size={...this.def.line_end_size,w:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_width",e)}}get end_arrow_length(){return this.def.line_end_size?.len??"med"}set end_arrow_length(e){this.def.line_end_size={...this.def.line_end_size,len:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_length",e)}}}function p(i,e,t,r){if(Object.values(i).includes(r))return r;throw new Error(`${t}: ${String(r)} is not one of ${e}'s ${Object.keys(i).join(", ")}.`)}export class Background{holder;constructor(e){return this.holder=e,a(this,"_Background")}get fill(){return new FillFormat(()=>this.holder.background,e=>{this.holder.background=e??"bg1"})}}export const adjustmentDefaults=i=>te(i).map(e=>e.value/1e5);export class Adjustments{def;constructor(e){return this.def=e,a(this,"Adjustments",{index:t=>this._values()[t],setIndex:(t,r)=>{this._set(t,Number(r))}})}_values(){return this.def.adjustments??adjustmentDefaults(this.def.geometry??"rect")}get length(){return this._values().length}_set(e,t){const r=this._values();if(e<0||e>=r.length)throw new RangeError(`adjustments[${String(e)}]: ${this.def.geometry??"this shape"} has ${String(r.length)}.`);if(!Number.isFinite(t))throw new Error(`adjustments[${String(e)}] = ${String(t)} is not a number.`);r[e]=t,this.def.adjustments=r}}const Ne={left:0,top:0,width:0,height:0};export class Shape{def;inherit;base;constructor(e,t=()=>{},r=""){return this.def=e,this.inherit=t,this.base=r,a(this,"Shape")}get _def(){return this.def}_frame(){return this.def.frame??this.inherit()??Ne}_own(){return this.def.frame??={...this._frame()},this.def.frame}get name(){return this.def.name}set name(e){this.def.name=e}get shape_type(){return this.def.path?"freeform":this.def.kind==="audio"||this.def.kind==="item"?"movie":M(this.def.geometry)?"line":this.def.kind}get is_placeholder(){return this.def.kind==="placeholder"}get has_table(){return this.def.table!==void 0}get has_chart(){return this.def.chart!==void 0}get chart(){if(!this.def.chart)throw new Error(`${this.def.name} is not a chart.`);return new ge(this.def.chart)}get table(){if(!this.def.table)throw new Error(`${this.def.name} is not a table.`);return new Table(this.def.table)}get placeholder_format(){if(!this.def.placeholder)throw new Error(`${this.def.name} is not a placeholder.`);return a({...this.def.placeholder},"_PlaceholderFormat")}get left(){return l(this._frame().left)}set left(e){this._own().left=e}get top(){return l(this._frame().top)}set top(e){this._own().top=e}get width(){return l(this._frame().width)}set width(e){this._own().width=e}get height(){return l(this._frame().height)}set height(e){this._own().height=e}get rotation(){return this.def.rotation??0}set rotation(e){if(!Number.isFinite(e))throw new Error(`${this.def.name}: rotation is a number of degrees.`);const t=(Math.trunc(e*6e4)%216e5+216e5)%216e5/6e4;t===0?Reflect.deleteProperty(this.def,"rotation"):this.def.rotation=t}get flip_h(){return this.def.flip?.h===!0}set flip_h(e){this._flip("h",e)}get flip_v(){return this.def.flip?.v===!0}set flip_v(e){this._flip("v",e)}_flip(e,t){const r={...this.def.flip};t?r[e]=!0:Reflect.deleteProperty(r,e),Object.keys(r).length===0?Reflect.deleteProperty(this.def,"flip"):this.def.flip=r}get has_text_frame(){return this.def.text!==void 0}get text_frame(){if(!this.def.text)throw new Error(`${this.def.name} (a ${this.shape_type}) has no text frame: has_text_frame is false.`);return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e},"lt1",this.def,this.base)}get line(){return new LineFormat(this.def)}get shadow(){return new ShadowFormat(this.def)}get inner_shadow(){return new ShadowFormat(this.def,!0)}get glow(){return new GlowFormat(this.def)}get soft_edge(){return new SoftEdgeFormat(this.def)}get reflection(){return new ReflectionFormat(this.def)}get adjustments(){return new Adjustments(this.def)}_ends(e){if(this.def.path||!M(this.def.geometry))throw new Error(`${this.def.name}.${e}: it is not a connector (add_connector makes one).`);return se(this._frame(),this.def.flip,this.def.rotation)}_move(e,t){const r=re(e,t,this.def.rotation);this.def.frame=r.frame,r.flip?this.def.flip=r.flip:Reflect.deleteProperty(this.def,"flip")}get begin_x(){return l(Math.round(this._ends("begin_x")[0][0]))}set begin_x(e){const[t,r]=this._ends("begin_x");this._move([e,t[1]],r)}get begin_y(){return l(Math.round(this._ends("begin_y")[0][1]))}set begin_y(e){const[t,r]=this._ends("begin_y");this._move([t[0],e],r)}get end_x(){return l(Math.round(this._ends("end_x")[1][0]))}set end_x(e){const[t,r]=this._ends("end_x");this._move(t,[e,r[1]])}get end_y(){return l(Math.round(this._ends("end_y")[1][1]))}set end_y(e){const[t,r]=this._ends("end_y");this._move(t,[r[0],e])}begin_connect(e,t){this._connect("begin",e,t)}end_connect(e,t){this._connect("end",e,t)}_connect(e,t,r){const s=`${e}_connect`,[n,o]=this._ends(s);if(!(t instanceof Shape))throw new Error(`${this.def.name}.${s}(): its shape is a Shape.`);const h=t._def,f={frame:t._frame(),geometry:h.geometry,adjustments:h.adjustments,flip:h.flip,rotation:h.rotation,path:h.path},c=ne(f).length;if(!Number.isInteger(r)||r<0||r>=c)throw new Error(`${this.def.name}.${s}(): ${h.name} has connection sites 0 to ${String(c-1)}; ${String(r)} is not one.`);const u=ie(f,r)??(e==="begin"?n:o);this.def.connect={...this.def.connect,[e]:{shape:h.name,site:r}},this._move(e==="begin"?u:n,e==="begin"?o:u)}}const Le=i=>typeof i=="number"&&Number.isFinite(i),_=(i,e,t,r)=>{for(const[s,n]of Object.entries({left:i,top:e,width:t,height:r}))if(!Le(n))throw new Error(`${s} ${String(n)} is not a length (Emu, Inches, Pt, Cm, Mm).`);if(t<0||r<0)throw new Error("A shape's width and height are 0 or more.");return{left:Math.trunc(i),top:Math.trunc(e),width:Math.trunc(t),height:Math.trunc(r)}},Pe=new Set(Object.values(D));export class FreeformBuilder{steps;sx;sy;make;constructor(e,t,r){return this.steps=[{op:"move",x:e[0],y:e[1]}],[this.sx,this.sy]=typeof t=="number"?[t,t]:t,this.make=r,a(this,"FreeformBuilder")}add_line_segments(e,t=!0){for(const[r,s]of e)this.steps.push({op:"line",x:r,y:s});return t&&this.steps.push({op:"close"}),this}add_curve_segment(e,t,r,s,n,o){if(![e,t,r,s,n,o].every(h=>Number.isFinite(h)))throw new Error("add_curve_segment(x1, y1, x2, y2, x, y) takes six numbers in local units: its two control points and the point it ends at.");return this.steps.push({op:"curve",x1:e,y1:t,x2:r,y2:s,x:n,y:o}),this}move_to(e,t){return this.steps.push({op:"move",x:e,y:t}),this}convert_to_shape(e=0,t=0){this.steps.length<2&&refuse("convert_to_shape(): a freeform needs a segment.");const r=this.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),s=r.map(d=>d[0]),n=r.map(d=>d[1]),o=Math.min(...s),h=Math.min(...n),f=Math.max(...s)-o,c=Math.max(...n)-h;f===0&&c===0&&refuse("convert_to_shape(): a freeform's points are all one point.");const u=(d,m)=>({x:d-o,y:m-h});return this.make({w:f,h:c,steps:this.steps.map(d=>{if(d.op==="close")return d;if(d.op!=="curve")return{op:d.op,...u(d.x,d.y)};const m=u(d.x1,d.y1),y=u(d.x2,d.y2);return{op:"curve",x1:m.x,y1:m.y,x2:y.x,y2:y.y,...u(d.x,d.y)}})},_(Math.round(o*this.sx)+e,Math.round(h*this.sy)+t,Math.round(f*this.sx),Math.round(c*this.sy)))}}export class GroupShape{list;_name;make;constructor(e,t,r){return this.list=e,this._name=t,this.make=r,a(this,"GroupShape")}members(){return this.list.filter(e=>I(e.group,this._name))}box(){const e=this.members().flatMap(s=>s.frame?[s.frame]:[]),t=Math.min(...e.map(s=>s.left)),r=Math.min(...e.map(s=>s.top));return{left:e.length>0?t:0,top:e.length>0?r:0,right:Math.max(0,...e.map(s=>s.left+s.width)),bottom:Math.max(0,...e.map(s=>s.top+s.height))}}get shapes(){return this.make(this._name)}get shape_type(){return _e.GROUP}get name(){return this._name.split("/").pop()??this._name}set name(e){const t=this._name.lastIndexOf("/"),r=t<0?e:`${this._name.slice(0,t)}/${e}`;for(const s of this.members())s.group=`${r}${(s.group??"").slice(this._name.length)}`;this._name=r}get left(){return l(this.box().left)}set left(e){const t=e-this.box().left;for(const r of this.members())r.frame&&(r.frame.left+=t)}get top(){return l(this.box().top)}set top(e){const t=e-this.box().top;for(const r of this.members())r.frame&&(r.frame.top+=t)}get width(){const e=this.box();return l(e.right-e.left)}get height(){const e=this.box();return l(e.bottom-e.top)}}export class Cell{def;table;row;col;constructor(e,t,r,s){return this.def=e,this.table=t,this.row=r,this.col=s,a(this,"_Cell")}get text_frame(){return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e})}get borders(){return this.def.borders??{}}set borders(e){this.def.borders=Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r,color:N(r.color,`A cell's ${t} border`)}]))}get margin_left(){return l(this.def.text.margin_left??w.left)}set margin_left(e){this.def.text.margin_left=e}get margin_right(){return l(this.def.text.margin_right??w.right)}set margin_right(e){this.def.text.margin_right=e}get margin_top(){return l(this.def.text.margin_top??w.top)}set margin_top(e){this.def.text.margin_top=e}get margin_bottom(){return l(this.def.text.margin_bottom??w.bottom)}set margin_bottom(e){this.def.text.margin_bottom=e}get vertical_anchor(){return this.def.text.vertical_anchor}set vertical_anchor(e){e===void 0?delete this.def.text.vertical_anchor:this.def.text.vertical_anchor=e}get is_merge_origin(){return(this.def.span_width??1)>1||(this.def.span_height??1)>1}get is_spanned(){return this.def.spanned===!0}get span_width(){return this.def.span_width??1}get span_height(){return this.def.span_height??1}merge(e){const t=[this.row,e.row].sort((f,c)=>f-c),r=[this.col,e.col].sort((f,c)=>f-c),[s=0,n=0]=t,[o=0,h=0]=r;for(let f=s;f<=n;f++)for(let c=o;c<=h;c++){const u=this.table.rows[f]?.cells[c];u&&(f===s&&c===o?(h>o&&(u.span_width=h-o+1),n>s&&(u.span_height=n-s+1)):u.spanned=!0)}}split(){const e=this.span_width,t=this.span_height;delete this.def.span_width,delete this.def.span_height;for(let r=this.row;r<this.row+t;r++)for(let s=this.col;s<this.col+e;s++){const n=this.table.rows[r]?.cells[s];n&&delete n.spanned}}}export class Column{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Column")}get width(){return l(this.def.columns[this.at]??0)}set width(e){this.def.columns[this.at]=e}}export class Row{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Row")}get row(){const e=this.def.rows[this.at];if(!e)throw new Error(`The table has no row ${String(this.at)}.`);return e}get height(){return l(this.row.height)}set height(e){this.row.height=e}}export class Table{def;constructor(e){return this.def=e,a(this,"Table")}cell(e,t){const r=this.def.rows[e]?.cells[t];if(!r)throw new Error(`cell(): the table has ${String(this.def.rows.length)} rows and ${String(this.def.columns.length)} columns.`);return new Cell(r,this.def,e,t)}*iter_cells(){for(let e=0;e<this.def.rows.length;e++)for(let t=0;t<this.def.columns.length;t++)yield this.cell(e,t)}get columns(){return this.def.columns.map((e,t)=>new Column(this.def,t))}get rows(){return this.def.rows.map((e,t)=>new Row(this.def,t))}get style(){return Z(this.def.style)?.name??null}set style(e){if(e===null){delete this.def.style;return}const t=Z(e)??refuse(`Table.style: ${e} is none of PowerPoint's built-in table styles (${$e.slice(0,3).map(r=>r.name).join(", ")}…).`);this.def.style=t.id}flag(e){return this.def[e]===!0}get first_row(){return this.flag("first_row")}set first_row(e){this.def.first_row=e}get first_col(){return this.flag("first_col")}set first_col(e){this.def.first_col=e}get last_row(){return this.flag("last_row")}set last_row(e){this.def.last_row=e}get last_col(){return this.flag("last_col")}set last_col(e){this.def.last_col=e}get horz_banding(){return this.flag("horz_banding")}set horz_banding(e){this.def.horz_banding=e}get vert_banding(){return this.flag("vert_banding")}set vert_banding(e){this.def.vert_banding=e}}function Fe(i,e,t=[]){const r=new Set([...i,...t].map(n=>n.name));let s=1;for(;r.has(`${e}-${String(s)}`);)s++;return`${e}-${String(s)}`}export class ShapeCollection{list;base;components;inherit;group;under;constructor(e,t,r,s=()=>{},n=()=>[],o){return this.list=e,this.base=t,this.components=r,this.inherit=s,this.under=n,this.group=o,a(this,"SlideShapes",{index:h=>this._at(h)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}_at(e){const t=this.list[e];return t?this._wrap(t):void 0}*[Symbol.iterator](){for(const e of this.list)yield this._wrap(e)}get length(){return this.list.length}get(e){const t=this.list.find(r=>r.name===e);return t?this._wrap(t):void 0}get title(){const e=this.list.find(t=>t.placeholder?.type==="title"||t.placeholder?.type==="ctrTitle");return e?this._wrap(e):void 0}get placeholders(){return new Placeholders(this.list,this.inherit)}_add(e,t){const r={name:Fe(this.list,e,this.under()),...t,...this.group===void 0?{}:{group:this.group}};return this.list.push(r),this._wrap(r)}add_textbox(e,t,r,s){return this._add("textbox",{kind:"textbox",frame:_(e,t,r,s),text:{...E(),...Se}})}add_picture(e,t,r,s,n){return(s===void 0||n===void 0)&&refuse("add_picture() takes a width and a height here: a picture's own size is not read while a deck's code runs"),this._add("picture",{kind:"picture",frame:_(t,r,s??0,n??0),media:{path:e,base:this.base}})}add_movie(e,t,r,s,n,o={}){return this._add("movie",{kind:"movie",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.poster_frame_time===void 0?{}:{poster:o.poster_frame_time},...o.playback?{playback:{...o.playback}}:{}}})}add_audio(e,t,r,s=W.icon,n=W.icon,o={}){return this._add("audio",{kind:"audio",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.playback?{playback:{...o.playback}}:{}}})}add_shape(e,t,r,s,n){Pe.has(e)||refuse(`add_shape(): ${e} is not one of MSO_SHAPE's ${Object.keys(D).join(", ")}`);const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("shape",{kind:"autoshape",frame:_(t,r,s,n),geometry:e,fill:g.fill,line:g.line,line_width:g.line_width,text:o})}add_table(e,t,r,s,n,o){(e<1||t<1)&&refuse("add_table(): a table has at least a row and a column.");const h=Math.floor(n/t),f=Math.floor(o/e);return this._add("table",{kind:"table",frame:_(r,s,n,o),table:{style:Oe,first_row:!0,horz_banding:!0,columns:Array.from({length:t},()=>h),rows:Array.from({length:e},()=>({height:f,cells:Array.from({length:t},()=>({text:E()}))}))}})}add_chart(e,t,r,s,n,o){return this._add("chart",{kind:"chart",frame:_(t,r,s,n),chart:{type:e,categories:[...o.categories],series:o._series()}})}add_group_shape(){const e=this.group===void 0?"":`${this.group}/`;let t=1;for(;this.list.some(r=>I(r.group,`${e}group-${String(t)}`));)t++;return new GroupShape(this.list,`${e}group-${String(t)}`,r=>new ShapeCollection(this.list,this.base,this.components,this.inherit,this.under,r))}build_freeform(e=0,t=0,r=1){return new FreeformBuilder([e,t],r,(s,n)=>{const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("freeform",{kind:"autoshape",frame:n,path:s,fill:g.fill,line:g.line,line_width:g.line_width,text:o})})}add_connector(e,t,r,s,n){M(e)||refuse(`add_connector(): ${e} is not one of MSO_CONNECTOR's ${Object.keys(he).join(", ")}, nor a connector's preset (${be.join(", ")})`);const o=_(Math.min(t,s),Math.min(r,n),Math.abs(s-t),Math.abs(n-r)),h=s<t,f=n<r;return this._add("connector",{kind:"autoshape",frame:o,geometry:e,...h||f?{flip:{...h?{h}:{},...f?{v:f}:{}}}:{},line:Y.line,line_width:Y.line_width})}add_component(e,t,r,s,n,o={},h={}){if(!Object.hasOwn(this.components(),e))throw new Error(`add_component(): the presentation has no component ${e}; add it with prs.components.add("${e}", { … }) first.`);if(h.dur!==void 0&&!(Number.isFinite(h.dur)&&h.dur>0))throw new Error(`add_component(): dur is how long ${e} moves, seconds over 0; it was ${String(h.dur)}.`);return this._add(e,{kind:"component",frame:_(t,r,s,n),component:{name:e,props:o,...h.dur===void 0?{}:{dur:h.dur}}})}}export const NAME_OF_TYPE={title:"title",ctrTitle:"title",subTitle:"subtitle",body:"body",pic:"picture",media:"media",obj:"content",dt:"date",ftr:"footer",sldNum:"slide-number"};export class Placeholders{list;inherit;constructor(e,t=()=>{}){return this.list=e,this.inherit=t,a(this,"placeholders",{index:r=>this.get(r)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}*[Symbol.iterator](){for(const e of this.list)e.kind==="placeholder"&&(yield this._wrap(e))}get length(){return this.list.filter(e=>e.kind==="placeholder").length}get(e){const t=this.list.find(r=>r.kind==="placeholder"&&(typeof e=="number"?r.placeholder?.idx===e:r.name===e||r.placeholder?.type===e));return t?this._wrap(t):void 0}add(e,t,r,s,n,o={}){const h=typeof t=="object"?t:o,f=typeof t=="object"?void 0:t;Object.values(H).includes(e)||refuse(`placeholders.add(): ${e} is not one of PP_PLACEHOLDER's ${Object.keys(H).join(", ")}`);const c=this.list.filter(b=>b.kind==="placeholder"),u=new Set(c.map(b=>b.placeholder?.idx));let d=e==="title"||e==="ctrTitle"?0:ye[e]??1;for(u.has(d)&&d===0&&(d=1);u.has(d);)d++;const m=h.name??NAME_OF_TYPE[e];if(this.list.some(b=>b.name===m))throw new Error(`Two shapes are ${m}: give the placeholder a name ({ name }).`);const y=[f,r,s,n].filter(b=>b!==void 0);if(y.length!==0&&y.length!==4)throw new Error("placeholders.add(type, left, top, width, height): give all four, or none to take the master's frame.");const L={name:m,kind:"placeholder",placeholder:{type:e,idx:d,...h.orient==="vert"?{orient:"vert"}:{}},...y.length===4?{frame:_(f??0,r??0,s??0,n??0)}:{},text:{paragraphs:[],levels:Ee(e)}};return this.list.push(L),this._wrap(L)}}export class SlideLayout{def;master;ctx;constructor(e,t,r){return this.def=e,this.master=t,this.ctx=r,a(this,"SlideLayout")}get _def(){return this.def}inherit=e=>e.placeholder?X(this.master._def,e.placeholder.type)?.frame:void 0;get name(){return this.def.name}get slide_master(){return this.master}get display_master_shapes(){return this.def.display_master_shapes??!0}set display_master_shapes(e){e?delete this.def.display_master_shapes:this.def.display_master_shapes=!1}get color_map(){return this.def.color_map&&{...this.def.color_map}}set color_map(e){e===void 0?delete this.def.color_map:this.def.color_map=K(e)}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes,this.inherit)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components,this.inherit,()=>this.master._def.shapes)}}export class SlideLayouts{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideLayouts",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}get_by_name(e,t){return this.list.find(r=>r.name===e)??t}index(e){const t=this.list.indexOf(e);if(t<0)throw new Error(`${e.name} is not among these layouts.`);return t}add(e,t){if(!this.make)throw new Error("A layout is added to a master: master.slide_layouts.add(name).");const r=this.make(e);return t?.(r),r}}export class TextStyles{def;constructor(e){return this.def=e,a(this,"text_styles")}get title_style(){return k(this.def.title)}get body_style(){return k(this.def.body)}get other_style(){return k(this.def.other)}}export class SlideMaster{def;layouts=[];ctx;allLayouts;constructor(e,t,r){return this.def=e,this.ctx=t,this.allLayouts=r,a(this,"SlideMaster")}get _def(){return this.def}get name(){return this.def.name}get color_map(){return{...OFFICE_COLOR_MAP,...this.def.color_map}}set color_map(e){const t=K(e),r=Object.fromEntries(Object.entries(t).filter(([s,n])=>OFFICE_COLOR_MAP[s]!==n));Object.keys(r).length===0?delete this.def.color_map:this.def.color_map=r}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components)}get text_styles(){return new TextStyles(this.def.text_styles)}get slide_layouts(){return new SlideLayouts(this.layouts,e=>{if(this.allLayouts.some(s=>s.name===e))throw new Error(`Two layouts are "${e}": a layout's name is unique in the deck, as its slides file names it.`);const t={name:e,master:this.def.name,shapes:[]};this.def.layouts.push(t);const r=new SlideLayout(t,this,this.ctx);return this.layouts.push(r),this.allLayouts.push(r),r})}}export class SlideMasters{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideMasters",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}index(e){return this.list.indexOf(e)}add(e,t){const r=this.make(e);return t?.(r),r}}export class GeneratedSlide{own;def;layout;constructor(e,t,r){this.def=e,this.layout=t,this.own=t._def.shapes.filter(n=>n.kind==="placeholder").map(n=>({name:n.name,kind:"placeholder",...n.placeholder?{placeholder:{...n.placeholder}}:{},text:E()}));const s=n=>{const o=t._def.shapes.find(h=>h.kind==="placeholder"&&h.placeholder?.idx===n.placeholder?.idx);return o?o.frame??(o.placeholder?X(t.slide_master._def,o.placeholder.type)?.frame:void 0):void 0};return this._shapes=new ShapeCollection(this.own,r.base,r.components,s,()=>[...t.slide_master._def.shapes,...t._def.shapes]),this._placeholders=new Placeholders(this.own,s),a(this,"Slide")}_shapes;_placeholders;get shapes(){return this._shapes}get placeholders(){return this._placeholders}get slide_id(){return this.def.id}get slide_layout(){return this.layout}get has_notes_slide(){return this.def.notes!==void 0}get notes_slide(){const e=this.def;return a({notes_text_frame:a({get text(){return e.notes??""},set text(t){e.notes=t}},"TextFrame")},"NotesSlide")}get transition(){return this.def.transition}set transition(e){e===void 0?delete this.def.transition:this.def.transition=e}get animations(){return new Animations(this.def.animations??=[])}_done(){const e={},t=[];for(const r of this.own)r.kind==="placeholder"&&r.placeholder?(r.text?.paragraphs.some(s=>s.runs.length>0)&&(e[r.placeholder.idx]=r.text.paragraphs),r.frame&&t.push({...r,text:E()})):t.push(r);return{...this.def,shapes:t,text:e}}}export class Animations{list;constructor(e){return this.list=e,a(this,"Animations")}add(e,t,r={}){this.list.push({shape:typeof e=="string"?e:e.name,effect:t,...r})}get length(){return this.list.length}}class ze{gen;constructor(e){return this.gen=e,a(this,"slides")}add_slide(e,t){return this.gen._add(e,t)}}export class Generator{list=[];prs;ctx;constructor(e,t){return this.prs=e,this.ctx=t,a(this,"Generator")}data(e){return this.ctx.data(e)}get slides(){return new ze(this)}_add(e,t){const r=typeof e=="string"?this.prs._layout(e):e;if(!r)throw new Error(`add_slide(): the presentation has no layout ${typeof e=="string"?e:e.name}.`);if(!/^[A-Za-z0-9_-]+$/u.test(t))throw new Error(`add_slide(): ${t} is not an id of letters, digits, _ and -.`);if(this.list.some(n=>n.slide_id===t))throw new Error(`add_slide(): two slides are ${t}.`);const s=new GeneratedSlide({id:t,layout:r.name,shapes:[],text:{}},r,this.prs._ctx);return this.list.push(s),s}_made(){return this.list.map(e=>e._done())}}const Ie=()=>JSON.parse(JSON.stringify(xe));export class Presentation{masters=[];layouts=[];def;_ctx;constructor(e,t){return this.def={slide_width:e[0],slide_height:e[1],masters:[],components:{},generators:{}},this._ctx={base:t,components:()=>this.def.components},a(this,"Presentation")}get _def(){return this.def}get slide_width(){return l(this.def.slide_width)}set slide_width(e){this.def.slide_width=e}get slide_height(){return l(this.def.slide_height)}set slide_height(e){this.def.slide_height=e}get slide_masters(){return new SlideMasters(this.masters,e=>{if(this.masters.some(s=>s.name===e))throw new Error(`Two masters are "${e}".`);const t={name:e,background:"bg1",text_styles:Ie(),shapes:[],layouts:[]};this.def.masters.push(t);const r=new SlideMaster(t,this._ctx,this.layouts);return this.masters.push(r),r})}get slide_master(){const e=this.masters[0];if(!e)throw new Error("The presentation has no master yet: prs.slide_masters.add(name) makes one.");return e}get slide_layouts(){const e=this.masters[0];return e?e.slide_layouts:new SlideLayouts([])}get slides(){return refuse("A deck's slides are in the slides file presentation({ slides }) names, in order, each on a layout, and their words in its script; slides made from data are a generator's (prs.generators.add)")}save(){return refuse("A deck is not saved by its code: allyhub render writes its PDF, pictures and PPTX")}get theme(){return this.def.theme??={},this.def.theme}set theme(e){this.def.theme=e}get components(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.components,e))throw new Error(`Two components are "${e}".`);const r=oe(e,t);if(!r)throw new Error(`Component ${e} is not a component: give what defineComponent makes, or { props, layers }.`);this.def.components[e]=r}},"components")}get generators(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.generators,e))throw new Error(`Two generators are "${e}".`);this.def.generators[e]={name:e,make:r=>{const s=new Generator(this,r);return t(s),s._made()}}}},"generators")}_layout(e){return this.layouts.find(t=>t.name===e)}}export const DECK_BRAND="__allyhubDeck";export function isDeck(i){return typeof i=="object"&&i!==null&&DECK_BRAND in i}export const presentationFor=i=>(e,t)=>{const[r,s]=typeof e=="function"?[{},e]:[e,t];if(typeof s!="function")throw new Error(`A deck's module exports one deck: export default presentation({ slides: "./deck.yaml", script: "./deck.{locale}.yaml", size }, (prs) => { … masters, layouts, components … }), its slides and its script named from its folder.`);if(r.script!==void 0&&!r.script.includes("{locale}"))throw new Error(`presentation(): script ${r.script} names one file: write {locale} in its name for each language (./deck.{locale}.yaml).`);if(typeof r.size=="string"&&!Object.hasOwn(j,r.size))throw new Error(`presentation(): size ${r.size} is not one of ${Object.keys(j).join(", ")}, or { width, height } in EMU.`);return{[DECK_BRAND]:!0,kind:"slides",options:r,build:s,written:{file:i}}};export function evaluateDeck(i){const e=i.options.size??"16:9",t=typeof e=="string"?j[e]:[e.width,e.height],r=i.written.file.split("/").slice(0,-1).join("/"),s=new Presentation(t,r);return i.options.theme&&(s.theme=JSON.parse(JSON.stringify(i.options.theme))),i.build(s),s._def}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{clockOf as
|
|
2
|
+
import{clockOf as c}from"./animation.js";export function componentTime(t,n,i){const o=c(t,i);return Math.max(0,(o.rests.at(-1)??0)-o.comesOn(n))}export function componentAt(t,n,i){if(t.kind==="item"&&t.item)return{name:`/${t.item.path}`,props:{},width:Math.max(1,Math.round(t.frame.width*n)),height:Math.max(1,Math.round(t.frame.height*n)),t:t.item.playback?.trim?.start??0};if(t.component)return{name:t.component.name,props:t.component.props,width:Math.max(1,Math.round(t.frame.width*n)),height:Math.max(1,Math.round(t.frame.height*n)),t:i}}export function deckComponentAt(t,n){const i=t.width>0?n/t.width:0,o=new Map(t.slides.map(r=>[r.id,r])),e=t.slides[0]?.id;return(r,m)=>{const a=o.get(r);return a&&(m.component||m.kind==="item")?componentAt(m,i,componentTime(a,m.name,r===e)):void 0}}export function deckComponents(t,n){const i=deckComponentAt(t,n);return t.slides.flatMap(o=>o.shapes.flatMap(e=>{const r=i(o.id,e);return r?[{slide:o.id,shape:e.name,at:r}]:[]}))}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CAPS as ze,colorOfFile as de,groupLevels as Ae,SHOW_JUMPS as Te,showJumpOf as je,slideLinkOf as Ee,UNDERLINES as Fe}from"@allyhub/formats";import{readMarks as Ne,markRuns as Le}from"@allyhub/piece";import{chartOfFile as Me}from"@allyhub/chart";import{AUTOSHAPE_STYLE as R,SHADOW_DEFAULTS as I,PATTERN_DEFAULTS as se,TILE_DEFAULTS as W,INNER_SHADOW_DEFAULTS as H,GLOW_DEFAULTS as q,REFLECTION_DEFAULTS as X,CONNECTOR_STYLE as fe,DRAWN_TEXTBOX_FRAME as ce,TEXT_FALLBACK as ue,TEXT_INSETS as B,isConnectorGeometry as Ce,placeholderFrame as Pe,styleKindOf as Re}from"./office.js";import{resolveAnimation as De,resolveTransition as Ue,unitsAcross as Ie,EFFECT_OPTIONS as We,TRANSITION_OPTIONS as He}from"./animation.js";import{glued as Ge}from"./connect.js";import{pathSteps as Xe}from"./path.js";import{CHART_AXIS_WORDS as Be}from"./script.js";import{cellLook as Ke,tableStyleOf as Q}from"./table-style.js";import{masterPlaceholder as Je}from"./placeholders.js";import{DECK_FONTS as Ye,OFFICE_THEME as Ve,themeOver as Ze}from"./theme.js";import{Pt as S}from"./units.js";export function joinPath(i,t){if(t.startsWith("/"))return t.slice(1);const l=[];for(const r of[...i.split("/"),...t.split("/")])r===""||r==="."||(r===".."?l.pop():l.push(r));return l.join("/")}const pe={left:0,top:0,width:0,height:0};function qe(i,t){const l={...i.color_map,...t.color_map};return Object.keys(l).length>0?{color_map:l}:{}}const K=()=>Array.from({length:9},()=>({...ue,font:{...ue.font},margin_left:0}));export function levelsOver(i,...t){return i.map((l,r)=>{let o={...l,font:{...l.font}};for(const y of t){const a=y?.[r];a&&(o={...o,...a.alignment===void 0?{}:{alignment:a.alignment},...a.line_spacing===void 0?{}:{line_spacing:a.line_spacing},...a.space_before===void 0?{}:{space_before:a.space_before},...a.space_after===void 0?{}:{space_after:a.space_after},...a.margin_left===void 0?{}:{margin_left:a.margin_left},...a.indent===void 0?{}:{indent:a.indent},font:{...o.font,...a.font}},a.numbered!==void 0&&(o.numbered=a.numbered,delete o.bullet),a.bullet===null?(delete o.bullet,delete o.numbered):a.bullet!==void 0?(delete o.numbered,o.bullet={char:a.bullet,...a.bullet_font===void 0?{}:{font:a.bullet_font}}):a.bullet_font!==void 0&&o.bullet&&(o.bullet={...o.bullet,font:a.bullet_font}),o=bulletLookOver(o,a))}return o})}export function bulletLookOver(i,t){const l={...i};return t.bullet_color===null?delete l.bullet_color:t.bullet_color!==void 0&&(l.bullet_color=t.bullet_color),t.bullet_size===null?delete l.bullet_size:t.bullet_size!==void 0&&(l.bullet_size=t.bullet_size),t.start_at!==void 0&&(l.start_at=t.start_at),l}function ee(i,...t){const l=t.filter(o=>o!==void 0),r=o=>{for(let y=l.length-1;y>=0;y--){const a=l[y]?.[o];if(a!==void 0)return a}};return{vertical_anchor:r("vertical_anchor")??i.vertical_anchor,orientation:r("orientation")??"horz",auto_size:r("auto_size")??i.auto_size,word_wrap:r("word_wrap")??i.word_wrap,margins:{left:r("margin_left")??B.left,top:r("margin_top")??B.top,right:r("margin_right")??B.right,bottom:r("margin_bottom")??B.bottom}}}const he={vertical_anchor:"t",auto_size:"none",word_wrap:!0};export const plainLevels=i=>levelsOver(K(),i.text_styles.other);function ne(i,t){return{...ee(he,t),levels:levelsOver(K(),i.text_styles.other,t.levels)}}function Qe(i,t,...l){return{...ee(Pe(t),...l),levels:levelsOver(K(),i.text_styles[Re(t)],...l.map(r=>r?.levels))}}const en=Array.from({length:9},()=>({font:{color:R.font_color}})),me={vertical_anchor:R.vertical_anchor};function _e(i,t){return{...ee(he,t),levels:levelsOver(K(),i.text_styles.other,en,t.levels)}}const J=i=>{const t={...i};return delete t.paragraphs,t},Y=i=>({paragraphs:[],levels:[],...i}),C=i=>i==="none"?null:colorOfFile(i),nn=/<span((?:\s+(?:color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="[^"\n]*")+)\s*>(.*?)<\/span>/gu,tn=/(color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="([^"\n]*)"/gu,V=57344,on=256,ge="",rn=/[\ue000-\ue100]|[^\ue000-\ue100]+/gu;export const spaceOfFile=i=>typeof i=="number"?S(i):{lines:i.lines},colorOfFile=i=>de(i)??"dk1";function te(i){const{shadow:t,gradient:l,inner_shadow:r,glow:o,reflection:y}=i;return{...r?{inner_shadow:{color:r.color===void 0?H.color:colorOfFile(r.color),blur:r.blur===void 0?H.blur:S(r.blur),distance:r.distance===void 0?H.distance:S(r.distance),angle:r.angle??H.angle,transparency:r.transparency??H.transparency}}:{},...o?{glow:{color:o.color===void 0?q.color:colorOfFile(o.color),size:o.size===void 0?q.size:S(o.size),transparency:o.transparency??q.transparency}}:{},...i.soft_edges===void 0?{}:{soft_edges:S(i.soft_edges)},...y?{reflection:{transparency:y.transparency??X.transparency,size:y.size??X.size,distance:y.distance===void 0?X.distance:S(y.distance),blur:y.blur===void 0?X.blur:S(y.blur)}}:{},...i.fill_transparency===void 0?{}:{fill_transparency:i.fill_transparency},...l?{gradient:{angle:l.angle??0,...l.path===void 0?{}:{path:l.path},...l.focus===void 0?{}:{focus:{left:l.focus.left??.5,top:l.focus.top??.5,right:l.focus.right??.5,bottom:l.focus.bottom??.5}},stops:l.stops.map(a=>({at:a.at,color:colorOfFile(a.color),...a.transparency===void 0?{}:{transparency:a.transparency}}))}}:{},...t?{shadow:{color:t.color===void 0?I.color:colorOfFile(t.color),blur:t.blur===void 0?I.blur:S(t.blur),distance:t.distance===void 0?I.distance:S(t.distance),angle:t.angle??I.angle,transparency:t.transparency??I.transparency}}:{}}}const an=i=>({...i.tile?{tile:{...i.tile}}:{},...i.transparency===void 0?{}:{transparency:i.transparency}});function be(i,t){const{pattern:l,picture_fill:r}=i;return{...l?{pattern:{preset:l.preset,fg:colorOfFile(l.fg??se.fg),bg:colorOfFile(l.bg??se.bg)}}:{},...r?{picture_fill:{path:joinPath(t,r.path),...r.tile?{tile:{scale_x:r.tile.scale_x??W.scale_x,scale_y:r.tile.scale_y??W.scale_y,offset_x:r.tile.x===void 0?W.offset_x:S(r.tile.x),offset_y:r.tile.y===void 0?W.offset_y:S(r.tile.y),align:r.tile.align??W.align}}:{},...r.transparency===void 0?{}:{transparency:r.transparency}}}:{}}}function ye(i,t,l=[]){const r=Q(i.style);return{...i,rows:i.rows.map((o,y)=>({height:o.height,cells:o.cells.map((a,E)=>{const N=l[y],v=r?Ke(r,i,y,E,i.rows.length,i.columns.length,y+(a.span_height??1)-1,E+(a.span_width??1)-1):void 0,F=ne(t,a.text),L=v&&(v.bold!==void 0||v.text!==void 0)?{...F,levels:F.levels.map(P=>({...P,font:{...P.font,...v.bold===void 0?{}:{bold:v.bold},...v.text===void 0?{}:{color:v.text}}}))}:F;return{...a,text:{paragraphs:a.text.paragraphs,style:Z({...L,auto_size:"shape"},N),own:J(a.text),empty:!1},...N?{fileText:N}:{}}})}))}}function Z(i,t){return t?{...i,...t.anchor===void 0?{}:{vertical_anchor:t.anchor},...t.orientation===void 0?{}:{orientation:t.orientation},levels:i.levels.map(l=>{const r={...l.font,...t.size===void 0?{}:{size:S(t.size)},...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline},...t.strike===void 0?{}:{strike:t.strike},...t.caps===void 0?{}:{caps:t.caps},...t.font===void 0?{}:{name:t.font}};t.color!==void 0&&(r.color=colorOfFile(t.color));const o={...l,font:r,...t.align===void 0?{}:{alignment:t.align},...t.line_spacing===void 0?{}:{line_spacing:{lines:t.line_spacing}},...t.space_before===void 0?{}:{space_before:spaceOfFile(t.space_before)},...t.space_after===void 0?{}:{space_after:spaceOfFile(t.space_after)}};return t.bullet_color!==void 0&&(o.bullet_color=colorOfFile(t.bullet_color)),t.bullet_size!==void 0&&(o.bullet_size=t.bullet_size),t.start_at!==void 0&&(o.start_at=t.start_at),t.numbered!==void 0?(o.numbered=t.numbered,delete o.bullet):t.bullet===!1?(delete o.bullet,delete o.numbered):t.bullet!==void 0&&(o.bullet={char:t.bullet},delete o.numbered),(t.numbered!==void 0||t.bullet!==void 0&&t.bullet!==!1)&&l.margin_left===0?{...o,margin_left:$e,indent:-$e}:o})}:i}function ln(i,t){if(!t)return[...i];const l=t.numbered!==void 0||t.bullet!==void 0;return i.map(r=>{const o={...r};return t.align!==void 0&&delete o.alignment,t.line_spacing!==void 0&&delete o.line_spacing,t.space_before!==void 0&&delete o.space_before,t.space_after!==void 0&&delete o.space_after,t.bullet_color!==void 0&&delete o.bullet_color,t.bullet_size!==void 0&&delete o.bullet_size,t.start_at!==void 0&&delete o.start_at,l&&(delete o.bullet,delete o.bullet_font,delete o.numbered),o})}const dn=i=>Fe.includes(i),sn=i=>ze.includes(i);function fn(i){const t={};for(const[,l,r=""]of i.matchAll(tn))if(l==="font")t.name=r.trim();else if(l==="link")t.link=r.trim();else if(l==="highlight")t.highlight=r.trim().toUpperCase();else if(l==="bold")t.bold=r.trim()!=="false";else if(l==="italic")t.italic=r.trim()!=="false";else if(l==="strike"){const o=r.trim();t.strike=o==="dblStrike"?o:o!=="false"}else if(l==="underline"){const o=r.trim();t.underline=dn(o)&&o!=="sng"?o:o!=="false"}else if(l==="caps"){const o=r.trim();sn(o)&&(t.caps=o)}else if(l==="size"){const o=Number(r);Number.isFinite(o)&&o>0&&(t.size=S(o))}else if(l==="baseline"){const o=Number(r);Number.isFinite(o)&&(t.baseline=o)}else if(l==="spacing"){const o=Number(r);Number.isFinite(o)&&(t.spacing=S(o))}else{const o=de(r.trim());o!==void 0&&(t.color=o)}return t}const $e=342900;export function paragraphsOfWords(i,t=0,l=Ye.code){return i===void 0?[]:typeof i=="string"?i.split(/\r?\n/u).map(r=>{const o=[],y=r.replace(nn,(v,F,L)=>(o.push(fn(F)),`${String.fromCharCode(V+o.length-1)}${L}${ge}`)),a=Ne(y);let E;const N=Le(a.text,a.marks).flatMap(v=>{const F=v.kinds.includes("code"),L={...v.kinds.includes("strong")?{bold:!0}:{},...v.kinds.includes("em")?{italic:!0}:{},...F?{name:l}:{}};return[...v.text.matchAll(rn)].flatMap(P=>{const D=P[0],U=D.charCodeAt(0);if(D===ge)return E=void 0,[];if(U>=V&&U<V+on)return E=o[U-V],[];const G={...E,...L};return[{text:D,...Object.keys(G).length>0?{font:G}:{},...F?{code:!0}:{}}]})});return{runs:N.length>0?N:[{text:""}],level:t}}):i.flatMap(r=>paragraphsOfWords(r,Array.isArray(r)?Math.min(t+1,8):t,l))}const ke=i=>({left:S(i.x),top:S(i.y),width:S(i.w),height:S(i.h)}),cn=new Set(["dt","ftr","sldNum"]),we=i=>({...i.locked?{locked:!0}:{},...i.link===void 0?{}:{link:i.link},...i.rotation===void 0||i.rotation===0?{}:{rotation:i.rotation},...i.flip_h||i.flip_v?{flip:{...i.flip_h?{h:!0}:{},...i.flip_v?{v:!0}:{}}}:{}});function xe(i,t,l){if(!t)return;t.fill!==void 0&&(i.background=colorOfFile(t.fill));const r=t.gradient&&te({gradient:t.gradient}).gradient;r&&(i.background_gradient=r),t.picture!==void 0&&(i.background_picture=joinPath(l,t.picture))}const un=i=>{const t=Q(i.style);return{...t?{style:t.id}:{},...i.first_row===void 0?{}:{first_row:i.first_row},...i.last_row===void 0?{}:{last_row:i.last_row},...i.first_col===void 0?{}:{first_col:i.first_col},...i.last_col===void 0?{}:{last_col:i.last_col},...i.horz_banding===void 0?{}:{horz_banding:i.horz_banding},...i.vert_banding===void 0?{}:{vert_banding:i.vert_banding}}},Se=i=>i===void 0?void 0:{left:i.left??0,top:i.top??0,right:i.right??0,bottom:i.bottom??0};export function resolveDeck(i){const{code:t,file:l,words:r,prefix:o,base:y}=i,a=[],E=Ze(i.theme??Ve,t.theme),N=new Map;for(const e of t.masters)for(const n of e.layouts)N.set(n.name,{layout:n,master:e});const v=[],F=(e,n,s)=>{const h=He[n.type];return n.direction!==void 0&&!h.directions.includes(n.direction)&&a.push({slide:e,path:`${s}.transition.direction`,message:h.directions.length===0?`A ${n.type} transition has no direction (${n.direction}).`:`A ${n.type} transition goes ${h.directions.join(", ")}, not ${n.direction}.`}),n.through_black===!0&&!h.throughBlack&&a.push({slide:e,path:`${s}.transition.through_black`,message:`A ${n.type} transition does not go through black: only a fade, a cut and a reveal do.`}),Ue(n)},L=(e,n,s)=>({name:e.name,kind:e.kind,frame:{...e.frame??pe},...e.flip?{flip:{...e.flip}}:{},...e.connect?{connect:{...e.connect.begin?{begin:{...e.connect.begin}}:{},...e.connect.end?{end:{...e.connect.end}}:{}}}:{},...e.rotation===void 0?{}:{rotation:e.rotation},level:n,...e.text?{text:{paragraphs:e.text.paragraphs,style:e.kind==="autoshape"?_e(s,e.text):ne(s,e.text),own:J(e.text),empty:!1}}:{},...e.fill===void 0?{}:{fill:e.fill},...e.fill_transparency===void 0?{}:{fill_transparency:e.fill_transparency},...e.gradient?{gradient:e.gradient}:{},...e.pattern?{pattern:e.pattern}:{},...e.picture_fill?{picture_fill:{...an(e.picture_fill),path:joinPath(e.picture_fill.base,e.picture_fill.path)}}:{},...e.shadow===void 0?{}:{shadow:e.shadow},...e.inner_shadow?{inner_shadow:e.inner_shadow}:{},...e.glow?{glow:e.glow}:{},...e.soft_edges===void 0?{}:{soft_edges:e.soft_edges},...e.reflection?{reflection:e.reflection}:{},...e.line===void 0?{}:{line:e.line},...e.line_width===void 0?{}:{line_width:e.line_width},...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_cap===void 0?{}:{line_cap:e.line_cap},...e.line_join===void 0?{}:{line_join:e.line_join},...e.line_compound===void 0?{}:{line_compound:e.line_compound},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size},...e.path?{path:e.path}:{},...e.table?{table:ye(e.table,s)}:{},...e.chart?{chart:e.chart}:{},...e.link===void 0?{}:{link:e.link},...e.group===void 0?{}:{group:e.group},...e.geometry?{geometry:e.geometry}:{},...e.adjustments?{adjustments:[...e.adjustments]}:{},...e.media?{media:{path:joinPath(e.media.base,e.media.path),...e.media.poster===void 0?{}:{poster:e.media.poster},...e.media.playback?{playback:e.media.playback}:{}}}:{},...e.component?{component:{...e.component}}:{},sources:{frame:{from:n}}}),P=(e,n)=>{const s=e.placeholder?.type??"body",h=Je(n,s),g=e.frame??h?.frame??pe;return{name:e.name,kind:"placeholder",frame:{...g},level:"slide",...e.placeholder?{placeholder:{...e.placeholder}}:{},text:{paragraphs:[],style:Qe(n,s,h?.text,e.text),empty:!0},...e.fill===void 0?{}:{fill:e.fill},...e.line===void 0?{}:{line:e.line},sources:{frame:{from:e.frame||!h?"layout":"master"},text:{from:"layout"}}}},D=(e,n,s,h)=>{const g=t.components[e];if(!g){a.push({...s,message:/\.[cm]?[jt]sx?(?:#|$)/u.test(e)?`${e} names no component: its module has no such export, or the export is not made with defineComponent.`:`There is no component ${e} in the deck's module (it has ${Object.keys(t.components).join(", ")||"none"}).`});return}for(const $ of Object.keys(n??{}))Object.hasOwn(g.props,$)||a.push({...s,message:`Component ${e} has no prop ${$} a person sets (it has ${Object.keys(g.props).join(", ")||"none"}).`});return{name:e,props:{...n??{}},...h===void 0?{}:{dur:h}}},U=(e,n,s,h,g)=>{const $={slide:h,shape:e,path:s};if(!n.frame){a.push({...$,message:`Shape ${e} is the slide's own: it needs a frame { x, y, w, h } in points.`});return}const T=ke(n.frame),u={frame:{from:"slide",path:`${s}.frame`}},x={name:e,frame:T,level:"slide",...n.fill===void 0?{}:{fill:C(n.fill)},...te(n),...be(n,y),...n.line===void 0?{}:{line:C(n.line)},...n.line_dash===void 0?{}:{line_dash:n.line_dash},...n.line_cap===void 0?{}:{line_cap:n.line_cap},...n.line_join===void 0?{}:{line_join:n.line_join},...n.line_compound===void 0?{}:{line_compound:n.line_compound},...n.line_begin===void 0?{}:{line_begin:n.line_begin},...n.line_end===void 0?{}:{line_end:n.line_end},...n.line_begin_size===void 0?{}:{line_begin_size:n.line_begin_size},...n.line_end_size===void 0?{}:{line_end_size:n.line_end_size},...n.group===void 0?{}:{group:n.group},...we(n)};if(n.textbox)return{...x,kind:"textbox",text:{paragraphs:paragraphsOfWords(r(`${o}.${h}.${e}`),0,E.fonts.code),style:Z(ne(g,Y(ce)),n.text),own:J(Y(ce)),empty:!1},...n.text?{fileText:{...n.text}}:{},sources:{...u,text:{from:"slide",path:`${s}.text`}}};if(n.picture!==void 0){const p=Se(n.crop);return{...x,kind:"picture",media:{path:joinPath(y,n.picture),...p?{crop:p}:{}},sources:{...u,media:{from:"slide",path:`${s}.picture`}}}}if(n.movie!==void 0)return{...x,kind:"movie",media:{path:joinPath(y,n.movie),...n.poster===void 0?{}:{poster:n.poster},...n.playback?{playback:n.playback}:{}},sources:{...u,media:{from:"slide",path:`${s}.movie`}}};if(n.audio!==void 0)return{...x,kind:"audio",media:{path:joinPath(y,n.audio),...n.playback?{playback:n.playback}:{}},sources:{...u,media:{from:"slide",path:`${s}.audio`}}};if(n.chart){const p=`${o}.${h}.${e}`,j=c=>typeof c=="string"?c:void 0,w=Object.fromEntries(Be.flatMap(c=>{const d=j(r(`${p}.${c}`));return d===void 0?[]:[[c,d]]})),O=Me(n.chart,{title:j(r(p))??j(r(`${p}.title`)),axisTitles:w,base:y,rows:c=>i.data?.(c),problem:c=>{a.push({...$,message:`Chart ${e}: ${c}`})}});return O?{...x,kind:"chart",chart:O,sources:u}:void 0}if(n.table){const p=n.table;p.style!==void 0&&!Q(p.style)&&a.push({...$,message:`Table ${e}'s style ${p.style} is none of PowerPoint's built-in table styles: name one as its gallery does (Medium Style 2 - Accent 1, Light Style 1, No Style, Table Grid) or by its id.`});const j=T.width/p.columns.reduce((f,m)=>f+m,0),w=T.height/p.rows.reduce((f,m)=>f+m.height,0),O=r(`${o}.${h}.${e}`),c=Array.isArray(O)?O:[],d=new Map;for(const f of p.merged??[]){const m=f.rows??1,_=f.columns??1;for(let k=f.row;k<f.row+m;k++)for(let z=f.column;z<f.column+_;z++)d.set(`${String(k)},${String(z)}`,"under");d.set(`${String(f.row)},${String(f.column)}`,{w:_,h:m})}return c.length>p.rows.length&&a.push({...$,message:`Table ${e} has ${String(p.rows.length)} rows and its words ${String(c.length)}.`}),{...x,kind:"table",table:ye({...un(p),columns:p.columns.map(f=>Math.round(f*j)),rows:p.rows.map((f,m)=>{const _=c[m],k=Array.isArray(_)?_:_===void 0?[]:[_];return{height:Math.round(f.height*w),cells:p.columns.map((z,M)=>{const A=d.get(`${String(m)},${String(M)}`);return{text:{levels:[],paragraphs:A==="under"?[]:paragraphsOfWords(k[M],0,E.fonts.code)},...A==="under"?{spanned:!0}:{},...A!==void 0&&A!=="under"&&A.w>1?{span_width:A.w}:{},...A!==void 0&&A!=="under"&&A.h>1?{span_height:A.h}:{},...f.fill===void 0?{}:{fill:colorOfFile(f.fill)},...f.line===void 0?{}:{borders:{bottom:{color:colorOfFile(f.line),width:S(1)}}}}})}})},g,p.rows.map(f=>f.text)),sources:u}}const b=n.path&&Xe(n.path.d);if(n.path&&!b){a.push({...$,message:`Shape ${e}'s path starts with M and says only M, L, C and Z, absolute.`});return}if(n.geometry!==void 0||n.path&&b){const p=!n.path&&Ce(n.geometry);return{...x,kind:"autoshape",...n.path&&b?{path:{w:n.path.w,h:n.path.h,steps:b}}:n.geometry===void 0?{}:{geometry:n.geometry,...n.adjustments?{adjustments:[...n.adjustments]}:{}},...p?{line:n.line===void 0?fe.line:C(n.line),line_width:n.line_width===void 0?fe.line_width:S(n.line_width)}:{fill:n.fill===void 0?R.fill:C(n.fill),line:n.line===void 0?R.line:C(n.line),line_width:n.line_width===void 0?R.line_width:S(n.line_width)},...n.text&&!p?{fileText:{...n.text}}:{},...p?{}:{text:{paragraphs:paragraphsOfWords(r(`${o}.${h}.${e}`)).map(j=>n.text?.align===void 0?{alignment:R.alignment,...j}:j),style:Z(_e(g,Y(me)),n.text),own:J(Y(me)),empty:!1}},sources:{...u,fill:{from:"slide",path:`${s}.fill`}}}}if(n.component!==void 0){const p=D(n.component,n.props,$,n.dur);return p?{...x,kind:"component",component:p,sources:u}:void 0}},G=(e,n,s)=>{if(n.frame&&(e.frame=ke(n.frame),e.sources.frame={from:"slide",path:`${s}.frame`}),Object.assign(e,we(n)),n.dur!==void 0&&e.component&&(e.component={...e.component,dur:n.dur}),n.text&&e.text&&(e.text.style=Z(e.text.style,n.text),e.text.paragraphs=ln(e.text.paragraphs,n.text),e.fileText={...n.text},e.sources.text={from:"slide",path:`${s}.text`}),n.line!==void 0&&(e.line=C(n.line),e.sources.line={from:"slide",path:`${s}.line`}),n.line_width!==void 0&&(e.line_width=S(n.line_width)),n.line_dash!==void 0&&(e.line_dash=n.line_dash),n.line_cap!==void 0&&(e.line_cap=n.line_cap),n.line_join!==void 0&&(e.line_join=n.line_join),n.line_compound!==void 0&&(e.line_compound=n.line_compound),n.line_begin!==void 0&&(e.line_begin=n.line_begin),n.line_end!==void 0&&(e.line_end=n.line_end),n.line_begin_size!==void 0&&(e.line_begin_size=n.line_begin_size),n.line_end_size!==void 0&&(e.line_end_size=n.line_end_size),(n.fill!==void 0||n.gradient!==void 0||n.pattern!==void 0||n.picture_fill!==void 0)&&(delete e.gradient,delete e.pattern,delete e.picture_fill),n.fill!==void 0&&(e.fill=C(n.fill),e.sources.fill={from:"slide",path:`${s}.fill`}),Object.assign(e,te(n),be(n,y)),(n.picture!==void 0||n.movie!==void 0)&&(e.placeholder?.type==="pic"||e.placeholder?.type==="media"||e.placeholder?.type==="obj")){const h=Se(n.crop);e.kind=n.picture!==void 0?"picture":"movie",e.media={path:joinPath(y,n.picture??n.movie??""),...h?{crop:h}:{},...n.poster===void 0?{}:{poster:n.poster},...n.playback&&n.movie!==void 0?{playback:n.playback}:{}},e.sources.media={from:"slide",path:`${s}.${n.picture!==void 0?"picture":"movie"}`},delete e.text}else n.playback&&e.media&&(e.kind==="movie"||e.kind==="audio")&&(e.media={...e.media,playback:{...e.media.playback,...n.playback}})},ie=(e,n,s,h,g)=>{const $=N.get(n);if(!$){a.push({slide:e,path:`slides.${String(s)}.layout`,message:`Slide ${e} is on the layout "${n}", which the deck's module does not have (it has ${[...N.keys()].join(", ")||"none"}).`});return}const{layout:T,master:u}=$,x=[...(T.display_master_shapes===!1?[]:u.shapes).filter(p=>p.kind!=="placeholder").map(p=>L(p,"master",u)),...T.shapes.filter(p=>p.kind!=="placeholder").map(p=>L(p,"layout",u))],b=T.shapes.filter(p=>p.kind==="placeholder").map((p,j)=>({shape:P(p,u),order:j}));return{slide:{id:e,layout:T.name,master:u.name,hidden:h,background:T.background??u.background,...qe(u,T),shapes:x,animations:[],file:{index:s,...g===void 0?{}:{generate:g}}},placed:b,master:u}},oe=(e,n,s)=>{if(!n)return;const h=T=>{const u=n[T];if(u===void 0)return e.connect?.[T];const x=u==="none"?void 0:s(u.shape);return u==="none"||x===void 0?void 0:{shape:x,site:u.site}},g=h("begin"),$=h("end");g||$?e.connect={...g?{begin:g}:{},...$?{end:$}:{}}:delete e.connect},re=(e,n,s,h,g,$,T,u,x,b=()=>{})=>{const p=new Set(s.map(c=>c.shape.name));let j=s.length;for(const[c,d]of Object.entries(h??{})){const f=$(c);if(f===void 0)continue;const m=`${g}.shapes.${c}`,_=d.textbox!==void 0||d.geometry!==void 0||d.path!==void 0||d.table!==void 0||d.chart!==void 0||d.component!==void 0||d.audio!==void 0||(d.picture!==void 0||d.movie!==void 0)&&!p.has(f),k=s.find(M=>M.shape.name===f);if(k&&!_){G(k.shape,d,m),oe(k.shape,d.connect,$),k.shown=!0,d.z!==void 0&&(k.z=d.z);continue}if(k){a.push({slide:e.id,shape:f,path:m,message:`Slide ${e.id} has a ${k.shape.kind} ${f} already: a shape of its own needs another name.`});continue}if(!_){a.push({slide:e.id,shape:f,path:m,message:`Slide ${e.id} has no shape ${f} to change (its layout's placeholders and its own shapes are ${[...p].join(", ")||"none"}).`});continue}const z=U(f,d,m,e.id,n);z&&oe(z,d.connect,$),z&&(s.push({shape:z,order:j++,...d.z===void 0?{}:{z:d.z}}),p.add(f))}const w=s.filter(c=>c.shown===!0||!cn.has(c.shape.placeholder?.type??"")||T(c.shape)!==void 0);s.splice(0,s.length,...w),s.sort((c,d)=>(c.z??0)-(d.z??0)||c.order-d.order);const O=(c,d)=>{const f=_=>{const k=_.shape.group;return k===void 0?void 0:Ae(k)[d]},m=new Map(c.flatMap((_,k)=>{const z=f(_);return z===void 0?[]:[[z,k]]}));return c.flatMap((_,k)=>{const z=f(_);return z===void 0?[_]:m.get(z)===k?O(c.filter(M=>f(M)===z),d+1):[]})};s.splice(0,s.length,...O(s,0));for(const c of s){const d=b(c.shape);d!==void 0&&(c.shape.alt=d);const f=c.shape.text;if(c.shape.kind==="placeholder"&&f){const m=T(c.shape);f.paragraphs=paragraphsOfWords(m,0,E.fonts.code),f.empty=f.paragraphs.length===0||f.paragraphs.every(_=>_.runs.every(k=>k.text===""))}}e.shapes.push(...s.map(c=>c.shape));for(const c of e.shapes){const d=c.connect;if(!d)continue;const f=Ge(c,m=>e.shapes.find(_=>_.name===m&&_.level===c.level&&_!==c));c.frame=f.frame,f.flip?c.flip=f.flip:delete c.flip;for(const m of f.lost){const _=d[m];_&&c.level==="slide"&&a.push({slide:e.id,shape:c.name,message:`Connector ${c.name}'s ${m} is glued to site ${String(_.site)} of ${_.shape}, which slide ${e.id} has not: it stays where it is.`})}}u!==void 0&&u.trim()!==""&&(e.notes=u);for(const[c,d]of(x??[]).entries()){const f=$(d.shape);if(f===void 0)continue;const m={slide:e.id,shape:f,path:`${g}.animations.${String(c)}`},_=e.shapes.find(A=>A.name===f&&A.level==="slide");if(!_){a.push({...m,message:`Slide ${e.id} has no shape ${f} to animate (it has ${e.shapes.filter(A=>A.level==="slide").map(A=>A.name).join(", ")}).`});continue}if(d.paragraph!==void 0&&d.paragraph>=(_.text?.paragraphs.length??0)){a.push({...m,message:`Shape ${f} has no paragraph ${String(d.paragraph)} to animate (it has ${String(_.text?.paragraphs.length??0)}).`});continue}const k=We[d.effect];d.direction!==void 0&&!k.directions.includes(d.direction)&&a.push({...m,path:`${m.path}.direction`,message:k.directions.length===0?`${f}'s ${d.effect} has no direction (${d.direction}).`:`${f}'s ${d.effect} goes ${k.directions.join(", ")}, not ${d.direction}.`}),d.amount!==void 0&&k.amount===void 0?a.push({...m,path:`${m.path}.amount`,message:`${f}'s ${d.effect} has no amount: only a Grow/Shrink, a spin and a Transparency do.`}):d.effect==="transparency"&&(d.amount??0)>1&&a.push({...m,path:`${m.path}.amount`,message:`${f}'s transparency is a share, at most 1 (it is ${String(d.amount)}).`}),d.animate_text!==void 0&&!_.text&&a.push({...m,path:`${m.path}.animate_text`,message:`${f} has no text to animate by ${d.animate_text}: it plays as one.`});const z=d.animate_text,M=De({...d,shape:f,..._.text?{}:{animate_text:void 0}},z===void 0?1:(d.paragraph===void 0?_.text?.paragraphs??[]:[_.text?.paragraphs[d.paragraph]]).reduce((A,ve)=>A+Ie(ve?.runs.map(Oe=>Oe.text)??[],z).length,0));M?e.animations.push(M):a.push({...m,message:`The animation of ${f} needs a path that starts with M and says only M, L and C, absolute.`})}},ae=new Set;l.slides.forEach((e,n)=>{const s=`slides.${String(n)}`;if(e.layout!==void 0){const u=ie(e.id,e.layout,n,e.hidden===!0);if(!u)return;const x=r(`${o}.${e.id}.notes`);e.transition&&(u.slide.transition=F(e.id,e.transition,s)),e.advance_after!==void 0&&(u.slide.advance=e.advance_after),e.section!==void 0&&(u.slide.section=e.section),xe(u.slide,e.background,y),re(u.slide,u.master,u.placed,e.shapes,s,b=>b,b=>r(`${o}.${e.id}.${b.name}`),typeof x=="string"?x:void 0,e.animations,b=>{const p=r(`${o}.${e.id}.alt.${b.name}`);return typeof p=="string"?p:void 0}),v.push(u.slide),ae.add(e.id);return}const h=e.generate??"",g=t.generators[h];if(g===void 0){a.push({slide:e.id,path:`${s}.generate`,message:`There is no generator ${h} in the deck's module (it has ${Object.keys(t.generators).join(", ")||"none"}).`});return}if(!Array.isArray(g)){a.push({slide:e.id,path:`${s}.generate`,message:`Generator ${h} threw: ${g.error}`,...g.stack===void 0?{}:{stack:g.stack}});return}const $=g,T=new Set(Array.isArray(e.hidden)?e.hidden:[]);for(const u of $){const x=`${e.id}/${u.id}`,b=ie(x,u.layout,n,T.has(u.id),h);if(!b)continue;for(const w of u.shapes){const O=w.placeholder?b.placed.find(c=>c.shape.placeholder?.idx===w.placeholder?.idx):void 0;if(O)w.frame&&(O.shape.frame={...w.frame}),O.shape.sources.frame={from:"code"},O.shown=!0;else{const c=L(w,"layout",b.master);b.placed.push({shape:{...c,level:"slide",sources:{frame:{from:"code"}}},order:b.placed.length})}}const p=`${u.id}/`,j=u.transition??(u===$[0]?e.transition:void 0);xe(b.slide,e.background,y),j&&(b.slide.transition=F(b.slide.id,j,s)),u===$[0]&&e.section!==void 0&&(b.slide.section=e.section),re(b.slide,b.master,b.placed,e.shapes,s,w=>w.startsWith(p)?w.slice(p.length):void 0,w=>{const O=w.placeholder===void 0?void 0:u.text[w.placeholder.idx];return O===void 0?void 0:O.map(c=>c.runs.map(d=>d.text).join(""))},u.notes,[...(u.animations??[]).map(w=>({...w,shape:`${p}${w.shape}`})),...e.animations??[]]);for(const w of b.slide.shapes){const O=w.placeholder===void 0?void 0:u.text[w.placeholder.idx];O&&w.text&&(w.text.paragraphs=O,w.text.empty=!1)}v.push(b.slide),ae.add(x)}for(const u of Object.keys(e.shapes??{})){const[x]=u.split("/");x!==void 0&&!$.some(b=>b.id===x)&&a.push({slide:e.id,path:`${s}.shapes.${u}`,message:`Generator ${h} makes no slide ${x}: ${u} changes nothing.`})}});const le=new Set(v.map(e=>e.id));for(const e of v)for(const n of e.shapes){if(n.level!=="slide")continue;const s=[...n.link===void 0?[]:[n.link],...(n.text?.paragraphs??[]).flatMap(h=>h.runs.flatMap(g=>g.font?.link===void 0?[]:[g.font.link]))];for(const h of new Set(s)){const g=Ee(h);(g!==void 0?!le.has(g):h.startsWith("ppaction://")&&je(h)===void 0)&&a.push({slide:e.id,shape:n.name,message:g!==void 0?`Shape ${n.name} links to slide ${g}, which the deck has not (it has ${[...le].join(", ")}).`:`Shape ${n.name} links to ${h}: a show jump is ppaction://hlinkshowjump?jump= and ${Te.join(", ")}.`})}}return v.forEach((e,n)=>{for(const s of e.shapes)s.placeholder?.type==="sldNum"&&s.text&&(s.text.paragraphs=[{level:0,runs:[{text:String(n+1),field:"slidenum"}]}],s.text.empty=!1)}),{deck:{width:t.slide_width,height:t.slide_height,theme:E,slides:v},problems:a}}
|
|
2
|
+
import{CAPS as Ae,colorOfFile as fe,groupLevels as ze,SHOW_JUMPS as Te,showJumpOf as je,slideLinkOf as Ee,UNDERLINES as Fe}from"@allyhub/formats";import{readMarks as Ne,markRuns as Me}from"@allyhub/piece";import{shownPath as Le}from"@allyhub/formats";import{chartOfFile as Ce}from"@allyhub/chart";import{AUTOSHAPE_STYLE as D,SHADOW_DEFAULTS as W,PATTERN_DEFAULTS as ce,TILE_DEFAULTS as H,INNER_SHADOW_DEFAULTS as G,GLOW_DEFAULTS as ee,REFLECTION_DEFAULTS as K,CONNECTOR_STYLE as ue,DRAWN_TEXTBOX_FRAME as pe,TEXT_FALLBACK as he,TEXT_INSETS as J,isConnectorGeometry as Pe,placeholderFrame as Re,styleKindOf as De}from"./office.js";import{resolveAnimation as Ue,resolveTransition as Ie,unitsAcross as We,EFFECT_OPTIONS as He,TRANSITION_OPTIONS as Ge}from"./animation.js";import{glued as Xe}from"./connect.js";import{pathSteps as Be}from"./path.js";import{CHART_AXIS_WORDS as Ke}from"./script.js";import{cellLook as Je,tableStyleOf as ne}from"./table-style.js";import{masterPlaceholder as Ye}from"./placeholders.js";import{DECK_FONTS as Ve,OFFICE_THEME as Ze,themeOver as qe}from"./theme.js";import{Pt as v}from"./units.js";export function joinPath(i,t){if(t.startsWith("/"))return t.slice(1);const d=[];for(const a of[...i.split("/"),...t.split("/")])a===""||a==="."||(a===".."?d.pop():d.push(a));return d.join("/")}const me={left:0,top:0,width:0,height:0};function Qe(i,t){const d={...i.color_map,...t.color_map};return Object.keys(d).length>0?{color_map:d}:{}}const Y=()=>Array.from({length:9},()=>({...he,font:{...he.font},margin_left:0}));export function levelsOver(i,...t){return i.map((d,a)=>{let o={...d,font:{...d.font}};for(const g of t){const r=g?.[a];r&&(o={...o,...r.alignment===void 0?{}:{alignment:r.alignment},...r.line_spacing===void 0?{}:{line_spacing:r.line_spacing},...r.space_before===void 0?{}:{space_before:r.space_before},...r.space_after===void 0?{}:{space_after:r.space_after},...r.margin_left===void 0?{}:{margin_left:r.margin_left},...r.indent===void 0?{}:{indent:r.indent},font:{...o.font,...r.font}},r.numbered!==void 0&&(o.numbered=r.numbered,delete o.bullet),r.bullet===null?(delete o.bullet,delete o.numbered):r.bullet!==void 0?(delete o.numbered,o.bullet={char:r.bullet,...r.bullet_font===void 0?{}:{font:r.bullet_font}}):r.bullet_font!==void 0&&o.bullet&&(o.bullet={...o.bullet,font:r.bullet_font}),o=bulletLookOver(o,r))}return o})}export function bulletLookOver(i,t){const d={...i};return t.bullet_color===null?delete d.bullet_color:t.bullet_color!==void 0&&(d.bullet_color=t.bullet_color),t.bullet_size===null?delete d.bullet_size:t.bullet_size!==void 0&&(d.bullet_size=t.bullet_size),t.start_at!==void 0&&(d.start_at=t.start_at),d}function te(i,...t){const d=t.filter(o=>o!==void 0),a=o=>{for(let g=d.length-1;g>=0;g--){const r=d[g]?.[o];if(r!==void 0)return r}};return{vertical_anchor:a("vertical_anchor")??i.vertical_anchor,orientation:a("orientation")??"horz",auto_size:a("auto_size")??i.auto_size,word_wrap:a("word_wrap")??i.word_wrap,margins:{left:a("margin_left")??J.left,top:a("margin_top")??J.top,right:a("margin_right")??J.right,bottom:a("margin_bottom")??J.bottom}}}const _e={vertical_anchor:"t",auto_size:"none",word_wrap:!0};export const plainLevels=i=>levelsOver(Y(),i.text_styles.other);function ie(i,t){return{...te(_e,t),levels:levelsOver(Y(),i.text_styles.other,t.levels)}}function en(i,t,...d){return{...te(Re(t),...d),levels:levelsOver(Y(),i.text_styles[De(t)],...d.map(a=>a?.levels))}}const nn=Array.from({length:9},()=>({font:{color:D.font_color}})),ge={vertical_anchor:D.vertical_anchor};function be(i,t){return{...te(_e,t),levels:levelsOver(Y(),i.text_styles.other,nn,t.levels)}}const V=i=>{const t={...i};return delete t.paragraphs,t},Z=i=>({paragraphs:[],levels:[],...i}),P=i=>i==="none"?null:colorOfFile(i),tn=/<span((?:\s+(?:color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="[^"\n]*")+)\s*>(.*?)<\/span>/gu,on=/(color|font|size|bold|italic|underline|link|highlight|baseline|strike|spacing|caps)="([^"\n]*)"/gu,q=57344,an=256,ye="",rn=/[\ue000-\ue100]|[^\ue000-\ue100]+/gu;export const spaceOfFile=i=>typeof i=="number"?v(i):{lines:i.lines},colorOfFile=i=>fe(i)??"dk1";function oe(i){const{shadow:t,gradient:d,inner_shadow:a,glow:o,reflection:g}=i;return{...a?{inner_shadow:{color:a.color===void 0?G.color:colorOfFile(a.color),blur:a.blur===void 0?G.blur:v(a.blur),distance:a.distance===void 0?G.distance:v(a.distance),angle:a.angle??G.angle,transparency:a.transparency??G.transparency}}:{},...o?{glow:{color:o.color===void 0?ee.color:colorOfFile(o.color),size:o.size===void 0?ee.size:v(o.size),transparency:o.transparency??ee.transparency}}:{},...i.soft_edges===void 0?{}:{soft_edges:v(i.soft_edges)},...g?{reflection:{transparency:g.transparency??K.transparency,size:g.size??K.size,distance:g.distance===void 0?K.distance:v(g.distance),blur:g.blur===void 0?K.blur:v(g.blur)}}:{},...i.fill_transparency===void 0?{}:{fill_transparency:i.fill_transparency},...d?{gradient:{angle:d.angle??0,...d.path===void 0?{}:{path:d.path},...d.focus===void 0?{}:{focus:{left:d.focus.left??.5,top:d.focus.top??.5,right:d.focus.right??.5,bottom:d.focus.bottom??.5}},stops:d.stops.map(r=>({at:r.at,color:colorOfFile(r.color),...r.transparency===void 0?{}:{transparency:r.transparency}}))}}:{},...t?{shadow:{color:t.color===void 0?W.color:colorOfFile(t.color),blur:t.blur===void 0?W.blur:v(t.blur),distance:t.distance===void 0?W.distance:v(t.distance),angle:t.angle??W.angle,transparency:t.transparency??W.transparency}}:{}}}const dn=i=>({...i.tile?{tile:{...i.tile}}:{},...i.transparency===void 0?{}:{transparency:i.transparency}});function $e(i,t){const{pattern:d,picture_fill:a}=i;return{...d?{pattern:{preset:d.preset,fg:colorOfFile(d.fg??ce.fg),bg:colorOfFile(d.bg??ce.bg)}}:{},...a?{picture_fill:{path:joinPath(t,a.path),...a.tile?{tile:{scale_x:a.tile.scale_x??H.scale_x,scale_y:a.tile.scale_y??H.scale_y,offset_x:a.tile.x===void 0?H.offset_x:v(a.tile.x),offset_y:a.tile.y===void 0?H.offset_y:v(a.tile.y),align:a.tile.align??H.align}}:{},...a.transparency===void 0?{}:{transparency:a.transparency}}}:{}}}function ke(i,t,d=[]){const a=ne(i.style);return{...i,rows:i.rows.map((o,g)=>({height:o.height,cells:o.cells.map((r,j)=>{const N=d[g],_=a?Je(a,i,g,j,i.rows.length,i.columns.length,g+(r.span_height??1)-1,j+(r.span_width??1)-1):void 0,E=ie(t,r.text),C=_&&(_.bold!==void 0||_.text!==void 0)?{...E,levels:E.levels.map(R=>({...R,font:{...R.font,..._.bold===void 0?{}:{bold:_.bold},..._.text===void 0?{}:{color:_.text}}}))}:E;return{...r,text:{paragraphs:r.text.paragraphs,style:Q({...C,auto_size:"shape"},N),own:V(r.text),empty:!1},...N?{fileText:N}:{}}})}))}}function Q(i,t){return t?{...i,...t.anchor===void 0?{}:{vertical_anchor:t.anchor},...t.orientation===void 0?{}:{orientation:t.orientation},levels:i.levels.map(d=>{const a={...d.font,...t.size===void 0?{}:{size:v(t.size)},...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline},...t.strike===void 0?{}:{strike:t.strike},...t.caps===void 0?{}:{caps:t.caps},...t.font===void 0?{}:{name:t.font}};t.color!==void 0&&(a.color=colorOfFile(t.color));const o={...d,font:a,...t.align===void 0?{}:{alignment:t.align},...t.line_spacing===void 0?{}:{line_spacing:{lines:t.line_spacing}},...t.space_before===void 0?{}:{space_before:spaceOfFile(t.space_before)},...t.space_after===void 0?{}:{space_after:spaceOfFile(t.space_after)}};return t.bullet_color!==void 0&&(o.bullet_color=colorOfFile(t.bullet_color)),t.bullet_size!==void 0&&(o.bullet_size=t.bullet_size),t.start_at!==void 0&&(o.start_at=t.start_at),t.numbered!==void 0?(o.numbered=t.numbered,delete o.bullet):t.bullet===!1?(delete o.bullet,delete o.numbered):t.bullet!==void 0&&(o.bullet={char:t.bullet},delete o.numbered),(t.numbered!==void 0||t.bullet!==void 0&&t.bullet!==!1)&&d.margin_left===0?{...o,margin_left:we,indent:-we}:o})}:i}function ln(i,t){if(!t)return[...i];const d=t.numbered!==void 0||t.bullet!==void 0;return i.map(a=>{const o={...a};return t.align!==void 0&&delete o.alignment,t.line_spacing!==void 0&&delete o.line_spacing,t.space_before!==void 0&&delete o.space_before,t.space_after!==void 0&&delete o.space_after,t.bullet_color!==void 0&&delete o.bullet_color,t.bullet_size!==void 0&&delete o.bullet_size,t.start_at!==void 0&&delete o.start_at,d&&(delete o.bullet,delete o.bullet_font,delete o.numbered),o})}const sn=i=>Fe.includes(i),fn=i=>Ae.includes(i);function cn(i){const t={};for(const[,d,a=""]of i.matchAll(on))if(d==="font")t.name=a.trim();else if(d==="link")t.link=a.trim();else if(d==="highlight")t.highlight=a.trim().toUpperCase();else if(d==="bold")t.bold=a.trim()!=="false";else if(d==="italic")t.italic=a.trim()!=="false";else if(d==="strike"){const o=a.trim();t.strike=o==="dblStrike"?o:o!=="false"}else if(d==="underline"){const o=a.trim();t.underline=sn(o)&&o!=="sng"?o:o!=="false"}else if(d==="caps"){const o=a.trim();fn(o)&&(t.caps=o)}else if(d==="size"){const o=Number(a);Number.isFinite(o)&&o>0&&(t.size=v(o))}else if(d==="baseline"){const o=Number(a);Number.isFinite(o)&&(t.baseline=o)}else if(d==="spacing"){const o=Number(a);Number.isFinite(o)&&(t.spacing=v(o))}else{const o=fe(a.trim());o!==void 0&&(t.color=o)}return t}const we=342900;export function paragraphsOfWords(i,t=0,d=Ve.code){return i===void 0?[]:typeof i=="string"?i.split(/\r?\n/u).map(a=>{const o=[],g=a.replace(tn,(_,E,C)=>(o.push(cn(E)),`${String.fromCharCode(q+o.length-1)}${C}${ye}`)),r=Ne(g);let j;const N=Me(r.text,r.marks).flatMap(_=>{const E=_.kinds.includes("code"),C={..._.kinds.includes("strong")?{bold:!0}:{},..._.kinds.includes("em")?{italic:!0}:{},...E?{name:d}:{}};return[..._.text.matchAll(rn)].flatMap(R=>{const U=R[0],I=U.charCodeAt(0);if(U===ye)return j=void 0,[];if(I>=q&&I<q+an)return j=o[I-q],[];const X={...j,...C};return[{text:U,...Object.keys(X).length>0?{font:X}:{},...E?{code:!0}:{}}]})});return{runs:N.length>0?N:[{text:""}],level:t}}):i.flatMap(a=>paragraphsOfWords(a,Array.isArray(a)?Math.min(t+1,8):t,d))}const xe=i=>({left:v(i.x),top:v(i.y),width:v(i.w),height:v(i.h)}),un=new Set(["dt","ftr","sldNum"]),Se=i=>({...i.locked?{locked:!0}:{},...i.link===void 0?{}:{link:i.link},...i.rotation===void 0||i.rotation===0?{}:{rotation:i.rotation},...i.flip_h||i.flip_v?{flip:{...i.flip_h?{h:!0}:{},...i.flip_v?{v:!0}:{}}}:{}});function Oe(i,t,d){if(!t)return;t.fill!==void 0&&(i.background=colorOfFile(t.fill));const a=t.gradient&&oe({gradient:t.gradient}).gradient;a&&(i.background_gradient=a),t.picture!==void 0&&(i.background_picture=joinPath(d,t.picture))}function pn(i,t,d){if(i.data===void 0)return;let a;try{const _=t(Le(i.data));a=Array.isArray(_)?_:t(i.data)}catch(_){d(`${i.data} cannot be read: ${_ instanceof Error?_.message:String(_)}`);return}if(!Array.isArray(a)||a.length===0){d(`${i.data} holds no rows.`);return}const o=a,g=Object.keys(o[0]??{}),r=i.fields??g,j=r.filter(_=>!g.includes(_));if(j.length>0){d(`${i.data} has no column ${j.join(", ")} (it has ${g.join(", ")}).`);return}const N=_=>typeof _=="string"||typeof _=="number"||typeof _=="boolean"?String(_):"";return[...i.head===!1?[]:[[...r]],...o.map(_=>r.map(E=>N(_[E])))]}const hn=i=>{const t=ne(i.style);return{...t?{style:t.id}:{},...i.first_row===void 0?{}:{first_row:i.first_row},...i.last_row===void 0?{}:{last_row:i.last_row},...i.first_col===void 0?{}:{first_col:i.first_col},...i.last_col===void 0?{}:{last_col:i.last_col},...i.horz_banding===void 0?{}:{horz_banding:i.horz_banding},...i.vert_banding===void 0?{}:{vert_banding:i.vert_banding}}},ve=i=>i===void 0?void 0:{left:i.left??0,top:i.top??0,right:i.right??0,bottom:i.bottom??0};export function resolveDeck(i){const{code:t,file:d,words:a,prefix:o,base:g}=i,r=[],j=qe(i.theme??Ze,t.theme),N=new Map;for(const e of t.masters)for(const n of e.layouts)N.set(n.name,{layout:n,master:e});const _=[],E=(e,n,l)=>{const m=Ge[n.type];return n.direction!==void 0&&!m.directions.includes(n.direction)&&r.push({slide:e,path:`${l}.transition.direction`,message:m.directions.length===0?`A ${n.type} transition has no direction (${n.direction}).`:`A ${n.type} transition goes ${m.directions.join(", ")}, not ${n.direction}.`}),n.through_black===!0&&!m.throughBlack&&r.push({slide:e,path:`${l}.transition.through_black`,message:`A ${n.type} transition does not go through black: only a fade, a cut and a reveal do.`}),Ie(n)},C=(e,n,l)=>({name:e.name,kind:e.kind,frame:{...e.frame??me},...e.flip?{flip:{...e.flip}}:{},...e.connect?{connect:{...e.connect.begin?{begin:{...e.connect.begin}}:{},...e.connect.end?{end:{...e.connect.end}}:{}}}:{},...e.rotation===void 0?{}:{rotation:e.rotation},level:n,...e.text?{text:{paragraphs:e.text.paragraphs,style:e.kind==="autoshape"?be(l,e.text):ie(l,e.text),own:V(e.text),empty:!1}}:{},...e.fill===void 0?{}:{fill:e.fill},...e.fill_transparency===void 0?{}:{fill_transparency:e.fill_transparency},...e.gradient?{gradient:e.gradient}:{},...e.pattern?{pattern:e.pattern}:{},...e.picture_fill?{picture_fill:{...dn(e.picture_fill),path:joinPath(e.picture_fill.base,e.picture_fill.path)}}:{},...e.shadow===void 0?{}:{shadow:e.shadow},...e.inner_shadow?{inner_shadow:e.inner_shadow}:{},...e.glow?{glow:e.glow}:{},...e.soft_edges===void 0?{}:{soft_edges:e.soft_edges},...e.reflection?{reflection:e.reflection}:{},...e.line===void 0?{}:{line:e.line},...e.line_width===void 0?{}:{line_width:e.line_width},...e.line_dash===void 0?{}:{line_dash:e.line_dash},...e.line_cap===void 0?{}:{line_cap:e.line_cap},...e.line_join===void 0?{}:{line_join:e.line_join},...e.line_compound===void 0?{}:{line_compound:e.line_compound},...e.line_begin===void 0?{}:{line_begin:e.line_begin},...e.line_end===void 0?{}:{line_end:e.line_end},...e.line_begin_size===void 0?{}:{line_begin_size:e.line_begin_size},...e.line_end_size===void 0?{}:{line_end_size:e.line_end_size},...e.path?{path:e.path}:{},...e.table?{table:ke(e.table,l)}:{},...e.chart?{chart:e.chart}:{},...e.link===void 0?{}:{link:e.link},...e.group===void 0?{}:{group:e.group},...e.geometry?{geometry:e.geometry}:{},...e.adjustments?{adjustments:[...e.adjustments]}:{},...e.media?{media:{path:joinPath(e.media.base,e.media.path),...e.media.poster===void 0?{}:{poster:e.media.poster},...e.media.playback?{playback:e.media.playback}:{}}}:{},...e.component?{component:{...e.component}}:{},sources:{frame:{from:n}}}),R=(e,n)=>{const l=e.placeholder?.type??"body",m=Ye(n,l),b=e.frame??m?.frame??me;return{name:e.name,kind:"placeholder",frame:{...b},level:"slide",...e.placeholder?{placeholder:{...e.placeholder}}:{},text:{paragraphs:[],style:en(n,l,m?.text,e.text),empty:!0},...e.fill===void 0?{}:{fill:e.fill},...e.line===void 0?{}:{line:e.line},sources:{frame:{from:e.frame||!m?"layout":"master"},text:{from:"layout"}}}},U=(e,n,l,m)=>{const b=t.components[e];if(!b){r.push({...l,message:/\.[cm]?[jt]sx?(?:#|$)/u.test(e)?`${e} names no component: its module has no such export, or the export is not made with defineComponent.`:`There is no component ${e} in the deck's module (it has ${Object.keys(t.components).join(", ")||"none"}).`});return}for(const w of Object.keys(n??{}))Object.hasOwn(b.props,w)||r.push({...l,message:`Component ${e} has no prop ${w} a person sets (it has ${Object.keys(b.props).join(", ")||"none"}).`});return{name:e,props:{...n??{}},...m===void 0?{}:{dur:m}}},I=(e,n,l,m,b)=>{const w={slide:m,shape:e,path:l};if(!n.frame){r.push({...w,message:`Shape ${e} is the slide's own: it needs a frame { x, y, w, h } in points.`});return}const z=xe(n.frame),c={frame:{from:"slide",path:`${l}.frame`}},S={name:e,frame:z,level:"slide",...n.fill===void 0?{}:{fill:P(n.fill)},...oe(n),...$e(n,g),...n.line===void 0?{}:{line:P(n.line)},...n.line_dash===void 0?{}:{line_dash:n.line_dash},...n.line_cap===void 0?{}:{line_cap:n.line_cap},...n.line_join===void 0?{}:{line_join:n.line_join},...n.line_compound===void 0?{}:{line_compound:n.line_compound},...n.line_begin===void 0?{}:{line_begin:n.line_begin},...n.line_end===void 0?{}:{line_end:n.line_end},...n.line_begin_size===void 0?{}:{line_begin_size:n.line_begin_size},...n.line_end_size===void 0?{}:{line_end_size:n.line_end_size},...n.group===void 0?{}:{group:n.group},...Se(n)};if(n.textbox)return{...S,kind:"textbox",text:{paragraphs:paragraphsOfWords(a(`${o}.${m}.${e}`),0,j.fonts.code),style:Q(ie(b,Z(pe)),n.text),own:V(Z(pe)),empty:!1},...n.text?{fileText:{...n.text}}:{},sources:{...c,text:{from:"slide",path:`${l}.text`}}};if(n.picture!==void 0){const u=ve(n.crop);return{...S,kind:"picture",media:{path:joinPath(g,n.picture),...u?{crop:u}:{}},sources:{...c,media:{from:"slide",path:`${l}.picture`}}}}if(n.item!==void 0)return{...S,kind:"item",item:{path:joinPath(g,n.item),...n.playback?{playback:n.playback}:{}},sources:{...c,media:{from:"slide",path:`${l}.item`}}};if(n.movie!==void 0)return{...S,kind:"movie",media:{path:joinPath(g,n.movie),...n.poster===void 0?{}:{poster:n.poster},...n.playback?{playback:n.playback}:{}},sources:{...c,media:{from:"slide",path:`${l}.movie`}}};if(n.audio!==void 0)return{...S,kind:"audio",media:{path:joinPath(g,n.audio),...n.playback?{playback:n.playback}:{}},sources:{...c,media:{from:"slide",path:`${l}.audio`}}};if(n.chart){const u=`${o}.${m}.${e}`,A=p=>typeof p=="string"?p:void 0,x=Object.fromEntries(Ke.flatMap(p=>{const s=A(a(`${u}.${p}`));return s===void 0?[]:[[p,s]]})),T=Ce(n.chart,{title:A(a(u))??A(a(`${u}.title`)),axisTitles:x,base:g,rows:p=>i.data?.(p),problem:p=>{r.push({...w,message:`Chart ${e}: ${p}`})}});return T?{...S,kind:"chart",chart:T,sources:c}:void 0}if(n.table){const u=n.table;u.style!==void 0&&!ne(u.style)&&r.push({...w,message:`Table ${e}'s style ${u.style} is none of PowerPoint's built-in table styles: name one as its gallery does (Medium Style 2 - Accent 1, Light Style 1, No Style, Table Grid) or by its id.`});const A=u.data===void 0?void 0:pn(u,f=>i.data?.(f),f=>{r.push({...w,message:`Table ${e}: ${f}`})});if(u.data!==void 0&&A===void 0)return;const x=A===void 0?u.rows:A.map((f,y)=>u.rows[Math.min(y,u.rows.length-1)]??u.rows[0]),T=z.width/u.columns.reduce((f,y)=>f+y,0),p=z.height/x.reduce((f,y)=>f+(y?.height??0),0),s=a(`${o}.${m}.${e}`),h=A??(Array.isArray(s)?s:[]),k=new Map;for(const f of u.merged??[]){const y=f.rows??1,O=f.columns??1;for(let M=f.row;M<f.row+y;M++)for(let F=f.column;F<f.column+O;F++)k.set(`${String(M)},${String(F)}`,"under");k.set(`${String(f.row)},${String(f.column)}`,{w:O,h:y})}return A===void 0&&h.length>u.rows.length&&r.push({...w,message:`Table ${e} has ${String(u.rows.length)} rows and its words ${String(h.length)}.`}),{...S,kind:"table",table:ke({...hn(u),columns:u.columns.map(f=>Math.round(f*T)),rows:x.flatMap((f,y)=>{if(!f)return[];const O=h[y],M=Array.isArray(O)?O:O===void 0?[]:[O];return{height:Math.round(f.height*p),cells:u.columns.map((F,B)=>{const L=k.get(`${String(y)},${String(B)}`);return{text:{levels:[],paragraphs:L==="under"?[]:paragraphsOfWords(M[B],0,j.fonts.code)},...L==="under"?{spanned:!0}:{},...L!==void 0&&L!=="under"&&L.w>1?{span_width:L.w}:{},...L!==void 0&&L!=="under"&&L.h>1?{span_height:L.h}:{},...f.fill===void 0?{}:{fill:colorOfFile(f.fill)},...f.line===void 0?{}:{borders:{bottom:{color:colorOfFile(f.line),width:v(1)}}}}})}})},b,x.map(f=>f?.text)),sources:c}}const $=n.path&&Be(n.path.d);if(n.path&&!$){r.push({...w,message:`Shape ${e}'s path starts with M and says only M, L, C and Z, absolute.`});return}if(n.geometry!==void 0||n.path&&$){const u=!n.path&&Pe(n.geometry);return{...S,kind:"autoshape",...n.path&&$?{path:{w:n.path.w,h:n.path.h,steps:$}}:n.geometry===void 0?{}:{geometry:n.geometry,...n.adjustments?{adjustments:[...n.adjustments]}:{}},...u?{line:n.line===void 0?ue.line:P(n.line),line_width:n.line_width===void 0?ue.line_width:v(n.line_width)}:{fill:n.fill===void 0?D.fill:P(n.fill),line:n.line===void 0?D.line:P(n.line),line_width:n.line_width===void 0?D.line_width:v(n.line_width)},...n.text&&!u?{fileText:{...n.text}}:{},...u?{}:{text:{paragraphs:paragraphsOfWords(a(`${o}.${m}.${e}`)).map(A=>n.text?.align===void 0?{alignment:D.alignment,...A}:A),style:Q(be(b,Z(ge)),n.text),own:V(Z(ge)),empty:!1}},sources:{...c,fill:{from:"slide",path:`${l}.fill`}}}}if(n.component!==void 0){const u=U(n.component,n.props,w,n.dur);return u?{...S,kind:"component",component:u,sources:c}:void 0}},X=(e,n,l)=>{if(n.frame&&(e.frame=xe(n.frame),e.sources.frame={from:"slide",path:`${l}.frame`}),Object.assign(e,Se(n)),n.dur!==void 0&&e.component&&(e.component={...e.component,dur:n.dur}),n.text&&e.text&&(e.text.style=Q(e.text.style,n.text),e.text.paragraphs=ln(e.text.paragraphs,n.text),e.fileText={...n.text},e.sources.text={from:"slide",path:`${l}.text`}),n.line!==void 0&&(e.line=P(n.line),e.sources.line={from:"slide",path:`${l}.line`}),n.line_width!==void 0&&(e.line_width=v(n.line_width)),n.line_dash!==void 0&&(e.line_dash=n.line_dash),n.line_cap!==void 0&&(e.line_cap=n.line_cap),n.line_join!==void 0&&(e.line_join=n.line_join),n.line_compound!==void 0&&(e.line_compound=n.line_compound),n.line_begin!==void 0&&(e.line_begin=n.line_begin),n.line_end!==void 0&&(e.line_end=n.line_end),n.line_begin_size!==void 0&&(e.line_begin_size=n.line_begin_size),n.line_end_size!==void 0&&(e.line_end_size=n.line_end_size),(n.fill!==void 0||n.gradient!==void 0||n.pattern!==void 0||n.picture_fill!==void 0)&&(delete e.gradient,delete e.pattern,delete e.picture_fill),n.fill!==void 0&&(e.fill=P(n.fill),e.sources.fill={from:"slide",path:`${l}.fill`}),Object.assign(e,oe(n),$e(n,g)),(n.picture!==void 0||n.movie!==void 0)&&(e.placeholder?.type==="pic"||e.placeholder?.type==="media"||e.placeholder?.type==="obj")){const m=ve(n.crop);e.kind=n.picture!==void 0?"picture":"movie",e.media={path:joinPath(g,n.picture??n.movie??""),...m?{crop:m}:{},...n.poster===void 0?{}:{poster:n.poster},...n.playback&&n.movie!==void 0?{playback:n.playback}:{}},e.sources.media={from:"slide",path:`${l}.${n.picture!==void 0?"picture":"movie"}`},delete e.text}else n.playback&&e.media&&(e.kind==="movie"||e.kind==="audio")&&(e.media={...e.media,playback:{...e.media.playback,...n.playback}})},ae=(e,n,l,m,b)=>{const w=N.get(n);if(!w){r.push({slide:e,path:`slides.${String(l)}.layout`,message:`Slide ${e} is on the layout "${n}", which the deck's module does not have (it has ${[...N.keys()].join(", ")||"none"}).`});return}const{layout:z,master:c}=w,S=[...(z.display_master_shapes===!1?[]:c.shapes).filter(u=>u.kind!=="placeholder").map(u=>C(u,"master",c)),...z.shapes.filter(u=>u.kind!=="placeholder").map(u=>C(u,"layout",c))],$=z.shapes.filter(u=>u.kind==="placeholder").map((u,A)=>({shape:R(u,c),order:A}));return{slide:{id:e,layout:z.name,master:c.name,hidden:m,background:z.background??c.background,...Qe(c,z),shapes:S,animations:[],file:{index:l,...b===void 0?{}:{generate:b}}},placed:$,master:c}},re=(e,n,l)=>{if(!n)return;const m=z=>{const c=n[z];if(c===void 0)return e.connect?.[z];const S=c==="none"?void 0:l(c.shape);return c==="none"||S===void 0?void 0:{shape:S,site:c.site}},b=m("begin"),w=m("end");b||w?e.connect={...b?{begin:b}:{},...w?{end:w}:{}}:delete e.connect},de=(e,n,l,m,b,w,z,c,S,$=()=>{})=>{const u=new Set(l.map(p=>p.shape.name));let A=l.length;for(const[p,s]of Object.entries(m??{})){const h=w(p);if(h===void 0)continue;const k=`${b}.shapes.${p}`,f=s.textbox!==void 0||s.geometry!==void 0||s.path!==void 0||s.table!==void 0||s.chart!==void 0||s.component!==void 0||s.audio!==void 0||s.item!==void 0||(s.picture!==void 0||s.movie!==void 0)&&!u.has(h),y=l.find(M=>M.shape.name===h);if(y&&!f){X(y.shape,s,k),re(y.shape,s.connect,w),y.shown=!0,s.z!==void 0&&(y.z=s.z);continue}if(y){r.push({slide:e.id,shape:h,path:k,message:`Slide ${e.id} has a ${y.shape.kind} ${h} already: a shape of its own needs another name.`});continue}if(!f){r.push({slide:e.id,shape:h,path:k,message:`Slide ${e.id} has no shape ${h} to change (its layout's placeholders and its own shapes are ${[...u].join(", ")||"none"}).`});continue}const O=I(h,s,k,e.id,n);O&&re(O,s.connect,w),O&&(l.push({shape:O,order:A++,...s.z===void 0?{}:{z:s.z}}),u.add(h))}const x=l.filter(p=>p.shown===!0||!un.has(p.shape.placeholder?.type??"")||z(p.shape)!==void 0);l.splice(0,l.length,...x),l.sort((p,s)=>(p.z??0)-(s.z??0)||p.order-s.order);const T=(p,s)=>{const h=f=>{const y=f.shape.group;return y===void 0?void 0:ze(y)[s]},k=new Map(p.flatMap((f,y)=>{const O=h(f);return O===void 0?[]:[[O,y]]}));return p.flatMap((f,y)=>{const O=h(f);return O===void 0?[f]:k.get(O)===y?T(p.filter(M=>h(M)===O),s+1):[]})};l.splice(0,l.length,...T(l,0));for(const p of l){const s=$(p.shape);s!==void 0&&(p.shape.alt=s);const h=p.shape.text;if(p.shape.kind==="placeholder"&&h){const k=z(p.shape);h.paragraphs=paragraphsOfWords(k,0,j.fonts.code),h.empty=h.paragraphs.length===0||h.paragraphs.every(f=>f.runs.every(y=>y.text===""))}}e.shapes.push(...l.map(p=>p.shape));for(const p of e.shapes){const s=p.connect;if(!s)continue;const h=Xe(p,k=>e.shapes.find(f=>f.name===k&&f.level===p.level&&f!==p));p.frame=h.frame,h.flip?p.flip=h.flip:delete p.flip;for(const k of h.lost){const f=s[k];f&&p.level==="slide"&&r.push({slide:e.id,shape:p.name,message:`Connector ${p.name}'s ${k} is glued to site ${String(f.site)} of ${f.shape}, which slide ${e.id} has not: it stays where it is.`})}}c!==void 0&&c.trim()!==""&&(e.notes=c);for(const[p,s]of(S??[]).entries()){const h=w(s.shape);if(h===void 0)continue;const k={slide:e.id,shape:h,path:`${b}.animations.${String(p)}`},f=e.shapes.find(F=>F.name===h&&F.level==="slide");if(!f){r.push({...k,message:`Slide ${e.id} has no shape ${h} to animate (it has ${e.shapes.filter(F=>F.level==="slide").map(F=>F.name).join(", ")}).`});continue}if(s.paragraph!==void 0&&s.paragraph>=(f.text?.paragraphs.length??0)){r.push({...k,message:`Shape ${h} has no paragraph ${String(s.paragraph)} to animate (it has ${String(f.text?.paragraphs.length??0)}).`});continue}const y=He[s.effect];s.direction!==void 0&&!y.directions.includes(s.direction)&&r.push({...k,path:`${k.path}.direction`,message:y.directions.length===0?`${h}'s ${s.effect} has no direction (${s.direction}).`:`${h}'s ${s.effect} goes ${y.directions.join(", ")}, not ${s.direction}.`}),s.amount!==void 0&&y.amount===void 0?r.push({...k,path:`${k.path}.amount`,message:`${h}'s ${s.effect} has no amount: only a Grow/Shrink, a spin and a Transparency do.`}):s.effect==="transparency"&&(s.amount??0)>1&&r.push({...k,path:`${k.path}.amount`,message:`${h}'s transparency is a share, at most 1 (it is ${String(s.amount)}).`}),s.animate_text!==void 0&&!f.text&&r.push({...k,path:`${k.path}.animate_text`,message:`${h} has no text to animate by ${s.animate_text}: it plays as one.`});const O=s.animate_text,M=Ue({...s,shape:h,...f.text?{}:{animate_text:void 0}},O===void 0?1:(s.paragraph===void 0?f.text?.paragraphs??[]:[f.text?.paragraphs[s.paragraph]]).reduce((F,B)=>F+We(B?.runs.map(L=>L.text)??[],O).length,0));M?e.animations.push(M):r.push({...k,message:`The animation of ${h} needs a path that starts with M and says only M, L and C, absolute.`})}},le=new Set;d.slides.forEach((e,n)=>{const l=`slides.${String(n)}`;if(e.layout!==void 0){const c=ae(e.id,e.layout,n,e.hidden===!0);if(!c)return;const S=a(`${o}.${e.id}.notes`);e.transition&&(c.slide.transition=E(e.id,e.transition,l)),e.advance_after!==void 0&&(c.slide.advance=e.advance_after),e.section!==void 0&&(c.slide.section=e.section),Oe(c.slide,e.background,g),de(c.slide,c.master,c.placed,e.shapes,l,$=>$,$=>a(`${o}.${e.id}.${$.name}`),typeof S=="string"?S:void 0,e.animations,$=>{const u=a(`${o}.${e.id}.alt.${$.name}`);return typeof u=="string"?u:void 0}),_.push(c.slide),le.add(e.id);return}const m=e.generate??"",b=t.generators[m];if(b===void 0){r.push({slide:e.id,path:`${l}.generate`,message:`There is no generator ${m} in the deck's module (it has ${Object.keys(t.generators).join(", ")||"none"}).`});return}if(!Array.isArray(b)){r.push({slide:e.id,path:`${l}.generate`,message:`Generator ${m} threw: ${b.error}`,...b.stack===void 0?{}:{stack:b.stack}});return}const w=b,z=new Set(Array.isArray(e.hidden)?e.hidden:[]);for(const c of w){const S=`${e.id}/${c.id}`,$=ae(S,c.layout,n,z.has(c.id),m);if(!$)continue;for(const x of c.shapes){const T=x.placeholder?$.placed.find(p=>p.shape.placeholder?.idx===x.placeholder?.idx):void 0;if(T)x.frame&&(T.shape.frame={...x.frame}),T.shape.sources.frame={from:"code"},T.shown=!0;else{const p=C(x,"layout",$.master);$.placed.push({shape:{...p,level:"slide",sources:{frame:{from:"code"}}},order:$.placed.length})}}const u=`${c.id}/`,A=c.transition??(c===w[0]?e.transition:void 0);Oe($.slide,e.background,g),A&&($.slide.transition=E($.slide.id,A,l)),c===w[0]&&e.section!==void 0&&($.slide.section=e.section),de($.slide,$.master,$.placed,e.shapes,l,x=>x.startsWith(u)?x.slice(u.length):void 0,x=>{const T=x.placeholder===void 0?void 0:c.text[x.placeholder.idx];return T===void 0?void 0:T.map(p=>p.runs.map(s=>s.text).join(""))},c.notes,[...(c.animations??[]).map(x=>({...x,shape:`${u}${x.shape}`})),...e.animations??[]]);for(const x of $.slide.shapes){const T=x.placeholder===void 0?void 0:c.text[x.placeholder.idx];T&&x.text&&(x.text.paragraphs=T,x.text.empty=!1)}_.push($.slide),le.add(S)}for(const c of Object.keys(e.shapes??{})){const[S]=c.split("/");S!==void 0&&!w.some($=>$.id===S)&&r.push({slide:e.id,path:`${l}.shapes.${c}`,message:`Generator ${m} makes no slide ${S}: ${c} changes nothing.`})}});const se=new Set(_.map(e=>e.id));for(const e of _)for(const n of e.shapes){if(n.level!=="slide")continue;const l=[...n.link===void 0?[]:[n.link],...(n.text?.paragraphs??[]).flatMap(m=>m.runs.flatMap(b=>b.font?.link===void 0?[]:[b.font.link]))];for(const m of new Set(l)){const b=Ee(m);(b!==void 0?!se.has(b):m.startsWith("ppaction://")&&je(m)===void 0)&&r.push({slide:e.id,shape:n.name,message:b!==void 0?`Shape ${n.name} links to slide ${b}, which the deck has not (it has ${[...se].join(", ")}).`:`Shape ${n.name} links to ${m}: a show jump is ppaction://hlinkshowjump?jump= and ${Te.join(", ")}.`})}}return _.forEach((e,n)=>{for(const l of e.shapes)l.placeholder?.type==="sldNum"&&l.text&&(l.text.paragraphs=[{level:0,runs:[{text:String(n+1),field:"slidenum"}]}],l.text.empty=!1)}),{deck:{width:t.slide_width,height:t.slide_height,theme:j,slides:_},problems:r}}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{readFile as
|
|
2
|
+
import{readFile as I}from"node:fs/promises";import{join as N,posix as f}from"node:path";import{problem as y}from"@allyhub/diagnostics";import{besideModule as K,deckReferences as U,loadFailure as D,mergeScript as B,messagePrefix as H,nodeStackPlace as M,parseComponentRef as L,pieceLocales as W,readScripts as G,referenceModule as J,resolveDims as Q,resolveMatrix as V,stageName as X}from"@allyhub/build";import{USE_FORMS as j,shownOf as Y}from"@allyhub/formats";import{checkDeck as Z,readSlidesFile as ee}from"@allyhub/slides-core";import{deckOf as te}from"./deck-info.js";export const DECK_DPI=144;const A=914400;export const deckFormat=([t,s])=>`${String(Math.round(t/A*DECK_DPI))}x${String(Math.round(s/A*DECK_DPI))}`;export async function readDeck(t,s){const r=[],i=t.id,u=s.claim(i,t.entry);if(u!==void 0)return r.push(y("AK-B001",`${t.entry} and ${u} both have the piece id ${i}.`,{where:{file:t.entry}})),{problems:r};const d=await s.meta.request({type:"run",module:K(import.meta.url,"evaluate"),file:t.entry,input:{files:!0}});if(r.push(...d.problems),!d.ok)return d.error!=="timeout"&&r.push(D(t.entry,d.error??"",M(d.stack,s.root))),{problems:r};const{slides:n,script:k}=d.value;if(n===void 0||k===void 0)return r.push(y("AK-M011",`The deck ${i} names no ${n===void 0?"slides":"script"}: presentation({ slides: "./${f.basename(i)}.yaml", script: "./${f.basename(i)}.{locale}.yaml" }, …) names its slides' file and its script, a file per language, from its module's folder.`,{piece:i,where:{file:t.entry}})),{problems:r};const w=[{path:n,role:"slides"},{path:k,role:"script"}],v=await G(s.root,s.files,k,i);r.push(...v.problems),r.push(...B(s.messages,i,v.scripts));const O=W(s.messages,v.scripts),$=e=>({file:n,...e===void 0?{}:{line:e}});let p,b=()=>{},c;try{c=await I(N(s.root,n),"utf8")}catch{r.push(y("AK-M011",`The deck ${i} names ${n} for its slides, which is not there: write it, its slides listed each on one of ${f.basename(t.entry)}'s layouts (slides: [{ id: cover, layout: Title Slide }]).`,{piece:i,where:{file:n}}))}const m=c===void 0?void 0:ee(c);if(m){b=m.readable?.lineOf??m.lineOf;for(const e of m.problems)r.push(y("AK-M011",`${n}: ${e.message}`,{piece:i,where:$(e.line)}));p=m.readable?.file}const T=r.length,_={slides:p,words:Object.fromEntries(O.map(e=>[e,s.messages.messages[e]??{}])),prefix:H(i),tables:Object.fromEntries(Object.entries(s.lent).map(([e,o])=>[e,o.value])),shown:Object.fromEntries(Object.entries(s.lent).flatMap(([e,o])=>o.shown===void 0?[]:[[e,o.shown]]))},h=await s.meta.request({type:"run",module:K(import.meta.url,"evaluate"),file:t.entry,input:_});if(r.push(...h.problems),!h.ok)return h.error!=="timeout"&&r.push(D(t.entry,h.error??"",M(h.stack,s.root))),{problems:r,files:w};const a=h.value,P=e=>{const o=M(e.stack,s.root);return o?{file:o.file,line:o.line}:$(e.path===void 0?void 0:b(e.path))};for(const e of[...a.problems,...Z(a.resolved,{mediaKind:o=>s.media[o]?.kind})])r.push(y("AK-M011",e.stack===void 0?`${n}: ${e.message}`:e.message,{piece:i,...e.slide===void 0?{}:{part:e.slide},where:P(e)}));if(a.resolved.slides.length===0)return r.length===T&&m?.file&&r.push(y("AK-K003",m.file.slides.length===0?`The deck has no slides: ${n} lists none (slides: [{ id: cover, layout: Title Slide }]).`:`The deck has no slides: ${n} lists only generators, and they made none.`,{piece:i,where:$(b("slides"))})),{problems:r,files:w};const x=Q(void 0,{locales:O}),R=await V({root:s.root,piece:i,file:t.entry,dims:x,matrix:void 0,files:[]}),S=deckFormat(a.size),F={id:i,idFrom:"path",kind:t.kind,dir:t.dir,file:t.entry,place:i,...a.title===void 0?{}:{title:a.title},format:S,formatEntry:S,dims:x,combos:R.combos,options:{},meta:{},script:k,info:{slides:n,...p?{file:p}:{},size:a.size,layouts:a.layouts,components:a.components,generators:a.generators,code:a.code,data:a.data},loads:{kindData:{slides:p??{slides:[]},slidesFile:n,code:a.code}},counts:{value:p??null}},z=f.dirname(n)===f.dirname(t.entry),C=e=>{const o=/[\w#./-]/u;for(let l=z?c?.indexOf(e)??-1:-1;c!==void 0&&l>=0;){const g=c[l-1]??" ",q=c[l+e.length]??" ";if(!o.test(g)&&!o.test(q))return{from:n,line:c.slice(0,l).split(`
|
|
3
|
+
`).length};l=c.indexOf(e,l+1)}return{}},E=[...Object.keys(a.data).filter(e=>e.includes("#")&&Y(e)===void 0).map(e=>({of:e,...C(e),types:[j.data],role:"data"})),...a.resolved.slides.flatMap(e=>e.shapes.flatMap(o=>{if(o.kind!=="item"||!o.item)return[];const l=f.relative(f.dirname(n),o.item.path),g=b(o.sources.media?.path??"");return[{of:l.startsWith(".")?l:`./${l}`,from:n,...g===void 0?{}:{line:g},types:[j.live,"wav"],madeFor:["pptx"],role:"item"}]}))];return{problems:r,files:w,...E.length>0?{uses:E}:{},piece:F,stage:se(F,n)}}function se(t,s){const r=f.dirname(t.file),i=U(te(t)?.file).flatMap(u=>{const d=J(r,u),n=L(u);return d!==void 0&&n?[{of:u,module:d,name:n.name}]:[]});return{name:X(t.id),module:t.file,of:s,components:i}}const re={read:readDeck,onStage:!0,checks:[import.meta.resolve("@allyhub/slides-core"),import.meta.resolve("@allyhub/video-measure"),import.meta.resolve("@allyhub/video-core")],still:async(t,s,r)=>new(await import("@allyhub/video-measure")).OpenedFilm(t).still(s,r.format===void 0?{}:{format:r.format}),checkPiece:async t=>(await import("./check.js")).checkDeck(t),ready:async(t,s)=>(await import("./export.js")).deckReady(t,s),render:async(t,s)=>(await import("./export.js")).renderDeck(s)};export default re;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{existsSync as k}from"node:fs";import{mkdir as v,readFile as I,stat as O,writeFile as S}from"node:fs/promises";import{basename as b,dirname as T,join as
|
|
3
|
-
`)}}});const M={unread:"not read",extension:"an extension not read",part:"a part not read","cannot-hold":"cannot hold",approximated:"approximated",missing:"missing"};function U(e){const
|
|
2
|
+
import{existsSync as k}from"node:fs";import{mkdir as v,readFile as I,stat as O,writeFile as S}from"node:fs/promises";import{basename as b,dirname as T,join as c,posix as g,resolve as z}from"node:path";import{z as i}from"zod";import{ZIP_LIMITS as P,itemIdOf as C}from"@allyhub/formats";import{PROJECT_DIR as D,defineCliCommand as y,listWork as E,projectRoot as R}from"@allyhub/build";import{CommandError as p,EXIT as f}from"@allyhub/protocol";import{CAPABILITIES as $}from"@allyhub/slides-core";import{groupReport as F}from"@allyhub/ooxml";import{importDeck as N,nameOf as q,readPptx as A}from"@allyhub/slides-pptx";export const slidesCapabilities=y({input:i.strictObject({}),output:i.looseObject({}),examples:["allyhub slides capabilities"],run:()=>Promise.resolve({value:{...$},text:JSON.stringify($,null,2)})});const L=i.string().transform(e=>e.replace(/^\/+/gu,"")).refine(e=>e.endsWith(".ts")&&!e.split("/").some(o=>o===""||o==="."||o===".."),{message:"a .ts file from the project's root, such as reviews/q3.ts"});export const slidesImport=y({input:i.strictObject({file:i.string().describe("The .pptx to make a deck of"),to:L.optional().describe("The deck's module, from the project's root (default <the file's name>.ts); its slides are <name>.yaml beside it, its script <name>.<lang>.yaml, its pictures and videos beside them under names no file there has"),maxUnzipped:i.number().positive().default(P.bytes/1024/1024).describe("The most MB the file may unzip to"),lang:i.string().regex(/^[a-z]{2,3}(-[a-z0-9]+)*$/u).default("en").describe("The language of its words: its script is <name>.<lang>.yaml"),dir:D}),positional:["file"],output:i.looseObject({}),examples:["allyhub slides import ~/Downloads/q3-review.pptx --to reviews/q3.ts","allyhub slides import 培训.pptx --to training/onboarding.ts --lang zh-cn"],run:async(e,o)=>{const a=await R(o.cwd,e.dir),s=z(o.cwd,e.file),x=await I(s).catch(()=>{throw new p("not-found",`There is no file ${s}.`,{exit:f.notFound})}),n=e.to??`${q(b(s).replace(/\.pptx$/iu,""),new Set,"deck")}.ts`,h=g.dirname(n),l=t=>h==="."?t:`${h}/${t}`;let r;try{r=N(A(new Uint8Array(x),{bytes:e.maxUnzipped*1024*1024}),{lang:e.lang,source:b(s),name:g.basename(n,".ts"),taken:t=>k(c(a,l(t)))})}catch(t){throw new p("bad-file",`${s} is not a PowerPoint file this can read: ${t.message}`,{exit:f.usage})}const m=[...r.files.keys()].map(l);for(const t of m)if(await O(c(a,t)).catch(()=>{}))throw new p("place-taken",`${t} is already there.`,{exit:f.conflict,hint:"Name another module with --to."});for(const[t,j]of r.files){const w=c(a,l(t));await v(T(w),{recursive:!0}),await S(w,j,{flag:"wx"})}await E(a,{kind:"slides",file:n});const d=C(n),u=F(r.report);return{value:{id:d,files:m,report:r.report,skipped:Object.fromEntries(r.reasons)},text:[`Made ${m.join(", ")}; listed in allyhub.yaml as ${d}.`,...u.length>0?[`Not carried over as it is (${String(r.report.length)}, grouped; all with --json):`,...u.map(U)]:[],`allyhub check, then allyhub frames ${d}, to see it.`].join(`
|
|
3
|
+
`)}}});const M={unread:"not read",extension:"an extension not read",part:"a part not read","cannot-hold":"cannot hold",approximated:"approximated",missing:"missing"};function U(e){const o=e.where.length>3?`${e.where.slice(0,3).join("; ")} and ${String(e.where.length-3)} more`:e.where.join("; ");return` ${M[e.kind]}: ${e.what}${e.detail===void 0?"":` (${e.detail})`}${e.count>1?` ×${String(e.count)}`:""} at ${o}`}
|