@allyhub/sdk 0.8.0 → 0.10.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 +19 -0
- package/NOTICE +46 -49
- package/dist/dom.d.ts +1 -209
- package/dist/dom.js +1 -1
- package/dist/image.d.ts +2 -0
- package/dist/image.js +2 -0
- package/dist/index.d.ts +1 -21
- package/dist/index.js +1 -1
- package/dist/media.d.ts +1 -5
- package/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/levels.d.ts +4 -5
- package/dist/node_modules/@allyhub/audio/dist/levels.js +1 -1
- package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.d.ts +1 -6
- package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.js +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +4 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +22 -0
- package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/LICENSE +241 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/fact.d.ts +37 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/fact.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/index.d.ts +4 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +43 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/rules.d.ts +30 -0
- package/dist/node_modules/@allyhub/diagnostics/dist/rules.js +2 -0
- package/dist/node_modules/@allyhub/diagnostics/package.json +14 -0
- package/dist/node_modules/@allyhub/formats/dist/contributed.d.ts +126 -0
- package/dist/node_modules/@allyhub/formats/dist/contributed.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/reference.d.ts +7 -12
- package/dist/node_modules/@allyhub/formats/dist/data/reference.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/script.d.ts +9 -4
- package/dist/node_modules/@allyhub/formats/dist/data/script.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +107 -83
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +185 -8
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.d.ts +2 -1
- package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +42 -0
- package/dist/node_modules/@allyhub/formats/dist/data/work.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/extension.d.ts +91 -0
- package/dist/node_modules/@allyhub/formats/dist/extension.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/files.d.ts +51 -0
- package/dist/node_modules/@allyhub/formats/dist/files.js +2 -0
- package/dist/node_modules/@allyhub/formats/dist/index.d.ts +5 -1
- package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/items.d.ts +226 -90
- package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +7 -1
- package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +96 -42
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-draw/dist/context.d.ts +5 -0
- package/dist/node_modules/@allyhub/image-draw/dist/context.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/contrast.d.ts +13 -0
- package/dist/node_modules/@allyhub/image-draw/dist/contrast.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/env.d.ts +112 -0
- package/dist/node_modules/@allyhub/image-draw/dist/env.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/errors.d.ts +20 -0
- package/dist/node_modules/@allyhub/image-draw/dist/errors.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/fonts.d.ts +110 -0
- package/dist/node_modules/@allyhub/image-draw/dist/fonts.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/guards.d.ts +32 -0
- package/dist/node_modules/@allyhub/image-draw/dist/guards.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/hash.d.ts +3 -0
- package/dist/node_modules/@allyhub/image-draw/dist/hash.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/inspect.d.ts +113 -0
- package/dist/node_modules/@allyhub/image-draw/dist/inspect.js +3 -0
- package/dist/node_modules/@allyhub/image-draw/dist/layer-style.d.ts +151 -0
- package/dist/node_modules/@allyhub/image-draw/dist/layer-style.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/paint.d.ts +29 -0
- package/dist/node_modules/@allyhub/image-draw/dist/paint.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/pictures.d.ts +39 -0
- package/dist/node_modules/@allyhub/image-draw/dist/pictures.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/plan.d.ts +52 -0
- package/dist/node_modules/@allyhub/image-draw/dist/plan.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/reads.d.ts +145 -0
- package/dist/node_modules/@allyhub/image-draw/dist/reads.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/shape-path.d.ts +26 -0
- package/dist/node_modules/@allyhub/image-draw/dist/shape-path.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/stage.d.ts +56 -0
- package/dist/node_modules/@allyhub/image-draw/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/styles.d.ts +35 -0
- package/dist/node_modules/@allyhub/image-draw/dist/styles.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/dist/tone.d.ts +53 -0
- package/dist/node_modules/@allyhub/image-draw/dist/tone.js +2 -0
- package/dist/node_modules/@allyhub/image-draw/package.json +14 -0
- package/dist/node_modules/@allyhub/image-measure/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-measure/dist/contrast.d.ts +43 -0
- package/dist/node_modules/@allyhub/image-measure/dist/contrast.js +2 -0
- package/dist/node_modules/@allyhub/image-measure/dist/layout.d.ts +186 -0
- package/dist/node_modules/@allyhub/image-measure/dist/layout.js +5 -0
- package/dist/node_modules/@allyhub/image-measure/package.json +14 -0
- package/dist/node_modules/@allyhub/image-sdk/LICENSE +241 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.d.ts +13 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.js +2 -0
- package/dist/{define.d.ts → node_modules/@allyhub/image-sdk/dist/define.d.ts} +21 -4
- package/dist/node_modules/@allyhub/image-sdk/dist/define.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/dom.d.ts +210 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/dom.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/fill.d.ts +21 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/fill.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/group.d.ts +17 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/group.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +166 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/media.d.ts +6 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/media.js +2 -0
- package/dist/{messages.d.ts → node_modules/@allyhub/image-sdk/dist/messages.d.ts} +1 -1
- package/dist/node_modules/@allyhub/image-sdk/dist/picture.d.ts +59 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/picture.js +2 -0
- package/dist/{props.d.ts → node_modules/@allyhub/image-sdk/dist/props.d.ts} +4 -4
- package/dist/node_modules/@allyhub/image-sdk/dist/shape.d.ts +34 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/shape.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/stack.d.ts +16 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/stack.js +2 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.d.ts +38 -0
- package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.js +2 -0
- package/dist/{written.js → node_modules/@allyhub/image-sdk/dist/written.js} +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +19 -0
- package/dist/node_modules/@allyhub/measure/LICENSE +241 -0
- package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +195 -0
- package/dist/node_modules/@allyhub/measure/dist/compare.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +8 -0
- package/dist/node_modules/@allyhub/measure/dist/grain.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/image.d.ts +16 -0
- package/dist/node_modules/@allyhub/measure/dist/image.js +2 -0
- package/dist/node_modules/@allyhub/measure/dist/index.d.ts +4 -0
- package/dist/node_modules/@allyhub/measure/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/measure/package.json +13 -0
- package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.d.ts +4 -1
- package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.d.ts +15 -1
- package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/LICENSE +241 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.d.ts +1 -9
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/context.d.ts +39 -0
- package/dist/node_modules/@allyhub/piece/dist/context.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.d.ts +2 -2
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/export.d.ts +27 -10
- package/dist/node_modules/@allyhub/piece/dist/export.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/formats.d.ts +12 -68
- package/dist/node_modules/@allyhub/piece/dist/formats.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +104 -0
- package/dist/node_modules/@allyhub/piece/dist/index.d.ts +26 -0
- package/dist/node_modules/@allyhub/piece/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layer-style.d.ts +1558 -0
- package/dist/node_modules/@allyhub/piece/dist/layer-style.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +389 -0
- package/dist/node_modules/@allyhub/piece/dist/layer.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +437 -0
- package/dist/node_modules/@allyhub/piece/dist/layout.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.d.ts +1 -1
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.d.ts +39 -9
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.js +1 -1
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.d.ts +6 -0
- package/dist/node_modules/@allyhub/piece/dist/names.d.ts +26 -0
- package/dist/node_modules/@allyhub/piece/dist/names.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +21 -0
- package/dist/node_modules/@allyhub/piece/dist/page/console.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +3 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +4 -0
- package/dist/node_modules/@allyhub/piece/dist/page/locate.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/picture.d.ts +62 -0
- package/dist/node_modules/@allyhub/piece/dist/picture.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/piece.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/piece.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/script.d.ts +9 -4
- package/dist/node_modules/@allyhub/piece/dist/script.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/source.d.ts +131 -0
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +291 -0
- package/dist/node_modules/@allyhub/piece/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/piece/dist/version.d.ts +15 -0
- package/dist/node_modules/@allyhub/piece/dist/version.js +2 -0
- package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.d.ts +1 -20
- package/dist/node_modules/@allyhub/piece/package.json +18 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +271 -0
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +3 -10
- package/dist/node_modules/@allyhub/protocol/dist/app.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +337 -0
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +12 -1
- package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +155 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +235 -133
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/files.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +65 -197
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/image.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +6 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
- package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +98 -0
- package/dist/node_modules/@allyhub/protocol/dist/kinds.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +274 -0
- package/dist/node_modules/@allyhub/protocol/dist/mail.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +77 -91
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +59 -0
- package/dist/node_modules/@allyhub/protocol/dist/peer.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +21 -0
- package/dist/node_modules/@allyhub/protocol/dist/place.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +125 -0
- package/dist/node_modules/@allyhub/protocol/dist/presence.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +35 -0
- package/dist/node_modules/@allyhub/protocol/dist/shape.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +2 -8
- package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +70 -40
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +224 -177
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/package.json +5 -1
- package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +14 -0
- package/dist/node_modules/@allyhub/runtimes/dist/declared.js +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +15 -0
- package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.js +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/dist/packages.js +3 -3
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +1 -0
- package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
- package/dist/node_modules/@allyhub/runtimes/manifest.json +0 -82
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/define.d.ts +2 -0
- package/dist/node_modules/@allyhub/scenery/dist/define.js +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
- package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
- package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
- package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/code.d.ts +4 -4
- package/dist/node_modules/@allyhub/sheet/dist/api/code.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +15 -11
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +70 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.d.ts +6 -0
- 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/define.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.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/kernels.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/maths.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.d.ts +9 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/server.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/chart.d.ts +9 -0
- package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/file.d.ts +5 -0
- package/dist/node_modules/@allyhub/sheet/dist/file.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/ast.d.ts +12 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.d.ts +5 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/generated.d.ts +5 -19
- package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/import.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +5 -5
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +88 -3
- package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/patch.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/patch.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/printed.d.ts +19 -0
- package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/sdk.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/sdk.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.d.ts +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +8 -6
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +6 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +2 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.d.ts +7 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.d.ts +12 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
- package/dist/node_modules/@allyhub/sheet/package.json +5 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +23 -7
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +101 -11
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +18 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/code.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/connect.d.ts +62 -0
- package/dist/node_modules/@allyhub/slides-core/dist/connect.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +24 -0
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +223 -0
- package/dist/node_modules/@allyhub/slides-core/dist/fact.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +4 -4
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/measure.d.ts +4 -2
- package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/merge.d.ts +5 -5
- package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +25 -4
- package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/path.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +20 -11
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +18 -0
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/stage.d.ts +28 -11
- package/dist/node_modules/@allyhub/slides-core/dist/units.d.ts +3 -6
- package/dist/node_modules/@allyhub/slides-core/dist/units.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/package.json +5 -1
- package/dist/node_modules/@allyhub/video-core/dist/audio-types.d.ts +1 -2
- package/dist/node_modules/@allyhub/video-core/dist/captions.d.ts +1 -10
- package/dist/node_modules/@allyhub/video-core/dist/captions.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/check.d.ts +62 -0
- package/dist/node_modules/@allyhub/video-core/dist/check.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/cut-report.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/cut-report.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/edits.d.ts +3 -3
- package/dist/node_modules/@allyhub/video-core/dist/edits.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/fact.d.ts +21 -762
- package/dist/node_modules/@allyhub/video-core/dist/fact.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/footage-motion.d.ts +3 -2
- package/dist/node_modules/@allyhub/video-core/dist/footage-motion.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/index.d.ts +3 -17
- package/dist/node_modules/@allyhub/video-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/measure.d.ts +72 -423
- package/dist/node_modules/@allyhub/video-core/dist/measure.js +1 -4
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.d.ts +44 -0
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/motion.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +24 -432
- package/dist/node_modules/@allyhub/video-core/dist/piece.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/placement.d.ts +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +8 -14
- package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/script-edit.d.ts +11 -6
- package/dist/node_modules/@allyhub/video-core/dist/script-edit.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/seams.d.ts +2 -3
- package/dist/node_modules/@allyhub/video-core/dist/sound-under.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/sound-under.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/speech.d.ts +2 -4
- package/dist/node_modules/@allyhub/video-core/dist/speech.js +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/stage.d.ts +52 -0
- package/dist/node_modules/@allyhub/video-core/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +18 -136
- package/dist/node_modules/@allyhub/video-core/dist/timeline.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/timing.d.ts +3 -3
- package/dist/node_modules/@allyhub/video-core/dist/timing.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/transcript.d.ts +2 -2
- package/dist/node_modules/@allyhub/video-core/dist/transcript.js +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/LICENSE +241 -0
- package/dist/node_modules/@allyhub/video-sdk/NOTICE +118 -0
- package/dist/{free.d.ts → node_modules/@allyhub/video-sdk/dist/free.d.ts} +14 -10
- package/dist/node_modules/@allyhub/video-sdk/dist/free.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/index.d.ts +28 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/index.js +2 -0
- package/dist/{input.d.ts → node_modules/@allyhub/video-sdk/dist/input.d.ts} +76 -22
- package/dist/node_modules/@allyhub/video-sdk/dist/input.js +2 -0
- package/dist/{module.d.ts → node_modules/@allyhub/video-sdk/dist/module.d.ts} +6 -4
- package/dist/node_modules/@allyhub/video-sdk/dist/module.js +2 -0
- package/dist/{parts.d.ts → node_modules/@allyhub/video-sdk/dist/parts.d.ts} +15 -6
- package/dist/node_modules/@allyhub/video-sdk/dist/parts.js +2 -0
- package/dist/{phone.d.ts → node_modules/@allyhub/video-sdk/dist/phone.d.ts} +12 -5
- package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +2 -0
- package/dist/{piece.d.ts → node_modules/@allyhub/video-sdk/dist/piece.d.ts} +26 -16
- package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/route.d.ts +46 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/route.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/scenery.d.ts +2 -0
- package/dist/node_modules/@allyhub/video-sdk/dist/scenery.js +2 -0
- package/dist/node_modules/@allyhub/video-sdk/package.json +19 -0
- package/dist/scenery.d.ts +1 -1
- package/dist/scenery.js +1 -1
- package/dist/sheets.d.ts +1 -1
- package/dist/sheets.js +1 -1
- package/dist/slides.d.ts +1 -9
- package/dist/slides.js +1 -1
- package/docs/README.md +10 -6
- package/docs/batches.md +5 -5
- package/docs/canvas.md +28 -0
- package/docs/contract.md +2 -2
- package/docs/defaults.md +298 -22
- package/docs/docs.md +80 -66
- package/docs/footage.md +7 -7
- package/docs/image.md +165 -0
- package/docs/layers.md +22 -13
- package/docs/modeling.md +4 -4
- package/docs/pictures.md +65 -0
- package/docs/project.md +51 -31
- package/docs/scenery.md +14 -15
- package/docs/sheets.md +46 -28
- package/docs/slides.md +121 -67
- package/docs/sound.md +3 -3
- package/docs/speech.md +8 -8
- package/docs/video.md +16 -13
- package/docs/websites.md +4 -4
- package/docs/x.md +73 -0
- package/package.json +7 -2
- package/dist/define.js +0 -2
- package/dist/free.js +0 -2
- package/dist/input.js +0 -2
- package/dist/module.js +0 -2
- package/dist/node_modules/@allyhub/formats/dist/data/comments.d.ts +0 -94
- package/dist/node_modules/@allyhub/formats/dist/data/comments.js +0 -2
- package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package-lock.json +0 -227
- package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package.json +0 -8
- package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package-lock.json +0 -105
- package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package.json +0 -8
- package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package-lock.json +0 -128
- package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package.json +0 -9
- package/dist/node_modules/@allyhub/video-core/dist/export.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/formats.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/gen.d.ts +0 -37
- package/dist/node_modules/@allyhub/video-core/dist/problem.d.ts +0 -278
- package/dist/node_modules/@allyhub/video-core/dist/problem.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/script.js +0 -2
- package/dist/node_modules/@allyhub/video-core/dist/source.d.ts +0 -7
- package/dist/parts.js +0 -2
- package/dist/phone.js +0 -2
- package/dist/piece.js +0 -2
- /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.js +0 -0
- /package/dist/{fit.d.ts → node_modules/@allyhub/image-sdk/dist/fit.d.ts} +0 -0
- /package/dist/{fit.js → node_modules/@allyhub/image-sdk/dist/fit.js} +0 -0
- /package/dist/{messages.js → node_modules/@allyhub/image-sdk/dist/messages.js} +0 -0
- /package/dist/{props.js → node_modules/@allyhub/image-sdk/dist/props.js} +0 -0
- /package/dist/{text.d.ts → node_modules/@allyhub/image-sdk/dist/text.d.ts} +0 -0
- /package/dist/{text.js → node_modules/@allyhub/image-sdk/dist/text.js} +0 -0
- /package/dist/{written.d.ts → node_modules/@allyhub/image-sdk/dist/written.d.ts} +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/gen.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/source.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.js +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.d.ts +0 -0
- /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.js +0 -0
- /package/dist/{anim.d.ts → node_modules/@allyhub/video-sdk/dist/anim.d.ts} +0 -0
- /package/dist/{anim.js → node_modules/@allyhub/video-sdk/dist/anim.js} +0 -0
- /package/dist/{noise.d.ts → node_modules/@allyhub/video-sdk/dist/noise.d.ts} +0 -0
- /package/dist/{noise.js → node_modules/@allyhub/video-sdk/dist/noise.js} +0 -0
- /package/dist/{paths.d.ts → node_modules/@allyhub/video-sdk/dist/paths.d.ts} +0 -0
- /package/dist/{paths.js → node_modules/@allyhub/video-sdk/dist/paths.js} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{Document as D,isMap as
|
|
3
|
-
`?"":b(e)}const
|
|
4
|
-
`,
|
|
5
|
-
`,
|
|
6
|
-
`).map((e,i)=>i===0||e===""?e:" ".repeat(
|
|
7
|
-
`);function
|
|
8
|
-
${n.slice(
|
|
9
|
-
`?N:
|
|
2
|
+
import{Document as D,isMap as d,isScalar as Y,isSeq as l,parseDocument as I}from"yaml";const L=n=>Y(n.key)?String(n.key.value):void 0,F=96,J=n=>Y(n)&&!(typeof n.value=="string"&&/[\n\r]/u.test(n.value)),G=n=>J(n)||l(n)&&n.items.every(J),H=new Set(["","sheets[]","tables[]","cells","columns","rows","names","scenarios"]);function $(n,t){if(l(n)){for(const e of n.items)$(e,`${t}[]`);n.flow=n.items.every(J)}else if(d(n)){for(const e of n.items)$(e.value,L(e)??"");n.flow=!H.has(t)&&n.items.length>0&&n.items.every(e=>G(e.value)||d(e.value)&&e.value.flow===!0),n.flow&&new D(n).toString({lineWidth:0,flowCollectionPadding:!0}).length>F&&(n.flow=!1)}}const P={lineWidth:0,flowCollectionPadding:!0};export function writeYaml(n){const t=new D(n,{aliasDuplicateObjects:!1});$(t.contents,"");const e=t.toString(P);return e===`{}
|
|
3
|
+
`?"":b(e)}function b(n){const t=I(n,{uniqueKeys:!1});if(t.errors.length>0)return n;const e=[];M(t.contents,r=>{if(!l(r)||!r.flow||!r.range)return;const[o,s]=r.range;if(n[o]!=="["||n[s-1]!=="]")return;const c=n.slice(o+1,s-1),u=/^ [^[\]{}"'\n]* $/u.test(c);(u||c.startsWith(" {"))&&n[o+1]===" "&&e.push(o+1),(u||c.endsWith("} "))&&n[s-2]===" "&&e.push(s-2)});let i=n;for(const r of[...new Set(e)].sort((o,s)=>s-o))i=i.slice(0,r)+i.slice(r+1);return i}function M(n,t){if(t(n),d(n))for(const e of n.items)M(e.key,t),M(e.value,t);else if(l(n))for(const e of n.items)M(e,t)}const T=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function m(n,t){if(n===t)return!0;if(Array.isArray(n)&&Array.isArray(t))return n.length===t.length&&n.every((r,o)=>m(r,t[o]));if(!T(n)||!T(t))return!1;const e=r=>Object.keys(r).filter(o=>r[o]!==void 0),i=e(n);return i.length===e(t).length&&i.every(r=>r in t&&m(n[r],t[r]))}function q(n,t,e,i,r){if(!m(t,e)){if(d(n)&&!n.flow&&T(t)&&T(e)){for(const o of new Set([...Object.keys(t),...Object.keys(e)])){const s=n.items.find(c=>L(c)===o)?.value;m(t[o],e[o])||q(s,t[o],e[o],[...i,o],r)}return}if(l(n)&&!n.flow&&Array.isArray(t)&&Array.isArray(e)&&e.length>0){const o=Math.min(t.length,e.length);let s=0;for(;s<o&&m(t[s],e[s]);)s++;let c=0;for(;c<o-s&&m(t[t.length-1-c],e[e.length-1-c]);)c++;const u=t.length-s-c,y=e.length-s-c,h=Math.min(u,y);for(let f=s;f<s+h;f++)q(n.items[f],t[f],e[f],[...i,f],r);for(let f=s+u-1;f>=s+h;f--)r.push({path:[...i,f],value:void 0});for(let f=s+h;f<s+y;f++)r.push({path:[...i,f],value:e[f],...c>0?{insert:!0}:{}});return}r.push({path:i,value:e})}}const A=(n,t)=>n.lastIndexOf(`
|
|
4
|
+
`,t-1)+1,W=(n,t)=>{const e=n.indexOf(`
|
|
5
|
+
`,t);return e<0?n.length:e+1},E=(n,t)=>n.split(`
|
|
6
|
+
`).map((e,i)=>i===0||e===""?e:" ".repeat(t)+e).join(`
|
|
7
|
+
`);function K(n,t,e,i){const r=new D({[n]:t},{aliasDuplicateObjects:!1}),o=r.contents;$(o,"");const s=o.items[0];return(d(i)||l(i))&&(d(s?.value)||l(s?.value))&&(s.value.flow=i.flow??!1),E(b(r.toString(P).replace(/\n$/,"")),e)}function _(n,t,e){const i=new D([n],{aliasDuplicateObjects:!1}),r=i.contents;return $(r,e),r.flow=!1,E(b(i.toString(P).replace(/\n$/,"")),t)}function Q(n,t){let e=n.contents;for(const i of t.slice(0,-1))if(d(e)){if(e.flow)return;e=e.items.find(r=>L(r)===String(i))?.value}else if(l(e)){if(e.flow)return;e=e.items[Number(i)]}else return;return d(e)||l(e)?e:void 0}function V(n,t){const e=t.items[0]?.range?.[0];if(e===void 0)return;const i=A(n,e),r=n.indexOf("-",i);return r>=0&&r<e?r-i:void 0}function X(n,t){const e=I(n);if(e.errors.length>0)return;const{path:i,value:r}=t,o=i[i.length-1],s=Q(e,i);if(o===void 0||!s||s.flow)return;if(l(s)){const g=Number(o),a=V(n,s);if(a===void 0)return;const p=s.items[g];if(r===void 0){const v=p?.range?.[0],S=p?.range?.[1];return v===void 0||S===void 0?void 0:n.slice(0,A(n,v))+n.slice(W(n,S-1))}if(t.insert===!0){const v=p?.range?.[0];if(v===void 0)return;const S=A(n,v);return`${n.slice(0,S)}${" ".repeat(a)}${_(r,a,String(i[i.length-2]))}
|
|
8
|
+
${n.slice(S)}`}if(p)return;const N=s.items[s.items.length-1]?.range?.[1];if(N===void 0)return;const j=n.charAt(N-1)===`
|
|
9
|
+
`?N:W(n,N),B=j>0&&n.charAt(j-1)!==`
|
|
10
10
|
`?`
|
|
11
|
-
`:"";return`${n.slice(0,j)}${
|
|
12
|
-
${n.slice(j)}`}const
|
|
11
|
+
`:"";return`${n.slice(0,j)}${B}${" ".repeat(a)}${_(r,a,String(i[i.length-2]??""))}
|
|
12
|
+
${n.slice(j)}`}const c=String(o),u=s.items.find(g=>L(g)===c),y=u?.key,h=u?.value??void 0,C=s.items[0]?.key?.range?.[0],O=C===void 0?2*(i.length-1):C-A(n,C);if(u&&y?.range){const g=y.range[0],a=h?.range?h.range[1]:y.range[1];if(r===void 0)return n.slice(0,A(n,g))+n.slice(W(n,a-1));const p=n.charAt(a-1)===`
|
|
13
13
|
`?`
|
|
14
|
-
`:"";return n.slice(0,
|
|
14
|
+
`:"";return n.slice(0,g)+K(c,r,O,h)+p+n.slice(a)}if(r===void 0)return n;const R=K(c,r,O,void 0),U=s.items[s.items.length-1],w=(U?.value??U?.key)?.range?.[1];if(w===void 0){const g=n===""||n.endsWith(`
|
|
15
15
|
`)?"":`
|
|
16
|
-
`;return`${n}${
|
|
16
|
+
`;return`${n}${g}${" ".repeat(O)}${R}
|
|
17
17
|
`}const k=n.charAt(w-1)===`
|
|
18
|
-
`?w:
|
|
18
|
+
`?w:W(n,w),z=k>0&&n.charAt(k-1)!==`
|
|
19
19
|
`?`
|
|
20
|
-
`:"";return`${n.slice(0,k)}${
|
|
21
|
-
${n.slice(k)}`}const
|
|
20
|
+
`:"";return`${n.slice(0,k)}${z}${" ".repeat(O)}${R}
|
|
21
|
+
${n.slice(k)}`}const Z=400;export function patchYaml(n,t){const e=I(n);if(e.errors.length>0||n.trim()!==""&&!d(e.contents)||n.trim()==="")return writeYaml(t);const i=[];if(q(e.contents,e.toJS(),t,[],i),i.length===0)return n;if(i.length>Z)return writeYaml(t);let r=n;for(const s of i){const c=X(r,s);if(c===void 0)return writeYaml(t);r=c}const o=I(r);return o.errors.length===0&&m(o.toJS(),x(t))?r:writeYaml(t)}const x=n=>JSON.parse(JSON.stringify(n));
|
|
@@ -24,8 +24,12 @@ export interface DrawnPicture {
|
|
|
24
24
|
export declare function drawingPart(charts: readonly Chart[], pictures?: readonly DrawnPicture[]): string;
|
|
25
25
|
/** What a chart reads as, before its references are named as the sheet names them. */
|
|
26
26
|
export type ReadChart = SheetChart;
|
|
27
|
-
/**
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A chart part as sheet.yaml writes one, or why it cannot be. A series
|
|
29
|
+
* whose numbers are in no cell of the workbook is left out, and `said`
|
|
30
|
+
* says so: written again, its numbers would be in the chart alone.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readChart(root: Tag | undefined, said?: string[], has?: (sheet: string) => boolean): ReadChart | string;
|
|
29
33
|
export interface Anchored {
|
|
30
34
|
/** Its relationship in the drawing's part. */
|
|
31
35
|
id: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CHART_DEFAULTS as Q,chartSpaceXml as ce}from"@allyhub/chart";import{columnLetter as Y}from"../address.js";import{Reference as Z,Union as ae}from"../calc/types.js";import{chartDef as fe,chartSize as de}from"../chart.js";import{sheetPrefix as le}from"../formula/print.js";import{HEAD as ue,attr as y,el as s,flag as ee,numberAttr as M,tag as r,tags as R,textOf as O}from"./xml.js";const he="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",me="http://schemas.openxmlformats.org/drawingml/2006/main",te="http://schemas.openxmlformats.org/drawingml/2006/chart",re="http://schemas.openxmlformats.org/officeDocument/2006/relationships",g=9525,xe=(e,t)=>`${le(e.sheet.name)}$${Y(e.left)}$${String(e.top+1)}${e.single?"":`:$${Y(e.right)}$${String(t+1)}`}`;function _(e,t,n){if(!n?.node)return;const o=e.eval(n.node,{sheet:t,row:0,col:0,dr:0,dc:0}),i=a=>xe(a,Math.min(a.bottom,Math.max(a.top,a.sheet.lastRow)));if(o instanceof Z)return i(o);if(o instanceof ae)return`(${o.parts.map(i).join(",")})`}function pe(e,t,n){if(!n?.node)return!1;const o=e.eval(n.node,{sheet:t,row:0,col:0,dr:0,dc:0});return o instanceof Z&&typeof e.value(o.sheet,o.top,o.left)=="number"}export function chartPart(e,t,n){const o=fe(e,t,n),i={name:l=>_(e,t,n.series[l]?.name),categories:_(e,t,n.categories),numeric:pe(e,t,n.categories),values:l=>_(e,t,n.series[l]?.values)??"",x:l=>_(e,t,n.series[l]?.x??n.categories)},a=_(e,t,n.title);return ce(o,{refs:i,...a===void 0?{}:{titleRef:a}})}const ge=(e,t,n)=>s("xdr:oneCellAnchor",{},s("xdr:from",{},`<xdr:col>${String(e.col)}</xdr:col>`,`<xdr:colOff>${String(Math.round(e.x*g))}</xdr:colOff>`,`<xdr:row>${String(e.row)}</xdr:row>`,`<xdr:rowOff>${String(Math.round((e.y??0)*g))}</xdr:rowOff>`),s("xdr:ext",{cx:Math.round(e.width*g),cy:Math.round(e.height*g)}),s("xdr:pic",{},s("xdr:nvPicPr",{},s("xdr:cNvPr",{id:t,name:e.name,descr:e.path}),s("xdr:cNvPicPr",{},s("a:picLocks",{noChangeAspect:!0}))),s("xdr:blipFill",{},s("a:blip",{"xmlns:r":re,"r:embed":`rId${String(n)}`}),s("a:stretch",{},s("a:fillRect"))),s("xdr:spPr",{},s("a:xfrm",{},s("a:off",{x:0,y:0}),s("a:ext",{cx:Math.round(e.width*g),cy:Math.round(e.height*g)})),s("a:prstGeom",{prst:"rect"},s("a:avLst")))),s("xdr:clientData"));export function drawingPart(e,t=[]){const n=(o,i)=>{const{width:a,height:l}=de(o.spec);return s("xdr:oneCellAnchor",{},s("xdr:from",{},`<xdr:col>${String(o.at.col)}</xdr:col>`,`<xdr:colOff>${String(Math.round((o.spec.x??0)*g))}</xdr:colOff>`,`<xdr:row>${String(o.at.row)}</xdr:row>`,`<xdr:rowOff>${String(Math.round((o.spec.y??0)*g))}</xdr:rowOff>`),s("xdr:ext",{cx:Math.round(a*g),cy:Math.round(l*g)}),s("xdr:graphicFrame",{macro:""},s("xdr:nvGraphicFramePr",{},s("xdr:cNvPr",{id:i+2,name:`Chart ${String(i+1)}`}),s("xdr:cNvGraphicFramePr")),s("xdr:xfrm",{},s("a:off",{x:0,y:0}),s("a:ext",{cx:0,cy:0})),s("a:graphic",{},s("a:graphicData",{uri:te},s("c:chart",{"xmlns:c":te,"xmlns:r":re,"r:id":`rId${String(i+1)}`})))),s("xdr:clientData"))};return ue+s("xdr:wsDr",{"xmlns:xdr":he,"xmlns:a":me},...e.map(n),...t.map((o,i)=>ge(o,e.length+i+2,e.length+i+1)))}function I(e){if(Array.isArray(e))return e.map(I).join("");if(typeof e!="object"||e===null)return"";const t=e,n=[];for(const[o,i]of Object.entries(t))o==="t"?n.push(O(i)):typeof i=="object"&&n.push(I(i));return n.join("")}const V=e=>{const t=r(e?.solidFill),n=y(r(t?.srgbClr),"val");return n!==void 0?`#${n.toUpperCase()}`:we[y(r(t?.schemeClr),"val")??""]},we={accent1:"#4472C4",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#5B9BD5",accent6:"#70AD47"},$=(e,t)=>y(r(e?.[t]),"val"),A=(e,t)=>M(r(e?.[t]),"val"),F=(e,t)=>ee(r(e?.[t]),"val");function ne(e){if(!e)return;const t=r(e.tx),n=r(t?.strRef);if(n)return`=${O(n.f)}`;const o=I(t?.rich);return o===""?void 0:o}function oe(e){if(!e)return;const t=r(e.scaling),n=r(e.numFmt),o=y(n,"formatCode"),i={},a=ne(r(e.title));a!==void 0&&(i.title=a);const l=A(t,"min"),x=A(t,"max"),u=A(e,"majorUnit");return l!==void 0&&(i.min=l),x!==void 0&&(i.max=x),u!==void 0&&u>0&&(i.major=u),F(e,"delete")===!0&&(i.visible=!1),$(t,"orientation")==="maxMin"&&(i.reverse=!0),o!==void 0&&o!=="General"&&ee(n,"sourceLinked")!==!0&&(i.format=o),i}const j=e=>{const t=r(e?.numRef)??r(e?.strRef),n=t?O(t.f):"";return n===""?void 0:n};function be(e,t){const n=j(r(e[t?"yVal":"val"]));if(n===void 0)return"its numbers are written in the chart";const o={values:n},i=r(e.tx),a=j(i);if(a!==void 0)o.name=`=${a}`;else{const d=O(i?.v);d!==""&&(o.name=d)}const l=r(e.spPr),x=r(l?.ln),u=r(e.marker),w=t||u!==void 0,c=V(l)??(w?V(x)??V(r(u?.spPr)):void 0);c!==void 0&&(o.color=c);const f=M(x,"w");if(w&&f!==void 0&&x?.noFill===void 0){const d=Number((f/12700).toFixed(2));d!==Q.lineWidth&&(o.line_width=d)}F(e,"smooth")===!0&&(o.smooth=!0);const m=A(u,"size");m!==void 0&&m!==Q.marker&&(o.marker_size=m);const v=t?j(r(e.xVal)):void 0;v!==void 0&&(o.x=v);const b=t?void 0:j(r(e.cat));return{series:o,...b===void 0?{}:{categories:b}}}function ve(e){const t=$(e,"barDir")==="bar"?"bar":"column",n=$(e,"grouping");return n==="stacked"?`${t}-stacked`:n==="percentStacked"?`${t}-stacked-100`:`${t}-clustered`}function ye(e){const t=$(e,"grouping");return t==="stacked"?"area-stacked":t==="percentStacked"?"area-stacked-100":"area"}export function readChart(e){const t=r(e?.chartSpace),n=r(t?.chart),o=r(n?.plotArea);if(!n||!o)return"it has no plot";const i=Object.entries(o).filter(([h])=>h.endsWith("Chart")),[a]=i;if(!a)return"it has no plot";if(i.length>1||Array.isArray(a[1])&&a[1].length>1)return"it combines several kinds of chart";const[l,x]=a,u=r(x);if(!u)return"it has no plot";const w=R(u.ser),c=l==="scatterChart",f=[];let m;for(const h of w){const P=be(h,c);if(typeof P=="string")return P;f.push(P.series),m??=P.categories}if(f.length===0)return"it has no series";const v=h=>r(r(h.spPr)?.ln)?.noFill!==void 0,b=h=>$(r(h.marker),"symbol")==="none",d=(()=>{switch(l){case"barChart":return ve(u);case"lineChart":return w.every(b)?"line":"line-markers";case"areaChart":return ye(u);case"pieChart":return"pie";case"doughnutChart":return"doughnut";case"scatterChart":return w.every(v)?"scatter":w.some(h=>F(h,"smooth")===!0)?"scatter-smooth":"scatter-lines";default:return}})();if(!d)return`a sheet has no ${l.replace(/Chart$/u,"")} chart`;const S=ne(r(n.title)),k=r(n.legend),C=$(k,"legendPos"),D=r(u.dLbls),p=h=>F(D,h)===!0,se=p("showVal")||p("showPercent")||p("showCatName")||p("showSerName"),H=$(D,"dLblPos"),z=A(u,"gapWidth"),W=A(u,"overlap"),E=A(u,"holeSize"),X=F(u,"varyColors"),B=d==="pie"||d==="doughnut",N={value:R(o.valAx).find((h,P,ie)=>c?P===ie.length-1:!0),category:c?R(o.valAx)[0]:r(o.catAx)??r(o.dateAx)},G=oe(N.value),T=oe(N.category);G&&N.value?.majorGridlines===void 0&&(G.gridlines=!1),T&&N.category?.majorGridlines!==void 0&&(T.gridlines=!0);const U=M(r(r(r(r(t?.txPr)?.p)?.pPr)?.defRPr),"sz"),q=h=>h&&Object.keys(h).length>0?h:void 0,J=q(G),K=q(T);return{type:d,at:"A1",...S===void 0?{}:{title:S},...m===void 0?{}:{categories:m},series:B?f.slice(0,1):f,...k?{legend:C==="b"?"bottom":C==="t"?"top":C==="l"?"left":"right"}:{},...se?{labels:{...p("showVal")?{value:!0}:{},...p("showPercent")?{percentage:!0}:{},...p("showCatName")?{category:!0}:{},...p("showSerName")?{series:!0}:{},...H===void 0?{}:{position:H}}}:{},...z===void 0||z===150?{}:{gap_width:z},...W===void 0||d.includes("stacked")?{}:{overlap:W},...E===void 0||E===50?{}:{hole_size:E},...X===!0&&l==="barChart"?{vary_by_categories:!0}:{},...X===!1&&B?{vary_by_categories:!1}:{},...J?{value_axis:J}:{},...K?{category_axis:K}:{},...U===void 0||U===900?{}:{size:U/100}}}const L=e=>Math.round(e/g);export function chartAnchors(e,t,n){const o=r(e?.wsDr),i=[],a=[];let l=0;const x=c=>({col:Number(O(c?.col)),row:Number(O(c?.row)),colOff:L(Number(O(c?.colOff))),rowOff:L(Number(O(c?.rowOff)))}),u=c=>y(r(r(r(r(c.graphicFrame)?.graphic)?.graphicData)?.chart),"id"),w=(c,f,m,v)=>{const b={at:{row:f.row,col:f.col},...f.colOff>0?{x:f.colOff}:{},...f.rowOff>0?{y:f.rowOff}:{},width:m,height:v},d=r(c.pic),S=y(r(r(d?.blipFill)?.blip),"embed");if(d&&S!==void 0){const C=r(r(d.nvPicPr)?.cNvPr),D=y(C,"name"),p=y(C,"descr");a.push({id:S,...b,...D===void 0?{}:{name:D},...p===void 0?{}:{descr:p}});return}const k=u(c);if(k===void 0){l+=1;return}i.push({id:k,...b})};for(const c of R(o?.oneCellAnchor)){const f=r(c.ext);w(c,x(r(c.from)),L(M(f,"cx")??0),L(M(f,"cy")??0))}for(const c of R(o?.twoCellAnchor)){const f=x(r(c.from)),m=x(r(c.to));let v=m.colOff-f.colOff;for(let d=f.col;d<m.col;d++)v+=t(d);let b=m.rowOff-f.rowOff;for(let d=f.row;d<m.row;d++)b+=n(d);w(c,f,v,b)}return{anchors:i,pictures:a,others:l}}
|
|
2
|
+
import{CHART_DEFAULTS as pe,chartSpaceXml as Ce}from"@allyhub/chart";import{columnLetter as xe}from"../address.js";import{Reference as ge,Union as ke}from"../calc/types.js";import{CellError as Pe}from"../values.js";import{categoryNumbers as Se,chartDef as Me,chartSize as Fe}from"../chart.js";import{parseFormula as Re}from"../formula/parse.js";import{sheetPrefix as we}from"../formula/print.js";import{HEAD as De,attr as b,el as d,flag as ye,numberAttr as j,tag as r,tags as O,textOf as P}from"./xml.js";const Ne="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",_e="http://schemas.openxmlformats.org/drawingml/2006/main",be="http://schemas.openxmlformats.org/drawingml/2006/chart",ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships",v=9525,je=(e,t)=>`${we(e.sheet.name)}$${xe(e.left)}$${String(e.top+1)}${e.single?"":`:$${xe(e.right)}$${String(t+1)}`}`;function E(e,t,n){if(!n?.node)return;const o=e.eval(n.node,{sheet:t,row:0,col:0,dr:0,dc:0}),s=l=>je(l,Math.min(l.bottom,Math.max(l.top,l.sheet.lastRow)));if(o instanceof ge)return s(o);if(o instanceof ke)return`(${o.parts.map(s).join(",")})`;const a=n.node;if(a.kind==="name"&&a.sheet!==void 0&&!(o instanceof Pe&&o.code==="#NAME?"))return`${we(a.sheet)}${a.name}`}function Ee(e,t,n){if(!n?.node)return!1;const o=e.eval(n.node,{sheet:t,row:0,col:0,dr:0,dc:0});return o instanceof ge&&typeof e.value(o.sheet,o.top,o.left)=="number"}export function chartPart(e,t,n){const o=Me(e,t,n),s=n.series.map((i,f)=>({s:i,i:f,values:E(e,t,i.values)})).filter(i=>i.values!==void 0),a={...o,series:s.flatMap(i=>o.series[i.i]??[])},l=Ee(e,t,n.categories),h=l?Se(e,t,n):void 0,m={name:i=>E(e,t,s[i]?.s.name),categories:E(e,t,n.categories),numeric:l,...h===void 0?{}:{categoryNumbers:h.values,categoryFormat:h.format},values:i=>s[i]?.values??"",x:i=>E(e,t,s[i]?.s.x??n.categories)},y=E(e,t,n.title);return Ce(a,{refs:m,...y===void 0?{}:{titleRef:y}})}const Le=(e,t,n)=>d("xdr:oneCellAnchor",{},d("xdr:from",{},`<xdr:col>${String(e.col)}</xdr:col>`,`<xdr:colOff>${String(Math.round(e.x*v))}</xdr:colOff>`,`<xdr:row>${String(e.row)}</xdr:row>`,`<xdr:rowOff>${String(Math.round((e.y??0)*v))}</xdr:rowOff>`),d("xdr:ext",{cx:Math.round(e.width*v),cy:Math.round(e.height*v)}),d("xdr:pic",{},d("xdr:nvPicPr",{},d("xdr:cNvPr",{id:t,name:e.name,descr:e.path}),d("xdr:cNvPicPr",{},d("a:picLocks",{noChangeAspect:!0}))),d("xdr:blipFill",{},d("a:blip",{"xmlns:r":ve,"r:embed":`rId${String(n)}`}),d("a:stretch",{},d("a:fillRect"))),d("xdr:spPr",{},d("a:xfrm",{},d("a:off",{x:0,y:0}),d("a:ext",{cx:Math.round(e.width*v),cy:Math.round(e.height*v)})),d("a:prstGeom",{prst:"rect"},d("a:avLst")))),d("xdr:clientData"));export function drawingPart(e,t=[]){const n=(o,s)=>{const{width:a,height:l}=Fe(o.spec);return d("xdr:oneCellAnchor",{},d("xdr:from",{},`<xdr:col>${String(o.at.col)}</xdr:col>`,`<xdr:colOff>${String(Math.round((o.spec.x??0)*v))}</xdr:colOff>`,`<xdr:row>${String(o.at.row)}</xdr:row>`,`<xdr:rowOff>${String(Math.round((o.spec.y??0)*v))}</xdr:rowOff>`),d("xdr:ext",{cx:Math.round(a*v),cy:Math.round(l*v)}),d("xdr:graphicFrame",{macro:""},d("xdr:nvGraphicFramePr",{},d("xdr:cNvPr",{id:s+2,name:`Chart ${String(s+1)}`}),d("xdr:cNvGraphicFramePr")),d("xdr:xfrm",{},d("a:off",{x:0,y:0}),d("a:ext",{cx:0,cy:0})),d("a:graphic",{},d("a:graphicData",{uri:be},d("c:chart",{"xmlns:c":be,"xmlns:r":ve,"r:id":`rId${String(s+1)}`})))),d("xdr:clientData"))};return De+d("xdr:wsDr",{"xmlns:xdr":Ne,"xmlns:a":_e},...e.map(n),...t.map((o,s)=>Le(o,e.length+s+2,e.length+s+1)))}function Z(e){if(Array.isArray(e))return e.map(Z).join("");if(typeof e!="object"||e===null)return"";const t=e,n=[];for(const[o,s]of Object.entries(t))o==="t"?n.push(P(s)):typeof s=="object"&&n.push(Z(s));return n.join("")}const ee=e=>{const t=r(e?.solidFill),n=b(r(t?.srgbClr),"val");return n!==void 0?`#${n.toUpperCase()}`:ze[b(r(t?.schemeClr),"val")??""]},ze={accent1:"#4472C4",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#5B9BD5",accent6:"#70AD47"},A=(e,t)=>b(r(e?.[t]),"val"),M=(e,t)=>j(r(e?.[t]),"val"),L=(e,t)=>ye(r(e?.[t]),"val"),Ge=e=>/^"(?:[^"]|"")*"$/u.test(e)?e.slice(1,-1).replaceAll('""','"'):void 0,$e=e=>Ge(e)??`=${e}`;function Oe(e){if(!e)return;const t=r(e.tx),n=r(t?.strRef);if(n)return $e(P(n.f));const o=Z(t?.rich);return o===""?void 0:o}function te(e){if(!e)return;const t=r(e.scaling),n=r(e.numFmt),o=b(n,"formatCode"),s={},a=Oe(r(e.title));a!==void 0&&(s.title=a);const l=M(t,"min"),h=M(t,"max"),m=M(e,"majorUnit");return l!==void 0&&(s.min=l),h!==void 0&&(s.max=h),m!==void 0&&m>0&&(s.major=m),L(e,"delete")===!0&&(s.visible=!1),A(t,"orientation")==="maxMin"&&(s.reverse=!0),o!==void 0&&o!=="General"&&ye(n,"sourceLinked")!==!0&&(s.format=o),s}const G=e=>{const t=r(e?.numRef)??r(e?.strRef),n=t?P(t.f):"";return n===""?void 0:n};function Ie(e,t){const n=G(r(e[t?"yVal":"val"]));if(n===void 0)return"its numbers are written in the chart";const o={values:n},s=r(e.tx),a=G(s);if(a!==void 0)o.name=$e(a);else{const u=P(s?.v);u!==""&&(o.name=u)}const l=r(e.spPr),h=r(l?.ln),m=r(e.marker),y=t||m!==void 0,i=ee(l)??(y?ee(h)??ee(r(m?.spPr)):void 0);i!==void 0&&(o.color=i);const f=j(h,"w");if(y&&f!==void 0&&h?.noFill===void 0){const u=Math.max(.25,Number((f/12700).toFixed(2)));u!==pe.lineWidth&&(o.line_width=u)}L(e,"smooth")===!0&&(o.smooth=!0);const p=M(m,"size");p!==void 0&&p!==pe.marker&&(o.marker_size=p);const $=t?G(r(e.xVal)):void 0;$!==void 0&&(o.x=$);const g=t?void 0:G(r(e.cat));return{series:o,...g===void 0?{}:{categories:g}}}function ne(e,t){const n=O(t.ser),o=a=>r(r(a.spPr)?.ln)?.noFill!==void 0,s=a=>A(r(a.marker),"symbol")==="none";switch(e){case"barChart":return Te(t);case"lineChart":return n.every(s)?"line":"line-markers";case"areaChart":return We(t);case"pieChart":return"pie";case"doughnutChart":return"doughnut";case"scatterChart":return n.every(o)?"scatter":n.some(a=>L(a,"smooth")===!0)?"scatter-smooth":"scatter-lines";default:return}}function Te(e){const t=A(e,"barDir")==="bar"?"bar":"column",n=A(e,"grouping");return n==="stacked"?`${t}-stacked`:n==="percentStacked"?`${t}-stacked-100`:`${t}-clustered`}function We(e){const t=A(e,"grouping");return t==="stacked"?"area-stacked":t==="percentStacked"?"area-stacked-100":"area"}function I(e,t){if(e===void 0)return;const n=e.replace(/^=/u,"");if(/(?:^|[(,])'?\[\d+\]/u.test(n))return"it reads another workbook";if(e.includes("#REF!"))return"its cells were deleted (#REF!)";const o=/^(?:'((?:[^']|'')+)'|([^!'(),]+))!/u.exec(n),s=o?.[1]?.replaceAll("''","'")??o?.[2];if(s!==void 0&&!t(s))return`it reads a sheet the workbook does not have (${s})`;const a=Re(`=${n}`);if(!a.ok||!T(a.node))return`it names no cells (${n})`}function T(e){switch(e.kind){case"ref":case"name":case"structured":return!0;case"paren":return T(e.arg);case"binary":return(e.op===","||e.op===":")&&T(e.left)&&T(e.right);default:return!1}}export function readChart(e,t=[],n=()=>!0){const o=r(e?.chartSpace),s=r(o?.chart),a=r(s?.plotArea);if(!s||!a)return"it has no plot";const l=Object.entries(a).filter(([c])=>c.endsWith("Chart")).flatMap(([c,x])=>O(x).map(k=>({kind:c,plot:k}))),[h]=l;if(!h)return"it has no plot";const m=O(a.valAx),y=c=>O(c.axId).map(x=>b(x,"val")),i=c=>{const x=m.find(k=>y(c).includes(b(r(k.axId),"val")));return x!==void 0&&A(x,"axPos")==="r"},f=l.length>1,p=l.map(({kind:c,plot:x})=>({kind:c,plot:x,type:ne(c,x),secondary:f&&i(x)}));if(f&&p.some(c=>c.type===void 0||!(c.type.startsWith("column")||c.type.startsWith("line")||c.type.startsWith("area"))))return"it combines several kinds of chart, not columns, lines and areas";const $=p.find(c=>!c.secondary)??p[0]??h,{kind:g,plot:u}=$,F=g==="scatterChart",S=[];let R,D;const z=p.flatMap(c=>O(c.plot.ser).map(x=>({s:x,of:c})));for(const[c,{s:x,of:k}]of z.entries()){const w=Ie(x,F);if(typeof w=="string")return w;if(f){const Y=k.type;Y!==void 0&&Y!==ne(g,u)&&(w.series.type=Y),k.secondary&&(w.series.secondary=!0)}const Q=I(w.series.values,n);if(Q!==void 0){t.push(`series ${String(c+1)}, as ${Q}`),D=Q;continue}w.series.name?.startsWith("=")===!0&&I(w.series.name,n)!==void 0&&delete w.series.name,I(w.series.x,n)!==void 0&&delete w.series.x,S.push(w.series),I(w.categories,n)===void 0&&(R??=w.categories)}if(S.length===0)return D===void 0?"it has no series":`every series ${D.replace(/^it /u,"")}`;const _=ne(g,u);if(!_)return`a sheet has no ${g.replace(/Chart$/u,"")} chart`;const re=Oe(r(s.title)),oe=r(s.legend),U=A(oe,"legendPos"),se=r(u.dLbls),C=c=>L(se,c)===!0,Ae=C("showVal")||C("showPercent")||C("showCatName")||C("showSerName"),ie=A(se,"dLblPos"),V=M(u,"gapWidth"),ce=M(u,"overlap"),B=M(u,"holeSize"),ae=L(u,"varyColors"),de=_==="pie"||_==="doughnut",fe=c=>y(u).includes(b(r(c.axId),"val")),ue=[...O(a.catAx),...O(a.dateAx)],N={value:f?m.find(fe)??m[0]:m.find((c,x,k)=>F?x===k.length-1:!0),category:F?m[0]:f?ue.find(fe)??ue[0]:r(a.catAx)??r(a.dateAx),second:p.some(c=>c.secondary)?m.find(c=>A(c,"axPos")==="r"):void 0},H=te(N.value),X=te(N.category);H&&N.value?.majorGridlines===void 0&&(H.gridlines=!1),X&&N.category?.majorGridlines!==void 0&&(X.gridlines=!0);const q=j(r(r(r(r(o?.txPr)?.p)?.pPr)?.defRPr),"sz"),J=c=>c&&Object.keys(c).length>0?c:void 0,le=J(H),me=J(X),K=te(N.second);K&&N.second?.majorGridlines!==void 0&&(K.gridlines=!0);const he=J(K);return{type:_,at:"A1",...re===void 0?{}:{title:re},...R===void 0?{}:{categories:R},series:de?S.slice(0,1):S,...oe?{legend:U==="b"?"bottom":U==="t"?"top":U==="l"?"left":"right"}:{},...Ae?{labels:{...C("showVal")?{value:!0}:{},...C("showPercent")?{percentage:!0}:{},...C("showCatName")?{category:!0}:{},...C("showSerName")?{series:!0}:{},...ie===void 0?{}:{position:ie}}}:{},...V===void 0||V===150?{}:{gap_width:V},...ce===void 0||_.includes("stacked")?{}:{overlap:ce},...B===void 0||B===50?{}:{hole_size:B},...ae===!0&&g==="barChart"?{vary_by_categories:!0}:{},...ae===!1&&de?{vary_by_categories:!1}:{},...le?{value_axis:le}:{},...me?{category_axis:me}:{},...he?{secondary_axis:he}:{},...q===void 0||q===900?{}:{size:q/100}}}const W=e=>Math.round(e/v);export function chartAnchors(e,t,n){const o=r(e?.wsDr),s=[],a=[];let l=0;const h=i=>({col:Number(P(i?.col)),row:Number(P(i?.row)),colOff:W(Number(P(i?.colOff))),rowOff:W(Number(P(i?.rowOff)))}),m=i=>b(r(r(r(r(i.graphicFrame)?.graphic)?.graphicData)?.chart),"id"),y=(i,f,p,$)=>{const g={at:{row:f.row,col:f.col},...f.colOff>0?{x:f.colOff}:{},...f.rowOff>0?{y:f.rowOff}:{},width:p,height:$},u=r(i.pic),F=b(r(r(u?.blipFill)?.blip),"embed");if(u&&F!==void 0){const R=r(r(u.nvPicPr)?.cNvPr),D=b(R,"name"),z=b(R,"descr");a.push({id:F,...g,...D===void 0?{}:{name:D},...z===void 0?{}:{descr:z}});return}const S=m(i);if(S===void 0){l+=1;return}s.push({id:S,...g})};for(const i of O(o?.oneCellAnchor)){const f=r(i.ext);y(i,h(r(i.from)),W(j(f,"cx")??0),W(j(f,"cy")??0))}for(const i of O(o?.twoCellAnchor)){const f=h(r(i.from)),p=h(r(i.to));let $=p.colOff-f.colOff;for(let u=f.col;u<p.col;u++)$+=t(u);let g=p.rowOff-f.rowOff;for(let u=f.row;u<p.row;u++)g+=n(u);y(i,f,$,g)}return{anchors:s,pictures:a,others:l}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{parseFormula as
|
|
2
|
+
import{parseFormula as h}from"../formula/parse.js";import{printFormula as w}from"../formula/print.js";import{FUNCTIONS as k}from"../calc/functions/index.js";import{fileName as O,plainName as S}from"./functions.js";function f(r){switch(r.kind){case"ref":return r.col2!==void 0||r.row2!==void 0;case"structured":return!r.thisRow||r.columns.length>1;case"paren":return f(r.arg);case"binary":return r.op===":"||r.op===",";default:return!1}}const g=new Set(["+","-","*","/","^","&","=","<>","<","<=",">",">="]),y=new Set(`BYCOL BYROW CHOOSECOLS CHOOSEROWS DROP EXPAND FILTER HSTACK MAKEARRAY MAP
|
|
3
3
|
RANDARRAY SCAN SEQUENCE SORT SORTBY TAKE TEXTSPLIT TOCOL TOROW UNIQUE VSTACK
|
|
4
|
-
WRAPCOLS WRAPROWS`.split(/\s+/u)),
|
|
4
|
+
WRAPCOLS WRAPROWS`.split(/\s+/u)),R=new Set(["IF","IFERROR","IFNA"]);function p(r,t){const a=k.get(r);if(a?.kind==="scalar")return!0;if(a?.kind!=="raw")return!1;const{fixed:s,group:e}=a.params;return t<s.length?s[t]==="value":e.length>0&&e[(t-s.length)%e.length]==="value"}export function needsArray(r,t=()=>!1){const a=e=>f(e)||e.kind==="array"||e.kind==="name"&&t(e.name)||e.kind==="paren"&&a(e.arg);if(r.kind!=="array"&&a(r))return!0;const s=e=>{switch(e.kind){case"unary":return e.op==="@"?!1:a(e.arg)||s(e.arg);case"postfix":return e.op==="%"?a(e.arg)||s(e.arg):!1;case"paren":return s(e.arg);case"binary":return g.has(e.op)&&(a(e.left)||a(e.right))?!0:s(e.left)||s(e.right);case"call":return e.name==="LET"||e.name==="LAMBDA"||y.has(e.name)||e.args.some((n,u)=>p(e.name,u)&&a(n))||R.has(e.name)&&e.args[0]&&a(e.args[0])?!0:e.args.some(s);case"invoke":return s(e.callee)||e.args.some(s);default:return!1}};return s(r)}export function narrowed(r,t=()=>!1){const a=e=>e.kind!=="array"&&(f(e)||e.kind==="name"&&t(e.name))?{kind:"unary",op:"@",arg:e}:s(e),s=e=>{switch(e.kind){case"unary":return e.op==="@"?e:{...e,arg:a(e.arg)};case"postfix":return e.op==="%"?{...e,arg:a(e.arg)}:e;case"paren":return{...e,arg:s(e.arg)};case"binary":return g.has(e.op)?{...e,left:a(e.left),right:a(e.right)}:e;case"call":{const[n,...u]=e.args;return R.has(e.name)&&n?{...e,args:[a(n),...u]}:e.args.some((i,c)=>p(e.name,c))?{...e,args:e.args.map((i,c)=>p(e.name,c)?a(i):i)}:e}default:return e}};return a(r)}const A=(r,t)=>({kind:"call",name:r,written:r,args:t});function E(r,t){return{...r,...r.table===void 0&&t!==void 0?{table:t}:{},sections:r.thisRow?["#This Row"]:r.sections,thisRow:!1}}function d(r,t,a,s){const e=(n,u=!1)=>d(n,t,a,u&&s);switch(r.kind){case"name":{const n=r.name.toLowerCase();return a.has(n)?{...r,name:`_xlpm.${r.name}`}:t.isTable(r.name)?{...r,name:`${r.name}[]`}:r}case"structured":return E(r,t.table);case"unary":return r.op==="@"?s?e(r.arg,!0):A("_xlfn.SINGLE",[e(r.arg)]):{...r,arg:e(r.arg,!0)};case"postfix":return r.op==="#"?A("_xlfn.ANCHORARRAY",[e(r.arg)]):{...r,arg:e(r.arg,!0)};case"paren":return{...r,arg:e(r.arg,!0)};case"binary":return{...r,left:e(r.left,g.has(r.op)),right:e(r.right,g.has(r.op))};case"call":{const n=O(r.name);if(r.name==="LET"||r.name==="LAMBDA"){const u=new Set(a),i=r.args.length-1,c=r.args.map((l,m)=>(r.name==="LAMBDA"||m%2===0)&&m<i&&l.kind==="name"?(u.add(l.name.toLowerCase()),{...l,name:`_xlpm.${l.name}`}):d(l,t,u,!1));return{...r,written:n,args:c}}return{...r,written:n,args:r.args.map(u=>e(u))}}case"invoke":return{...r,callee:e(r.callee),args:r.args.map(n=>e(n))};case"array":return{...r,rows:r.rows.map(n=>n.map(u=>e(u)))};default:return r}}export const fileFormula=(r,t)=>w(d(r,t,new Set,!t.array)).slice(1);function o(r){switch(r.kind){case"name":return r.name.toLowerCase().startsWith("_xlpm.")?{...r,name:r.name.slice(6)}:r;case"structured":return r;case"unary":case"postfix":case"paren":return{...r,arg:o(r.arg)};case"binary":return{...r,left:o(r.left),right:o(r.right)};case"call":{const a=S(r.written).toUpperCase(),s=r.args.map(o),[e]=s;return a==="ANCHORARRAY"&&e&&s.length===1?{kind:"postfix",op:"#",arg:e}:a==="SINGLE"&&e&&s.length===1?{kind:"unary",op:"@",arg:e}:{...r,name:a,written:a,args:s}}case"invoke":return{...r,callee:o(r.callee),args:r.args.map(o)};case"array":return{...r,rows:r.rows.map(t=>t.map(o))};default:return r}}export function readFileFormula(r,t,a){const s=h(`=${r}`);if(!s.ok)return s;const e=o(s.node);return{ok:!0,node:t?e:narrowed(e,a)}}export function isRangeText(r){const t=h(`=${r}`);return t.ok&&f(o(t.node))}
|
|
@@ -41,8 +41,9 @@ export interface ImportOptions {
|
|
|
41
41
|
tolerance?: number;
|
|
42
42
|
/** What the file may unzip to; ZIP_LIMITS unless it says. */
|
|
43
43
|
zip?: Partial<ZipLimits>;
|
|
44
|
+
/** Whether a file is there already, by its path from the sheet's folder: a file made beside it takes another name. */
|
|
45
|
+
taken?: (path: string) => boolean;
|
|
44
46
|
}
|
|
45
|
-
/** Whether a value the engine gives is what a file cached. */
|
|
46
47
|
export declare function sameValue(a: Scalar, b: Scalar, tolerance: number): boolean;
|
|
47
48
|
/** The files of a sheet made of an Excel file's bytes, what could not be carried over and how the engine agrees with it. */
|
|
48
49
|
export declare function importXlsx(bytes: Uint8Array, o: ImportOptions): ImportedXlsx;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{SHEET_DATA as re,SHEET_FILE as ie,SHEET_FILES as j,SHEET_NOTE_AUTHOR as le,SHEET_PICTURE_HEIGHT as P,SHEET_SEPARATOR as fe}from"@allyhub/formats";import{cellName as y,columnLetter as M,contains as T,overlaps as A,rangeName as v,readAddress as ae,readArea as W}from"../address.js";import{rectangles as O}from"../api/rectangles.js";import{chartAfter as ce}from"../chart.js";import{analyse as ue}from"../calc/analyse.js";import{FUNCTIONS as he}from"../calc/functions/index.js";import{checkWorkbook as de}from"../check.js";import{writeCsv as me}from"../csv.js";import{pictureSize as pe}from"../files.js";import{isDateCode as z}from"../format.js";import{moveFormula as we,relativeKey as B}from"../formula/move.js";import{printFormula as E,sheetPrefix as U}from"../formula/print.js";import{mapNode as ge,walk as H}from"../formula/walk.js";import{CellError as N,isoOfSerial as ke,readTyped as F,writeTyped as I}from"../values.js";import{FormulaCell as be,validName as V}from"../workbook.js";import{writeYaml as ye}from"../write.js";import{readFileFormula as $e}from"./formula.js";import{hasDate as q}from"./numfmt.js";import{placesLine as D,readXlsx as xe}from"./read.js";import{LISTS_SHEET as Le}from"./write.js";const J=100,ve=.5,K=1462,Z=64,X=1e4;export const COMPARE_TOLERANCE=1e-9;const Y=a=>a.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/gu,"")||"rows",k=a=>{for(const e in a)if(Object.hasOwn(a,e))return!1;return!0},G=(a,e)=>`${String(a)} ${e}${a===1?"":"s"}`,S=a=>({row:a.row,col:a.col});function Q(a){return a===""||a.length>255||/^[/\\]|^[A-Za-z]:|\\|\0/u.test(a)?!1:a.split("/").every(e=>e!==""&&e!=="."&&e!=="..")}class Ee{cells;starts;first;constructor(e){let o=!0;for(let t=1;t<e.length&&o;t++){const n=e[t-1],r=e[t];n&&r&&(r.row<n.row||r.row===n.row&&r.col<=n.col)&&(o=!1)}if(!o){e.sort((t,n)=>t.row-n.row||t.col-n.col);for(let t=e.length-1;t>0;t--){const n=e[t-1],r=e[t];r&&n?.row===r.row&&n.col===r.col&&e.splice(t-1,1)}}this.cells=e;const s=e[0]?.row??0,l=e[e.length-1]?.row??-1;this.first=s,this.starts=new Int32Array(Math.max(0,l-s+2));let i=0;for(let t=0;t<this.starts.length;t++){for(;i<e.length&&(e[i]?.row??0)<s+t;)i++;this.starts[t]=i}}get(e,o){const s=e-this.first;if(s<0||s>=this.starts.length-1)return;let l=this.starts[s]??0,i=(this.starts[s+1]??0)-1;for(;l<=i;){const t=l+i>>1,n=this.cells[t];if(!n)return;if(n.col===o)return n;n.col<o?l=t+1:i=t-1}}}class ee{list=[];add(e){this.list.push(e)}has(e,o){for(const s of this.list)if(T(s,e,o))return!0;return!1}}function te(a,e){const o=e.toLowerCase();return ge(a,s=>s.kind!=="structured"||s.table?.toLowerCase()!==o?s:Object.fromEntries(Object.entries(s).filter(([l])=>l!=="table")))}function oe(a){return a.headers===0?"has no header row":a.columns.length!==a.ref.right-a.ref.left+1||!V(a.name)?"cannot be held as a table":new Set(a.columns.map(e=>e.name.toLowerCase())).size===a.columns.length?void 0:"has two columns of one name"}function ne(a,e,o){let s;const l=new Set;H(a,t=>{t.kind==="call"&&(t.name==="LET"||t.name==="LAMBDA")&&t.args.forEach(n=>{n.kind==="name"&&l.add(n.name.toLowerCase())})});const i=t=>l.has(t)||o===void 0||o.names.has(t)||o.tables.has(t);return H(a,t=>{s===void 0&&(t.kind==="call"&&!he.has(t.name)&&(i(t.written.toLowerCase())||(s=`no function ${t.name}`)),t.kind==="name"&&!i(t.name.toLowerCase())&&(s=`no name ${t.name}`),t.kind==="structured"&&t.table!==void 0&&!i(t.table.toLowerCase())&&(s=`no table ${t.table}`),(t.kind==="ref"||t.kind==="name"||t.kind==="error")&&t.sheet!==void 0&&(t.sheet.startsWith("[")?s="it reads another workbook":e.has(t.sheet.toLowerCase())||(s=`no sheet ${t.sheet}`)))}),s}function Se(a){const e=new Set(a.book.sheets.map(o=>o.name.toLowerCase()));for(const o of a.book.sheets){const s=new Map,l=(t,n)=>{const r=s.get(n),f=y(t);r?r.push(f):s.set(n,[f])},i=[];for(const t of o.cells){if(t.unread!==void 0){l(t,/^\[|[!']\[|\[\d+\]/u.test(t.unread)?"it reads another workbook":`it could not be read: ${t.unread}`);continue}if(!t.node)continue;const n=ne(t.node,e,a);n!==void 0?(delete t.node,l(t,n)):(a.carried.set(t,o),t.array&&v(t.array)!==y(t)&&i.push(t))}Ce(a,o,i);for(const[t,n]of s)a.lost.push(`${o.name}: ${G(n.length,"formula")} kept as ${n.length===1?"its value":"their values"}, as ${t} (${D(n)})`)}}function Ce(a,e,o){if(o.length===0)return;const s=new Set;for(const l of o){const{array:i}=l;if(i)for(const t of e.cells)t!==l&&!t.node&&T(i,t.row,t.col)&&s.add(t)}e.cells=e.cells.filter(l=>!s.has(l));for(const l of s)a.spilled.set(l,e)}function C(a,e){const{value:o}=e;if(!a.book.date1904||typeof o!="number")return o;const s=a.book.looks[e.style]?.format;return z(s)&&s!==void 0&&q(s)?o+K:o}function R(a,e){if(typeof a!="number"||e===void 0||!z(e)||!q(e)||a<1)return;const o=ke(a);return F(o).value===a?o:void 0}const Me=(a,e)=>R(a,e)??I(a??null);function Oe(a,e){const o=R(a,e);return o!==void 0?o:a==null?null:typeof a=="number"||typeof a=="boolean"?a:I(a)}function _e(a){const e=[];for(let n=0;n<a.length;n++){const r=a[n];if(!r)continue;const f=e[e.length-1];f?.row===r.row&&f.right===r.col-1?(f.right=r.col,f.last=n):e.push({row:r.row,left:r.col,right:r.col,first:n,last:n})}const o=e.map((n,r)=>r),s=n=>{let r=n;for(;o[r]!==r;){const f=o[o[r]??r]??r;o[r]=f,r=f}return r};let l=0,i=0;for(let n=0;n<e.length;n++){const r=e[n];if(r){n>0&&e[n-1]?.row!==r.row&&(l=e[n-1]?.row===r.row-1?i:n,i=n);for(let f=l;f<i;f++){const c=e[f];c?.row===r.row-1&&c.right>=r.left&&c.left<=r.right&&(o[s(n)]=s(f))}}}const t=new Map;return e.forEach((n,r)=>{const f=s(r),c=t.get(f),u=n.right-n.left+1;c?(c.box.top=Math.min(c.box.top,n.row),c.box.bottom=Math.max(c.box.bottom,n.row),c.box.left=Math.min(c.box.left,n.left),c.box.right=Math.max(c.box.right,n.right),c.count+=u,c.runs.push(r)):t.set(f,{box:{top:n.row,bottom:n.row,left:n.left,right:n.right},count:u,runs:[r]})}),[...t.values()].map(n=>({box:n.box,count:n.count,cells:()=>n.runs.flatMap(r=>{const f=e[r];return f?a.slice(f.first,f.last+1):[]})}))}const se=a=>JSON.stringify(a);class Te{ctx;read;cells;inTables=new ee;columnLooks=new Map;rowLooks=new Map;lookDone=new ee;tables=[];areas=[];filtered=[];ownLooks=new Map;fileColumns=new Map;pictured=new Map;over=[];constructor(e,o){this.ctx=e,this.read=o,this.cells=new Ee(o.cells)}at(e,o){return this.cells.get(e,o)}look(e){return this.ctx.book.looks[e.style]??{}}code(e){return this.look(e).format}text(e){return e.node?E(e.node):Me(C(this.ctx,e),this.code(e))}baseLooks(){const{read:e}=this,{looks:o}=this.ctx.book;let s=-1;for(const i of e.cells)i.col>s&&(s=i.col);for(const i of e.columns){if(i.style===void 0)continue;const t=o[i.style];if(!(!t||k(t)))for(let n=i.min;n<=Math.min(i.max,s);n++)this.columnLooks.set(n,t)}for(const i of e.rows){const t=i.style===void 0?void 0:o[i.style];t&&!k(t)&&this.rowLooks.set(i.row,t)}const l=(i,t)=>{for(const n in t)if(!(n in i))return!1;return!0};for(const i of e.cells){const t=this.look(i),n=this.columnLooks.get(i.col);n&&!l(t,n)&&this.columnLooks.delete(i.col);const r=this.rowLooks.get(i.row);r&&!l(t,r)&&this.rowLooks.delete(i.row)}}ownLook(e){const o=this.columnLooks.get(e.col),s=this.rowLooks.get(e.row),l=this.look(e),i=l.format!==void 0&&z(l.format);if(!o&&!s&&!i){let f=this.ownLooks.get(e.style);return f||(f={look:l,key:se(l)},this.ownLooks.set(e.style,f)),f}const t={...o,...s},n={};for(const[f,c]of Object.entries(l))JSON.stringify(c)!==JSON.stringify(t[f])&&(n[f]=c);const r=n.format;if(typeof r=="string"){const f=e.node?void 0:R(C(this.ctx,e),r);f!==void 0&&F(f).format===r&&delete n.format}return{look:n,key:se(n)}}columnFormula(e,o,s){const l=new Map,i=s-o+1;for(let n=o;n<=s;n++){const r=this.at(n,e);if(!r||r.value===void 0&&!r.node||r.value===null&&!r.node)return;if(!r.node)continue;r.key??=B(r.node,r.row,r.col);const f=l.get(r.key);f?f.n+=1:l.set(r.key,{n:1,cell:r})}let t;for(const n of l.values())(!t||n.n>t.n)&&(t=n);return t&&t.n*2>i?t.cell:void 0}csv(e,o){const s=[];for(let l=0;l<e;l+=X){const i=[];for(let t=l;t<Math.min(e,l+X);t++)i.push(o(t));s.push(me(i))}return s.join("")}table(e){const{read:o,ctx:s}=this,l=p=>s.lost.push(`${o.name}: table ${e.name} ${p}`),i=e.ref.right-e.ref.left+1,t=oe(e);if(t!==void 0)return l(`${t}, so its cells are kept and it is no table`),!1;const n=e.ref.top,r=n+1,f=e.ref.bottom-e.totals;e.totals>0&&l("has a totals row, kept as plain cells under it");const c=e.columns.map((p,d)=>f>=r?this.columnFormula(e.ref.left+d,r,f):void 0),u=p=>{const d=c[p];if(!d)return!1;for(let g=r;g<=f;g++)if(this.at(g,e.ref.left+p)?.key!==d.key)return!1;return!0};let h=i;for(;h>1&&u(h-1);)h-=1;const w={},m=this.path(e.name);s.files.set(m,this.csv(f-r+2,p=>{if(p===0)return e.columns.slice(0,h).map(b=>b.name);const d=r+p-1,g=[];for(let b=0;b<h;b++){const x=this.at(d,e.ref.left+b),L=c[b];x?L&&x.key===L.key?g.push(""):x.node?g.push(E(te(x.node,e.name))):g.push(this.text(x)):g.push("")}return g})),this.inTables.add({...e.ref,bottom:f}),e.columns.forEach((p,d)=>{const g=e.ref.left+d,b=this.columnLook(g,r,f),x=c[d];x?.node&&(b.formula=E(te(we(x.node,r-x.row,0),e.name)));const L=this.fileColumns.get(g);L!==void 0&&r<=f&&(b.files=L===P?!0:{height:L}),k(b)||(w[p.name]=b)});const $=new Map;for(const[p,d]of e.filter?.columns??[]){const g=e.columns[p]?.name;g!==void 0&&$.set(g,d)}return(e.filter?.unread??0)>0&&l(`has ${G(e.filter?.unread??0,"filter")} by condition, its rows left as they were hidden`),this.tables.push({name:e.name,at:y({row:n,col:e.ref.left}),rows:m,...e.style!==void 0&&e.style!=="TableStyleMedium2"?{style:e.style}:{},...k(w)?{}:{columns:w},...e.filter===void 0?{filter:!1}:$.size>0?{filter:{columns:Object.fromEntries($)}}:{}}),e.filter?.unread===0&&e.filter.columns.size>0&&this.filtered.push({...e.ref,bottom:f}),this.areas.push({...e.ref,bottom:f}),!0}columnLook(e,o,s){let l,i={};for(let t=o;t<=s;t++){const n=this.at(t,e),r=n?this.ownLook(n):{look:{},key:"{}"};if(l===void 0)l=r.key,i=r.look;else if(l!==r.key)return{}}return k(i)?{}:(this.lookDone.add({top:o,bottom:s,left:e,right:e}),{...i})}path(e){const o=`${re}/${Y(e)}`;let s=`${o}.csv`;for(let l=2;this.ctx.files.has(s);l++)s=`${o}-${String(l)}.csv`;return s}loose(){const e=[],o=[];for(const s of this.read.cells)this.inTables.has(s.row,s.col)||(s.node?e.push(s):s.value!==void 0&&s.value!==null&&o.push(s));return{formulas:e,typed:o}}blockAreas(e,o){const s=[],l=O(o.map(S)),i=n=>!s.some(r=>A(r,n))&&!this.areas.some(r=>A(r,n))&&!l.some(r=>A(r,n)),t=n=>(n.bottom-n.top+1)*(n.right-n.left+1);for(const n of _e(e)){const{box:r}=n;if(!(t(r)<J)){if(n.count/t(r)>=ve&&i(r)){s.push(r);continue}for(const f of O(n.cells().map(S)))t(f)>=J&&i(f)&&s.push(f)}}return s.sort((n,r)=>n.top-r.top||n.left-r.left)}cells_(e){const{formulas:o,typed:s}=this.loose(),l=this.blockAreas(s,o),i=r=>l.some(f=>T(f,r.row,r.col));l.length>0&&(e.blocks=l.map(r=>{const f=this.path(this.read.name);return this.ctx.files.set(f,this.csv(r.bottom-r.top+1,c=>{const u=[];for(let h=r.left;h<=r.right;h++){const w=this.at(r.top+c,h);u.push(w?this.text(w):"")}return u})),{at:y({row:r.top,col:r.left}),rows:f}}));const t=[],n=new Map;for(const r of o){if(!r.node)continue;r.key??=B(r.node,r.row,r.col);const f=n.get(r.key);f?f.push(r):n.set(r.key,[r])}for(const r of n.values())for(const f of O(r.map(S))){const c=this.at(f.top,f.left);c?.node&&t.push([{row:f.top,col:f.left},v(f),E(c.node)])}for(const r of s)l.length>0&&i(r)||t.push([S(r),y(r),Oe(C(this.ctx,r),this.code(r))]);t.sort(([r],[f])=>r.row-f.row||r.col-f.col),t.length>0&&(e.cells=Object.fromEntries(t.map(([,r,f])=>[r,f])))}formats(e){const o=new Map,s=this.lookDone.list.length>0;for(const i of this.read.cells){if(s&&this.lookDone.has(i.row,i.col))continue;const t=this.ownLook(i);if(k(t.look))continue;const n=o.get(t.key);n?n.places.push(S(i)):o.set(t.key,{look:t.look,places:[S(i)]})}const l=[];for(const{look:i,places:t}of o.values())for(const n of O(t))l.push({range:v(n),...i});l.length>0&&(e.format=l)}columns(e){const{read:o}=this,s=new Map;let l=0;for(const t of o.cells)t.col>l&&(l=t.col);const i=[];for(const t of o.columns){if(t.width===void 0&&t.hidden!==!0&&t.level===void 0)continue;const n=t.max-Math.max(t.min,l+1)+1>Z?Math.max(l,t.min+Z-1):t.max;n<t.max&&i.push(`${M(n+1)}:${M(t.max)}`);for(let r=t.min;r<=n;r++)s.set(r,{...t.width===void 0?{}:{width:t.width},...t.hidden===!0?{hidden:!0}:{},...t.level===void 0?{}:{level:t.level}})}for(const[t,n]of this.columnLooks)s.set(t,{...s.get(t),...n});for(const[t,n]of this.fileColumns)this.tableColumn(t)||s.set(t,{...s.get(t),files:n===P?!0:{height:n}});s.size>0&&(e.columns=Object.fromEntries([...s.keys()].sort((t,n)=>t-n).map(t=>[M(t),s.get(t)??{}]))),i.length>0&&this.ctx.lost.push(`${o.name}: the size of columns ${D(i)}, past those that hold anything`)}tableColumn(e){return this.areas.some(o=>e>=o.left&&e<=o.right)}rows(e){const o={};for(const s of this.read.rows){const l=this.rowLooks.get(s.row),i=this.filtered.some(r=>s.row>r.top&&s.row<=r.bottom),t=s.height!==void 0&&this.pictured.get(s.row)!==s.height?s.height:void 0,n={...t===void 0?{}:{height:t},...s.hidden===!0&&!i?{hidden:!0}:{},...s.level===void 0?{}:{level:s.level},...l};k(n)||(o[String(s.row+1)]=n)}k(o)||(e.rows=o)}assetPath(e,o){const s=t=>{const n=this.ctx.assets.get(t);return!n||Ae(n,o.bytes)};if(e!==void 0&&Q(e)&&s(e))return e;const l=Y((o.name??"picture").replace(/\.[A-Za-z0-9]+$/u,""));let i=`${j}/${l}.${o.type}`;for(let t=2;!s(i);t++)i=`${j}/${l}-${String(t)}.${o.type}`;return i}pictures(){const e=this.over;for(const o of this.read.pictures){const s=this.at(o.row,o.col),l=typeof s?.value=="string"?s.value:"";if(o.y===void 0&&o.descr!==void 0&&Q(o.descr)&&l.split(fe).includes(o.descr)&&o.descr!==void 0){this.ctx.assets.set(o.descr,o.bytes),this.fileColumns.set(o.col,Math.max(this.fileColumns.get(o.col)??0,o.height)),this.pictured.set(o.row,Math.max(this.pictured.get(o.row)??0,o.height));continue}const t=this.assetPath(o.descr,o);this.ctx.assets.set(t,o.bytes);const n=pe(o.bytes),r=n?.width===o.width&&n.height===o.height;e.push({file:t,at:y({row:o.row,col:o.col}),...o.x===void 0?{}:{x:o.x},...o.y===void 0?{}:{y:o.y},...r?{}:{width:o.width,height:o.height}})}}build(){const{read:e}=this;this.baseLooks(),this.pictures();for(const s of e.tables)this.table(s);const o={name:e.name};return e.state!=="visible"&&(o.hidden=!0),e.gridlines===!1&&(o.gridlines=!1),e.tab!==void 0&&(o.tab=e.tab),e.state==="veryHidden"&&this.ctx.lost.push(`${e.name}: being very hidden; it is hidden`),e.freeze&&(e.freeze.row>0||e.freeze.col>0)&&(o.freeze=y(e.freeze)),this.tables.length>0&&(o.tables=this.tables),this.filter(o),this.columns(o),this.rows(o),this.cells_(o),e.merges.length>0&&(o.merges=e.merges.map(v)),this.formats(o),e.conditional.length>0&&(o.conditional=e.conditional),e.validations.length>0&&(o.validations=e.validations),e.charts.length>0&&(o.charts=e.charts.map(s=>this.chart(s))),this.over.length>0&&(o.pictures=this.over),k(e.links)||(o.links=e.links),e.notes.length>0&&(o.notes=Object.fromEntries(e.notes.map(s=>[s.ref,s.author===void 0||s.author===le?s.text:{text:s.text,author:s.author}]))),e.print&&(o.print=e.print),e.protect===!0&&(o.protect=!0),o}chart(e){return ce(e,o=>{const s=this.chartReference(o.replace(/^=/u,""));return o.startsWith("=")?`=${s}`:s})}chartReference(e){const o=e.lastIndexOf("!"),l=(o<0?this.read.name:e.slice(0,o)).replace(/^'|'$/gu,"").replaceAll("''","'"),i=W(e.slice(o+1).replaceAll("$",""));if(!i)return e;const t=this.ctx.book.sheets.find(n=>n.name.toLowerCase()===l.toLowerCase());for(const n of t?.tables??[]){const r=n.ref.top+1,c=i.left===i.right&&i.top===r&&i.bottom===n.ref.bottom&&i.left>=n.ref.left&&i.left<=n.ref.right?n.columns[i.left-n.ref.left]:void 0;if(c&&this.ctx.tables.has(n.name.toLowerCase()))return`${n.name}[${c.name}]`}return`${t===this.read||o<0?"":`${e.slice(0,o)}!`}${v(i)}`}filter(e){const{filter:o}=this.read;if(!o)return;const s={};for(const[l,i]of o.columns)s[M(o.ref.left+l)]=i;e.filter={range:v(o.ref),...k(s)?{}:{columns:s}},o.unread===0&&!k(s)&&this.filtered.push(o.ref)}}const Ae=(a,e)=>a.length===e.length&&a.every((o,s)=>o===e[s]),ze=new Set(["_xlnm._FilterDatabase","_xlnm.Print_Area","_xlnm.Print_Titles"]);function He(a){const e={},o=[],s=new Map,{book:l,lost:i}=a,t=new Set(l.sheets.map(f=>f.name.toLowerCase())),n=new Set,r=f=>{const c=Ie(f.text);if(c!==void 0)return typeof c=="string"?I(c):c;const u=$e(f.text,!0),h=u.ok?ne(u.node,t):"it could not be read";if(!u.ok||h!==void 0||Fe(u.node)){i.push(`the name ${f.name} (${f.text})${h===void 0?"":`: ${h}`}`);return}return E(u.node)};for(const f of l.names){if(f.name.startsWith("_xlnm.")){ze.has(f.name)||i.push(`Excel's name ${f.name}`);continue}if(/^_xl(?:fn|pm|ws|udf)/iu.test(f.name))continue;const c=f.name.toLowerCase(),u=f.sheet===void 0?"":String(f.sheet);if(!V(f.name)||a.tables.has(c)){i.push(`the name ${f.name}, which cannot be held here`);continue}if(n.has(`${u}|${c}`)){i.push(`a second name ${f.name}${u===""?"":` of ${l.sheets[f.sheet??0]?.name??""}`}`);continue}const h=r(f);if(h!==void 0)if(n.add(`${u}|${c}`),a.names.add(c),f.sheet===void 0)e[f.name]=h,f.hidden===!0&&o.push(f.name);else{const w=s.get(f.sheet)??{names:{},hidden:[]};w.names[f.name]=h,f.hidden===!0&&w.hidden.push(f.name),s.set(f.sheet,w)}}return{names:e,hidden:o,sheets:s}}function Ne(a,e){const o={},s=new Map;for(const[l,i]of Object.entries(e))typeof i=="string"&&i.startsWith("=")&&s.set(i.slice(1).replaceAll("$","").toLowerCase(),l);for(const l of a.book.sheets)for(const i of l.scenarios){const t={};let n=!0;for(const{at:r,value:f}of i.cells){const c=ae(r),u=c&&l.cells.find(m=>m.row===c.row&&m.col===c.col);String(u?.value??"")!==f&&(n=!1);const h=s.get(`${U(l.name)}${r}`.toLowerCase())??s.get(r.toLowerCase()),w=F(f);h===void 0?a.lost.push(`${l.name}: scenario ${i.name}'s cell ${r}, which has no name`):t[h]=typeof w.value=="number"?w.value:f}!n&&!k(t)&&(o[i.name]={...o[i.name],...t})}return o}function Fe(a){let e=!1;return H(a,o=>{e||=o.kind==="error"&&o.code==="#REF!"}),e}function Ie(a){const e=a.trim();return/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u.test(e)?Number(e):/^true$/iu.test(e)?!0:/^false$/iu.test(e)?!1:/^"((?:[^"]|"")*)"$/u.exec(e)?.[1]?.replaceAll('""','"')}const De=new RegExp(`^${Le.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}(?: \\(\\d+\\))?$`,"u");function Re(a){const e=a.sheets.find(i=>i.state==="veryHidden"&&De.test(i.name));if(!e)return;const o=U(e.name).toLowerCase(),s=i=>{const t=i.replace(/^=/u,"");if(!t.toLowerCase().startsWith(o))return;const n=W(t.slice(o.length).replaceAll("$",""));if(!n||n.left!==n.right)return;const r=[];for(let f=n.top;f<=n.bottom;f++){const c=e.cells.find(u=>u.row===f&&u.col===n.left);r.push(typeof c?.value=="string"?c.value:"")}return r};for(const i of a.sheets)i.validations=i.validations.map(t=>{const[n]=t.formula??[],r=t.type==="list"&&typeof n=="string"?s(n):void 0;if(!r)return t;const f={...t,values:r};return delete f.formula,f});const l=a.sheets.indexOf(e);a.sheets=a.sheets.filter(i=>i!==e),a.names=a.names.flatMap(i=>i.sheet===void 0||i.sheet<l?[i]:i.sheet===l?[]:[{...i,sheet:i.sheet-1}])}const _=a=>a instanceof N?a.code:a??null;export function sameValue(a,e,o){if(typeof a=="number"&&typeof e=="number")return a===e?!0:Math.abs(a-e)<=Math.max(Math.abs(a),Math.abs(e))*o;if(a instanceof N||e instanceof N)return a?.code===e?.code;if(a===null||e===null){const s=a??e;return s===null||s===""||s===0||s===!1}return a===e}function je(a,e){const o=[];for(const i of e.sheets)for(const t of i.formulas)t.shared.node&&ue(e,t.shared,i).volatile&&o.push(t);const s=new Set(o),l=[...o];for(;;){const i=l.pop();if(!i)return s;for(const t of a.readers(i.sheet,i.row,i.col))s.has(t)||(s.add(t),l.push(t))}}function Pe(a,e,o,s){const l={formulas:0,same:0,uncached:0,moving:0,differences:[]},i=je(o,e);for(const[t,n]of a.carried){if(!t.node)continue;const r=e.sheet(n.name);if(!r)continue;l.formulas+=1;const f=r.at(t.row,t.col);if(f instanceof be&&i.has(f)){l.moving+=1;continue}const c=C(a,t);if(c===void 0){l.uncached+=1;continue}const u=o.value(r,t.row,t.col);sameValue(c,u,s)?l.same+=1:l.differences.push({sheet:n.name,cell:y(t),formula:E(t.node),file:_(c),engine:_(u)})}for(const[t,n]of a.spilled){const r=e.sheet(n.name);if(!r)continue;l.formulas+=1;const f=r.spillAt(t.row,t.col);if(f&&i.has(f)){l.moving+=1;continue}const c=C(a,t),u=o.value(r,t.row,t.col);c===void 0?l.uncached+=1:sameValue(c,u,s)?l.same+=1:l.differences.push({sheet:n.name,cell:y(t),formula:f?`${y(f)}#`:"",file:_(c),engine:_(u)})}return l}function We(a,e){const o=new Map,s=[];for(const l of a){const i=e.find(r=>l.startsWith(`${r}: `));if(i===void 0){s.push(l);continue}const t=l.slice(i.length+2),n=o.get(t);n?n.push(i):o.set(t,[i])}for(const[l,i]of o)s.push(i.length===1?`${i[0]??""}: ${l}`:`${l}, on ${String(i.length)} sheets (${D(i)})`);return s}export function importXlsx(a,e){const o=xe(a,e.zip);if(Re(o),o.sheets.length===0)throw new Error("It holds no sheets.");const s={book:o,files:new Map,assets:new Map,lost:[...o.lost],tables:new Set(o.sheets.flatMap(m=>m.tables.filter($=>oe($)===void 0).map($=>$.name.toLowerCase()))),names:new Set,carried:new Map,spilled:new Map};o.date1904&&s.lost.push(`the 1904 date system: dates are moved to the 1900 one, ${String(K)} days on`),(o.font.name!==void 0&&o.font.name!=="Calibri"||o.font.size!==void 0&&o.font.size!==11)&&s.lost.push(`its default font, ${o.font.name??""} ${String(o.font.size??"")}`);const l=He(s);Se(s);const i=o.sheets.map((m,$)=>{const p=new Te(s,m).build(),d=l.sheets.get($);return d&&!k(d.names)&&(p.names=d.names),d&&d.hidden.length>0&&(p.hidden_names=d.hidden),p}),t=Ne(s,l.names),n={title:o.title??e.name,...k(l.names)?{}:{names:l.names},...l.hidden.length>0?{hidden_names:l.hidden}:{},sheets:i,...k(t)?{}:{scenarios:t}},r=ye(n),f=new Map([[ie,r],...s.files]),c=de({text:r,read:m=>f.get(m),exists:m=>f.has(m)||s.assets.has(m)}),{workbook:u,calc:h,problems:w}=c;return{files:f,assets:s.assets,lost:We(s.lost,o.sheets.map(m=>m.name)),problems:w,compared:u&&h?Pe(s,u,h,e.tolerance??COMPARE_TOLERANCE):{formulas:0,same:0,uncached:0,moving:0,differences:[]},sheets:o.sheets.length,tables:s.tables.size}}
|
|
2
|
+
import{SHEET_FILE as ie,SHEET_NOTE_AUTHOR as le,SHEET_PICTURE_HEIGHT as P,SHEET_SEPARATOR as fe}from"@allyhub/formats";import{cellName as $,columnLetter as M,contains as T,overlaps as z,rangeName as v,readAddress as ae,readArea as W}from"../address.js";import{rectangles as O}from"../api/rectangles.js";import{chartAfter as ce}from"../chart.js";import{analyse as ue}from"../calc/analyse.js";import{ITERATION_DEFAULTS as de}from"../calc/engine.js";import{FUNCTIONS as he}from"../calc/functions/index.js";import{checkWorkbook as me}from"../check.js";import{writeCsv as pe}from"@allyhub/formats";import{pictureSize as we}from"../files.js";import{isDateCode as N}from"../format.js";import{moveFormula as ge,relativeKey as ke}from"../formula/move.js";import{printFormula as S,sheetPrefix as B}from"../formula/print.js";import{mapNode as U,walk as R}from"../formula/walk.js";import{CellError as _,isoOfSerial as be,readTyped as I,writeTyped as H}from"../values.js";import{FormulaCell as V,validName as q}from"../workbook.js";import{writeYaml as ye}from"../write.js";import{readFileFormula as $e}from"./formula.js";import{hasDate as J}from"./numfmt.js";import{placesLine as F,readXlsx as xe}from"./read.js";import{LISTS_SHEET as Le}from"./write.js";const K=100,ve=.5,Y=1462,Z=64,X=1e4;export const COMPARE_TOLERANCE=1e-9;const G=f=>f.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/gu,"")||"rows",b=f=>{for(const e in f)if(Object.hasOwn(f,e))return!1;return!0},Q=(f,e)=>`${String(f)} ${e}${f===1?"":"s"}`,C=f=>({row:f.row,col:f.col});function ee(f){return f===""||f.length>255||/^[/\\]|^[A-Za-z]:|\\|\0/u.test(f)?!1:f.split("/").every(e=>e!==""&&e!=="."&&e!=="..")}class Se{cells;starts;first;constructor(e){let o=!0;for(let t=1;t<e.length&&o;t++){const n=e[t-1],i=e[t];n&&i&&(i.row<n.row||i.row===n.row&&i.col<=n.col)&&(o=!1)}if(!o){e.sort((t,n)=>t.row-n.row||t.col-n.col);for(let t=e.length-1;t>0;t--){const n=e[t-1],i=e[t];i&&n?.row===i.row&&n.col===i.col&&e.splice(t-1,1)}}this.cells=e;const s=e[0]?.row??0,l=e[e.length-1]?.row??-1;this.first=s,this.starts=new Int32Array(Math.max(0,l-s+2));let r=0;for(let t=0;t<this.starts.length;t++){for(;r<e.length&&(e[r]?.row??0)<s+t;)r++;this.starts[t]=r}}get(e,o){const s=e-this.first;if(s<0||s>=this.starts.length-1)return;let l=this.starts[s]??0,r=(this.starts[s+1]??0)-1;for(;l<=r;){const t=l+r>>1,n=this.cells[t];if(!n)return;if(n.col===o)return n;n.col<o?l=t+1:r=t-1}}}class te{list=[];add(e){this.list.push(e)}has(e,o){for(const s of this.list)if(T(s,e,o))return!0;return!1}}function oe(f,e){const o=e.toLowerCase();return U(f,s=>s.kind!=="structured"||s.table?.toLowerCase()!==o?s:Object.fromEntries(Object.entries(s).filter(([l])=>l!=="table")))}function Ce(f){const e=new Map;for(const s of f.sheets)for(const l of s.tables)l.totals>0&&e.set(l.name.toLowerCase(),{t:l,sheet:s.name});if(e.size===0)return;const o=(s,l)=>{const r=l.table===void 0?void 0:e.get(l.table.toLowerCase());if(!r||l.thisRow)return;const{t}=r,n=l.sections,i=n.includes("#All");if(!i&&!n.includes("#Totals"))return;const a=y=>t.columns.findIndex(x=>x.name.toLowerCase()===y.toLowerCase()),[c,u]=l.columns,d=c===void 0?0:a(c),m=c===void 0?t.columns.length-1:u===void 0?d:a(u);if(d<0||m<0)return;const p=i?t.ref.top:n.includes("#Data")?t.ref.top+t.headers:n.includes("#Headers")?t.ref.top:t.ref.bottom-t.totals+1,g=t.ref.bottom,h=t.ref.left+Math.min(d,m),w=t.ref.left+Math.max(d,m),k=p!==g||h!==w;return{kind:"ref",...r.sheet===s?{}:{sheet:r.sheet},col:{index:h,abs:!0},row:{index:p,abs:!0},...k?{col2:{index:w,abs:!0},row2:{index:g,abs:!0}}:{},range:k}};for(const s of f.sheets)for(const l of s.cells)l.node&&(l.node=U(l.node,r=>r.kind==="structured"?o(s.name,r)??r:r.kind==="unary"&&r.op==="@"&&r.arg.kind==="ref"&&!r.arg.range?r.arg:r))}const Ee=1e3;function ne(f){return f.headers===0?"has no header row":f.columns.length!==f.ref.right-f.ref.left+1||!q(f.name)?"cannot be held as a table":new Set(f.columns.map(e=>e.name.toLowerCase())).size===f.columns.length?void 0:"has two columns of one name"}function j(f,e,o){let s;const l=new Set;R(f,t=>{t.kind==="call"&&(t.name==="LET"||t.name==="LAMBDA")&&t.args.forEach(n=>{n.kind==="name"&&l.add(n.name.toLowerCase())})});const r=t=>l.has(t)||o===void 0||o.names.has(t)||o.tables.has(t);return R(f,t=>{s===void 0&&(t.kind==="call"&&!he.has(t.name)&&(r(t.written.toLowerCase())||(s=`no function ${t.name}`)),t.kind==="name"&&!r(t.name.toLowerCase())&&(s=`no name ${t.name}`),t.kind==="structured"&&t.table!==void 0&&!r(t.table.toLowerCase())&&(s=`no table ${t.table}`),(t.kind==="ref"||t.kind==="name"||t.kind==="error")&&t.sheet!==void 0&&(t.sheet.startsWith("[")?s="it reads another workbook":e.has(t.sheet.toLowerCase())||(s=`no sheet ${t.sheet}`)))}),s}function Me(f){const e=new Set(f.book.sheets.map(o=>o.name.toLowerCase()));for(const o of f.book.sheets){const s=new Map,l=(t,n)=>{const i=s.get(n),a=$(t);i?i.push(a):s.set(n,[a])},r=[];for(const t of o.cells){if(t.unread!==void 0){l(t,/^\[|[!']\[|\[\d+\]/u.test(t.unread)?"it reads another workbook":`it could not be read: ${t.unread}`);continue}if(!t.node)continue;const n=j(t.node,e,f);n!==void 0?(delete t.node,l(t,n)):(f.carried.set(t,o),t.array&&v(t.array)!==$(t)&&r.push(t))}Oe(f,o,r);for(const[t,n]of s)f.lost.push(`${o.name}: ${Q(n.length,"formula")} kept as ${n.length===1?"its value":"their values"}, as ${t} (${F(n)})`)}}function Oe(f,e,o){if(o.length===0)return;const s=new Set;for(const l of o){const{array:r}=l;if(r)for(const t of e.cells)t!==l&&!t.node&&T(r,t.row,t.col)&&s.add(t)}e.cells=e.cells.filter(l=>!s.has(l));for(const l of s)f.spilled.set(l,e)}function E(f,e){const{value:o}=e;if(!f.book.date1904||typeof o!="number")return o;const s=f.book.looks[e.style]?.format;return N(s)&&s!==void 0&&J(s)?o+Y:o}function D(f,e){if(typeof f!="number"||e===void 0||!N(e)||!J(e)||f<1)return;const o=be(f);return I(o).value===f?o:void 0}const _e=(f,e)=>D(f,e)??H(f??null);function se(f,e){const o=D(f,e);return o!==void 0?o:f==null?null:typeof f=="number"||typeof f=="boolean"?f:H(f)}function Ae(f){const e=[];for(let n=0;n<f.length;n++){const i=f[n];if(!i)continue;const a=e[e.length-1];a?.row===i.row&&a.right===i.col-1?(a.right=i.col,a.last=n):e.push({row:i.row,left:i.col,right:i.col,first:n,last:n})}const o=e.map((n,i)=>i),s=n=>{let i=n;for(;o[i]!==i;){const a=o[o[i]??i]??i;o[i]=a,i=a}return i};let l=0,r=0;for(let n=0;n<e.length;n++){const i=e[n];if(i){n>0&&e[n-1]?.row!==i.row&&(l=e[n-1]?.row===i.row-1?r:n,r=n);for(let a=l;a<r;a++){const c=e[a];c?.row===i.row-1&&c.right>=i.left&&c.left<=i.right&&(o[s(n)]=s(a))}}}const t=new Map;return e.forEach((n,i)=>{const a=s(i),c=t.get(a),u=n.right-n.left+1;c?(c.box.top=Math.min(c.box.top,n.row),c.box.bottom=Math.max(c.box.bottom,n.row),c.box.left=Math.min(c.box.left,n.left),c.box.right=Math.max(c.box.right,n.right),c.count+=u,c.runs.push(i)):t.set(a,{box:{top:n.row,bottom:n.row,left:n.left,right:n.right},count:u,runs:[i]})}),[...t.values()].map(n=>({box:n.box,count:n.count,cells:()=>n.runs.flatMap(i=>{const a=e[i];return a?f.slice(a.first,a.last+1):[]})}))}const re=f=>JSON.stringify(f);class Te{ctx;read;cells;inTables=new te;columnLooks=new Map;rowLooks=new Map;lookDone=new te;tables=[];areas=[];filtered=[];ownLooks=new Map;fileColumns=new Map;pictured=new Map;over=[];keys=new Map;constructor(e,o){this.ctx=e,this.read=o,this.cells=new Se(o.cells)}at(e,o){return this.cells.get(e,o)}look(e){return this.ctx.book.looks[e.style]??{}}code(e){return this.look(e).format}text(e){return e.node?S(e.node):_e(E(this.ctx,e),this.code(e))}baseLooks(){const{read:e}=this,{looks:o}=this.ctx.book;let s=-1;for(const r of e.cells)r.col>s&&(s=r.col);for(const r of e.columns){if(r.style===void 0)continue;const t=o[r.style];if(!(!t||b(t)))for(let n=r.min;n<=Math.min(r.max,s);n++)this.columnLooks.set(n,t)}for(const r of e.rows){const t=r.style===void 0?void 0:o[r.style];t&&!b(t)&&this.rowLooks.set(r.row,t)}const l=(r,t)=>{for(const n in t)if(!(n in r))return!1;return!0};for(const r of e.cells){const t=this.look(r),n=this.columnLooks.get(r.col);n&&!l(t,n)&&this.columnLooks.delete(r.col);const i=this.rowLooks.get(r.row);i&&!l(t,i)&&this.rowLooks.delete(r.row)}}ownLook(e){const o=this.columnLooks.get(e.col),s=this.rowLooks.get(e.row),l=this.look(e),r=l.format!==void 0&&N(l.format);if(!o&&!s&&!r){let a=this.ownLooks.get(e.style);return a||(a={look:l,key:re(l)},this.ownLooks.set(e.style,a)),a}const t={...o,...s},n={};for(const[a,c]of Object.entries(l))JSON.stringify(c)!==JSON.stringify(t[a])&&(n[a]=c);const i=n.format;if(typeof i=="string"){const a=e.node?void 0:D(E(this.ctx,e),i);a!==void 0&&I(a).format===i&&delete n.format}return{look:n,key:re(n)}}keyOf(e,o){if(e.key!==void 0)return e.key;const s=ke(o,e.row,e.col),l=this.keys.get(s);return l!==void 0?e.key=l:(this.keys.set(s,s),e.key=s)}columnFormula(e,o,s){const l=new Map,r=s-o+1;for(let n=o;n<=s;n++){const i=this.at(n,e);if(!i||i.value===void 0&&!i.node||i.value===null&&!i.node)return;if(!i.node)continue;const a=this.keyOf(i,i.node),c=l.get(a);c?c.n+=1:l.set(a,{n:1,cell:i})}let t;for(const n of l.values())(!t||n.n>t.n)&&(t=n);return t&&t.n*2>r?t.cell:void 0}csv(e,o){const s=[];for(let l=0;l<e;l+=X){const r=[];for(let t=l;t<Math.min(e,l+X);t++)r.push(o(t));s.push(pe(r))}return s.join("")}table(e){const{read:o,ctx:s}=this,l=h=>s.lost.push(`${o.name}: table ${e.name} ${h}`),r=e.ref.right-e.ref.left+1,t=ne(e);if(t!==void 0)return l(`${t}, so its cells are kept and it is no table`),!1;const n=e.ref.top,i=n+1;let a=e.ref.bottom-e.totals;if(e.totals===0){let h=n;for(const w of o.cells)w.col>=e.ref.left&&w.col<=e.ref.right&&w.row>h&&(h=w.row);a-h>Ee&&(l(`runs ${String(a-h)} empty rows past what it holds, which are left out`),a=h)}e.totals>0&&l("has a totals row, kept as plain cells under it");const c=e.columns.map((h,w)=>a>=i?this.columnFormula(e.ref.left+w,i,a):void 0),u=h=>{const w=c[h];if(!w)return!1;for(let k=i;k<=a;k++)if(this.at(k,e.ref.left+h)?.key!==w.key)return!1;return!0};let d=r;for(;d>1&&u(d-1);)d-=1;const m={},p=this.path(e.name);s.files.set(p,this.csv(a-i+2,h=>{if(h===0)return e.columns.slice(0,d).map(y=>y.name);const w=i+h-1,k=[];for(let y=0;y<d;y++){const x=this.at(w,e.ref.left+y),L=c[y];x?L&&x.key===L.key?k.push(""):x.node?k.push(S(oe(x.node,e.name))):k.push(this.text(x)):k.push("")}return k})),this.inTables.add({...e.ref,bottom:a}),e.columns.forEach((h,w)=>{const k=e.ref.left+w,y=this.columnLook(k,i,a),x=c[w];x?.node&&(y.formula=S(oe(ge(x.node,i-x.row,0),e.name)));const L=this.fileColumns.get(k);L!==void 0&&i<=a&&(y.files=L===P?!0:{height:L}),b(y)||(m[h.name]=y)});const g=new Map;for(const[h,w]of e.filter?.columns??[]){const k=e.columns[h]?.name;k!==void 0&&g.set(k,w)}return(e.filter?.unread??0)>0&&l(`has ${Q(e.filter?.unread??0,"filter")} by condition, its rows left as they were hidden`),this.tables.push({name:e.name,at:$({row:n,col:e.ref.left}),rows:p,...e.style!==void 0&&e.style!=="TableStyleMedium2"?{style:e.style}:{},...b(m)?{}:{columns:m},...e.filter===void 0?{filter:!1}:g.size>0?{filter:{columns:Object.fromEntries(g)}}:{}}),e.filter?.unread===0&&e.filter.columns.size>0&&this.filtered.push({...e.ref,bottom:a}),this.areas.push({...e.ref,bottom:a}),!0}columnLook(e,o,s){let l,r={};for(let t=o;t<=s;t++){const n=this.at(t,e),i=n?this.ownLook(n):{look:{},key:"{}"};if(l===void 0)l=i.key,r=i.look;else if(l!==i.key)return{}}return b(r)?{}:(this.lookDone.add({top:o,bottom:s,left:e,right:e}),{...r})}path(e){const o=G(e);let s=`${o}.csv`;for(let l=2;this.ctx.files.has(s)||this.ctx.taken(s);l++)s=`${o}-${String(l)}.csv`;return s}loose(){const e=[],o=[];for(const s of this.read.cells)this.inTables.has(s.row,s.col)||(s.node?e.push(s):s.value!==void 0&&s.value!==null&&o.push(s));return{formulas:e,typed:o}}blockAreas(e,o){const s=[],l=O(o.map(C)),r=n=>!s.some(i=>z(i,n))&&!this.areas.some(i=>z(i,n))&&!l.some(i=>z(i,n)),t=n=>(n.bottom-n.top+1)*(n.right-n.left+1);for(const n of Ae(e)){const{box:i}=n;if(!(t(i)<K)){if(n.count/t(i)>=ve&&r(i)){s.push(i);continue}for(const a of O(n.cells().map(C)))t(a)>=K&&r(a)&&s.push(a)}}return s.sort((n,i)=>n.top-i.top||n.left-i.left)}cells_(e){const{formulas:o,typed:s}=this.loose(),l=this.blockAreas(s,o),r=i=>l.some(a=>T(a,i.row,i.col));l.length>0&&(e.blocks=l.map(i=>{const a=this.path(this.read.name);return this.ctx.files.set(a,this.csv(i.bottom-i.top+1,c=>{const u=[];for(let d=i.left;d<=i.right;d++){const m=this.at(i.top+c,d);u.push(m?this.text(m):"")}return u})),{at:$({row:i.top,col:i.left}),rows:a}}));const t=[],n=new Map;for(const i of o){if(!i.node)continue;const a=this.keyOf(i,i.node),c=n.get(a);c?c.push(i):n.set(a,[i])}for(const i of n.values())for(const a of O(i.map(C))){const c=this.at(a.top,a.left);c?.node&&t.push([{row:a.top,col:a.left},v(a),S(c.node)])}for(const i of s)l.length>0&&r(i)||t.push([C(i),$(i),se(E(this.ctx,i),this.code(i))]);t.sort(([i],[a])=>i.row-a.row||i.col-a.col),t.length>0&&(e.cells=Object.fromEntries(t.map(([,i,a])=>[i,a])))}formats(e){const o=new Map,s=this.lookDone.list.length>0;for(const r of this.read.cells){if(s&&this.lookDone.has(r.row,r.col))continue;const t=this.ownLook(r);if(b(t.look))continue;const n=o.get(t.key);n?n.places.push(C(r)):o.set(t.key,{look:t.look,places:[C(r)]})}const l=[];for(const{look:r,places:t}of o.values())for(const n of O(t))l.push({range:v(n),...r});l.length>0&&(e.format=l)}columns(e){const{read:o}=this,s=new Map;let l=0;for(const t of o.cells)t.col>l&&(l=t.col);const r=[];for(const t of o.columns){if(t.width===void 0&&t.hidden!==!0&&t.level===void 0)continue;const n=t.max-Math.max(t.min,l+1)+1>Z?Math.max(l,t.min+Z-1):t.max;n<t.max&&r.push(`${M(n+1)}:${M(t.max)}`);const i=t.width!==void 0&&t.width<=0;for(let a=t.min;a<=n;a++)s.set(a,{...t.width===void 0||i?{}:{width:t.width},...t.hidden===!0||i?{hidden:!0}:{},...t.level===void 0?{}:{level:t.level}})}for(const[t,n]of this.columnLooks)s.set(t,{...s.get(t),...n});for(const[t,n]of this.fileColumns)this.tableColumn(t)||s.set(t,{...s.get(t),files:n===P?!0:{height:n}});s.size>0&&(e.columns=Object.fromEntries([...s.keys()].sort((t,n)=>t-n).map(t=>[M(t),s.get(t)??{}]))),r.length>0&&this.ctx.lost.push(`${o.name}: the size of columns ${F(r)}, past those that hold anything`)}tableColumn(e){return this.areas.some(o=>e>=o.left&&e<=o.right)}rows(e){const o={};for(const s of this.read.rows){const l=this.rowLooks.get(s.row),r=this.filtered.some(a=>s.row>a.top&&s.row<=a.bottom),t=s.height!==void 0&&this.pictured.get(s.row)!==s.height?s.height:void 0,n=t!==void 0&&t<=0,i={...t===void 0||n?{}:{height:t},...(s.hidden===!0||n)&&!r?{hidden:!0}:{},...s.level===void 0?{}:{level:s.level},...l};b(i)||(o[String(s.row+1)]=i)}b(o)||(e.rows=o)}assetPath(e,o){const s=t=>{const n=this.ctx.assets.get(t);return n?ze(n,o.bytes):!this.ctx.taken(t)};if(e!==void 0&&ee(e)&&s(e))return e;const l=G((o.name??"picture").replace(/\.[A-Za-z0-9]+$/u,""));let r=`${l}.${o.type}`;for(let t=2;!s(r);t++)r=`${l}-${String(t)}.${o.type}`;return r}pictures(){const e=this.over;for(const o of this.read.pictures){const s=this.at(o.row,o.col),l=typeof s?.value=="string"?s.value:"";if(o.y===void 0&&o.descr!==void 0&&ee(o.descr)&&l.split(fe).includes(o.descr)&&o.descr!==void 0){this.ctx.assets.set(o.descr,o.bytes),this.fileColumns.set(o.col,Math.max(this.fileColumns.get(o.col)??0,o.height)),this.pictured.set(o.row,Math.max(this.pictured.get(o.row)??0,o.height));continue}if(o.width<=0||o.height<=0){this.ctx.lost.push(`${this.read.name}: a picture of no size at ${$({row:o.row,col:o.col})}`);continue}const t=this.assetPath(o.descr,o);this.ctx.assets.set(t,o.bytes);const n=we(o.bytes),i=n?.width===o.width&&n.height===o.height;e.push({file:t,at:$({row:o.row,col:o.col}),...o.x===void 0?{}:{x:o.x},...o.y===void 0?{}:{y:o.y},...i?{}:{width:o.width,height:o.height}})}}build(){const{read:e}=this;this.baseLooks(),this.pictures();for(const s of e.tables)this.table(s);const o={name:e.name};return e.state!=="visible"&&(o.hidden=!0),e.gridlines===!1&&(o.gridlines=!1),e.tab!==void 0&&(o.tab=e.tab),e.state==="veryHidden"&&this.ctx.lost.push(`${e.name}: being very hidden; it is hidden`),e.freeze&&(e.freeze.row>0||e.freeze.col>0)&&(o.freeze=$(e.freeze)),this.tables.length>0&&(o.tables=this.tables),this.filter(o),this.columns(o),this.rows(o),this.cells_(o),e.merges.length>0&&(o.merges=e.merges.map(v)),this.formats(o),e.conditional.length>0&&(o.conditional=e.conditional),e.validations.length>0&&(o.validations=e.validations),e.charts.length>0&&(o.charts=e.charts.map(s=>this.chart(s))),this.over.length>0&&(o.pictures=this.over),b(e.links)||(o.links=e.links),e.notes.length>0&&(o.notes=Object.fromEntries(e.notes.map(s=>[s.ref,s.author===void 0||s.author===le?s.text:{text:s.text,author:s.author}]))),e.print&&(o.print=e.print),e.protect===!0&&(o.protect=!0),o}chart(e){return ce(e,o=>{const s=this.chartReference(o.replace(/^=/u,""));return o.startsWith("=")?`=${s}`:s})}chartReference(e){const o=e.lastIndexOf("!"),l=(o<0?this.read.name:e.slice(0,o)).replace(/^'|'$/gu,"").replaceAll("''","'"),r=W(e.slice(o+1).replaceAll("$",""));if(!r)return e;const t=this.ctx.book.sheets.find(n=>n.name.toLowerCase()===l.toLowerCase());for(const n of t?.tables??[]){const i=n.ref.top+1,c=r.left===r.right&&r.top===i&&r.bottom===n.ref.bottom&&r.left>=n.ref.left&&r.left<=n.ref.right?n.columns[r.left-n.ref.left]:void 0;if(c&&this.ctx.tables.has(n.name.toLowerCase()))return`${n.name}[${c.name}]`}return`${t===this.read||o<0?"":`${e.slice(0,o)}!`}${v(r)}`}filter(e){const{filter:o}=this.read;if(!o)return;const s={};for(const[l,r]of o.columns)s[M(o.ref.left+l)]=r;e.filter={range:v(o.ref),...b(s)?{}:{columns:s}},o.unread===0&&!b(s)&&this.filtered.push(o.ref)}}const ze=(f,e)=>f.length===e.length&&f.every((o,s)=>o===e[s]),Ne=new Set(["_xlnm._FilterDatabase","_xlnm.Print_Area","_xlnm.Print_Titles"]);function Re(f){const e={},o=[],s=new Map,{book:l,lost:r}=f,t=new Set(l.sheets.map(u=>u.name.toLowerCase())),n=new Set,i=[];let a;const c=u=>{a=void 0;const d=Fe(u.text);if(d!==void 0)return typeof d=="string"?H(d):d;const m=$e(u.text,!0),p=m.ok?j(m.node,t):"it could not be read";if(!m.ok||p!==void 0||He(m.node)){r.push(`the name ${u.name} (${u.text})${p===void 0?"":`: ${p}`}`);return}return a=m.node,S(m.node)};for(const u of l.names){if(u.name.startsWith("_xlnm.")){Ne.has(u.name)||r.push(`Excel's name ${u.name}`);continue}if(/^_xl(?:fn|pm|ws|udf)/iu.test(u.name))continue;const d=u.name.toLowerCase(),m=u.sheet===void 0?"":String(u.sheet);if(!q(u.name)||f.tables.has(d)){r.push(`the name ${u.name}, which cannot be held here`);continue}if(n.has(`${m}|${d}`)){r.push(`a second name ${u.name}${m===""?"":` of ${l.sheets[u.sheet??0]?.name??""}`}`);continue}const p=c(u);if(p===void 0)continue;n.add(`${m}|${d}`),f.names.add(d);const g=u.sheet===void 0?void 0:s.get(u.sheet)??{names:{},hidden:[]},h=g?.names??e;h[u.name]=p,u.hidden===!0&&(g?.hidden??o).push(u.name),g&&u.sheet!==void 0&&s.set(u.sheet,g),a&&i.push({held:h,n:u,node:a})}for(const{held:u,n:d,node:m}of i){const p=j(m,t,{names:f.names,tables:f.tables});p!==void 0&&(u[d.name]="=#NAME?",r.push(`the name ${d.name} (${d.text}): ${p}; it holds #NAME?, as in Excel`))}return{names:e,hidden:o,sheets:s}}function Ie(f,e){const o={},s=new Map;for(const[l,r]of Object.entries(e))typeof r=="string"&&r.startsWith("=")&&s.set(r.slice(1).replaceAll("$","").toLowerCase(),l);for(const l of f.book.sheets)for(const r of l.scenarios){const t={};let n=!0;for(const{at:i,value:a}of r.cells){const c=ae(i),u=c&&l.cells.find(p=>p.row===c.row&&p.col===c.col);String(u?.value??"")!==a&&(n=!1);const d=s.get(`${B(l.name)}${i}`.toLowerCase())??s.get(i.toLowerCase()),m=I(a);d===void 0?f.lost.push(`${l.name}: scenario ${r.name}'s cell ${i}, which has no name`):t[d]=typeof m.value=="number"?m.value:a}!n&&!b(t)&&(o[r.name]={...o[r.name],...t})}return o}function He(f){let e=!1;return R(f,o=>{e||=o.kind==="error"&&o.code==="#REF!"}),e}function Fe(f){const e=f.trim();return/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u.test(e)?Number(e):/^true$/iu.test(e)?!0:/^false$/iu.test(e)?!1:/^"((?:[^"]|"")*)"$/u.exec(e)?.[1]?.replaceAll('""','"')}const je=new RegExp(`^${Le.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}(?: \\(\\d+\\))?$`,"u");function De(f){const e=f.sheets.find(r=>r.state==="veryHidden"&&je.test(r.name));if(!e)return;const o=B(e.name).toLowerCase(),s=r=>{const t=r.replace(/^=/u,"");if(!t.toLowerCase().startsWith(o))return;const n=W(t.slice(o.length).replaceAll("$",""));if(!n||n.left!==n.right)return;const i=[];for(let a=n.top;a<=n.bottom;a++){const c=e.cells.find(u=>u.row===a&&u.col===n.left);i.push(typeof c?.value=="string"?c.value:"")}return i};for(const r of f.sheets)r.validations=r.validations.map(t=>{const[n]=t.formula??[],i=t.type==="list"&&typeof n=="string"?s(n):void 0;if(!i)return t;const a={...t,values:i};return delete a.formula,a});const l=f.sheets.indexOf(e);f.sheets=f.sheets.filter(r=>r!==e),f.names=f.names.flatMap(r=>r.sheet===void 0||r.sheet<l?[r]:r.sheet===l?[]:[{...r,sheet:r.sheet-1}])}const A=f=>f instanceof _?f.code:f??null,Pe=new Map([["#SPILL!","#VALUE!"],["#CALC!","#VALUE!"]]);export function sameValue(f,e,o){if(typeof f=="number"&&typeof e=="number")return f===e?!0:Math.abs(f-e)<=Math.max(Math.abs(f),Math.abs(e))*o;if(f instanceof _||e instanceof _){const s=l=>l instanceof _?Pe.get(l.code)??l.code:void 0;return s(f)===s(e)}if(f===null||e===null){const s=f??e;return s===null||s===""||s===0||s===!1}return f===e}function We(f,e){const o=[];for(const r of e.sheets)for(const t of r.formulas)t.shared.node&&ue(e,t.shared,r).volatile&&o.push(t);const s=new Set(o),l=[...o];for(;;){const r=l.pop();if(!r)return s;for(const t of f.readers(r.sheet,r.row,r.col))s.has(t)||(s.add(t),l.push(t))}}function Be(f){const e=f.file.iteration;return(e===void 0||e===!0?void 0:e.max_change)??de.max_change}function Ue(f,e,o,s){const l={formulas:0,same:0,uncached:0,moving:0,differences:[]},r=We(o,e);for(const[t,n]of f.carried){if(!t.node)continue;const i=e.sheet(n.name);if(!i)continue;l.formulas+=1;const a=i.at(t.row,t.col);if(a instanceof V&&r.has(a)){l.moving+=1;continue}const c=E(f,t);if(c===void 0){l.uncached+=1;continue}const u=o.value(i,t.row,t.col);a instanceof V&&o.iterates(a)&&typeof c=="number"&&typeof u=="number"&&Math.abs(c-u)<=Be(e)||sameValue(c,u,s)?l.same+=1:l.differences.push({sheet:n.name,cell:$(t),formula:S(t.node),file:A(c),engine:A(u)})}for(const[t,n]of f.spilled){const i=e.sheet(n.name);if(!i)continue;l.formulas+=1;const a=i.spillAt(t.row,t.col);if(a&&r.has(a)){l.moving+=1;continue}const c=E(f,t),u=o.value(i,t.row,t.col);c===void 0?l.uncached+=1:sameValue(c,u,s)?l.same+=1:l.differences.push({sheet:n.name,cell:$(t),formula:a?`${$(a)}#`:"",file:A(c),engine:A(u)})}return l}function Ve(f,e){const o=new Map,s=[];for(const l of f){const r=e.find(i=>l.startsWith(`${i}: `));if(r===void 0){s.push(l);continue}const t=l.slice(r.length+2),n=o.get(t);n?n.push(r):o.set(t,[r])}for(const[l,r]of o)s.push(r.length===1?`${r[0]??""}: ${l}`:`${l}, on ${String(r.length)} sheets (${F(r)})`);return s}function qe(f,e,o){const s=o.circularCells();if(s.length===0)return!1;const l=new Map;for(const[n,i]of f.carried)l.set(`${i.name}|${String(n.row)}|${String(n.col)}`,n);let r=0,t=0;for(const n of s){const i=l.get(`${n.sheet.name}|${String(n.row)}|${String(n.col)}`),a=i===void 0?void 0:E(f,i),c=e[n.sheet.index],u=n.shared.source.path??[];if(a===void 0||!c||u[2]!=="cells"){a!==void 0&&(t+=1);continue}const d=se(a,void 0),m=c.cells??={},p=$(n),g=m[p],h=m[String(u[3])],w=h!==null&&typeof h=="object"?h:{};m[p]=g!==null&&typeof g=="object"?{...g,start:d}:{...w,formula:n.text,start:d},r+=1}return t>0&&f.lost.push(`where ${String(t)} cells of a table or a block start iterative calculation: they start from 0`),r>0}export function importXlsx(f,e){const o=xe(f,e.zip);if(De(o),Ce(o),o.sheets.length===0)throw new Error("It holds no sheets.");const s={book:o,taken:e.taken??(()=>!1),files:new Map,assets:new Map,lost:[...o.lost],tables:new Set(o.sheets.flatMap(p=>p.tables.filter(g=>ne(g)===void 0).map(g=>g.name.toLowerCase()))),names:new Set,carried:new Map,spilled:new Map};o.date1904&&s.lost.push(`the 1904 date system: dates are moved to the 1900 one, ${String(Y)} days on`),(o.font.name!==void 0&&o.font.name!=="Calibri"||o.font.size!==void 0&&o.font.size!==11)&&s.lost.push(`its default font, ${o.font.name??""} ${String(o.font.size??"")}`);const l=Re(s);Me(s);const r=o.sheets.map((p,g)=>{const h=new Te(s,p).build(),w=l.sheets.get(g);return w&&!b(w.names)&&(h.names=w.names),w&&w.hidden.length>0&&(h.hidden_names=w.hidden),h}),t=Ie(s,l.names),n={title:o.title??e.name,...b(l.names)?{}:{names:l.names},...l.hidden.length>0?{hidden_names:l.hidden}:{},sheets:r,...b(t)?{}:{scenarios:t},...o.iteration===void 0?{}:{iteration:o.iteration}},i=()=>{const p=ye(n),g=new Map([[ie,p],...s.files]);return{files:g,...me({text:p,read:h=>g.get(h),exists:h=>g.has(h)||s.assets.has(h)})}};let a=i();a.calc&&qe(s,r,a.calc)&&(a=i());const{files:c,workbook:u,calc:d,problems:m}=a;return{files:c,assets:s.assets,lost:Ve(s.lost,o.sheets.map(p=>p.name)),problems:m,compared:u&&d?Ue(s,u,d,e.tolerance??COMPARE_TOLERANCE):{formulas:0,same:0,uncached:0,moving:0,differences:[]},sheets:o.sheets.length,tables:s.tables.size}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZipLimits } from "@allyhub/formats";
|
|
2
|
-
import type { SheetConditional, SheetFilterColumn, SheetHeaderFooter, SheetPrint, SheetValidation } from "@allyhub/formats";
|
|
2
|
+
import type { SheetConditional, SheetFilterColumn, SheetHeaderFooter, SheetIteration, SheetPrint, SheetValidation } from "@allyhub/formats";
|
|
3
3
|
import { type Area, type Place } from "../address.js";
|
|
4
4
|
import type { Node } from "../formula/ast.js";
|
|
5
5
|
import { type Scalar } from "../values.js";
|
|
@@ -145,6 +145,8 @@ export interface ReadBook {
|
|
|
145
145
|
};
|
|
146
146
|
/** Its title, from its document properties. */
|
|
147
147
|
title?: string;
|
|
148
|
+
/** Its iterative calculation, when it is on. */
|
|
149
|
+
iteration?: SheetIteration;
|
|
148
150
|
/** What this model holds nothing of, a line each. */
|
|
149
151
|
lost: string[];
|
|
150
152
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{ZipLimitError as ve}from"@allyhub/formats";import{SHEET_ICONS as Se,SHEET_MARGINS as de,SHEET_OPERATORS as Ce,SHEET_PAPERS as Ee,SHEET_VALIDATIONS as Ne}from"@allyhub/formats";import{MAX_COLUMNS as q,MAX_ROWS as K,cellName as Y,columnLetter as Ae,readAddress as Oe,readArea as G,readAreas as ee}from"../address.js";import{SHEET_CHART_DEFAULTS as ce}from"../chart.js";import{moveFormula as Te,relativeKey as Ie}from"../formula/move.js";import{printFormula as fe}from"../formula/print.js";import{ERR as Le,errorOf as Re,serialOfDate as Me}from"../values.js";import{OFFICE_THEME as Fe,colorOf as F,paletteOf as le,themeColors as De}from"./colors.js";import{chartAnchors as je,readChart as Pe}from"./charts.js";import{isRangeText as ze,readFileFormula as te}from"./formula.js";import{BUILTIN_FORMATS as _e}from"./numfmt.js";import{XmlStream as ue}from"./sax.js";import{attr as u,flag as v,numberAttr as k,readXml as he,readXstring as A,tag as d,tags as x,textOf as E}from"./xml.js";import{ZipIn as He}from"./zip.js";const pe=7,Ve=r=>Math.floor((256*r+Math.floor(128/pe))/256*pe),Ue=r=>Math.round(r*4/3),ne=5;export function placesLine(r){const e=r.slice(0,ne).join(", ");return r.length>ne?`${e} and ${String(r.length-ne)} more`:e}const H=(r,e,t=`${e}s`)=>`${String(r)} ${r===1?e:t}`;export const GRID_END=`Excel's grid ends at ${Ae(q-1)}${String(K)} (${K.toLocaleString("en-US")} rows, ${q.toLocaleString("en-US")} columns)`;function We(r,e){let t=0,n=0;const o=r.length;for(;t<o;t++){const i=r.charCodeAt(t),c=i>=65&&i<=90,a=i>=97&&i<=122;if(!c&&!a)break;n=n*26+(c?i-64:i-96)}if(t===0||t===o)return;let s=0;for(let i=t;i<o;i++){const c=r.charCodeAt(i);if(c<48||c>57)return;s=s*10+c-48}if(s!==0){if(t>3||n>q||s>K)throw new Error(`${e} has a cell at ${r}, and ${GRID_END}.`);return{row:s-1,col:n-1}}}class Be{zip;constructor(e,t){this.zip=new He(e,t)}get names(){return this.zip.names}has(e){return this.zip.has(e)}text(e){return this.zip.text(e)}bytes(e){return this.zip.bytesOf(e)}xml(e){const t=this.text(e);return t===void 0?void 0:he(t)}stream(e,t){const n=this.zip.streamText(e,o=>{t.push(o)});return n&&t.end(),n}rels(e){const t=e.lastIndexOf("/"),n=`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`,o=this.xml(n);return x(d(o?.Relationships)?.Relationship).map(s=>{const i=u(s,"Type")??"",c=u(s,"Target")??"",a=u(s,"TargetMode")==="External";return{id:u(s,"Id")??"",type:i.slice(i.lastIndexOf("/")+1),target:a?c:Xe(e,c),external:a}})}count(e){return this.names.filter(t=>e.test(t)).length}}function Xe(r,e){if(e.startsWith("/"))return e.slice(1);const t=r.split("/").slice(0,-1);for(const n of e.split("/"))n===".."?t.pop():n!=="."&&t.push(n);return t.join("/")}function qe(r,e){const t=[];if(e===void 0)return t;let n,o=0,s=!1;const i={open(c){if(c==="si"){n={text:"",rich:!1};return}if(n){if(o>0||c==="rPh"||c==="phoneticPr"||c==="extLst"){o+=1;return}c==="r"&&(n.rich=!0),c==="t"&&(s=!0)}},close(c){if(o>0){o-=1;return}if(c==="si"){n&&t.push({...n,text:A(n.text)}),n=void 0;return}c==="t"&&(s=!1)},text(c){n&&s&&o===0&&(n.text+=c)}};return r.stream(e,new ue(i)),t}function W(r,e){const t=r[e];if(t===void 0)return!1;const n=u(d(t),"val");return n===void 0||n!=="0"&&n!=="false"}const Ge=new Set(["double","singleAccounting","doubleAccounting"]);function Ze(r,e,t){const n={},o=(a,l)=>u(d(a?.[l]),"val");if(W(r,"b")&&(n.bold=!0),W(r,"i")&&(n.italic=!0),W(r,"strike")&&(n.strike=!0),W(r,"u")){const a=o(r,"u");n.underline=a!==void 0&&Ge.has(a)?a:!0}const s=o(r,"name");s!==void 0&&s!==o(e,"name")&&(n.font=s);const i=o(r,"sz");i!==void 0&&i!==o(e,"sz")&&(n.size=Number(i));const c=F(d(r.color),t);return c!==void 0&&c!==F(d(e?.color),t)&&(n.color=c),n}function Je(r,e){const t=d(r.patternFill),n=u(t,"patternType");if(n===void 0||n==="none")return;const o=F(d(t?.fgColor),e),s=F(d(t?.bgColor),e);return n==="solid"&&o!==void 0?o:{pattern:n,...o===void 0?{}:{color:o},...s===void 0?{}:{background:s}}}function me(r,e){const t={};for(const n of["left","right","top","bottom"]){const o=d(r[n]),s=u(o,"style");if(s===void 0||s==="none")continue;const i=F(d(o?.color),e);t[n]={style:s,...i===void 0?{}:{color:i}}}return Object.keys(t).length===0?void 0:t}function Ke(r){const e={},t=u(r,"horizontal");t!==void 0&&t!=="general"&&(e.align=t);const n=u(r,"vertical");n!==void 0&&n!=="bottom"&&(e.valign=n),v(r,"wrapText")===!0&&(e.wrap=!0),v(r,"shrinkToFit")===!0&&(e.shrink=!0);const o=k(r,"indent");o!==void 0&&o>0&&(e.indent=o);const s=k(r,"textRotation");return s!==void 0&&s>0&&s<=180&&(e.rotation=s),e}function ge(r,e){const t={},n=d(r.font);if(n){const a=(f,p)=>{n[f]!==void 0&&(t[p]=W(n,f))};a("b","bold"),a("i","italic"),a("strike","strike"),n.u!==void 0&&(t.underline=W(n,"u"));const l=F(d(n.color),e);l!==void 0&&(t.color=l)}const o=d(d(r.fill)?.patternFill),s=F(d(o?.bgColor),e)??F(d(o?.fgColor),e);s!==void 0&&(t.fill=s);const i=d(r.border),c=i&&me(i,e);return c!==void 0&&(t.border=c),t}function Qe(r,e){const t=d(r?.styleSheet),n=le(e,t),o=new Map(x(d(t?.numFmts)?.numFmt).map(w=>[k(w,"numFmtId")??-1,u(w,"formatCode")??"General"])),s=x(d(t?.fonts)?.font),i=x(d(t?.fills)?.fill),c=x(d(t?.borders)?.border),a=x(d(t?.cellXfs)?.xf),l=s[k(a[0],"fontId")??0],f=new Set;i.some(w=>w.gradientFill!==void 0)&&f.add("gradient fills");const p=a.map(w=>{const m={},$=s[k(w,"fontId")??0];$&&(Object.assign(m,Ze($,l,n)),$.vertAlign!==void 0&&f.add("superscript and subscript"));const S=i[k(w,"fillId")??0],O=S&&Je(S,n);O!==void 0&&(m.fill=O);const T=c[k(w,"borderId")??0],z=T&&me(T,n);z!==void 0&&(m.border=z),T&&u(d(T.diagonal),"style")!==void 0&&f.add("diagonal borders");const D=d(w.alignment);D&&(Object.assign(m,Ke(D)),k(D,"textRotation")===255&&f.add("vertical text"));const I=k(w,"numFmtId")??0,M=o.get(I)??_e[I];return M!==void 0&&M!=="General"&&(m.format=M),m}),h=u(d(l?.name),"val"),b=u(d(l?.sz),"val");return{looks:p,dxfs:x(d(t?.dxfs)?.dxf).map(w=>ge(w,n)),font:{...h===void 0?{}:{name:h},...b===void 0?{}:{size:Number(b)}},lost:[...f]}}function be(r){const e=new Map;let t=0;for(const n of x(r.filterColumn)){const o=k(n,"colId")??0,s=d(n.filters);if(!s){Object.keys(n).some(c=>c!=="colId"&&c!=="hiddenButton")&&(t+=1);continue}if(s.dateGroupItem!==void 0){t+=1;continue}const i=x(s.filter).map(c=>A(u(c,"val")??""));e.set(o,{...i.length===0?{}:{values:i},...v(s,"blank")===!0?{blanks:!0}:{}})}return{columns:e,unread:t}}function Ye(r){const e=d(r?.table),t=G(u(e,"ref")??""),n=u(e,"displayName")??u(e,"name");if(!t||n===void 0)return;const o=d(e?.tableStyleInfo),s=d(e?.autoFilter);return{name:n,ref:t,headers:k(e,"headerRowCount")??1,totals:k(e,"totalsRowCount")??0,columns:x(d(e?.tableColumns)?.tableColumn).map(i=>({name:A(u(i,"name")??"").trim(),calculated:i.calculatedColumnFormula!==void 0})),style:u(o,"name")??"none",...s?{filter:be(s)}:{}}}function oe(r){const e=r.trim();if(e==="")return;const t=/^"((?:[^"]|"")*)"$/u.exec(e);if(t)return(t[1]??"").replaceAll('""','"');const n=Number(e);if(!Number.isNaN(n))return n;const o=te(e,!0);return o.ok?fe(o.node):void 0}const xe=r=>r!==void 0&&Ce.includes(r);function re(r){const e=u(r,"type")??"num",t=u(r,"val")??(r.f===void 0?void 0:E(r.f)),n=t===void 0?void 0:oe(t);return{at:e,...n===void 0?{}:{value:n}}}const et=Se,tt=r=>{const e=r.formula??r.f;return(Array.isArray(e)?e:e===void 0?[]:[e]).map(E)};function nt(r,e,t,n){const o=u(r,"type")??"",s={range:e,...v(r,"stopIfTrue")===!0?{stop:!0}:{}},i={...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline!==!1},...t.strike===void 0?{}:{strike:t.strike},...t.color===void 0?{}:{color:t.color},...typeof t.fill=="string"?{fill:t.fill}:{},...t.border===void 0?{}:{border:t.border}},c=tt(r);switch(o){case"cellIs":{const a=u(r,"operator"),l=c.flatMap(f=>{const p=oe(f);return p===void 0?[]:[p]});return!xe(a)||l.length===0?`a cellIs rule of ${a??"no operator"}`:{...s,...i,type:"cellIs",operator:a,formula:l}}case"containsText":case"notContainsText":case"beginsWith":case"endsWith":{const a=u(r,"text");return a===void 0?`a ${o} rule with no text`:{...s,...i,type:"containsText",...o==="containsText"?{}:{operator:o==="notContainsText"?"notContains":o},text:A(a)}}case"duplicateValues":case"uniqueValues":return{...s,...i,type:o};case"top10":return{...s,...i,type:"top10",rank:k(r,"rank")??10,...v(r,"percent")===!0?{percent:!0}:{},...v(r,"bottom")===!0?{bottom:!0}:{}};case"aboveAverage":return{...s,...i,type:"aboveAverage",...v(r,"aboveAverage")===!1?{below:!0}:{},...v(r,"equalAverage")===!0?{equal:!0}:{}};case"expression":{const a=c[0]===void 0?void 0:te(c[0],!0);return a?.ok?{...s,...i,type:"expression",formula:fe(a.node)}:"an expression rule that cannot be read"}case"dataBar":{const a=d(r.dataBar),l=F(d(a?.color??a?.fillColor),n),[f,p]=x(a?.cfvo).map(re);return l===void 0?"a data bar with no colour":{...s,type:"dataBar",color:l,...f&&f.at!=="min"?{min:f}:{},...p&&p.at!=="max"?{max:p}:{},...v(a,"showValue")===!1?{show:!1}:{}}}case"colorScale":{const a=d(r.colorScale),l=x(a?.cfvo).map(re),f=x(a?.color).map(h=>F(h,n)),p=l.flatMap((h,b)=>{const w=f[b];return w===void 0?[]:[{...h,color:w}]});return p.length<2?"a colour scale with too few stops":{...s,type:"colorScale",stops:p.slice(0,3)}}case"iconSet":{const a=d(r.iconSet),l=u(a,"iconSet")??"3TrafficLights1";if(!et.includes(l))return`the icon set ${l}`;if(a?.cfIcon!==void 0)return"an icon set of icons chosen one by one";const f=x(a?.cfvo).map(re);return{...s,type:"iconSet",icons:l,...f.length>=3?{stops:f.slice(0,5)}:{},...v(a,"reverse")===!0?{reverse:!0}:{},...v(a,"showValue")===!1?{show:!1}:{}}}default:return`a ${o} rule`}}const we={conditional:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}",validations:"{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}"},ye=(r,e)=>x(d(r.extLst)?.ext).find(t=>u(t,"uri")?.toUpperCase()===e.toUpperCase());function ot(r,e,t){const n=[],o=[],s=new Set,i=(a,l,f)=>{const p=nt(a,l,f,t);typeof p=="string"?o.push(`${p} on ${l}`):n.push({priority:k(a,"priority")??0,rule:p})};for(const a of x(r.conditionalFormatting)){const l=u(a,"sqref")??"";if(!ee(l)){o.push(`a rule on ${l}`);continue}for(const f of x(a.cfRule)){const p=E(d(d(f.extLst)?.ext)?.id);p!==""&&s.add(p.toUpperCase());const h=k(f,"dxfId");i(f,l,h===void 0?{}:e[h]??{})}}const c=d(ye(r,we.conditional)?.conditionalFormattings);for(const a of x(c?.conditionalFormatting)){const l=E(a.sqref).trim();for(const f of x(a.cfRule)){if(s.has((u(f,"id")??"").toUpperCase()))continue;if(!ee(l)){o.push(`a rule on ${l}`);continue}const p=d(f.dxf);i(f,l,p?ge(p,t):{})}}return{rules:n.sort((a,l)=>a.priority-l.priority).map(a=>a.rule),unread:o}}const rt=Ne;function $e(r,e,t,n){const o=u(r,"type")??"none";if(o==="none"&&u(r,"prompt")===void 0)return;if(!rt.includes(o)||!ee(e))return`a ${o} rule on ${e}`;const s=/^"((?:[^"]|"")*)"$/u.exec(t.trim()),i=o==="list"&&s?(s[1]??"").replaceAll('""','"').split(","):void 0,c=[t,n].flatMap(w=>{const m=oe(w);return m===void 0?[]:[m]}),a=u(r,"operator"),l=w=>Object.fromEntries(Object.entries(w).filter(([,m])=>m!==void 0)),f=l({title:u(r,"promptTitle"),message:u(r,"prompt")}),p=l({style:u(r,"errorStyle"),title:u(r,"errorTitle"),message:u(r,"error")}),h=v(r,"showInputMessage")!==!0,b=v(r,"showErrorMessage")!==!0;return{range:e,type:o,...xe(a)&&a!=="between"?{operator:a}:{},...i?{values:i}:{formula:c},...v(r,"allowBlank")===!0?{}:{blank:!1},...v(r,"showDropDown")===!0?{dropdown:!1}:{},...h||Object.keys(f).length>0?{prompt:{...f,...h?{show:!1}:{}}}:{},...b||Object.keys(p).length>0?{error:{...p,...b?{show:!1}:{}}}:{}}}function st(r){const e=[],t=[],n=s=>{typeof s=="string"?t.push(s):s&&e.push(s)};for(const s of x(d(r.dataValidations)?.dataValidation))n($e(s,u(s,"sqref")??"",E(s.formula1),E(s.formula2)));const o=d(ye(r,we.validations)?.dataValidations);for(const s of x(o?.dataValidation))n($e(s,E(s.sqref).trim(),E(d(s.formula1)?.f),E(d(s.formula2)?.f)));return{rules:e,unread:t}}function it(r){const e=/^(-?\d{4,})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?)?(?:Z|[+-]\d{2}:?\d{2})?$/u.exec(r)??/^()()()(\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/u.exec(r);if(!e)return;const t=e[1]==="",n=t?1899:Number(e[1]),o=t?12:Number(e[2]),s=t?30:Number(e[3]),i=Number(e[4]??0)*3600+Number(e[5]??0)*60+Number(e[6]??0)+Number(e[7]??0),c=new Date(Date.UTC(n,o-1,s)+i*1e3);if(Number.isNaN(c.getTime()))return;const a=Me(c);return t?a-Math.floor(a):a}function se(r,e,t){const n=te(r,e,t);return n.ok?{node:n.node}:{unread:r}}class at{cells=[];rows=[];rich=[];outlined=!1;rest=[];xml;masters=new Map;strings;name;isRangeName;inData=!1;row=-1;nextRow=0;nextCol=0;cell;target;buffer="";skip=0;constructor(e,t,n){this.strings=e,this.name=t,this.isRangeName=n,this.xml=new ue(this),this.xml.capture=this.rest}open(e,t){if(!this.inData){e==="sheetData"&&(this.inData=!0,this.xml.capture=void 0);return}const n=this.cell;if(n){if(this.skip>0){this.skip+=1;return}switch(e){case"v":this.target="v",this.buffer="";return;case"f":n.f={...t,text:""},this.target="f",this.buffer="";return;case"is":n.inline={text:"",rich:!1};return;case"r":n.inline&&(n.inline.rich=!0);return;case"t":n.inline&&(this.target="t",this.buffer="");return;case"rPh":case"phoneticPr":case"extLst":this.skip=1;return;default:return}}e==="row"?this.openRow(t):e==="c"&&(this.cell={r:t.r,s:t.s,t:t.t,cm:t.cm,v:void 0,f:void 0,inline:void 0})}close(e){if(!this.inData)return;const t=this.cell;if(!t){e==="sheetData"&&(this.inData=!1,this.xml.capture=this.rest);return}if(this.skip>0){this.skip-=1;return}if(e===this.target){e==="v"?t.v=this.buffer:e==="f"&&t.f?t.f.text=this.buffer:t.inline&&(t.inline.text+=this.buffer),this.target=void 0;return}e==="c"&&(this.cell=void 0,this.readCell(t))}text(e){this.target!==void 0&&this.skip===0&&(this.buffer+=e)}openRow(e){const t=e.r,n=t===void 0?void 0:Number(t);if(n!==void 0&&Number.isInteger(n)&&n>K)throw new Error(`${this.name} has a row ${t??""}, and ${GRID_END}.`);const o=n!==void 0&&Number.isInteger(n)&&n>0?n-1:this.nextRow;this.row=o,this.nextRow=o+1,this.nextCol=0;const s={row:o},i=e.ht===void 0?void 0:Number(e.ht),c=f=>f==="1"||f==="true";i!==void 0&&Number.isFinite(i)&&c(e.customHeight)&&(s.height=Ue(i)),c(e.hidden)&&(s.hidden=!0);const a=e.s===void 0?void 0:Number(e.s);a!==void 0&&a!==0&&c(e.customFormat)&&(s.style=a);const l=Number(e.outlineLevel??0);l>0&&(s.level=Math.min(7,l),this.outlined=!0),Object.keys(s).length>1&&this.rows.push(s)}value(e,t){const n=e.t??"n";if(n==="inlineStr"){const s=e.inline;return s?{value:A(s.text),...s.rich?{rich:!0}:{}}:{value:e.v===void 0?"":A(e.v)}}const o=e.v;if(o===void 0)return{value:void 0};switch(n){case"s":{const s=this.strings[Number(o)];return s?{value:s.text,...s.rich?{rich:!0}:{}}:{value:""}}case"str":return{value:A(o)};case"b":return{value:o.trim()==="1"||o.trim()==="true"};case"e":return{value:Re(o.trim())??Le.VALUE};case"d":return{value:it(o.trim())??o};default:{if(o.trim()==="")return{value:void 0};const s=Number(o);if(Number.isNaN(s))throw new Error(`${t} says it holds a number and holds ${o}.`);return{value:s}}}}formula(e,t,n,o){const s=e.f;if(s===void 0)return;const i=s.t??"normal",c=s.text;if(i==="dataTable"){o.unread=`a data table's {=TABLE(${s.r1??""})}`;return}if(i==="array"){Object.assign(o,se(c,!0,this.isRangeName));const a=G(s.ref??"");a&&(o.array=a),e.cm!==void 0&&(o.dynamic=!0);return}if(i==="shared"){const a=s.si??"";if(c!==""){const f=se(c,!1,this.isRangeName),p=f.node?Ie(f.node,t,n):"";this.masters.set(a,{node:f.node,unread:f.unread,row:t,col:n,key:p}),Object.assign(o,f),f.node&&(o.key=p);return}const l=this.masters.get(a);if(!l){o.unread=`a shared formula of a group that has no first cell (${a})`;return}l.node?(o.node=Te(l.node,t-l.row,n-l.col),o.key=l.key):l.unread!==void 0&&(o.unread=l.unread);return}c!==""&&Object.assign(o,se(c,!1,this.isRangeName))}readCell(e){const t=e.r===void 0?void 0:We(e.r,this.name),n=t?.row??this.row,o=t?.col??this.nextCol;if(o>=q)throw new Error(`${this.name} has a cell past its last column, and ${GRID_END}.`);this.nextCol=o+1;const s=e.r??Y({row:n,col:o}),{value:i,rich:c}=this.value(e,s),a={row:n,col:o,value:i,style:e.s===void 0?0:Number(e.s)||0};c===!0&&(a.rich=!0,this.rich.push(s)),this.formula(e,n,o,a),this.cells.push(a)}}function dt(r,e,t){const n=[],o=p=>n.push(`${r}: ${p}`);t.length>0&&o(`${H(t.length,"cell")} of rich text, kept as plain text (${placesLine(t)})`);const s=x(d(e.hyperlinks)?.hyperlink).filter(p=>u(p,"tooltip")!==void 0);s.length>0&&o(`the tooltips of ${H(s.length,"link")} (${placesLine(s.map(p=>u(p,"ref")??""))})`),e.sortState!==void 0&&o("a sort");const i=d(e.sheetProtection);v(i,"sheet")===!0&&(u(i,"password")!==void 0||u(i,"hashValue")!==void 0)&&o("its protection's password: it is protected with none"),e.protectedRanges!==void 0&&o("protected ranges");const c=d(e.headerFooter);(c?.evenHeader!==void 0||c?.evenFooter!==void 0||c?.firstHeader!==void 0||c?.firstFooter!==void 0)&&o("its print header and footer of the first or even pages");const a=d(e.printOptions);a&&["gridLines","headings","horizontalCentered","verticalCentered"].some(p=>v(a,p)===!0)&&o("its print options (gridlines, headings, centring)"),(e.rowBreaks!==void 0||e.colBreaks!==void 0)&&o("its page breaks"),e.oleObjects!==void 0&&o("embedded objects"),e.controls!==void 0&&o("form controls"),e.dataConsolidate!==void 0&&o("a consolidation"),e.customSheetViews!==void 0&&o("custom views"),x(d(e.sheetViews)?.sheetView).some(p=>u(d(p.pane),"state")==="split")&&o("a split, not frozen, window");const f=JSON.stringify(e.extLst??"");return f.includes("sparklineGroups")&&o("sparklines"),f.includes("slicerList")&&o("slicers"),n}function ct(r,e){const t=[],n=(s,i,c)=>{const a=r.count(s);a>0&&t.push(H(a,i,c))};r.has("xl/vbaProject.bin")&&t.push("VBA macros"),n(/^xl\/pivotTables\/pivotTable\d*\.xml$/u,"pivot table"),n(/^xl\/chartsheets\/[^/]+\.xml$/u,"chart sheet"),n(/^xl\/dialogsheets\/[^/]+\.xml$/u,"dialog sheet"),n(/^xl\/macrosheets\/[^/]+\.xml$/u,"macro sheet");const o=r.names.filter(s=>s.startsWith("xl/media/")&&!e.has(s)).length;return o>0&&t.push(H(o,"image")),n(/^xl\/embeddings\//u,"embedded object"),n(/^xl\/slicers\/[^/]+\.xml$/u,"slicer part"),n(/^xl\/timelines\/[^/]+\.xml$/u,"timeline part"),n(/^xl\/ctrlProps\/[^/]+\.xml$/u,"form control"),n(/^xl\/activeX\/[^/]+\.xml$/u,"ActiveX control"),n(/^xl\/queryTables\/[^/]+\.xml$/u,"query table"),r.has("xl/connections.xml")&&t.push("data connections"),r.names.some(s=>s.startsWith("xl/richData/"))&&t.push("rich values (data types, pictures in cells)"),r.names.some(s=>/^customXml\/item\d+\.xml$/u.test(s)&&(r.text(s)??"").includes("DataMashup"))&&t.push("Power Query queries"),t}export function readHeaderFooter(r){const e={left:"",center:"",right:""};let t="center",n=new Set;for(let o=0;o<r.length;o++){const s=r[o],i=r[o+1];if(s==="&"&&(i==="L"||i==="C"||i==="R")){t=i==="L"?"left":i==="C"?"center":"right",n=new Set([...n,t]),o+=1;continue}if(s==="&"&&i==="&"){e[t]+="&&",o+=1;continue}e[t]+=s??""}return Object.fromEntries(Object.entries(e).filter(([o,s])=>s!==""||n.has(o)))}const ft=new Map(Object.entries(Ee).map(([r,e])=>[e,r]));function lt(r,e,t){const n={},o=d(r.pageSetup),s=u(o,"orientation");(s==="portrait"||s==="landscape")&&(n.orientation=s);const i=k(o,"paperSize");if(i!==void 0){const h=ft.get(i);h?n.paper=h:t.push(`${e}: its paper size, Excel's number ${String(i)}`)}v(d(d(r.sheetPr)?.pageSetUpPr),"fitToPage")===!0&&(n.fit={width:k(o,"fitToWidth")??1,height:k(o,"fitToHeight")??1});const c=d(r.pageMargins),a={};for(const h of Object.keys(de)){const b=k(c,h);b!==void 0&&b!==de[h]&&(a[h]=b)}Object.keys(a).length>0&&(n.margins=a);const l=d(r.headerFooter),f=E(l?.oddHeader),p=E(l?.oddFooter);return f!==""&&(n.header=readHeaderFooter(A(f))),p!==""&&(n.footer=readHeaderFooter(A(p))),n}function ut(r,e,t,n,o){const s=r.rels(e),i=new Map;for(const a of s.filter(l=>l.type==="comments")){const l=d(r.xml(a.target)?.comments),f=d(l?.authors)?.author,p=(Array.isArray(f)?f:f===void 0?[]:[f]).map(h=>A(E(h)));for(const h of x(d(l?.commentList)?.comment)){const b=u(h,"ref")??"",w=d(h.text),m=x(w?.r),$=A(m.length>0?m.map(O=>E(O.t)).join(""):E(w?.t)),S=p[k(h,"authorId")??-1];b!==""&&$!==""&&i.set(b,{ref:b,text:$,...S===void 0||S===""?{}:{author:S}})}}let c=0;for(const a of s.filter(l=>l.type==="threadedComment")){const l=d(r.xml(a.target)?.ThreadedComments),f=new Map;for(const p of x(l?.threadedComment)){const h=u(p,"ref")??"",b=A(E(p.text)),w=f.get(h)??{texts:[]};if(w.texts.length===0){const m=n.get(u(p,"personId")??"");m!==void 0&&(w.author=m)}w.texts.push(b),f.set(h,w)}for(const[p,h]of f)c+=1,i.set(p,{ref:p,text:h.texts.join(`
|
|
3
|
-
`),...
|
|
2
|
+
import{ZipLimitError as Ne}from"@allyhub/formats";import{SHEET_ICONS as Ie,SHEET_MARGINS as fe,SHEET_OPERATORS as Le,SHEET_PAPERS as Me,SHEET_VALIDATIONS as Re}from"@allyhub/formats";import{MAX_COLUMNS as Z,MAX_ROWS as Q,cellName as ee,columnLetter as le,readAddress as ue,readArea as B,readAreas as te}from"../address.js";import{ITERATION_DEFAULTS as he}from"../calc/engine.js";import{SHEET_CHART_DEFAULTS as pe}from"../chart.js";import{moveFormula as Fe,relativeKey as me}from"../formula/move.js";import{parseFormula as De}from"../formula/parse.js";import{printFormula as ge}from"../formula/print.js";import{ERR as je,errorOf as Pe,serialOfDate as _e}from"../values.js";import{OFFICE_THEME as ze,colorOf as D,paletteOf as be,themeColors as He}from"./colors.js";import{chartAnchors as Ve,readChart as Ue}from"./charts.js";import{isRangeText as Be,readFileFormula as ne}from"./formula.js";import{BUILTIN_FORMATS as We}from"./numfmt.js";import{XmlStream as we}from"./sax.js";import{attr as l,flag as v,numberAttr as k,readXml as xe,readXstring as N,tag as d,tags as x,textOf as E}from"./xml.js";import{ZipIn as Xe}from"./zip.js";function qe(r){if(v(r,"iterate")!==!0)return;const e=k(r,"iterateCount"),t=k(r,"iterateDelta"),o=e===void 0?void 0:Math.min(32767,Math.max(1,Math.round(e))),n=t===void 0?void 0:Math.max(0,t),s={...o===void 0||o===he.max_iterations?{}:{max_iterations:o},...n===void 0||n===he.max_change?{}:{max_change:n}};return Object.keys(s).length>0?s:!0}const ye=7,Ge=r=>Math.floor((256*r+Math.floor(128/ye))/256*ye),Ze=r=>Math.round(r*4/3),oe=5;export function placesLine(r){const e=r.slice(0,oe).join(", ");return r.length>oe?`${e} and ${String(r.length-oe)} more`:e}const V=(r,e,t=`${e}s`)=>`${String(r)} ${r===1?e:t}`;export const GRID_END=`Excel's grid ends at ${le(Z-1)}${String(Q)} (${Q.toLocaleString("en-US")} rows, ${Z.toLocaleString("en-US")} columns)`;function Je(r,e){let t=0,o=0;const n=r.length;for(;t<n;t++){const i=r.charCodeAt(t),c=i>=65&&i<=90,a=i>=97&&i<=122;if(!c&&!a)break;o=o*26+(c?i-64:i-96)}if(t===0||t===n)return;let s=0;for(let i=t;i<n;i++){const c=r.charCodeAt(i);if(c<48||c>57)return;s=s*10+c-48}if(s!==0){if(t>3||o>Z||s>Q)throw new Error(`${e} has a cell at ${r}, and ${GRID_END}.`);return{row:s-1,col:o-1}}}class Ke{zip;constructor(e,t){this.zip=new Xe(e,t)}get names(){return this.zip.names}has(e){return this.zip.has(e)}text(e){return this.zip.text(e)}bytes(e){return this.zip.bytesOf(e)}xml(e){const t=this.text(e);return t===void 0?void 0:xe(t)}stream(e,t){const o=this.zip.streamText(e,n=>{t.push(n)});return o&&t.end(),o}rels(e){const t=e.lastIndexOf("/"),o=`${e.slice(0,t+1)}_rels/${e.slice(t+1)}.rels`,n=this.xml(o);return x(d(n?.Relationships)?.Relationship).map(s=>{const i=l(s,"Type")??"",c=l(s,"Target")??"",a=l(s,"TargetMode")==="External";return{id:l(s,"Id")??"",type:i.slice(i.lastIndexOf("/")+1),target:a?c:Qe(e,c),external:a}})}count(e){return this.names.filter(t=>e.test(t)).length}}function Qe(r,e){if(e.startsWith("/"))return e.slice(1);const t=r.split("/").slice(0,-1);for(const o of e.split("/"))o===".."?t.pop():o!=="."&&t.push(o);return t.join("/")}function Ye(r,e){const t=[];if(e===void 0)return t;let o,n=0,s=!1;const i={open(c){if(c==="si"){o={text:"",rich:!1};return}if(o){if(n>0||c==="rPh"||c==="phoneticPr"||c==="extLst"){n+=1;return}c==="r"&&(o.rich=!0),c==="t"&&(s=!0)}},close(c){if(n>0){n-=1;return}if(c==="si"){o&&t.push({...o,text:N(o.text)}),o=void 0;return}c==="t"&&(s=!1)},text(c){o&&s&&n===0&&(o.text+=c)}};return r.stream(e,new we(i)),t}function W(r,e){const t=r[e];if(t===void 0)return!1;const o=l(d(t),"val");return o===void 0||o!=="0"&&o!=="false"}const et=new Set(["double","singleAccounting","doubleAccounting"]);function tt(r,e,t){const o={},n=(a,f)=>l(d(a?.[f]),"val");if(W(r,"b")&&(o.bold=!0),W(r,"i")&&(o.italic=!0),W(r,"strike")&&(o.strike=!0),W(r,"u")){const a=n(r,"u");o.underline=a!==void 0&&et.has(a)?a:!0}const s=n(r,"name");s!==void 0&&s!==n(e,"name")&&(o.font=s);const i=n(r,"sz");i!==void 0&&i!==n(e,"sz")&&(o.size=Number(i));const c=D(d(r.color),t);return c!==void 0&&c!==D(d(e?.color),t)&&(o.color=c),o}function nt(r,e){const t=d(r.patternFill),o=l(t,"patternType");if(o===void 0||o==="none")return;const n=D(d(t?.fgColor),e),s=D(d(t?.bgColor),e);return o==="solid"&&n!==void 0?n:{pattern:o,...n===void 0?{}:{color:n},...s===void 0?{}:{background:s}}}function $e(r,e){const t={};for(const o of["left","right","top","bottom"]){const n=d(r[o]),s=l(n,"style");if(s===void 0||s==="none")continue;const i=D(d(n?.color),e);t[o]={style:s,...i===void 0?{}:{color:i}}}return Object.keys(t).length===0?void 0:t}function ot(r){const e={},t=l(r,"horizontal");t!==void 0&&t!=="general"&&(e.align=t);const o=l(r,"vertical");o!==void 0&&o!=="bottom"&&(e.valign=o),v(r,"wrapText")===!0&&(e.wrap=!0),v(r,"shrinkToFit")===!0&&(e.shrink=!0);const n=k(r,"indent");n!==void 0&&n>0&&(e.indent=n);const s=k(r,"textRotation");return s!==void 0&&s>0&&s<=180&&(e.rotation=s),e}function ke(r,e){const t={},o=d(r.font);if(o){const a=(h,u)=>{o[h]!==void 0&&(t[u]=W(o,h))};a("b","bold"),a("i","italic"),a("strike","strike"),o.u!==void 0&&(t.underline=W(o,"u"));const f=D(d(o.color),e);f!==void 0&&(t.color=f)}const n=d(d(r.fill)?.patternFill),s=D(d(n?.bgColor),e)??D(d(n?.fgColor),e);s!==void 0&&(t.fill=s);const i=d(r.border),c=i&&$e(i,e);return c!==void 0&&(t.border=c),t}function rt(r,e){const t=d(r?.styleSheet),o=be(e,t),n=new Map(x(d(t?.numFmts)?.numFmt).map(m=>[k(m,"numFmtId")??-1,l(m,"formatCode")?.replace(/^$/u,"General")??"General"])),s=x(d(t?.fonts)?.font),i=x(d(t?.fills)?.fill),c=x(d(t?.borders)?.border),a=x(d(t?.cellXfs)?.xf),f=s[k(a[0],"fontId")??0],h=new Set;i.some(m=>m.gradientFill!==void 0)&&h.add("gradient fills");const u=a.map(m=>{const $={},g=s[k(m,"fontId")??0];g&&(Object.assign($,tt(g,f,o)),g.vertAlign!==void 0&&h.add("superscript and subscript"));const S=i[k(m,"fillId")??0],C=S&&nt(S,o);C!==void 0&&($.fill=C);const I=c[k(m,"borderId")??0],M=I&&$e(I,o);M!==void 0&&($.border=M),I&&l(d(I.diagonal),"style")!==void 0&&h.add("diagonal borders");const R=d(m.alignment);R&&(Object.assign($,ot(R)),k(R,"textRotation")===255&&h.add("vertical text"));const j=k(m,"numFmtId")??0,O=n.get(j)??We[j];return O!==void 0&&O!=="General"&&($.format=O),$}),b=l(d(f?.name),"val"),p=l(d(f?.sz),"val");return{looks:u,dxfs:x(d(t?.dxfs)?.dxf).map(m=>ke(m,o)),font:{...b===void 0?{}:{name:b},...p===void 0?{}:{size:Number(p)}},lost:[...h]}}function ve(r){const e=new Map;let t=0;for(const o of x(r.filterColumn)){const n=k(o,"colId")??0,s=d(o.filters);if(!s){Object.keys(o).some(c=>c!=="colId"&&c!=="hiddenButton")&&(t+=1);continue}if(s.dateGroupItem!==void 0){t+=1;continue}const i=x(s.filter).map(c=>N(l(c,"val")??""));e.set(n,{...i.length===0?{}:{values:i},...v(s,"blank")===!0?{blanks:!0}:{}})}return{columns:e,unread:t}}function st(r){const e=d(r?.table),t=B(l(e,"ref")??""),o=l(e,"displayName")??l(e,"name");if(!t||o===void 0)return;const n=d(e?.tableStyleInfo),s=d(e?.autoFilter);return{name:o,ref:t,headers:k(e,"headerRowCount")??1,totals:k(e,"totalsRowCount")??0,columns:x(d(e?.tableColumns)?.tableColumn).map(i=>({name:N(l(i,"name")??"").trim(),calculated:i.calculatedColumnFormula!==void 0})),style:l(n,"name")??"none",...s?{filter:ve(s)}:{}}}function re(r){const e=r.trim();if(e==="")return;const t=/^"((?:[^"]|"")*)"$/u.exec(e);if(t)return(t[1]??"").replaceAll('""','"');const o=Number(e);if(!Number.isNaN(o))return o;const n=ne(e,!0);return n.ok?ge(n.node):void 0}const Se=r=>r!==void 0&&Le.includes(r);function se(r){const e=l(r,"type")??"num",t=l(r,"val")??(r.f===void 0?void 0:E(r.f)),o=t===void 0?void 0:re(t);return{at:e,...o===void 0?{}:{value:o}}}const it=Ie,at=r=>{const e=r.formula??r.f;return(Array.isArray(e)?e:e===void 0?[]:[e]).map(E)};function dt(r,e,t,o){const n=l(r,"type")??"",s={range:e,...v(r,"stopIfTrue")===!0?{stop:!0}:{}},i={...t.bold===void 0?{}:{bold:t.bold},...t.italic===void 0?{}:{italic:t.italic},...t.underline===void 0?{}:{underline:t.underline!==!1},...t.strike===void 0?{}:{strike:t.strike},...t.color===void 0?{}:{color:t.color},...typeof t.fill=="string"?{fill:t.fill}:{},...t.border===void 0?{}:{border:t.border}},c=at(r);switch(n){case"cellIs":{const a=l(r,"operator"),f=c.flatMap(h=>{const u=re(h);return u===void 0?[]:[u]});return!Se(a)||f.length===0?`a cellIs rule of ${a??"no operator"}`:{...s,...i,type:"cellIs",operator:a,formula:f}}case"containsText":case"notContainsText":case"beginsWith":case"endsWith":{const a=l(r,"text");return a===void 0?`a ${n} rule with no text`:{...s,...i,type:"containsText",...n==="containsText"?{}:{operator:n==="notContainsText"?"notContains":n},text:N(a)}}case"duplicateValues":case"uniqueValues":return{...s,...i,type:n};case"top10":return{...s,...i,type:"top10",rank:k(r,"rank")??10,...v(r,"percent")===!0?{percent:!0}:{},...v(r,"bottom")===!0?{bottom:!0}:{}};case"aboveAverage":return{...s,...i,type:"aboveAverage",...v(r,"aboveAverage")===!1?{below:!0}:{},...v(r,"equalAverage")===!0?{equal:!0}:{}};case"expression":{const a=c[0]===void 0?void 0:ne(c[0],!0);return a?.ok?{...s,...i,type:"expression",formula:ge(a.node)}:"an expression rule that cannot be read"}case"dataBar":{const a=d(r.dataBar),f=D(d(a?.color??a?.fillColor),o),[h,u]=x(a?.cfvo).map(se);return f===void 0?"a data bar with no colour":{...s,type:"dataBar",color:f,...h&&h.at!=="min"?{min:h}:{},...u&&u.at!=="max"?{max:u}:{},...v(a,"showValue")===!1?{show:!1}:{}}}case"colorScale":{const a=d(r.colorScale),f=x(a?.cfvo).map(se),h=x(a?.color).map(b=>D(b,o)),u=f.flatMap((b,p)=>{const m=h[p];return m===void 0?[]:[{...b,color:m}]});return u.length<2?"a colour scale with too few stops":{...s,type:"colorScale",stops:u.slice(0,3)}}case"iconSet":{const a=d(r.iconSet),f=l(a,"iconSet")??"3TrafficLights1";if(!it.includes(f))return`the icon set ${f}`;if(a?.cfIcon!==void 0)return"an icon set of icons chosen one by one";const h=x(a?.cfvo).map(se);return{...s,type:"iconSet",icons:f,...h.length>=3?{stops:h.slice(0,5)}:{},...v(a,"reverse")===!0?{reverse:!0}:{},...v(a,"showValue")===!1?{show:!1}:{}}}default:return`a ${n} rule`}}const Ce={conditional:"{78C0D931-6437-407d-A8EE-F0AAD7539E65}",validations:"{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}"},Te=(r,e)=>x(d(r.extLst)?.ext).find(t=>l(t,"uri")?.toUpperCase()===e.toUpperCase());function ct(r,e,t){const o=[],n=[],s=new Set,i=(a,f,h)=>{const u=dt(a,f,h,t);typeof u=="string"?n.push(`${u} on ${f}`):o.push({priority:k(a,"priority")??0,rule:u})};for(const a of x(r.conditionalFormatting)){const f=l(a,"sqref")??"";if(!te(f)){n.push(`a rule on ${f}`);continue}for(const h of x(a.cfRule)){const u=E(d(d(h.extLst)?.ext)?.id);u!==""&&s.add(u.toUpperCase());const b=k(h,"dxfId");i(h,f,b===void 0?{}:e[b]??{})}}const c=d(Te(r,Ce.conditional)?.conditionalFormattings);for(const a of x(c?.conditionalFormatting)){const f=E(a.sqref).trim();for(const h of x(a.cfRule)){if(s.has((l(h,"id")??"").toUpperCase()))continue;if(!te(f)){n.push(`a rule on ${f}`);continue}const u=d(h.dxf);i(h,f,u?ke(u,t):{})}}return{rules:o.sort((a,f)=>a.priority-f.priority).map(a=>a.rule),unread:n}}const ft=Re;function Ee(r,e,t,o){const n=l(r,"type")??"none";if(n==="none"&&l(r,"prompt")===void 0)return;if(!ft.includes(n)||!te(e))return`a ${n} rule on ${e}`;const s=/^"((?:[^"]|"")*)"$/u.exec(t.trim()),i=n==="list"&&s?(s[1]??"").replaceAll('""','"').split(","):void 0,c=[t,o].flatMap(m=>{const $=re(m);return $===void 0?[]:[$]}),a=l(r,"operator"),f=m=>Object.fromEntries(Object.entries(m).filter(([,$])=>$!==void 0)),h=f({title:l(r,"promptTitle"),message:l(r,"prompt")}),u=f({style:l(r,"errorStyle"),title:l(r,"errorTitle"),message:l(r,"error")}),b=v(r,"showInputMessage")!==!0,p=v(r,"showErrorMessage")!==!0;return{range:e,type:n,...Se(a)&&a!=="between"?{operator:a}:{},...i?{values:i}:{formula:c},...v(r,"allowBlank")===!0?{}:{blank:!1},...v(r,"showDropDown")===!0?{dropdown:!1}:{},...b||Object.keys(h).length>0?{prompt:{...h,...b?{show:!1}:{}}}:{},...p||Object.keys(u).length>0?{error:{...u,...p?{show:!1}:{}}}:{}}}function lt(r){const e=[],t=[],o=s=>{typeof s=="string"?t.push(s):s&&e.push(s)};for(const s of x(d(r.dataValidations)?.dataValidation))o(Ee(s,l(s,"sqref")??"",E(s.formula1),E(s.formula2)));const n=d(Te(r,Ce.validations)?.dataValidations);for(const s of x(n?.dataValidation))o(Ee(s,E(s.sqref).trim(),E(d(s.formula1)?.f),E(d(s.formula2)?.f)));return{rules:e,unread:t}}function ut(r){const e=/^(-?\d{4,})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?)?(?:Z|[+-]\d{2}:?\d{2})?$/u.exec(r)??/^()()()(\d{2}):(\d{2})(?::(\d{2})(\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/u.exec(r);if(!e)return;const t=e[1]==="",o=t?1899:Number(e[1]),n=t?12:Number(e[2]),s=t?30:Number(e[3]),i=Number(e[4]??0)*3600+Number(e[5]??0)*60+Number(e[6]??0)+Number(e[7]??0),c=new Date(Date.UTC(o,n-1,s)+i*1e3);if(Number.isNaN(c.getTime()))return;const a=_e(c);return t?a-Math.floor(a):a}let ie;function Oe(r,e){const t=r.row-e.row,o=r.col-e.col;Object.defineProperty(r,"node",{get:()=>(ie?.cell!==r&&(ie={cell:r,node:Fe(e.node,t,o)}),ie.node),set:n=>{Object.defineProperty(r,"node",{value:n,writable:!0,enumerable:!0,configurable:!0})},enumerable:!0,configurable:!0}),r.key=e.key}function ae(r,e,t){const o=ne(r,e,t);return o.ok?{node:o.node}:{unread:r}}function ht(r){const e=B(r.ref??""),t=f=>{if(f===void 0||f==="")return"";const h=ue(f.replaceAll("$",""));return h?`$${le(h.col)}$${String(h.row+1)}`:void 0},o=t(r.r1),n=t(r.r2);if(!e||o===void 0||o===""||n===void 0)return;const s=r.dt2D==="1"||r.dt2D==="true",i=r.dtr==="1"||r.dtr==="true",c=s?`${o},${n}`:i?`${o},`:`,${o}`,a=De(`=TABLE(${c})`);return a.ok?{ref:e,node:a.node}:void 0}function pt(r){for(const{ref:e,node:t}of r.dataTables){const o=new Set;for(const n of r.cells)n.row<e.top||n.row>e.bottom||n.col<e.left||n.col>e.right||(n.node=t,Reflect.deleteProperty(n,"unread"),o.add(`${String(n.row)}:${String(n.col)}`));for(let n=e.top;n<=e.bottom;n++)for(let s=e.left;s<=e.right;s++)o.has(`${String(n)}:${String(s)}`)||r.cells.push({row:n,col:s,value:void 0,node:t,style:0})}}class mt{cells=[];rows=[];dataTables=[];rich=[];outlined=!1;rest=[];xml;masters=new Map;above=new Map;left;strings;name;isRangeName;inData=!1;row=-1;nextRow=0;nextCol=0;cell;target;buffer="";skip=0;constructor(e,t,o){this.strings=e,this.name=t,this.isRangeName=o,this.xml=new we(this),this.xml.capture=this.rest}open(e,t){if(!this.inData){e==="sheetData"&&(this.inData=!0,this.xml.capture=void 0);return}const o=this.cell;if(o){if(this.skip>0){this.skip+=1;return}switch(e){case"v":this.target="v",this.buffer="";return;case"f":o.f={...t,text:""},this.target="f",this.buffer="";return;case"is":o.inline={text:"",rich:!1};return;case"r":o.inline&&(o.inline.rich=!0);return;case"t":o.inline&&(this.target="t",this.buffer="");return;case"rPh":case"phoneticPr":case"extLst":this.skip=1;return;default:return}}e==="row"?this.openRow(t):e==="c"&&(this.cell={r:t.r,s:t.s,t:t.t,cm:t.cm,v:void 0,f:void 0,inline:void 0})}close(e){if(!this.inData)return;const t=this.cell;if(!t){e==="sheetData"&&(this.inData=!1,this.xml.capture=this.rest);return}if(this.skip>0){this.skip-=1;return}if(e===this.target){e==="v"?t.v=this.buffer:e==="f"&&t.f?t.f.text=this.buffer:t.inline&&(t.inline.text+=this.buffer),this.target=void 0;return}e==="c"&&(this.cell=void 0,this.readCell(t))}text(e){this.target!==void 0&&this.skip===0&&(this.buffer+=e)}openRow(e){const t=e.r,o=t===void 0?void 0:Number(t);if(o!==void 0&&Number.isInteger(o)&&o>Q)throw new Error(`${this.name} has a row ${t??""}, and ${GRID_END}.`);const n=o!==void 0&&Number.isInteger(o)&&o>0?o-1:this.nextRow;this.row=n,this.nextRow=n+1,this.nextCol=0;const s={row:n},i=e.ht===void 0?void 0:Number(e.ht),c=h=>h==="1"||h==="true";i!==void 0&&Number.isFinite(i)&&c(e.customHeight)&&(s.height=Ze(i)),c(e.hidden)&&(s.hidden=!0);const a=e.s===void 0?void 0:Number(e.s);a!==void 0&&a!==0&&c(e.customFormat)&&(s.style=a);const f=Number(e.outlineLevel??0);f>0&&(s.level=Math.min(7,f),this.outlined=!0),Object.keys(s).length>1&&this.rows.push(s)}value(e,t){const o=e.t??"n";if(o==="inlineStr"){const s=e.inline;return s?{value:N(s.text),...s.rich?{rich:!0}:{}}:{value:e.v===void 0?"":N(e.v)}}const n=e.v;if(n===void 0)return{value:void 0};switch(o){case"s":{const s=this.strings[Number(n)];return s?{value:s.text,...s.rich?{rich:!0}:{}}:{value:""}}case"str":return{value:N(n)};case"b":return{value:n.trim()==="1"||n.trim()==="true"};case"e":return{value:Pe(n.trim())??je.VALUE};case"d":return{value:ut(n.trim())??n};default:{if(n.trim()==="")return{value:void 0};const s=Number(n);if(Number.isNaN(s))throw new Error(`${t} says it holds a number and holds ${n}.`);return{value:s}}}}formula(e,t,o,n){const s=e.f;if(s===void 0)return;const i=s.t??"normal",c=s.text;if(i==="dataTable"){const p=ht(s);p?this.dataTables.push(p):n.unread=`a data table's {=TABLE(${s.r1??""})}`;return}if(i==="array"){Object.assign(n,ae(c,!0,this.isRangeName));const p=B(s.ref??"");p&&(n.array=p),e.cm!==void 0&&(n.dynamic=!0);return}if(i==="shared"){const p=s.si??"";if(c!==""){const $=ae(c,!1,this.isRangeName),g=$.node?me($.node,t,o):"";this.masters.set(p,{node:$.node,unread:$.unread,row:t,col:o,key:g}),Object.assign(n,$),$.node&&(n.key=g);return}const m=this.masters.get(p);if(!m){n.unread=`a shared formula of a group that has no first cell (${p})`;return}m.node?Oe(n,{node:m.node,row:m.row,col:m.col,key:m.key}):m.unread!==void 0&&(n.unread=m.unread);return}if(c==="")return;const a=ae(c,!1,this.isRangeName);if(!a.node){Object.assign(n,a);return}const f=me(a.node,t,o),h=this.left?.row===t?this.left:void 0,u=[this.above.get(o),h].find(p=>p?.key===f);u?Oe(n,u):(n.node=a.node,n.key=f);const b=u??{node:a.node,row:t,col:o,key:f};this.above.set(o,b),this.left=b}readCell(e){const t=e.r===void 0?void 0:Je(e.r,this.name),o=t?.row??this.row,n=t?.col??this.nextCol;if(n>=Z)throw new Error(`${this.name} has a cell past its last column, and ${GRID_END}.`);this.nextCol=n+1;const s=e.r??ee({row:o,col:n}),{value:i,rich:c}=this.value(e,s),a={row:o,col:n,value:i,style:e.s===void 0?0:Number(e.s)||0};c===!0&&(a.rich=!0,this.rich.push(s)),this.formula(e,o,n,a),this.cells.push(a)}}function gt(r,e,t){const o=[],n=u=>o.push(`${r}: ${u}`);t.length>0&&n(`${V(t.length,"cell")} of rich text, kept as plain text (${placesLine(t)})`);const s=x(d(e.hyperlinks)?.hyperlink).filter(u=>l(u,"tooltip")!==void 0);s.length>0&&n(`the tooltips of ${V(s.length,"link")} (${placesLine(s.map(u=>l(u,"ref")??""))})`),e.sortState!==void 0&&n("a sort");const i=d(e.sheetProtection);v(i,"sheet")===!0&&(l(i,"password")!==void 0||l(i,"hashValue")!==void 0)&&n("its protection's password: it is protected with none"),e.protectedRanges!==void 0&&n("protected ranges");const c=d(e.headerFooter);(c?.evenHeader!==void 0||c?.evenFooter!==void 0||c?.firstHeader!==void 0||c?.firstFooter!==void 0)&&n("its print header and footer of the first or even pages");const a=d(e.printOptions);a&&["gridLines","headings","horizontalCentered","verticalCentered"].some(u=>v(a,u)===!0)&&n("its print options (gridlines, headings, centring)"),(e.rowBreaks!==void 0||e.colBreaks!==void 0)&&n("its page breaks"),e.oleObjects!==void 0&&n("embedded objects"),e.controls!==void 0&&n("form controls"),e.dataConsolidate!==void 0&&n("a consolidation"),e.customSheetViews!==void 0&&n("custom views"),x(d(e.sheetViews)?.sheetView).some(u=>l(d(u.pane),"state")==="split")&&n("a split, not frozen, window");const h=JSON.stringify(e.extLst??"");return h.includes("sparklineGroups")&&n("sparklines"),h.includes("slicerList")&&n("slicers"),o}function bt(r,e){const t=[],o=(s,i,c)=>{const a=r.count(s);a>0&&t.push(V(a,i,c))};r.has("xl/vbaProject.bin")&&t.push("VBA macros"),o(/^xl\/pivotTables\/pivotTable\d*\.xml$/u,"pivot table"),o(/^xl\/chartsheets\/[^/]+\.xml$/u,"chart sheet"),o(/^xl\/dialogsheets\/[^/]+\.xml$/u,"dialog sheet"),o(/^xl\/macrosheets\/[^/]+\.xml$/u,"macro sheet");const n=r.names.filter(s=>s.startsWith("xl/media/")&&!e.has(s)).length;return n>0&&t.push(V(n,"image")),o(/^xl\/embeddings\//u,"embedded object"),o(/^xl\/slicers\/[^/]+\.xml$/u,"slicer part"),o(/^xl\/timelines\/[^/]+\.xml$/u,"timeline part"),o(/^xl\/ctrlProps\/[^/]+\.xml$/u,"form control"),o(/^xl\/activeX\/[^/]+\.xml$/u,"ActiveX control"),o(/^xl\/queryTables\/[^/]+\.xml$/u,"query table"),r.has("xl/connections.xml")&&t.push("data connections"),r.names.some(s=>s.startsWith("xl/richData/"))&&t.push("rich values (data types, pictures in cells)"),r.names.some(s=>/^customXml\/item\d+\.xml$/u.test(s)&&(r.text(s)??"").includes("DataMashup"))&&t.push("Power Query queries"),t}export function readHeaderFooter(r){const e={left:"",center:"",right:""};let t="center",o=new Set;for(let n=0;n<r.length;n++){const s=r[n],i=r[n+1];if(s==="&"&&(i==="L"||i==="C"||i==="R")){t=i==="L"?"left":i==="C"?"center":"right",o=new Set([...o,t]),n+=1;continue}if(s==="&"&&i==="&"){e[t]+="&&",n+=1;continue}e[t]+=s??""}return Object.fromEntries(Object.entries(e).filter(([n,s])=>s!==""||o.has(n)))}const wt=new Map(Object.entries(Me).map(([r,e])=>[e,r]));function xt(r,e,t){const o={},n=d(r.pageSetup),s=l(n,"orientation");(s==="portrait"||s==="landscape")&&(o.orientation=s);const i=k(n,"paperSize");if(i!==void 0){const b=wt.get(i);b?o.paper=b:t.push(`${e}: its paper size, Excel's number ${String(i)}`)}v(d(d(r.sheetPr)?.pageSetUpPr),"fitToPage")===!0&&(o.fit={width:k(n,"fitToWidth")??1,height:k(n,"fitToHeight")??1});const c=d(r.pageMargins),a={};for(const b of Object.keys(fe)){const p=k(c,b);p!==void 0&&p!==fe[b]&&(a[b]=p)}Object.keys(a).length>0&&(o.margins=a);const f=d(r.headerFooter),h=E(f?.oddHeader),u=E(f?.oddFooter);return h!==""&&(o.header=readHeaderFooter(N(h))),u!==""&&(o.footer=readHeaderFooter(N(u))),o}function yt(r,e,t,o,n){const s=r.rels(e),i=new Map;for(const a of s.filter(f=>f.type==="comments")){const f=d(r.xml(a.target)?.comments),h=d(f?.authors)?.author,u=(Array.isArray(h)?h:h===void 0?[]:[h]).map(b=>N(E(b)));for(const b of x(d(f?.commentList)?.comment)){const p=l(b,"ref")??"",m=d(b.text),$=x(m?.r),g=N($.length>0?$.map(C=>E(C.t)).join(""):E(m?.t)),S=u[k(b,"authorId")??-1];p!==""&&g!==""&&i.set(p,{ref:p,text:g,...S===void 0||S===""?{}:{author:S}})}}let c=0;for(const a of s.filter(f=>f.type==="threadedComment")){const f=d(r.xml(a.target)?.ThreadedComments),h=new Map;for(const u of x(f?.threadedComment)){const b=l(u,"ref")??"",p=N(E(u.text)),m=h.get(b)??{texts:[]};if(m.texts.length===0){const $=o.get(l(u,"personId")??"");$!==void 0&&(m.author=$)}m.texts.push(p),h.set(b,m)}for(const[u,b]of h)c+=1,i.set(u,{ref:u,text:b.texts.join(`
|
|
3
|
+
`),...b.author===void 0?{}:{author:b.author}})}return c>0&&n.push(`${t}: ${V(c,"threaded comment")}, kept as notes, replies after the first line`),[...i.values()]}function $t(r,e,t,o,n,s,i,c,a,f,h){const u=new mt(n,t,a);if(!r.stream(e,u.xml))throw new Error(`${e} is not in the file.`);pt(u);const b=xe(u.rest.join("")),p=d(b.worksheet);if(!p)throw new Error(`${e} is not a worksheet.`);const m=x(d(p.cols)?.col).map(y=>{const T=k(y,"width"),F=k(y,"style"),_=k(y,"outlineLevel")??0,A=(k(y,"min")??1)-1,de=(k(y,"max")??1)-1;if(de>=Z)throw new Error(`${t} sets a column past its last, and ${GRID_END}.`);const ce=v(y,"customWidth"),Y=T===void 0?void 0:Ge(T);return{min:A,max:de,...Y!==void 0&&(ce===!0||ce===void 0&&Y!==Ae)?{width:Y}:{},...v(y,"hidden")===!0?{hidden:!0}:{},...F===void 0||F===0?{}:{style:F},..._>0?{level:Math.min(7,_)}:{}}}),$=x(d(p.mergeCells)?.mergeCell).flatMap(y=>{const T=B(l(y,"ref")??"");return T?[T]:[]}),g=x(d(p.sheetViews)?.sheetView)[0],S=d(g?.pane);let C;const I=l(S,"state");if(I==="frozen"||I==="frozenSplit"){const y=ue(l(g,"topLeftCell")??"A1")??{row:0,col:0};C={row:y.row+(k(S,"ySplit")??0),col:y.col+(k(S,"xSplit")??0)}}const M=r.rels(e),R=M.filter(y=>y.type==="table").flatMap(y=>{const T=st(r.xml(y.target));return T?[T]:[]}),j=D(d(d(p.sheetPr)?.tabColor),s),O=gt(t,p,u.rich),X=ct(p,i,s),q=lt(p);for(const y of X.unread)O.push(`${t}: a conditional format, ${y}`);for(const y of q.unread)O.push(`${t}: a data validation, ${y}`);const z=d(p.autoFilter),J=B(l(z,"ref")??""),P=z&&J?{ref:J,...ve(z)}:void 0;P&&P.unread>0&&O.push(`${t}: ${V(P.unread,"filter")} by condition on ${l(z,"ref")??""}, its rows left as they were hidden`);const{charts:G,pictures:K}=vt(r,e,t,m,u.rows,O,f,h),U={},w=new Map(M.map(y=>[y.id,y]));for(const y of x(d(p.hyperlinks)?.hyperlink)){const T=l(y,"ref");if(T===void 0)continue;const F=l(y,"location"),_=l(y,"id"),A=_===void 0?void 0:w.get(_)?.target;A!==void 0?U[T]=F===void 0?A:`${A}#${F}`:F!==void 0&&(U[T]=`#${F}`)}const L=d(p.sheetProtection),H=xt(p,t,O);return{sheet:{name:t,state:o,cells:u.cells,merges:$,...C?{freeze:C}:{},...l(g,"showGridLines")==="0"?{gridlines:!1}:{},...j===void 0?{}:{tab:j},columns:m,rows:u.rows,tables:R,conditional:X.rules,validations:q.rules,scenarios:x(d(p.scenarios)?.scenario).map(y=>({name:l(y,"name")??"",cells:x(y.inputCells).map(T=>({at:l(T,"r")??"",value:l(T,"val")??""}))})),...P?{filter:P}:{},charts:G,links:U,notes:yt(r,e,t,c,O),pictures:K,...v(L,"sheet")===!0?{protect:!0}:{},...Object.keys(H).length>0?{print:H}:{}},lost:O}}const Ae=64,kt=20;function vt(r,e,t,o,n,s,i,c){const a=p=>o.find(m=>p>=m.min&&p<=m.max)?.width??Ae,f=new Map(n.map(p=>[p.row,p.height])),h=p=>f.get(p)??kt,u=[],b=[];for(const p of r.rels(e).filter(m=>m.type==="drawing")){const m=Ve(r.xml(p.target),a,h),$=r.rels(p.target);for(const g of m.anchors){const S=$.find(R=>R.id===g.id),C=ee(g.at);if(g.width<=0||g.height<=0){s.push(`${t}: the chart at ${C}, of no size`);continue}const I=[],M=Ue(S?r.xml(S.target):void 0,I,c);if(typeof M=="string"){s.push(`${t}: the chart at ${C}, as ${M}`);continue}for(const R of I)s.push(`${t}: the chart at ${C} without its ${R}`);u.push({...M,at:C,...g.x===void 0?{}:{x:g.x},...g.y===void 0?{}:{y:g.y},...g.width===pe.width?{}:{width:g.width},...g.height===pe.height?{}:{height:g.height}})}for(const g of m.pictures){const S=$.find(M=>M.id===g.id),C=S&&!S.external?r.bytes(S.target):void 0;if(!S||!C){s.push(`${t}: the picture at ${ee(g.at)}, whose image is not in the file`);continue}i.add(S.target);const I=S.target.slice(S.target.lastIndexOf(".")+1).toLowerCase();b.push({row:g.at.row,col:g.at.col,...g.x===void 0?{}:{x:g.x},...g.y===void 0?{}:{y:g.y},width:g.width,height:g.height,...g.name===void 0?{}:{name:g.name},...g.descr===void 0?{}:{descr:g.descr},bytes:C,type:I})}m.others>0&&s.push(`${t}: ${V(m.others,"shape")} of its drawing`)}return{charts:u,pictures:b}}function St(r,e,t){for(const o of r){if(o.sheet===void 0)continue;const n=e[o.sheet];if(!n)continue;const s=o.text.split(",").map(i=>i.slice(i.lastIndexOf("!")+1).replaceAll("$",""));if(o.name==="_xlnm.Print_Area"){const[i]=s;s.length>1&&t.push(`${n.name}: its print area's ranges after the first`),i!==void 0&&B(i)&&(n.print={...n.print,area:i})}else if(o.name==="_xlnm.Print_Titles")for(const i of s)/^\d+:\d+$/u.test(i)?n.print={...n.print,title_rows:i}:/^[A-Za-z]+:[A-Za-z]+$/u.test(i)&&(n.print={...n.print,title_cols:i})}}export function readXlsx(r,e){let t;try{t=new Ke(r,e)}catch(w){throw w instanceof Ne?w:new Error("It is not a zip file, as an .xlsx file is.")}const o=t.rels(""),n=o.find(w=>w.type==="officeDocument")?.target??"xl/workbook.xml";if(n.endsWith(".bin"))throw new Error("It is a binary workbook (.xlsb): save it as .xlsx.");const s=t.xml(n),i=d(s?.workbook);if(!i)throw new Error("It has no workbook part.");const c=t.rels(n),a=w=>c.find(L=>L.type===w)?.target,f=(()=>{const w=a("theme");return w===void 0?void 0:t.text(w)})(),h=f===void 0?ze:He(f),u=a("styles"),b=u===void 0?void 0:t.xml(u),p=rt(b,h),m=be(h,d(b?.styleSheet)),$=Ye(t,a("sharedStrings")),g=[];for(const w of p.lost)g.push(w);const S=d(i.workbookPr),C=qe(d(i.calcPr)),I=d(i.workbookProtection);(v(I,"lockStructure")===!0||v(I,"lockWindows")===!0)&&g.push("the workbook's protection"),i.fileSharing!==void 0&&g.push("its write protection");const M=new Map,R=a("person");if(R!==void 0)for(const w of x(d(t.xml(R)?.personList)?.person))M.set(l(w,"id")??"",N(l(w,"displayName")??""));const j=x(d(i.definedNames)?.definedName).map(w=>{const L=k(w,"localSheetId");return{name:l(w,"name")??"",text:N(E(w)),...L===void 0?{}:{sheet:L},...v(w,"hidden")===!0?{hidden:!0}:{}}}),O=[],X=new Set,q=new Map(c.map(w=>[w.id,w])),z=x(d(i.sheets)?.sheet),J=new Set(z.filter(w=>q.get(l(w,"id")??"")?.type==="worksheet").map(w=>N(l(w,"name")??"").toLowerCase()));for(const[w,L]of z.entries()){const H=q.get(l(L,"id")??""),y=N(l(L,"name")??"");if(H?.type!=="worksheet"){H?.type!=="chartsheet"&&H?.type!=="dialogsheet"&&g.push(`${y}: a sheet of a kind this cannot read`);continue}const T=new Map;for(const A of j)(A.sheet===void 0||A.sheet===w)&&(A.sheet!==void 0||!T.has(A.name.toLowerCase()))&&T.set(A.name.toLowerCase(),Be(A.text));const F=l(L,"state"),_=$t(t,H.target,y,F==="hidden"||F==="veryHidden"?F:"visible",$,m,p.dxfs,M,A=>T.get(A.toLowerCase())===!0,X,A=>J.has(A.toLowerCase()));O[w]=_.sheet,g.push(..._.lost)}St(j,O,g);const P=o.find(w=>w.type==="core-properties")?.target,G=P===void 0?void 0:E(d(t.xml(P)?.coreProperties)?.title).trim(),K=O.filter(w=>w!==void 0),U=new Map;return O.forEach((w,L)=>{w!==void 0&&U.set(L,K.indexOf(w))}),{sheets:K,names:j.flatMap(w=>{if(w.sheet===void 0)return[w];const L=U.get(w.sheet);return L===void 0?[]:[{...w,sheet:L}]}),looks:p.looks,dxfs:p.dxfs,date1904:v(S,"date1904")===!0,font:p.font,...G===void 0||G===""?{}:{title:G},...C===void 0?{}:{iteration:C},lost:[...bt(t,X),...g]}}
|
|
@@ -14,8 +14,14 @@ export declare class XmlStream {
|
|
|
14
14
|
private buffer;
|
|
15
15
|
private readonly handler;
|
|
16
16
|
private depth;
|
|
17
|
+
/** A piece ended in a CR, which the next may follow with its LF. */
|
|
18
|
+
private cr;
|
|
17
19
|
constructor(handler: XmlHandler);
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Line ends are XML's first (2.11 End-of-Line Handling): a CR LF or a CR
|
|
22
|
+
* is a LF, as Excel reads it; a CR written as stays one.
|
|
23
|
+
*/
|
|
24
|
+
push(piece: string): void;
|
|
19
25
|
end(): void;
|
|
20
26
|
private emitText;
|
|
21
27
|
private run;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
const b={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};export function unescapeXml(r){return r.includes("&")?r.replace(/&(#x[0-9A-Fa-f]+|#\d+|[A-Za-z]+);/gu,(e,
|
|
2
|
+
const b={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};export function unescapeXml(r){return r.includes("&")?r.replace(/&(#x[0-9A-Fa-f]+|#\d+|[A-Za-z]+);/gu,(e,n)=>n.startsWith("#x")?String.fromCodePoint(Number.parseInt(n.slice(2),16)):n.startsWith("#")?String.fromCodePoint(Number.parseInt(n.slice(1),10)):b[n]??e):r}const d=r=>{const e=r.indexOf(":");return e<0?r:r.slice(e+1)},p=r=>r===32||r===9||r===10||r===13;function x(r,e,n){let i=0;const t=r.length;for(;i<t&&!p(r.charCodeAt(i));)i++;const f=d(r.slice(0,i)),o={};for(;i<t;){for(;i<t&&p(r.charCodeAt(i));)i++;if(i>=t)break;const h=r.indexOf("=",i);if(h<0)throw new Error(`An attribute of <${f}> has no value.`);const u=r.slice(i,h).trim();let l=h+1;for(;l<t&&p(r.charCodeAt(l));)l++;const a=r[l];if(a!=='"'&&a!=="'")throw new Error(`An attribute of <${f}> is not quoted.`);const s=r.indexOf(a,l+1);if(s<0)throw new Error(`An attribute of <${f}> is not closed.`);u!=="xmlns"&&!u.startsWith("xmlns:")&&(o[d(u)]=unescapeXml(r.slice(l+1,s))),i=s+1}return e.open(f,o,n),f}export class XmlStream{capture;buffer="";handler;depth=0;cr=!1;constructor(e){this.handler=e}push(e){let n=this.cr?`\r${e}`:e;this.cr=n.endsWith("\r"),this.cr&&(n=n.slice(0,-1)),n=n.replace(/\r\n?/gu,`
|
|
3
|
+
`),this.buffer=this.buffer===""?n:this.buffer+n,this.run()}end(){if(this.cr&&(this.cr=!1,this.buffer+=`
|
|
4
|
+
`),this.run(),this.buffer.trim()!=="")throw new Error("The XML ends inside a tag or a comment.");if(this.depth>0)throw new Error("The XML ends before its elements do.")}emitText(e){e!==""&&(this.capture?.push(e),this.handler.text(unescapeXml(e)))}run(){const e=this.buffer,n=e.length;let i=0;for(;;){const t=e.indexOf("<",i);if(t<0){const s=e.lastIndexOf("&"),c=s>=i&&!e.includes(";",s)?s:n;this.emitText(e.slice(i,c)),i=c;break}t>i&&this.emitText(e.slice(i,t)),i=t;const f=e.charCodeAt(t+1);if(Number.isNaN(f))break;if(f===33){if(e.startsWith("<!--",t)){const c=e.indexOf("-->",t+4);if(c<0)break;this.capture?.push(e.slice(t,c+3)),i=c+3;continue}if(e.startsWith("<![CDATA[",t)){const c=e.indexOf("]]>",t+9);if(c<0)break;this.capture?.push(e.slice(t,c+3)),this.handler.text(e.slice(t+9,c)),i=c+3;continue}if(n-t<9)break;const s=e.indexOf(">",t);if(s<0)break;if(e.lastIndexOf("[",s)>t){const c=e.indexOf("]>",t);if(c<0)break;i=c+2}else i=s+1;continue}if(f===63){const s=e.indexOf("?>",t+2);if(s<0)break;this.capture?.push(e.slice(t,s+2)),i=s+2;continue}if(f===47){const s=e.indexOf(">",t+2);if(s<0)break;this.capture?.push(e.slice(t,s+1)),this.depth-=1,this.handler.close(d(e.slice(t+2,s).trim())),i=s+1;continue}let o=t+1,h=0;for(;o<n;o++){const s=e.charCodeAt(o);if(h!==0)s===h&&(h=0);else if(s===34||s===39)h=s;else if(s===62)break}if(o>=n)break;const u=e.charCodeAt(o-1)===47,l=e.slice(t,o+1),a=x(e.slice(t+1,u?o-1:o),this.handler,u);this.capture?.push(l),u?this.handler.close(a):this.depth+=1,i=o+1}this.buffer=i>=n?"":e.slice(i)}}
|
|
@@ -4,6 +4,12 @@ export declare const DEFAULT_FONT: {
|
|
|
4
4
|
readonly name: "Calibri";
|
|
5
5
|
readonly size: 11;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* A font's name as Excel takes one: 31 characters at most, past which it
|
|
9
|
+
* repairs the file. LibreOffice's list of faces ("Liberation Serif;Times
|
|
10
|
+
* New Roman") is its first face.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fontName(name: string): string;
|
|
7
13
|
export declare class Styles {
|
|
8
14
|
private readonly fonts;
|
|
9
15
|
private readonly fills;
|