@mseep/open-computer-use 1.0.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/.coderabbit.yaml +25 -0
- package/.dockerignore +95 -0
- package/.env.example +137 -0
- package/.githooks/pre-commit +68 -0
- package/.github/CODEOWNERS +125 -0
- package/.github/ISSUE_TEMPLATE/adr-proposal.md +41 -0
- package/.github/ISSUE_TEMPLATE/bug-report.md +49 -0
- package/.github/ISSUE_TEMPLATE/component-proposal.md +38 -0
- package/.github/ISSUE_TEMPLATE/config.yml +15 -0
- package/.github/ISSUE_TEMPLATE/dependency-proposal.md +59 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +15 -0
- package/.github/ISSUE_TEMPLATE/nfr-proposal.md +44 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +15 -0
- package/.github/codeql/codeql-config.yml +11 -0
- package/.github/codeql/extensions/security-models/python-sanitizers.model.yml +17 -0
- package/.github/codeql/extensions/security-models/qlpack.yml +7 -0
- package/.github/dependabot.yml +23 -0
- package/.github/security-exceptions.yml +23 -0
- package/.github/workflows/build.yml +420 -0
- package/.github/workflows/codeql.yml +33 -0
- package/.github/workflows/contracts-lint.yml +90 -0
- package/.github/workflows/docs-lint.yml +151 -0
- package/.github/workflows/helm.yml +131 -0
- package/.github/workflows/identity-lint.yml +30 -0
- package/.github/workflows/release-chart.yml +177 -0
- package/.github/workflows/release.yml +95 -0
- package/.github/workflows/security.yml +332 -0
- package/.github/workflows/stale.yml +31 -0
- package/.github/workflows/supply-chain.yml +242 -0
- package/.gitleaks.toml +53 -0
- package/.markdownlint.yaml +51 -0
- package/.semgrepignore +85 -0
- package/.vale/styles/Architecture/ap13-data-class-substrate.yml +12 -0
- package/.vale/styles/Architecture/banned-phrases.yml +23 -0
- package/.vale/styles/Architecture/banned-vocab.yml +23 -0
- package/.vale/styles/Architecture/marketing-tone.yml +19 -0
- package/.vale.ini +18 -0
- package/CHANGELOG.md +411 -0
- package/CLAUDE.md +218 -0
- package/CONTRIBUTING.md +82 -0
- package/Dockerfile +676 -0
- package/LICENSE +98 -0
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +36 -0
- package/README.md +516 -0
- package/SECURITY.md +45 -0
- package/THIRD-PARTY-LICENSES.md +14 -0
- package/apt-packages.txt +108 -0
- package/computer-use-server/.dockerignore +13 -0
- package/computer-use-server/Dockerfile +44 -0
- package/computer-use-server/README.md +84 -0
- package/computer-use-server/app.py +1544 -0
- package/computer-use-server/bin/list-subagent-models +449 -0
- package/computer-use-server/cli-defaults/README.md +31 -0
- package/computer-use-server/cli-defaults/codex.json +7 -0
- package/computer-use-server/cli-defaults/opencode.json +18 -0
- package/computer-use-server/cli_adapters/__init__.py +46 -0
- package/computer-use-server/cli_adapters/claude.py +163 -0
- package/computer-use-server/cli_adapters/codex.py +163 -0
- package/computer-use-server/cli_adapters/opencode.py +169 -0
- package/computer-use-server/cli_adapters/result.py +34 -0
- package/computer-use-server/cli_runtime.py +316 -0
- package/computer-use-server/context_vars.py +24 -0
- package/computer-use-server/docker_manager.py +1100 -0
- package/computer-use-server/docs_html.py +12 -0
- package/computer-use-server/mcp_resources.py +170 -0
- package/computer-use-server/mcp_tools.py +1430 -0
- package/computer-use-server/requirements.txt +17 -0
- package/computer-use-server/security.py +50 -0
- package/computer-use-server/skill_manager.py +664 -0
- package/computer-use-server/static/browser-viewer.js +445 -0
- package/computer-use-server/static/chart.umd.js +14 -0
- package/computer-use-server/static/docs.html +203 -0
- package/computer-use-server/static/github-dark.min.css +10 -0
- package/computer-use-server/static/github.min.css +10 -0
- package/computer-use-server/static/highlight.min.js +1213 -0
- package/computer-use-server/static/highlightjs-line-numbers.min.js +1 -0
- package/computer-use-server/static/icons.js +74 -0
- package/computer-use-server/static/jszip.min.js +13 -0
- package/computer-use-server/static/katex/auto-render.min.js +1 -0
- package/computer-use-server/static/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Bold.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Italic.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Math-Italic.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Script-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/computer-use-server/static/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/computer-use-server/static/katex/katex.min.css +1 -0
- package/computer-use-server/static/katex/katex.min.js +1 -0
- package/computer-use-server/static/locale.js +242 -0
- package/computer-use-server/static/mammoth.browser.min.js +21 -0
- package/computer-use-server/static/marked.min.js +6 -0
- package/computer-use-server/static/mermaid.min.js +2811 -0
- package/computer-use-server/static/pdf.min.js +22 -0
- package/computer-use-server/static/pdf.worker.min.js +22 -0
- package/computer-use-server/static/pptxviewjs.min.js +1 -0
- package/computer-use-server/static/preact-htm.min.js +1 -0
- package/computer-use-server/static/preview.css +1030 -0
- package/computer-use-server/static/preview.js +1522 -0
- package/computer-use-server/static/xlsx.full.min.js +22 -0
- package/computer-use-server/static/xterm-addon-fit.min.js +2 -0
- package/computer-use-server/static/xterm-addon-web-links.min.js +2 -0
- package/computer-use-server/static/xterm.css +218 -0
- package/computer-use-server/static/xterm.min.js +2 -0
- package/computer-use-server/system_prompt.py +761 -0
- package/computer-use-server/uploads.py +82 -0
- package/contracts/README.md +53 -0
- package/contracts/audit/audit-fanin.asyncapi.yaml +407 -0
- package/contracts/exec/exec-channel.schema.json +240 -0
- package/contracts/mcp/2025-06-18/ocu-constraints.schema.json +178 -0
- package/contracts/storage/file-artifact-api.schema.json +390 -0
- package/contracts/storage/file-ops.schema.json +217 -0
- package/contracts/storage/mount-config.schema.json +197 -0
- package/cron/Dockerfile +15 -0
- package/cron/cleanup-quick.sh +21 -0
- package/cron/cleanup.sh +127 -0
- package/data/outputs/.gitkeep +0 -0
- package/data/uploads/.gitkeep +0 -0
- package/docker-compose.test.yml +54 -0
- package/docker-compose.webui.yml +77 -0
- package/docker-compose.yml +96 -0
- package/docs/CLOUD.md +29 -0
- package/docs/COMPARISON.md +128 -0
- package/docs/DOCKER.md +469 -0
- package/docs/DYNAMIC-SKILLS.md +77 -0
- package/docs/FEATURES.md +100 -0
- package/docs/INSTALL.md +111 -0
- package/docs/KNOWN-BUGS.md +86 -0
- package/docs/MCP.md +320 -0
- package/docs/SCREENSHOTS.md +39 -0
- package/docs/SKILLS-USER-GUIDE.md +86 -0
- package/docs/SKILLS.md +483 -0
- package/docs/TERMINAL-TAB.md +56 -0
- package/docs/architecture/02-trust-boundaries.md +224 -0
- package/docs/architecture/03-c4-context.md +61 -0
- package/docs/architecture/04-bounded-contexts.md +119 -0
- package/docs/architecture/05-c4-container.md +88 -0
- package/docs/architecture/06-threat-model.md +172 -0
- package/docs/architecture/08-contracts.md +105 -0
- package/docs/architecture/MANIFESTO.md +38 -0
- package/docs/architecture/PROCESS.md +64 -0
- package/docs/architecture/README.md +37 -0
- package/docs/architecture/adr/0000-template.md +65 -0
- package/docs/architecture/adr/0001-layer-0-gate-legacy-exclusion.md +75 -0
- package/docs/architecture/adr/0002-session-view-descriptor.md +57 -0
- package/docs/architecture/adr/0003-sandbox-runtime-tier-ladder.md +63 -0
- package/docs/architecture/adr/0004-operator-authentication-substrate.md +63 -0
- package/docs/architecture/adr/0005-egress-credential-delivery-envoy-sds.md +62 -0
- package/docs/architecture/adr/0006-egress-forward-proxy-substrate.md +65 -0
- package/docs/architecture/adr/0007-egress-auth-mechanism.md +72 -0
- package/docs/architecture/adr/0008-session-egress-attribution.md +59 -0
- package/docs/architecture/adr/0009-audit-pipeline-pluggable-by-contract.md +76 -0
- package/docs/architecture/adr/0010-storage-backend-pluggable-adapter.md +60 -0
- package/docs/architecture/adr/0011-storage-egress-lane.md +67 -0
- package/docs/architecture/adr/0012-implementation-language.md +67 -0
- package/docs/architecture/adr/0020-sandbox-image-provisioning.md +82 -0
- package/docs/architecture/adr/README.md +53 -0
- package/docs/architecture/compliance/.gitkeep +0 -0
- package/docs/architecture/components/00-overview.md +42 -0
- package/docs/architecture/components/0000-template.md +50 -0
- package/docs/architecture/components/01-mcp-gateway.md +80 -0
- package/docs/architecture/components/02-control-operator-api.md +80 -0
- package/docs/architecture/components/04-storage-broker.md +104 -0
- package/docs/architecture/components/05-session-sandbox.md +93 -0
- package/docs/architecture/components/06-egress-trust-edge.md +95 -0
- package/docs/architecture/components/07-audit-pipeline.md +110 -0
- package/docs/architecture/diagrams/.gitkeep +0 -0
- package/docs/architecture/diagrams/02-trust-boundaries.mmd +111 -0
- package/docs/architecture/diagrams/06-threat-model.mmd +41 -0
- package/docs/architecture/diagrams/08-contracts.mmd +47 -0
- package/docs/architecture/diagrams/c4-container.mmd +59 -0
- package/docs/architecture/diagrams/c4-context.mmd +46 -0
- package/docs/architecture/glossary.md +172 -0
- package/docs/architecture/manifesto/.gitkeep +0 -0
- package/docs/architecture/manifesto/01-audience-and-buyer.md +57 -0
- package/docs/architecture/manifesto/02-nfrs.md +325 -0
- package/docs/architecture/manifesto/03-non-negotiables.md +35 -0
- package/docs/architecture/manifesto/04-non-goals.md +23 -0
- package/docs/architecture/manifesto/05-licensing-posture.md +61 -0
- package/docs/architecture/manifesto/06-starter-mode-policy.md +49 -0
- package/docs/architecture/manifesto/07-governance.md +60 -0
- package/docs/architecture/primitives-backlog.md +51 -0
- package/docs/architecture.svg +117 -0
- package/docs/claude-code-gateway.md +173 -0
- package/docs/cli-config-templates.md +240 -0
- package/docs/data-flow.svg +72 -0
- package/docs/demo-landing-page.gif +0 -0
- package/docs/demo-qwen-trending.gif +0 -0
- package/docs/dynamic-skills.svg +77 -0
- package/docs/file-flow.svg +126 -0
- package/docs/future-architecture/README.md +152 -0
- package/docs/future-architecture/adr/0001-control-plane-language-go.md +80 -0
- package/docs/future-architecture/adr/0002-guest-agent-language-go.md +84 -0
- package/docs/future-architecture/adr/0003-docker-poc-first-then-k8s.md +37 -0
- package/docs/future-architecture/adr/0004-pluggable-runtime-via-runtimeclass.md +34 -0
- package/docs/future-architecture/adr/0005-mcp-as-control-plane-gateway.md +34 -0
- package/docs/future-architecture/adr/0006-no-agpl-no-bsl-dependencies.md +41 -0
- package/docs/future-architecture/adr/0007-superseded-by-future-architecture.md +37 -0
- package/docs/future-architecture/adr/0008-internal-grpc-external-rest-mcp.md +106 -0
- package/docs/future-architecture/adr/0009-external-protocol-dialects.md +94 -0
- package/docs/future-architecture/adr/0010-lambda-as-inspiration-not-runtime.md +86 -0
- package/docs/future-architecture/adr/0011-kata-as-first-class-dind-runtime.md +84 -0
- package/docs/future-architecture/antipatterns.md +552 -0
- package/docs/future-architecture/architecture/01-layers.md +109 -0
- package/docs/future-architecture/architecture/02-layer4-control-plane.md +122 -0
- package/docs/future-architecture/architecture/03-layer3-providers.md +174 -0
- package/docs/future-architecture/architecture/04-layer2-runtimes.md +114 -0
- package/docs/future-architecture/architecture/04b-credential-broker.md +153 -0
- package/docs/future-architecture/architecture/05-layer1-guest-agent.md +138 -0
- package/docs/future-architecture/architecture/06-storage.md +134 -0
- package/docs/future-architecture/architecture/07-security.md +194 -0
- package/docs/future-architecture/architecture/08-networking.md +149 -0
- package/docs/future-architecture/architecture/09-templates.md +122 -0
- package/docs/future-architecture/architecture/10-observability.md +121 -0
- package/docs/future-architecture/design-notes.md +72 -0
- package/docs/future-architecture/gaps.md +281 -0
- package/docs/future-architecture/phase-template.md +123 -0
- package/docs/future-architecture/references.md +225 -0
- package/docs/future-architecture/research/01-kata-containers.md +100 -0
- package/docs/future-architecture/research/02-e2b-infra.md +133 -0
- package/docs/future-architecture/research/03-coder.md +115 -0
- package/docs/future-architecture/research/04-cloud-hypervisor.md +99 -0
- package/docs/future-architecture/research/05-firecracker.md +114 -0
- package/docs/future-architecture/research/06-agent-sandbox.md +142 -0
- package/docs/future-architecture/research/07-chromedp.md +78 -0
- package/docs/future-architecture/research/08-microsandbox.md +78 -0
- package/docs/future-architecture/research/09-agentbox.md +135 -0
- package/docs/future-architecture/research/10-sysbox.md +100 -0
- package/docs/future-architecture/research/11-firecracker-containerd.md +93 -0
- package/docs/future-architecture/research/12-docker-socket-proxy.md +59 -0
- package/docs/future-architecture/research/14-e2b-desktop-and-surf.md +107 -0
- package/docs/future-architecture/research/18-open-webui-terminals-observed.md +135 -0
- package/docs/future-architecture/research/bank-buyer.md +96 -0
- package/docs/future-architecture/research/enthusiast-audience.md +106 -0
- package/docs/future-architecture/research/proof-uipath-anthropic-2026-05.md +76 -0
- package/docs/future-architecture/research/widemoat-thesis-advisor.md +124 -0
- package/docs/future-architecture/roadmap.md +438 -0
- package/docs/kata-runtime.md +267 -0
- package/docs/kubernetes.md +86 -0
- package/docs/logo.png +0 -0
- package/docs/multi-cli.md +161 -0
- package/docs/openwebui-filter.md +134 -0
- package/docs/roadmap/implementation-roadmap.md +104 -0
- package/docs/sandbox-contents.svg +229 -0
- package/docs/screenshots/01-create-document.png +0 -0
- package/docs/screenshots/02-file-preview.png +0 -0
- package/docs/screenshots/03-browser-viewer.png +0 -0
- package/docs/screenshots/04-sub-agent-terminal.png +0 -0
- package/docs/screenshots/05-chat-overview.png +0 -0
- package/docs/screenshots/06-sub-agent-dashboard.png +0 -0
- package/docs/screenshots/07-frontend-design-skill.png +0 -0
- package/docs/screenshots/08-pptx-skill.png +0 -0
- package/docs/screenshots/09-skill-creator.png +0 -0
- package/docs/screenshots/10-data-chart.png +0 -0
- package/docs/shared-browser.svg +102 -0
- package/docs/system-prompt.md +113 -0
- package/docs/terminal-flow.svg +69 -0
- package/examples/helm/README.md +20 -0
- package/examples/helm/standalone/values.yaml +49 -0
- package/examples/helm/with-open-webui/README.md +99 -0
- package/examples/helm/with-open-webui/values-computer-use.yaml +32 -0
- package/examples/helm/with-open-webui/values-open-webui.yaml +67 -0
- package/fonts/NotoEmoji-Regular.ttf +0 -0
- package/helm/computer-use-server/.helmignore +17 -0
- package/helm/computer-use-server/Chart.yaml +32 -0
- package/helm/computer-use-server/README.md +211 -0
- package/helm/computer-use-server/templates/NOTES.txt +66 -0
- package/helm/computer-use-server/templates/_helpers.tpl +115 -0
- package/helm/computer-use-server/templates/configmap-dind-init.yaml +82 -0
- package/helm/computer-use-server/templates/configmap.yaml +18 -0
- package/helm/computer-use-server/templates/deployment.yaml +248 -0
- package/helm/computer-use-server/templates/ingress.yaml +38 -0
- package/helm/computer-use-server/templates/networkpolicy.yaml +50 -0
- package/helm/computer-use-server/templates/pdb.yaml +16 -0
- package/helm/computer-use-server/templates/pvc-data.yaml +20 -0
- package/helm/computer-use-server/templates/pvc-skills-cache.yaml +20 -0
- package/helm/computer-use-server/templates/pvc-user-data.yaml +20 -0
- package/helm/computer-use-server/templates/pvc-var-lib-docker.yaml +27 -0
- package/helm/computer-use-server/templates/secret.yaml +23 -0
- package/helm/computer-use-server/templates/service.yaml +22 -0
- package/helm/computer-use-server/templates/serviceaccount.yaml +15 -0
- package/helm/computer-use-server/templates/tests/test-health.yaml +23 -0
- package/helm/computer-use-server/values.schema.json +183 -0
- package/helm/computer-use-server/values.yaml +297 -0
- package/lychee.toml +36 -0
- package/openwebui/Dockerfile +52 -0
- package/openwebui/README.md +38 -0
- package/openwebui/functions/README.md +48 -0
- package/openwebui/functions/computer_link_filter.py +487 -0
- package/openwebui/init.sh +305 -0
- package/openwebui/patches/README.md +44 -0
- package/openwebui/patches/fix_artifacts_auto_show.py +441 -0
- package/openwebui/patches/fix_attached_files_position.py +87 -0
- package/openwebui/patches/fix_large_tool_args.py +156 -0
- package/openwebui/patches/fix_large_tool_results.py +289 -0
- package/openwebui/patches/fix_preview_url_detection.py +230 -0
- package/openwebui/patches/fix_skip_embedding_chat_files.py +229 -0
- package/openwebui/patches/fix_skip_rag_files_native_fc.py +100 -0
- package/openwebui/patches/fix_tool_loop_errors.py +510 -0
- package/package.json +39 -0
- package/requirements.txt +112 -0
- package/scripts/check-config.sh +141 -0
- package/scripts/docs-lint/ai-slop-detector.sh +202 -0
- package/scripts/docs-lint/architecture-tree-whitelist.sh +131 -0
- package/scripts/docs-lint/ascii-diagram-detector.sh +58 -0
- package/scripts/docs-lint/front-matter-validator.sh +97 -0
- package/scripts/docs-lint/gitignored-ref-detector.sh +122 -0
- package/scripts/docs-lint/identity-email-detector.sh +48 -0
- package/scripts/docs-lint/test-linters.sh +354 -0
- package/scripts/docs-lint/wc-budget.sh +61 -0
- package/scripts/githooks/pre-push +75 -0
- package/server.json +13 -0
- package/settings-wrapper/Dockerfile +9 -0
- package/settings-wrapper/README.md +119 -0
- package/settings-wrapper/app.py +113 -0
- package/settings-wrapper/requirements.txt +2 -0
- package/settings-wrapper/skills.json +25 -0
- package/skills/README.md +46 -0
- package/skills/examples/algorithmic-art/SKILL.md +405 -0
- package/skills/examples/algorithmic-art/templates/generator_template.js +223 -0
- package/skills/examples/algorithmic-art/templates/viewer.html +601 -0
- package/skills/examples/artifacts-builder/SKILL.md +74 -0
- package/skills/examples/artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/skills/examples/artifacts-builder/scripts/init-artifact.sh +322 -0
- package/skills/examples/artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/skills/examples/canvas-design/LICENSE.txt +202 -0
- package/skills/examples/canvas-design/SKILL.md +130 -0
- package/skills/examples/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
- package/skills/examples/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
- package/skills/examples/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
- package/skills/examples/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
- package/skills/examples/copy-editing/SKILL.md +447 -0
- package/skills/examples/copy-editing/evals/evals.json +89 -0
- package/skills/examples/copy-editing/references/plain-english-alternatives.md +394 -0
- package/skills/examples/internal-comms/LICENSE.txt +202 -0
- package/skills/examples/internal-comms/SKILL.md +32 -0
- package/skills/examples/internal-comms/examples/3p-updates.md +47 -0
- package/skills/examples/internal-comms/examples/company-newsletter.md +65 -0
- package/skills/examples/internal-comms/examples/faq-answers.md +30 -0
- package/skills/examples/internal-comms/examples/general-comms.md +16 -0
- package/skills/examples/mcp-builder/SKILL.md +328 -0
- package/skills/examples/mcp-builder/reference/evaluation.md +602 -0
- package/skills/examples/mcp-builder/reference/mcp_best_practices.md +915 -0
- package/skills/examples/mcp-builder/reference/node_mcp_server.md +916 -0
- package/skills/examples/mcp-builder/reference/python_mcp_server.md +752 -0
- package/skills/examples/mcp-builder/scripts/connections.py +151 -0
- package/skills/examples/mcp-builder/scripts/evaluation.py +373 -0
- package/skills/examples/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills/examples/mcp-builder/scripts/requirements.txt +2 -0
- package/skills/examples/product-marketing-context/SKILL.md +241 -0
- package/skills/examples/product-marketing-context/evals/evals.json +85 -0
- package/skills/examples/single-cell-rna-qc/SKILL.md +175 -0
- package/skills/examples/single-cell-rna-qc/references/scverse_qc_guidelines.md +186 -0
- package/skills/examples/single-cell-rna-qc/scripts/qc_analysis.py +232 -0
- package/skills/examples/single-cell-rna-qc/scripts/qc_core.py +233 -0
- package/skills/examples/single-cell-rna-qc/scripts/qc_plotting.py +235 -0
- package/skills/examples/skill-creator/SKILL.md +355 -0
- package/skills/examples/skill-creator/references/output-patterns.md +82 -0
- package/skills/examples/skill-creator/references/workflows.md +28 -0
- package/skills/examples/skill-creator/scripts/init_skill.py +303 -0
- package/skills/examples/skill-creator/scripts/package_skill.py +110 -0
- package/skills/examples/skill-creator/scripts/quick_validate.py +95 -0
- package/skills/examples/slack-gif-creator/SKILL.md +254 -0
- package/skills/examples/slack-gif-creator/core/easing.py +234 -0
- package/skills/examples/slack-gif-creator/core/frame_composer.py +176 -0
- package/skills/examples/slack-gif-creator/core/gif_builder.py +269 -0
- package/skills/examples/slack-gif-creator/core/validators.py +136 -0
- package/skills/examples/slack-gif-creator/requirements.txt +4 -0
- package/skills/examples/social-content/SKILL.md +278 -0
- package/skills/examples/social-content/evals/evals.json +92 -0
- package/skills/examples/social-content/references/platforms.md +170 -0
- package/skills/examples/social-content/references/post-templates.md +177 -0
- package/skills/examples/social-content/references/reverse-engineering.md +195 -0
- package/skills/examples/theme-factory/SKILL.md +59 -0
- package/skills/examples/theme-factory/theme-showcase.pdf +0 -0
- package/skills/examples/theme-factory/themes/arctic-frost.md +19 -0
- package/skills/examples/theme-factory/themes/botanical-garden.md +19 -0
- package/skills/examples/theme-factory/themes/desert-rose.md +19 -0
- package/skills/examples/theme-factory/themes/forest-canopy.md +19 -0
- package/skills/examples/theme-factory/themes/golden-hour.md +19 -0
- package/skills/examples/theme-factory/themes/midnight-galaxy.md +19 -0
- package/skills/examples/theme-factory/themes/modern-minimalist.md +19 -0
- package/skills/examples/theme-factory/themes/ocean-depths.md +19 -0
- package/skills/examples/theme-factory/themes/sunset-boulevard.md +19 -0
- package/skills/examples/theme-factory/themes/tech-innovation.md +19 -0
- package/skills/examples/web-artifacts-builder/LICENSE.txt +202 -0
- package/skills/examples/web-artifacts-builder/SKILL.md +74 -0
- package/skills/examples/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/skills/examples/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/skills/examples/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/skills/examples/writing-skills/SKILL.md +655 -0
- package/skills/examples/writing-skills/anthropic-best-practices.md +1150 -0
- package/skills/examples/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/skills/examples/writing-skills/graphviz-conventions.dot +172 -0
- package/skills/examples/writing-skills/persuasion-principles.md +187 -0
- package/skills/examples/writing-skills/render-graphs.js +168 -0
- package/skills/examples/writing-skills/testing-skills-with-subagents.md +384 -0
- package/skills/public/describe-image/SKILL.md +105 -0
- package/skills/public/describe-image/scripts/describe.py +389 -0
- package/skills/public/doc-coauthoring/SKILL.md +375 -0
- package/skills/public/docx/LICENSE.txt +30 -0
- package/skills/public/docx/SKILL.md +199 -0
- package/skills/public/docx/docx-js.md +350 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/public/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/public/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/public/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/public/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/public/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/public/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/public/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/public/docx/ooxml/scripts/pack.py +159 -0
- package/skills/public/docx/ooxml/scripts/unpack.py +29 -0
- package/skills/public/docx/ooxml/scripts/validate.py +69 -0
- package/skills/public/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/public/docx/ooxml/scripts/validation/base.py +951 -0
- package/skills/public/docx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/public/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/public/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/public/docx/ooxml.md +632 -0
- package/skills/public/docx/scripts/__init__.py +1 -0
- package/skills/public/docx/scripts/document.py +1292 -0
- package/skills/public/docx/scripts/templates/comments.xml +3 -0
- package/skills/public/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/public/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/public/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/public/docx/scripts/templates/people.xml +3 -0
- package/skills/public/docx/scripts/utilities.py +374 -0
- package/skills/public/file-reading/LICENSE.txt +30 -0
- package/skills/public/file-reading/SKILL.md +350 -0
- package/skills/public/frontend-design/LICENSE.txt +177 -0
- package/skills/public/frontend-design/SKILL.md +42 -0
- package/skills/public/gitlab-explorer/SKILL.md +174 -0
- package/skills/public/gitlab-explorer/references/git-commands.md +323 -0
- package/skills/public/gitlab-explorer/references/glab-commands.md +282 -0
- package/skills/public/gitlab-explorer/scripts/check_gitlab_auth.sh +109 -0
- package/skills/public/pdf/FORMS.md +205 -0
- package/skills/public/pdf/REFERENCE.md +612 -0
- package/skills/public/pdf/SKILL.md +364 -0
- package/skills/public/pdf/scripts/check_bounding_boxes.py +70 -0
- package/skills/public/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/skills/public/pdf/scripts/check_fillable_fields.py +12 -0
- package/skills/public/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/skills/public/pdf/scripts/create_validation_image.py +41 -0
- package/skills/public/pdf/scripts/extract_form_field_info.py +152 -0
- package/skills/public/pdf/scripts/fill_fillable_fields.py +114 -0
- package/skills/public/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/skills/public/pdf-reading/LICENSE.txt +30 -0
- package/skills/public/pdf-reading/REFERENCE.md +196 -0
- package/skills/public/pdf-reading/SKILL.md +305 -0
- package/skills/public/playwright-cli/SKILL.md +278 -0
- package/skills/public/playwright-cli/references/request-mocking.md +87 -0
- package/skills/public/playwright-cli/references/running-code.md +232 -0
- package/skills/public/playwright-cli/references/session-management.md +169 -0
- package/skills/public/playwright-cli/references/storage-state.md +275 -0
- package/skills/public/playwright-cli/references/test-generation.md +88 -0
- package/skills/public/playwright-cli/references/tracing.md +139 -0
- package/skills/public/playwright-cli/references/video-recording.md +43 -0
- package/skills/public/pptx/LICENSE.txt +30 -0
- package/skills/public/pptx/SKILL.md +484 -0
- package/skills/public/pptx/css.md +335 -0
- package/skills/public/pptx/html2pptx.md +893 -0
- package/skills/public/pptx/html2pptx.tgz +0 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/public/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/public/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/public/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/public/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/public/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/public/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/public/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/public/pptx/ooxml/scripts/pack.py +159 -0
- package/skills/public/pptx/ooxml/scripts/unpack.py +29 -0
- package/skills/public/pptx/ooxml/scripts/validate.py +69 -0
- package/skills/public/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/public/pptx/ooxml/scripts/validation/base.py +951 -0
- package/skills/public/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/public/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/public/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/public/pptx/ooxml.md +427 -0
- package/skills/public/pptx/scripts/inventory.py +1020 -0
- package/skills/public/pptx/scripts/rearrange.py +231 -0
- package/skills/public/pptx/scripts/replace.py +385 -0
- package/skills/public/pptx/scripts/thumbnail.py +450 -0
- package/skills/public/skill-creator/SKILL.md +356 -0
- package/skills/public/skill-creator/references/output-patterns.md +82 -0
- package/skills/public/skill-creator/references/workflows.md +28 -0
- package/skills/public/skill-creator/scripts/init_skill.py +303 -0
- package/skills/public/skill-creator/scripts/package_skill.py +110 -0
- package/skills/public/skill-creator/scripts/quick_validate.py +95 -0
- package/skills/public/sub-agent/SKILL.md +186 -0
- package/skills/public/sub-agent/references/security-review.md +153 -0
- package/skills/public/sub-agent/references/usage.md +207 -0
- package/skills/public/sub-agent/scripts/list_subagent_models.sh +22 -0
- package/skills/public/test-driven-development/SKILL.md +371 -0
- package/skills/public/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/public/webapp-testing/LICENSE.txt +202 -0
- package/skills/public/webapp-testing/SKILL.md +96 -0
- package/skills/public/webapp-testing/examples/console_logging.py +35 -0
- package/skills/public/webapp-testing/examples/element_discovery.py +40 -0
- package/skills/public/webapp-testing/examples/static_html_automation.py +33 -0
- package/skills/public/webapp-testing/scripts/with_server.py +106 -0
- package/skills/public/xlsx/LICENSE.txt +30 -0
- package/skills/public/xlsx/SKILL.md +316 -0
- package/skills/public/xlsx/preview_data.py +93 -0
- package/skills/public/xlsx/recalc.py +178 -0
- package/tests/README.md +42 -0
- package/tests/fixtures/cli/claude_v0.9.2.0_argv.json +46 -0
- package/tests/fixtures/cli/claude_v0.9.2.0_stdout.json +32 -0
- package/tests/fixtures/cli/codex_run.jsonl +4 -0
- package/tests/fixtures/cli/opencode_run.jsonl +6 -0
- package/tests/integration/README.md +56 -0
- package/tests/integration/conftest.py +280 -0
- package/tests/integration/pytest.ini +13 -0
- package/tests/integration/test_mcp_auth.py +85 -0
- package/tests/integration/test_mcp_tools.py +101 -0
- package/tests/integration/test_workspace_lifecycle.py +125 -0
- package/tests/orchestrator/mock_llm_server.py +343 -0
- package/tests/orchestrator/test_cli_adapters.py +566 -0
- package/tests/orchestrator/test_cli_adapters_live.py +527 -0
- package/tests/orchestrator/test_cli_runtime.py +451 -0
- package/tests/orchestrator/test_docker_manager.py +302 -0
- package/tests/orchestrator/test_dynamic_instructions.py +69 -0
- package/tests/orchestrator/test_mcp_resources.py +140 -0
- package/tests/orchestrator/test_mcp_tools.py +224 -0
- package/tests/orchestrator/test_passthrough_isolation.py +201 -0
- package/tests/orchestrator/test_readme_in_container.py +76 -0
- package/tests/orchestrator/test_render_cache.py +84 -0
- package/tests/orchestrator/test_runtime_cli_endpoint.py +108 -0
- package/tests/orchestrator/test_single_user_mode.py +212 -0
- package/tests/orchestrator/test_startup_warnings.py +123 -0
- package/tests/orchestrator/test_sub_agent_dispatch.py +327 -0
- package/tests/orchestrator/test_subagent_claude_compat.py +367 -0
- package/tests/orchestrator/test_system_prompt_endpoint.py +191 -0
- package/tests/orchestrator/test_tool_descriptions.py +52 -0
- package/tests/orchestrator/test_view_image.py +201 -0
- package/tests/patches/conftest.py +30 -0
- package/tests/patches/fixtures/__init__.py +10 -0
- package/tests/patches/fixtures/middleware_v0.9.1.py +5057 -0
- package/tests/patches/fixtures/middleware_v0.9.2.py +5120 -0
- package/tests/patches/fixtures/retrieval_v0.9.1.py +2684 -0
- package/tests/patches/fixtures/retrieval_v0.9.2.py +2700 -0
- package/tests/patches/test_fix_attached_files_position.py +118 -0
- package/tests/patches/test_fix_large_tool_args.py +130 -0
- package/tests/patches/test_fix_large_tool_results.py +531 -0
- package/tests/patches/test_fix_skip_embedding_chat_files.py +160 -0
- package/tests/patches/test_fix_skip_rag_files_native_fc.py +120 -0
- package/tests/patches/test_fix_tool_loop_errors.py +128 -0
- package/tests/security/test_path_traversal_app.py +132 -0
- package/tests/security/test_path_traversal_docker.py +36 -0
- package/tests/security/test_path_traversal_settings.py +87 -0
- package/tests/security/test_safe_path_util.py +166 -0
- package/tests/security/test_xss_preview.py +46 -0
- package/tests/test-default-model-resolution.py +136 -0
- package/tests/test-docker-image.sh +358 -0
- package/tests/test-list-subagent-models.sh +421 -0
- package/tests/test-mcp-endpoint-live.sh +92 -0
- package/tests/test-mcp-native-surface.sh +213 -0
- package/tests/test-no-cyrillic.sh +135 -0
- package/tests/test-opencode-error-mapping.py +130 -0
- package/tests/test-pr88-skills.sh +305 -0
- package/tests/test-project-structure.sh +202 -0
- package/tests/test-single-user-mode.sh +269 -0
- package/tests/test-skill-no-hardcoded-models.sh +65 -0
- package/tests/test-subagent-cli-surface.py +137 -0
- package/tests/test-subagent-runtime.sh +109 -0
- package/tests/test_codex_toml_converter.py +204 -0
- package/tests/test_default_resolver_no_legacy_global.py +159 -0
- package/tests/test_filter.py +648 -0
- package/tests/test_init_sh_unchanged.sh +49 -0
- package/tests/test_opencode_alias_map_drop.py +144 -0
- package/tests/test_requirements.py +91 -0
- package/tests/test_subagent_docstring.py +193 -0
- package/tests/test_tools.py +34 -0
- package/vendor/extract-text/README.md +46 -0
- package/vendor/extract-text/extract-text +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"===typeof exports&&"undefined"!==typeof module?e(exports,require("chart.js/auto"),require("jszip")):"function"===typeof define&&define.amd?define(["exports","chart.js/auto","jszip"],e):(t="undefined"!==typeof globalThis?globalThis:t||self,e(t.PptxViewJS={},t.Chart,t.JSZip))}(this,function(t,e,r){"use strict";var o="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{};function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t["default"]:t}function i(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")?t["default"]:t}function n(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&1===Object.keys(t).length?t["default"]:t}function a(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){var r=false;try{r=this instanceof t}catch{}if(r)return Reflect.construct(e,arguments,this.constructor);return e.apply(this,arguments)};r.prototype=e.prototype}else r={};Object.defineProperty(r,"__esModule",{value:true});Object.keys(t).forEach(function(e){var o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,o.get?o:{enumerable:true,get:function(){return t[e]}})});return r}var l={};var c;function h(){if(c)return l;c=1;class Logger{constructor(t="Default"){this.category=t;this.logElement=null;this.logHistory=[]}init(){this.logElement=document.getElementById("log")}log(t,e,r,o=null){const s=(new Date).toISOString().split("T")[1].split(".")[0];const i={timestamp:s,level:t.toUpperCase(),category:e,message:r,data:o};this.logHistory.push(i);const n=`[${e}] ${r}`;const a=new Set(["PPTXSlideRenderer","PPTXProcessor","Thumbnail Debug"]);if(!a.has(e))t.toLowerCase();if(this.logElement){const i=o?` | ${JSON.stringify(o)}`:"";const n=`[${s}] [${t.toUpperCase()}] [${e}] ${r}${i}\n`;this.logElement.textContent+=n;this.logElement.scrollTop=this.logElement.scrollHeight}}debug(t,e,r=null){this.log("debug",t,e,r)}info(t,e,r=null){this.log("info",t,e,r)}warn(t,e,r=null){this.log("warn",t,e,r)}error(t,e,r=null){this.log("error",t,e,r)}trace(t,e,r=null){this.log("trace",t,e,r)}logError(t,e){let r="Unknown error";let o={};if(e&&"object"===typeof e){r=e.message||e.toString()||"Unknown error";o={stack:e.stack,name:e.name||"Error"}}else if("string"===typeof e)r=e;else r=String(e);this.log("error",t,r,o)}markTiming(t){if("undefined"!==typeof window&&window.getGlobalMonitor){const e=window.getGlobalMonitor();e.start(t,{category:this.category})}else if("undefined"!==typeof performance&&performance.mark)try{performance.mark(t)}catch(t){void 0}}measureTiming(t){if("undefined"!==typeof window&&window.getGlobalMonitor){const e=window.getGlobalMonitor();const r=e.end(t,{category:this.category});if(r)this.log("trace",this.category,`${t} completed in ${Math.round(r.duration)}ms`)}else if("undefined"!==typeof performance&&performance.mark)try{performance.measure(t);const e=performance.getEntriesByName(t,"measure");if(e.length>0){const r=Math.round(e[e.length-1].duration);this.log("trace",this.category,`${t} completed in ${r}ms`)}}catch(t){void 0}}}const t=new Logger;class e{constructor(){this.steps={1:{name:"ZIP Processing",progress:0},2:{name:"XML Parsing",progress:0},3:{name:"DOM Creation",progress:0},4:{name:"Canvas Rendering",progress:0}}}updateProgress(t,e){if(this.steps[t]){this.steps[t].progress=Math.min(100,Math.max(0,e));const r=document.getElementById(`progress${t}`);const o=document.getElementById(`step${t}`);if(r)r.style.width=`${this.steps[t].progress}%`;if(o){o.classList.remove("active","processing");if(e>=100)o.classList.add("active");else if(e>0)o.classList.add("processing")}}}reset(){for(const t in this.steps)this.updateProgress(parseInt(t),0)}}const r=new e;class o{static async readAsArrayBuffer(t,e={}){if(!t||!(t instanceof File||t instanceof Blob))throw new Error("Invalid file parameter: must be File or Blob instance");if(0===t.size)throw new Error("Cannot read empty file");const{maxSize:r=100*1024*1024,timeout:o=8e4}=e;if(t.size>r)throw new Error(`File too large: ${t.size} bytes (max: ${r} bytes)`);return new Promise((e,r)=>{const s=new window.FileReader;const i=setTimeout(()=>{s.abort();r(new Error(`File reading timed out after ${o}ms`))},o);s.onload=t=>{clearTimeout(i);const o=t.target?.result;if(o instanceof ArrayBuffer)e(o);else r(new Error("Failed to read file as ArrayBuffer"))};s.onerror=()=>{clearTimeout(i);const t=s.error||new Error("Unknown file reading error");r(new Error(`Failed to read file: ${t.message}`))};s.onabort=()=>{clearTimeout(i);r(new Error("File reading was aborted"))};try{s.readAsArrayBuffer(t)}catch(t){clearTimeout(i);r(new Error(`Failed to start file reading: ${t.message}`))}})}static async readAsText(t,e={}){if(!t||!(t instanceof File||t instanceof Blob))throw new Error("Invalid file parameter: must be File or Blob instance");const{encoding:r="UTF-8",maxSize:o=50*1024*1024,timeout:s=8e4,validateText:i=true}=e;if(t.size>o)throw new Error(`File too large: ${t.size} bytes (max: ${o} bytes)`);return new Promise((e,o)=>{const n=new window.FileReader;const a=setTimeout(()=>{n.abort();o(new Error(`File reading timed out after ${s}ms`))},s);n.onload=t=>{clearTimeout(a);const r=t.target?.result;if("string"===typeof r){if(i&&r.includes("�")){o(new Error("File contains invalid characters - may not be a text file"));return}e(r)}else o(new Error("Failed to read file as text"))};n.onerror=()=>{clearTimeout(a);const t=n.error||new Error("Unknown file reading error");o(new Error(`Failed to read file as text: ${t.message}`))};n.onabort=()=>{clearTimeout(a);o(new Error("File reading was aborted"))};try{n.readAsText(t,r)}catch(t){clearTimeout(a);o(new Error(`Failed to start file reading: ${t.message}`))}})}static async readAsDataURL(t,e={}){if(!t||!(t instanceof File||t instanceof Blob))throw new Error("Invalid file parameter: must be File or Blob instance");const{maxSize:r=10*1024*1024,timeout:o=8e4}=e;if(t.size>r)throw new Error(`File too large for Data URL: ${t.size} bytes (max: ${r} bytes)`);return new Promise((e,r)=>{const s=new window.FileReader;const i=setTimeout(()=>{s.abort();r(new Error(`File reading timed out after ${o}ms`))},o);s.onload=t=>{clearTimeout(i);const o=t.target?.result;if("string"===typeof o&&o.startsWith("data:"))e(o);else r(new Error("Failed to read file as Data URL"))};s.onerror=()=>{clearTimeout(i);const t=s.error||new Error("Unknown file reading error");r(new Error(`Failed to read file as Data URL: ${t.message}`))};s.onabort=()=>{clearTimeout(i);r(new Error("File reading was aborted"))};try{s.readAsDataURL(t)}catch(t){clearTimeout(i);r(new Error(`Failed to start file reading: ${t.message}`))}})}static async readMultipleFiles(t,e="arrayBuffer",r={}){if(!Array.isArray(t)||0===t.length)throw new Error("Invalid files parameter: must be non-empty array");const{onProgress:o=null,maxConcurrent:s=3,...i}=r;const n=this[`readAs${e.charAt(0).toUpperCase()+e.slice(1)}`];if(!n)throw new Error(`Invalid read type: ${e}`);const a=[];let l=0;for(let e=0;e<t.length;e+=s){const r=t.slice(e,e+s);const c=r.map(async(r,s)=>{try{const a=await n.call(this,r,i);l++;if(o)o({completed:l,total:t.length,progress:l/t.length*100,currentFile:r.name||`File ${e+s+1}`});return a}catch(i){l++;if(o)o({completed:l,total:t.length,progress:l/t.length*100,currentFile:r.name||`File ${e+s+1}`,error:i.message});throw i}});const h=await Promise.all(c);a.push(...h)}return a}}const s=o;class i{static ERROR_TYPES={VALIDATION:"ValidationError",FILE_IO:"FileIOError",PARSING:"ParsingError",RENDERING:"RenderingError",NETWORK:"NetworkError",TIMEOUT:"TimeoutError",MEMORY:"MemoryError",UNKNOWN:"UnknownError"};static SEVERITY_LEVELS={LOW:"low",MEDIUM:"medium",HIGH:"high",CRITICAL:"critical"};static handle(t,e={}){const{context:r="Unknown",severity:o=this.SEVERITY_LEVELS.MEDIUM,displayToUser:s=true,logToConsole:i=true,throwAfterHandle:n=false,customHandler:a=null}=e;const l=this.normalizeError(t,r);if(i)this.logError(l,o);if(s)this.displayError(l,o);if(a&&"function"===typeof a)try{a(l,o)}catch(t){void 0}if(n)throw t instanceof Error?t:new Error(l.message);return l}static normalizeError(t,e){let r="Unknown error occurred";let o=null;let s=this.ERROR_TYPES.UNKNOWN;const i=t;if(t instanceof Error){r=t.message||"Error occurred";o=t.stack;s=t.name||this.categorizeError(t)}else if("string"===typeof t)r=t;else if(t&&"object"===typeof t){r=t.message||t.toString()||"Object error";o=t.stack;s=t.name||this.ERROR_TYPES.UNKNOWN}else r=String(t);return{message:r,context:e,stack:o,name:s,timestamp:(new Date).toISOString(),originalError:i,userAgent:navigator?.userAgent||"Unknown"}}static categorizeError(t){const e=t.message?.toLowerCase()||"";if(e.includes("validation")||e.includes("invalid"))return this.ERROR_TYPES.VALIDATION;if(e.includes("file")||e.includes("read")||e.includes("write"))return this.ERROR_TYPES.FILE_IO;if(e.includes("parse")||e.includes("xml")||e.includes("json"))return this.ERROR_TYPES.PARSING;if(e.includes("render")||e.includes("canvas")||e.includes("draw"))return this.ERROR_TYPES.RENDERING;if(e.includes("network")||e.includes("fetch")||e.includes("load"))return this.ERROR_TYPES.NETWORK;if(e.includes("timeout")||e.includes("timed out"))return this.ERROR_TYPES.TIMEOUT;if(e.includes("memory")||e.includes("allocation"))return this.ERROR_TYPES.MEMORY;return this.ERROR_TYPES.UNKNOWN}static logError(t,e){const r=`[${t.context}] ${t.message}`;switch(e){case this.SEVERITY_LEVELS.LOW:case this.SEVERITY_LEVELS.MEDIUM:case this.SEVERITY_LEVELS.HIGH:void 0;break;case this.SEVERITY_LEVELS.CRITICAL:void 0;if(t.stack)void 0}}static displayError(t,e){const r=document.getElementById("output");if(!r)return;const o=document.createElement("div");o.className=`error error--${e}`;const s=document.createElement("div");s.className="error__header";s.innerHTML=`\n <span class="error__icon">${this.getSeverityIcon(e)}</span>\n <span class="error__title">Error in ${t.context}</span>\n <span class="error__type">${t.name}</span>\n `;const i=document.createElement("div");i.className="error__message";i.textContent=t.message;const n=document.createElement("div");n.className="error__time";n.textContent=new Date(t.timestamp).toLocaleTimeString();o.appendChild(s);o.appendChild(i);o.appendChild(n);const a=document.createElement("button");a.className="error__dismiss";a.innerHTML="×";a.onclick=()=>o.remove();o.appendChild(a);o.style.transform="translateY(-100%)";o.style.transition="transform 0.3s ease-in-out";r.insertBefore(o,r.firstChild);requestAnimationFrame(()=>{o.style.transform="translateY(0)"});const l=this.getAutoDismissTime(e);if(l>0)setTimeout(()=>{if(o.parentNode){o.style.transform="translateY(-100%)";setTimeout(()=>o.remove(),300)}},l)}static getSeverityIcon(t){switch(t){case this.SEVERITY_LEVELS.LOW:return"ℹ️";case this.SEVERITY_LEVELS.MEDIUM:return"⚠️";case this.SEVERITY_LEVELS.HIGH:return"❌";case this.SEVERITY_LEVELS.CRITICAL:return"💥";default:return"❓"}}static getAutoDismissTime(t){switch(t){case this.SEVERITY_LEVELS.LOW:return 3e3;case this.SEVERITY_LEVELS.MEDIUM:return 5e3;case this.SEVERITY_LEVELS.HIGH:return 8e3;case this.SEVERITY_LEVELS.CRITICAL:return 0;default:return 5e3}}static createError(t,e={}){const{name:r=this.ERROR_TYPES.UNKNOWN,context:o="Unknown",cause:s=null,code:i=null,details:n=null}=e;const a=new Error(t);a.name=r;a.context=o;a.timestamp=(new Date).toISOString();if(s)a.cause=s;if(i)a.code=i;if(n)a.details=n;return a}}class n{static UNITS={EMU_PER_INCH:914400,EMU_PER_CM:36e4,EMU_PER_MM:36e3,EMU_PER_POINT:12700,INCHES_PER_MM:1/25.4,MM_PER_INCH:25.4,POINTS_PER_INCH:72};static VALIDATION={MAX_EMU:2147483647,MIN_EMU:-2147483648,MAX_PIXELS:32767,MAX_MM:59652,MIN_DPI:1,MAX_DPI:600};static validateInput(t,e,r={}){if("number"!==typeof t||!isFinite(t))throw i.createError(`Invalid ${e} value: must be a finite number`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});const{min:o=-1/0,max:s=1/0}=r;if(t<o||t>s)throw i.createError(`${e} value out of range: ${t} (valid range: ${o} to ${s})`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});return t}static emuToMM(t){const e=this.validateInput(t,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU});return e/this.UNITS.EMU_PER_MM}static mmToEMU(t){const e=this.validateInput(t,"MM",{min:-this.VALIDATION.MAX_MM,max:this.VALIDATION.MAX_MM});const r=e*this.UNITS.EMU_PER_MM;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(r)))}static emuToPoints(t){const e=this.validateInput(t,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU});return e/this.UNITS.EMU_PER_POINT}static pointsToEMU(t){const e=this.validateInput(t,"Points",{min:-3e4,max:3e4});const r=e*this.UNITS.EMU_PER_POINT;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(r)))}static emuToPixels(t,e=96){const r=this.validateInput(t,"EMU",{min:this.VALIDATION.MIN_EMU,max:this.VALIDATION.MAX_EMU});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r/this.UNITS.EMU_PER_INCH;return Math.round(s*o)}static pixelsToEMU(t,e=96){const r=this.validateInput(t,"Pixels",{min:-this.VALIDATION.MAX_PIXELS,max:this.VALIDATION.MAX_PIXELS});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r/o;const i=s*this.UNITS.EMU_PER_INCH;return Math.max(this.VALIDATION.MIN_EMU,Math.min(this.VALIDATION.MAX_EMU,Math.round(i)))}static mmToPixels(t,e=96){const r=this.validateInput(t,"MM",{min:-this.VALIDATION.MAX_MM,max:this.VALIDATION.MAX_MM});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r*this.UNITS.INCHES_PER_MM;return Math.round(s*o)}static pixelsToMM(t,e=96){const r=this.validateInput(t,"Pixels",{min:-this.VALIDATION.MAX_PIXELS,max:this.VALIDATION.MAX_PIXELS});const o=this.validateInput(e,"DPI",{min:this.VALIDATION.MIN_DPI,max:this.VALIDATION.MAX_DPI});const s=r/o;return s*this.UNITS.MM_PER_INCH}static convert(t,e,r,o=96){if(e===r)return t;const s=e.toLowerCase();const n=r.toLowerCase();let a;switch(s){case"emu":a=t;break;case"mm":a=this.mmToEMU(t);break;case"pixels":case"px":a=this.pixelsToEMU(t,o);break;case"points":case"pt":a=this.pointsToEMU(t);break;case"inches":case"in":const r=this.validateInput(t,"Inches",{min:-100,max:100});a=Math.round(r*this.UNITS.EMU_PER_INCH);break;default:throw i.createError(`Unsupported source unit: ${e}`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"})}switch(n){case"emu":return a;case"mm":return this.emuToMM(a);case"pixels":case"px":return this.emuToPixels(a,o);case"points":case"pt":return this.emuToPoints(a);case"inches":case"in":return a/this.UNITS.EMU_PER_INCH;default:throw i.createError(`Unsupported target unit: ${r}`,{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"})}}static convertBatch(t,e,r,o=96){if(!Array.isArray(t))throw i.createError("Values must be an array",{name:i.ERROR_TYPES.VALIDATION,context:"CoordinateTransform"});return t.map(t=>this.convert(t,e,r,o))}static getConversionFactor(t,e,r=96){return this.convert(1,t,e,r)}}class a{static decodeXMLEntities(t){if(!t)return t;const e={"&":"&","<":"<",">":">",""":'"',"'":"'"};return t.replace(/&[a-zA-Z0-9#]+;/g,t=>e[t]||t)}static encodeXMLEntities(t){if(!t)return t;return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}static extractNamespace(t){const e=t.indexOf(":");return-1!==e?t.substring(0,e):""}static extractLocalName(t){const e=t.indexOf(":");return-1!==e?t.substring(e+1):t}}class h{static getAttributeValue(t,e){return t.getAttribute?t.getAttribute(e):null}static getChildElements(t){if(!t.children)return[];return Array.from(t.children)}static getElementByTagName(t,e){if(!t.getElementsByTagName)return null;const r=t.getElementsByTagName(e);return r.length>0?r[0]:null}static getElementsByTagName(t,e){if(!t.getElementsByTagName)return[];return Array.from(t.getElementsByTagName(e))}static getTextContent(t){return t.textContent||t.innerText||""}}class u{static easeInOut(t){return t<.5?2*t*t:-1+(4-2*t)*t}static animate(t,e,r=null){const o=performance.now();function s(i){const n=i-o;const a=Math.min(n/t,1);e(a);if(a<1)requestAnimationFrame(s);else if(r)r()}requestAnimationFrame(s)}}document.addEventListener("DOMContentLoaded",function(){t.init()});let f=null;if("undefined"!==typeof window)try{if(window.PerformanceMonitor){f=new window.PerformanceMonitor({enabled:true,collectMemoryData:true,enableConsoleReports:false,maxHistoryEntries:500});window.performanceMonitor=f}}catch(t){}class d extends Logger{constructor(t){super(t);this.performanceMonitor=f}startPerformance(t,e={}){if(this.performanceMonitor)this.performanceMonitor.start(t,{...e,category:this.category});this.markTiming(t)}endPerformance(t,e={}){if(this.performanceMonitor){const r=this.performanceMonitor.end(t,{...e,category:this.category});if(r){const e=Math.round(100*r.duration)/100;this.trace(this.category,`${t} completed in ${e}ms`,{duration:e,memoryUsage:r.memorySnapshot?.jsHeapSize});if(e>1e3)this.warn(this.category,`Slow operation detected: ${t} took ${e}ms`)}}this.measureTiming(t)}measureSync(t,e,r={}){if(this.performanceMonitor){const{result:o,measure:s}=this.performanceMonitor.measure(t,e,{...r,category:this.category});if(s){const e=Math.round(100*s.duration)/100;this.trace(this.category,`${t} completed in ${e}ms`)}return o}else{this.startPerformance(t,r);try{const o=e();this.endPerformance(t,r);return o}catch(e){this.endPerformance(t,{...r,error:true});throw e}}}async measureAsync(t,e,r={}){if(this.performanceMonitor){const{result:o,measure:s}=await this.performanceMonitor.measureAsync(t,e,{...r,category:this.category});if(s){const e=Math.round(100*s.duration)/100;this.trace(this.category,`${t} completed in ${e}ms`)}return o}else{this.startPerformance(t,r);try{const o=await e();this.endPerformance(t,r);return o}catch(e){this.endPerformance(t,{...r,error:true});throw e}}}getPerformanceStats(){if(!this.performanceMonitor)return null;const t=this.performanceMonitor.getHistory();const e=t.filter(t=>t.startMetadata?.category===this.category||t.endMetadata?.category===this.category);if(0===e.length)return{category:this.category,operations:0};const r=e.reduce((t,e)=>t+e.duration,0);const o=r/e.length;const s=e.reduce((t,e)=>e.duration>t.duration?e:t);const i=e.reduce((t,e)=>e.duration<t.duration?e:t);return{category:this.category,operations:e.length,totalDuration:Math.round(r),averageDuration:Math.round(100*o)/100,slowestOperation:{name:s.name,duration:Math.round(100*s.duration)/100},fastestOperation:{name:i.name,duration:Math.round(100*i.duration)/100}}}}const p=new d;if("undefined"!==typeof window){window.Logger=Logger;window.EnhancedLogger=d;window.ProgressTracker=e;window.FileReader=s;window.ErrorHandler=i;window.CoordinateTransform=n;window.StringUtils=a;window.DOMUtils=h;window.AnimationUtils=u;window.logger=t;window.enhancedLogger=p;window.progressTracker=r;if(f)window.performanceMonitor=f}return l}var u=h();var f=s(u);var d={exports:{}};var p=d.exports;var g;function m(){if(g)return d.exports;g=1;!function(t){class e{constructor(t={}){this.options=this._validateOptions(t);try{this.logger="undefined"!==typeof Logger?new Logger("ChartFontConfig"):this._createFallbackLogger()}catch(t){this.logger=this._createFallbackLogger()}this.initializeDefaults();this.initializeScaling()}initializeDefaults(){this.defaults={global:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false,color:{r:0,g:0,b:0}},title:{fontFamily:"Calibri",fontSize:18,bold:false,italic:false,color:{r:0,g:0,b:0}},subtitle:{fontFamily:"Calibri",fontSize:14,bold:false,italic:false,color:{r:100,g:100,b:100}},axisTitle:{fontFamily:"Calibri",fontSize:12,bold:true,italic:false,color:{r:68,g:68,b:68}},axisLabels:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false,color:{r:68,g:68,b:68}},legend:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false,color:{r:60,g:60,b:60}},dataLabels:{fontFamily:"Calibri",fontSize:9,bold:true,italic:false,color:{r:50,g:50,b:50}},tickMarks:{fontFamily:"Calibri",fontSize:10,bold:false,italic:false,color:{r:68,g:68,b:68}}}}initializeScaling(){this.scaling={enabled:false!==this.options.enableResponsiveScaling,baseDimensions:{width:400,height:300},scaleFactors:{min:.7,max:1.5},dpiSupport:{enabled:false!==this.options.enableDpiScaling,baseDpi:96,currentDpi:this._getCurrentDpi()}}}getFont(t,e={},r={},o={}){try{const s=this.defaults[t]||this.defaults.global;const i=this._applyPptxOverrides(s,e);const n=this._applyCustomOverrides(i,r);const a=this._applyScaling(n,o);const l=this._normalizeFontConfig(a);this.logger.log("debug",this.constructor.name,`Font resolved for ${t}:`,{base:s,pptx:e,custom:r,final:l});return l}catch(e){this.logger.logError(this.constructor.name,`Error resolving font for ${t}:`,e);return this._getFallbackFont()}}_applyPptxOverrides(t,e){const r={...t};if(!e||"object"!==typeof e)return r;if(e.fontFamily)r.fontFamily=e.fontFamily;else if(e.family)r.fontFamily=e.family;else if(e.typeface)r.fontFamily=e.typeface;if(void 0!==e.fontSize)r.fontSize=this._convertPptxFontSize(e.fontSize);else if(void 0!==e.size)r.fontSize=this._convertPptxFontSize(e.size);else if(void 0!==e.sz)r.fontSize=this._convertPptxFontSize(e.sz,"hundredths");if(void 0!==e.bold)r.bold=Boolean(e.bold);else if(void 0!==e.b)r.bold="0"!==e.b&&false!==e.b;if(void 0!==e.italic)r.italic=Boolean(e.italic);else if(void 0!==e.i)r.italic="0"!==e.i&&false!==e.i;if(e.color)r.color=this._normalizeColor(e.color);return r}_applyCustomOverrides(t,e){const r={...t};if(!e||"object"!==typeof e)return r;if(e.fontFamily)r.fontFamily=e.fontFamily;if(e.family)r.fontFamily=e.family;if(void 0!==e.fontSize)r.fontSize=Number(e.fontSize);else if(void 0!==e.size)r.fontSize=Number(e.size);if(void 0!==e.bold)r.bold=Boolean(e.bold);if(void 0!==e.italic)r.italic=Boolean(e.italic);if(e.color)r.color=this._normalizeColor(e.color);return r}_applyScaling(t,e){const r={...t};if(!this.scaling.enabled||!e.chartWidth||!e.chartHeight)return r;try{const o=e.chartWidth/this.scaling.baseDimensions.width;const s=e.chartHeight/this.scaling.baseDimensions.height;const i=(o+s)/2;const n=Math.max(this.scaling.scaleFactors.min,Math.min(this.scaling.scaleFactors.max,i));let a=1;if(this.scaling.dpiSupport.enabled&&e.dpi)a=e.dpi/this.scaling.dpiSupport.baseDpi;else if(this.scaling.dpiSupport.enabled)a=this.scaling.dpiSupport.currentDpi/this.scaling.dpiSupport.baseDpi;const l=t.fontSize||11;const c=Math.round(l*n*a);r.fontSize=Math.max(8,c);this.logger.log("debug",this.constructor.name,"Font scaling applied:",{original:l,dimensionScale:n,dpiScale:a,final:r.fontSize})}catch(t){this.logger.log("warn",this.constructor.name,"Error applying font scaling:",t)}return r}_convertPptxFontSize(t,e="points"){const r=Number(t);if(isNaN(r))return 11;switch(e){case"hundredths":return Math.max(6,Math.round(r/100));case"emu":return Math.max(6,Math.round(r/12700));default:return Math.max(6,Math.round(r))}}_normalizeColor(t){if(!t)return{r:0,g:0,b:0};if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b)return{r:Math.max(0,Math.min(255,Number(t.r))),g:Math.max(0,Math.min(255,Number(t.g))),b:Math.max(0,Math.min(255,Number(t.b)))};if("string"===typeof t&&t.startsWith("#")){const e=t.slice(1);if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}if("string"===typeof t&&t.startsWith("rgb")){const e=t.match(/\d+/g);if(e&&e.length>=3)return{r:Number(e[0]),g:Number(e[1]),b:Number(e[2])}}return{r:0,g:0,b:0}}_normalizeFontConfig(t){return{fontFamily:t.fontFamily||t.family||"Calibri",fontSize:Math.max(6,Math.min(120,Number(t.fontSize||t.size||11))),bold:Boolean(t.bold),italic:Boolean(t.italic),color:this._normalizeColor(t.color)}}_getFallbackFont(){return{fontFamily:"Arial, sans-serif",fontSize:11,bold:false,italic:false,color:{r:0,g:0,b:0}}}_getCurrentDpi(){try{const t="undefined"!==typeof window&&window.devicePixelRatio||1;return 96*t}catch(t){return 96}}_createFallbackLogger(){return{debug:(...t)=>{},info:(...t)=>{},warn:(...t)=>{},error:(...t)=>{}}}_validateOptions(t){return{enableResponsiveScaling:false!==t.enableResponsiveScaling,enableDpiScaling:false!==t.enableDpiScaling,enablePptxOverrides:false!==t.enablePptxOverrides,logLevel:t.logLevel||"warn",...t}}setElementDefault(t,e){if(this.defaults[t]){this.defaults[t]={...this.defaults[t],...this._normalizeFontConfig(e)};this.logger.log("info",this.constructor.name,`Updated default font for ${t}`)}else this.logger.log("warn",this.constructor.name,`Unknown element type: ${t}`)}getElementTypes(){return Object.keys(this.defaults)}toCssString(t){const e=this._normalizeFontConfig(t);const r=e.italic?"italic ":"";const o=e.bold?"bold ":"";return`${r}${o}${e.fontSize}px ${e.fontFamily}`}toColorString(t){const e=this._normalizeColor(t.color);return`rgb(${e.r}, ${e.g}, ${e.b})`}}if("undefined"!==typeof window)window.ChartFontConfig=e;if("object"!=="undefined"&&t.exports)t.exports={ChartFontConfig:e}}(d);return d.exports}var y=m();var b=s(y);var x={};var S;function w(){if(S)return x;S=1;async function t(){if("undefined"!==typeof window&&window.JSZip&&"function"===typeof window.JSZip.loadAsync)return window.JSZip;if("undefined"!==typeof globalThis&&globalThis.JSZip&&"function"===typeof globalThis.JSZip.loadAsync)return globalThis.JSZip;try{const t=require("jszip");if(t&&"function"===typeof t.loadAsync)return t;if(t&&t.default&&"function"===typeof t.default.loadAsync)return t.default}catch(t){}if("undefined"!==typeof document){await new Promise((t,e)=>{const r=document.createElement("script");r.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js";r.onload=()=>t();r.onerror=()=>e(new Error("Failed to load JSZip"));document.head.appendChild(r)});if(window.JSZip)return window.JSZip}throw new Error("JSZip is not available")}class ZLib{constructor(){this.engine=null;this.files={};this.isModuleInit=true;if("undefined"!==typeof Logger)this.logger=new Logger("ZLib");else if("undefined"!==typeof window&&window.Logger)this.logger=new window.Logger("ZLib");else if("undefined"!==typeof globalThis&&globalThis.Logger)this.logger=new globalThis.Logger("ZLib");else this.logger={info:()=>{},debug:()=>{},warn:()=>{},error:()=>{},log:()=>{},logError:()=>{}};this.isOpen=false;this.lastError=null}validateInput(t,e){if(null===t||void 0===t){this.lastError=new Error(`${e}: Input data is null or undefined`);return false}if(!(t instanceof ArrayBuffer)&&!(t instanceof Uint8Array)&&!(t instanceof Blob)){this.lastError=new Error(`${e}: Invalid data type. Expected ArrayBuffer, Uint8Array, or Blob`);return false}if(0===t.byteLength||void 0!==t.size&&0===t.size){this.lastError=new Error(`${e}: Input data is empty`);return false}return true}async open(e){try{this.isOpen=false;this.lastError=null;if(!this.validateInput(e,"open")){this.logger.logError("ZLib","Failed to open ZIP:",this.lastError.message);return false}const JSZip=await t();let r=e;if(e instanceof Uint8Array)r=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);this.engine=await JSZip.loadAsync(r);if(!this.engine){this.lastError=new Error("Failed to create JSZip instance");this.logger.logError("ZLib","Failed to open ZIP:",this.lastError.message);return false}this.files={};let o=0;this.engine.forEach((t,e)=>{if(!e.dir){this.files[t]=null;o++}});if(0===o){this.lastError=new Error("ZIP file contains no readable files");this.logger.log("warn","ZLib","Opened ZIP file has no readable files")}this.isOpen=true;return true}catch(t){this.lastError=t;this.isOpen=false;this.logger.logError("ZLib","Failed to open ZIP:",t.message);if(t.message.includes("End of central directory not found"))this.logger.logError("ZLib","Invalid ZIP file: corrupted or not a ZIP file");else if(t.message.includes("encrypted"))this.logger.logError("ZLib","Cannot open encrypted ZIP files");else if(t.message.includes("Unsupported compression"))this.logger.logError("ZLib","ZIP file uses unsupported compression method");return false}}validatePath(t,e){if("string"!==typeof t){this.lastError=new Error(`${e}: Path must be a string`);return false}if(0===t.length){this.lastError=new Error(`${e}: Path cannot be empty`);return false}if(t.includes("..")||t.includes("//")){this.lastError=new Error(`${e}: Invalid path contains dangerous patterns`);return false}return true}checkReady(t){if(!this.isOpen||!this.engine){this.lastError=new Error(`${t}: ZIP archive is not open`);return false}return true}async getFile(t){try{if(!this.checkReady("getFile")){this.logger.logError("ZLib","Cannot get file:",this.lastError.message);return null}if(!this.validatePath(t,"getFile")){this.logger.logError("ZLib","Invalid file path:",this.lastError.message);return null}let e=this.engine.file(t);if(!e&&t.startsWith("/"))e=this.engine.file(t.substring(1));if(!e){this.logger.log("warn","ZLib",`File not found in ZIP: ${t}`);return null}const r=await e.async("arraybuffer");if(!r||0===r.byteLength){this.logger.log("warn","ZLib",`File is empty: ${t}`);return new Uint8Array(0)}return new Uint8Array(r)}catch(e){this.lastError=e;this.logger.logError("ZLib",`Failed to get file ${t}:`,e.message);return null}}async getFileText(t){try{if(!this.checkReady("getFileText")){this.logger.logError("ZLib","Cannot get file text:",this.lastError.message);return null}if(!this.validatePath(t,"getFileText")){this.logger.logError("ZLib","Invalid file path:",this.lastError.message);return null}let e=this.engine.file(t);if(!e&&t.startsWith("/"))e=this.engine.file(t.substring(1));if(!e){this.logger.log("warn","ZLib",`File not found in ZIP: ${t}`);return null}const r=await e.async("text");if("string"!==typeof r){this.logger.log("warn","ZLib",`File ${t} did not return valid text content`);return null}return r}catch(e){this.lastError=e;this.logger.logError("ZLib",`Failed to get file text ${t}:`,e.message);if(e.message.includes("binary"))this.logger.logError("ZLib",`File ${t} appears to be binary, cannot read as text`);else if(e.message.includes("encoding"))this.logger.logError("ZLib",`File ${t} has encoding issues`);return null}}getPaths(){try{if(!this.checkReady("getPaths")){this.logger.logError("ZLib","Cannot get paths:",this.lastError.message);return[]}const t=this.engine&&this.engine.files?Object.keys(this.engine.files):Object.keys(this.files);return t}catch(t){this.lastError=t;this.logger.logError("ZLib","Failed to get file paths:",t.message);return[]}}fileExists(t){try{if(!this.validatePath(t,"fileExists"))return false;if(!this.checkReady("fileExists"))return false;return this.files.hasOwnProperty(t)}catch(e){this.lastError=e;this.logger.logError("ZLib",`Error checking file existence for ${t}:`,e.message);return false}}getFileSize(t){try{if(!this.validatePath(t,"getFileSize"))return-1;if(!this.checkReady("getFileSize"))return-1;const e=this.engine.file(t);if(!e)return-1;return e._data?e._data.uncompressedSize:0}catch(e){this.lastError=e;this.logger.logError("ZLib",`Error getting file size for ${t}:`,e.message);return-1}}getLastError(){return this.lastError}close(){try{if(this.engine)this.engine=null;this.files={};this.isOpen=false;this.lastError=null}catch(t){this.logger.logError("ZLib","Error during ZIP cleanup:",t.message)}}async getFileData(t){try{if(!this.checkReady("getFileData"))throw this.lastError;if(!this.validatePath(t,"getFileData"))throw this.lastError;const e=t.startsWith("/")?t.substring(1):t;const r=this.engine.file(e);if(!r)throw new Error(`File not found: ${t}`);const o=await r.async("arraybuffer");if(!o)throw new Error(`Failed to read file data: ${t}`);return o}catch(e){this.lastError=e;this.logger.logError("ZLib",`Failed to get file data for ${t}:`,e.message);throw new Error(`Failed to extract file data: ${t} - ${e.message}`)}}getStats(){try{if(!this.checkReady("getStats"))return{isOpen:false,fileCount:0,totalSize:0,error:this.lastError?.message};const t=Object.keys(this.files);let e=0;t.forEach(t=>{const r=this.getFileSize(t);if(r>0)e+=r});return{isOpen:this.isOpen,fileCount:t.length,totalSize:e,files:t,lastError:this.lastError?.message||null}}catch(t){this.lastError=t;this.logger.logError("ZLib","Error getting archive stats:",t.message);return{isOpen:false,fileCount:0,totalSize:0,error:t.message}}}}class OpenXmlPackage{constructor(t){this.zip=t;this.parts={};this.contentTypes={};this.relationships={}}async initialize(){const t=await this.zip.getFileText("[Content_Types].xml");if(t)this.parseContentTypes(t);const e=await this.zip.getFileText("_rels/.rels");if(e)this.relationships[""]=this.parseRelationships(e);const r=this.zip.getPaths();for(const t of r)if(t.startsWith("_rels/")&&t.endsWith(".rels")&&"_rels/.rels"!==t){const e=t.match(/^(.+)\/_rels\/(.+)\.rels$/);if(e){const r=e[1];const o=e[2];const s=`/${r}/${o}`;const i=await this.zip.getFileText(t);if(i)this.relationships[s]=this.parseRelationships(i)}}for(const t of r)if(!t.startsWith("_rels/")&&"[Content_Types].xml"!==t){const e=`/${t}`;const r=this.getContentType(e);this.parts[e]=new OpenXmlPart(this,e,r)}}parseContentTypes(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");const o=t=>{const e=r.getElementsByTagName("*");const o=[];for(let r=0;r<e.length;r++)if(e[r].localName===t)o.push(e[r]);return o};o("Default").forEach(t=>{const e=t.getAttribute("Extension");const r=t.getAttribute("ContentType");if(e&&r)this.contentTypes[`ext:${e}`]=r});o("Override").forEach(t=>{const e=t.getAttribute("PartName");const r=t.getAttribute("ContentType");if(e&&r)this.contentTypes[e]=r})}parseRelationships(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");const o={};const s=t=>{const e=r.getElementsByTagName("*");const o=[];for(let r=0;r<e.length;r++)if(e[r].localName===t)o.push(e[r]);return o};const i=s("Relationship");i.forEach(t=>{const e=t.getAttribute("Id");const r=t.getAttribute("Type");const s=t.getAttribute("Target");if(!e)return;o[e]={type:r,target:s,targetMode:t.getAttribute("TargetMode")||"Internal"}});return o}getContentType(t){if(this.contentTypes[t])return this.contentTypes[t];const e=t.split(".").pop();if(e&&this.contentTypes[`ext:${e}`])return this.contentTypes[`ext:${e}`];return"application/octet-stream"}getPartByRelationshipType(t){const e=this.relationships[""]||{};for(const r of Object.values(e))if(r.type===t){const t=r.target.startsWith("/")?r.target:`/${r.target}`;return this.parts[t]}return null}getPartByUri(t){return this.parts[t]}}class OpenXmlPart{constructor(t,e,r){this.package=t;this.uri=e;this.contentType=r;this._content=null}async getDocumentContent(){if(null===this._content){const t=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await this.package.zip.getFileText(t)}return this._content}async getRelationships(){if(this.package.relationships[this.uri])return this.package.relationships[this.uri];const t=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels");const e=t.startsWith("/")?t.substring(1):t;const r=await this.package.zip.getFileText(e);if(r)return this.package.parseRelationships(r);return{}}}const OpenXmlTypes={presentation:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},extendedFileProperties:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"},coreFileProperties:{relationType:"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"},customFileProperties:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"},presentationProperties:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"},slide:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"},slideLayout:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"},slideMaster:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"},theme:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"},image:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"}};if("undefined"!==typeof window){window.ZLib=ZLib;window.OpenXmlPackage=OpenXmlPackage;window.OpenXmlPart=OpenXmlPart;window.OpenXmlTypes=OpenXmlTypes}if("undefined"!==typeof globalThis){globalThis.ZLib=ZLib;globalThis.OpenXmlPackage=OpenXmlPackage;globalThis.OpenXmlPart=OpenXmlPart;globalThis.OpenXmlTypes=OpenXmlTypes}return x}var C=w();var T=s(C);var P={};var v;function M(){if(v)return P;v=1;class XmlParserContext{constructor(){this.zip=null;this.imageMap={};this.layoutsMap={};this.mastersMap={};this.tablesMap={};this.tableStylesMap={};this.smartarts=[];this.connectorsPr=[];this.slideLayoutRels=new Map;this.slideMasterRels=new Map;this.masterLayoutMap=new Map;this.themeMap={};this.colorMaps={};this.logger=new Logger("XmlParserContext")}registerSlideMaster(t,e){this.slideMasterRels.set(t,e);this.mastersMap[t]=e;if(!this.masterLayoutMap.has(t))this.masterLayoutMap.set(t,[])}registerSlideLayout(t,e,r){this.slideLayoutRels.set(t,e);this.layoutsMap[t]=e;if(r){e.masterId=r;if(!this.masterLayoutMap.has(r))this.masterLayoutMap.set(r,[]);this.masterLayoutMap.get(r).push(t)}}getSlideMaster(t){return this.slideMasterRels.get(t)}getSlideLayout(t){return this.slideLayoutRels.get(t)}getLayoutsForMaster(t){const e=this.masterLayoutMap.get(t)||[];return e.map(t=>this.getSlideLayout(t)).filter(Boolean)}loadDataLinks(){return this.imageMap}generateSmartArts(){return this.smartarts}}class StaxParser{constructor(t,e,r){this.xml=t;this.part=e;this.context=r;this.parser=new DOMParser;this.doc=null;this.currentElement=null;this.depth=0;this.namespaces={p:"http://schemas.openxmlformats.org/presentationml/2006/main",a:"http://schemas.openxmlformats.org/drawingml/2006/main",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships"};this.logger=new Logger("StaxParser")}parse(){try{this.doc=this.parser.parseFromString(this.xml,"text/xml");const t=this.doc.querySelector("parsererror");if(t)throw new Error("XML parsing failed: "+t.textContent);return this.doc}catch(t){return null}}parseSlideMaster(t){if(!this.doc)this.parse();const e=this.doc.documentElement;if(!e||"sldMaster"!==e.localName)return null;const r={id:t,type:"slideMaster",name:this.getAttributeValue(e,"name")||`Master ${t}`,preserve:"true"===this.getAttributeValue(e,"preserve"),cSld:this.parseCommonSlideData(e),clrMap:this.parseColorMap(e),txStyles:this.parseTextStyles(e),sldLayoutLst:[],themeId:this.extractThemeId(e),hf:this.parseHeaderFooter(e),timing:this.parseTiming(e),transition:this.parseTransition(e)};return r}parseSlideLayout(t,e){if(!this.doc)this.parse();const r=this.doc.documentElement;if(!r||"sldLayout"!==r.localName)return null;const o={id:t,masterId:e,type:"slideLayout",name:this.getAttributeValue(r,"name")||`Layout ${t}`,matchingName:this.getAttributeValue(r,"matchingName")||"",preserve:"true"===this.getAttributeValue(r,"preserve"),showMasterSp:"false"!==this.getAttributeValue(r,"showMasterSp"),showMasterPhAnim:"true"===this.getAttributeValue(r,"showMasterPhAnim"),userDrawn:"false"!==this.getAttributeValue(r,"userDrawn"),layoutType:this.getLayoutType(r),cSld:this.parseCommonSlideData(r),clrMapOvr:this.parseColorMapOverride(r),hf:this.parseHeaderFooter(r),timing:this.parseTiming(r),transition:this.parseTransition(r)};return o}parseCommonSlideData(t){const e=this.getChildElement(t,"cSld");if(!e)return{name:"",bg:null,spTree:[]};return{name:this.getAttributeValue(e,"name")||"",bg:this.parseBackground(e),spTree:this.parseShapeTree(e)}}parseShapeTree(t){const e=this.getChildElement(t,"spTree");if(!e)return[];const r=[];const o=e.children;for(let t=0;t<o.length;t++){const e=o[t];const s=this.parseShape(e);if(s)r.push(s)}return r}parseShape(t){const e=t.localName;switch(e){case"sp":return this.parseRegularShape(t);case"pic":return this.parsePictureShape(t);case"grpSp":return this.parseGroupShape(t);case"cxnSp":return this.parseConnectorShape(t);case"graphicFrame":return this.parseGraphicFrame(t);default:return null}}parseRegularShape(t){const e=this.parsePlaceholder(t);return{type:"sp",id:this.getAttributeValue(t,"id"),name:this.getShapeName(t),properties:this.parseShapeProperties(t),textBody:this.parseTextBody(t),style:this.parseShapeStyle(t),placeholder:e,isPlaceholder:!!e}}getLayoutType(t){const e=this.getAttributeValue(t,"type");if(e)return e;const r=this.getChildElement(t,"cSld");if(r){const t=this.getChildElement(r,"spTree");if(t){const e=this.getPlaceholderTypes(t);return this.inferLayoutType(e)}}return"blank"}getPlaceholderTypes(t){const e=[];const r=t.children;for(let t=0;t<r.length;t++){const o=r[t];const s=this.parsePlaceholder(o);if(s)e.push(s.type)}return e}inferLayoutType(t){if(t.includes("title")&&t.includes("body"))return"titleAndContent";else if(t.includes("title"))return"titleOnly";else if(t.includes("body"))return"contentOnly";else if(0===t.length)return"blank";return"custom"}parsePlaceholder(t){const e=this.getChildElement(t,"nvSpPr")||this.getChildElement(t,"nvPicPr")||this.getChildElement(t,"nvGrpSpPr");if(!e)return null;const r=this.getChildElement(e,"nvPr");if(!r)return null;const o=this.getChildElement(r,"ph");if(!o)return null;const s=this.getAttributeValue(o,"idx");const i=null===s||void 0===s?void 0:isNaN(parseInt(s,10))?void 0:parseInt(s,10);return{type:this.getAttributeValue(o,"type")||"obj",idx:i,orient:this.getAttributeValue(o,"orient"),sz:this.getAttributeValue(o,"sz")}}parseTextStyles(t){const e=this.getChildElement(t,"txStyles");if(!e)return null;return{titleStyle:this.parseTextStyle(this.getChildElement(e,"titleStyle")),bodyStyle:this.parseTextStyle(this.getChildElement(e,"bodyStyle")),otherStyle:this.parseTextStyle(this.getChildElement(e,"otherStyle"))}}parseTextStyle(t){if(!t)return null;return{element:t,parsed:false}}parseColorMap(t){const e=this.getChildElement(t,"clrMap");if(!e)return null;const r={};const o=e.attributes;for(let t=0;t<o.length;t++){const e=o[t];r[e.name]=e.value}return r}parseColorMapOverride(t){const e=this.getChildElement(t,"clrMapOvr");if(!e)return null;const r=this.getChildElement(e,"masterClrMapping");if(r)return this.parseColorMap(r);const o=this.getChildElement(e,"overrideClrMapping");if(o)return this.parseColorMap(o);return null}parseBackground(t){const e=this.getChildElement(t,"bg");if(!e)return null;const r=this.getChildElement(e,"bgPr");if(r)return{type:"bgPr",fill:this.parseFill(r)};const o=this.getChildElement(e,"bgRef");if(o)return{type:"bgRef",idx:this.getAttributeValue(o,"idx")};return null}getChildElement(t,e){if(!t)return null;for(const r of Object.keys(this.namespaces)){const o=t.querySelector(`${r}\\:${e}, ${e}`);if(o)return o}return t.querySelector(e)}getAttributeValue(t,e){return t?t.getAttribute(e):null}getTextContent(t){return t?t.textContent:""}getElementsByTagName(t){if(!this.doc)this.parse();return this.doc?this.doc.getElementsByTagName(t):[]}getElementsByTagNameNS(t,e){if(!this.doc)this.parse();return this.doc?this.doc.getElementsByTagNameNS(t,e):[]}parseShapeProperties(t){return{}}parseTextBody(t){return null}parseShapeStyle(t){return null}getShapeName(t){const e=t.querySelector("cNvPr")||t.querySelector("p\\:cNvPr")||t.querySelector('[*|localName="cNvPr"]');if(e)return e.getAttribute("name")||"";return""}parsePictureShape(t){const e=this.parsePlaceholder(t);const r={type:"pic",id:this.getAttributeValue(t,"id"),name:this.getShapeName(t),properties:this.parseShapeProperties(t),style:this.parseShapeStyle(t),placeholder:e,isPlaceholder:!!e};const o=t.querySelector("blipFill, p\\:blipFill");if(o){const t=o.querySelector("blip, a\\:blip");if(t){const e=this.extractSVGRelationshipId(t);if(e){r.imageRelId=e;r.hasSVGAlternative=true}else{const e=t.getAttribute("r:embed")||t.getAttribute("r:id");if(e)r.imageRelId=e}const s=t.querySelector("effectLst, a\\:effectLst");if(s)r.imageEffects=this.parseImageEffects(s);const i=o.getAttribute("dpi")||o.getAttribute("rotWithShape");if(i)r.imageFillMode=i}}r.transform=this.parseTransform(t);return r}extractSVGRelationshipId(t){try{const e=t.querySelector('extLst, a\\:extLst, [*|localName="extLst"]');if(!e)return null;const r=e.querySelectorAll('ext, a\\:ext, [*|localName="ext"]');for(const t of r){const e=t.getAttribute("uri");if("{96DAC541-7B7A-43D3-8B79-37D633B846F1}"===e){const e=t.querySelector('svgBlip, asvg\\:svgBlip, [*|localName="svgBlip"]');if(e){const t=e.getAttribute("r:embed")||e.getAttribute("r:id");if(t)return t}}}return null}catch(t){return null}}parseGroupShape(t){return{type:"grpSp"}}parseConnectorShape(t){return{type:"cxnSp"}}parseGraphicFrame(t){const e={type:"graphicFrame",name:this.getShapeName(t),position:this.parseTransform(t)};const r=t.querySelector("graphic")||t.querySelector("a\\:graphic")||t.querySelector('[*|localName="graphic"]');if(r){const o=r.querySelector("graphicData")||r.querySelector("a\\:graphicData")||r.querySelector('[*|localName="graphicData"]');if(o){const r=o.getAttribute("uri");e.graphicData={uri:r};if("http://schemas.openxmlformats.org/drawingml/2006/table"===r){const t=o.querySelector("tbl");if(t)e.graphicData.tableXml=(new XMLSerializer).serializeToString(t)}else if("http://schemas.openxmlformats.org/drawingml/2006/chart"===r){e.graphicData.element=o;const r=o.querySelector("chart, c\\:chart");if(r){const t=r.getAttribute("r:id");if(t)e.graphicData.chartRef=t}if(window.ChartProcessor)try{const r=new ChartProcessor(this.context);r.parseChartFromGraphicFrame(t).then(t=>{if(t){e.chartData=t;if(window.currentProcessor&&window.currentProcessor.reRenderShape)window.currentProcessor.reRenderShape(e)}else{const t=r.parseEmbeddedChartData(o);if(t)e.chartData=t}}).catch(t=>{try{const t=r.parseEmbeddedChartData(o);if(t)e.chartData=t}catch(t){}})}catch(t){}else{e.graphicData.isChart=true;e.graphicData.chartXml=(new XMLSerializer).serializeToString(o)}}}}return e}parseHeaderFooter(t){return null}parseTiming(t){return null}parseTransition(t){return null}extractThemeId(t){return null}parseFill(t){return null}parseImageEffects(t){return null}parseTransform(t){const e=t.querySelector("xfrm")||t.querySelector("p\\:xfrm")||t.querySelector('[*|localName="xfrm"]');if(!e)return{x:0,y:0,width:0,height:0};const r=e.querySelector("off")||e.querySelector("a\\:off")||e.querySelector('[*|localName="off"]');let o=0,s=0;if(r){o=parseInt(r.getAttribute("x")||"0",10);s=parseInt(r.getAttribute("y")||"0",10)}const i=e.querySelector("ext")||e.querySelector("a\\:ext")||e.querySelector('[*|localName="ext"]');let n=0,a=0;if(i){n=parseInt(i.getAttribute("cx")||"0",10);a=parseInt(i.getAttribute("cy")||"0",10)}return{x:o,y:s,width:n,height:a}}parseSlide(t){try{const slide={shapes:[],background:null,name:"",id:null};const e=t.getAttribute("id");if(e)slide.id=e;const r=this.getChildElement(t,"cSld");if(r){const t=r.getAttribute("name");if(t)slide.name=t;slide.background=this.parseBackground(r);slide.shapes=this.parseShapeTree(r)}return slide}catch(t){return{shapes:[],background:null,name:"",id:null}}}}if("undefined"!==typeof window){window.XmlParserContext=XmlParserContext;window.StaxParser=StaxParser}if("undefined"!==typeof globalThis){globalThis.XmlParserContext=XmlParserContext;globalThis.StaxParser=StaxParser}return P}var A=M();var E=s(A);var _={};var F;function R(){if(F)return _;F=1;class CPresentation{constructor(){this.type="CPresentation";this.id=Math.random().toString(36).substr(2,9);this.slides=[];this.slideMasters=[];this.notesMasters=[];this.slideSize={cx:9144e3,cy:6858e3};this.currentSlide=0;this.app=null;this.core=null;this.customProperties=null;this.masterIds=[];this.theme=null}getSlidesCount(){return this.slides.length}getCurrentSlide(){return this.slides[this.currentSlide]||null}getSlide(t){return this.slides[t]||null}addSlide(slide){this.slides.push(slide);slide.setParent(this)}setCurrentSlide(t){if(t>=0&&t<this.slides.length)this.currentSlide=t}getSlideDimensions(){return{width:CoordinateTransform.emuToMM(this.slideSize.cx),height:CoordinateTransform.emuToMM(this.slideSize.cy)}}addSlideMaster(t){this.slideMasters.push(t);t.setParent(this)}draw(t){const e=this.getCurrentSlide();if(e)e.draw(t)}}class CSlide{constructor(){this.id=Math.random().toString(36).substr(2,9);this.commonSlideData=new t;this.layout=null;this.notes=null;this.timing=null;this.transition=null;this.showMasterShapes=true;this.width=254;this.height=190.5;this.parent=null;this.bounds={l:0,t:0,r:254,b:190.5};this.backgroundFill=null}setParent(t){this.parent=t}getName(){return this.commonSlideData?this.commonSlideData.name:""}getShapeTree(){return this.commonSlideData?this.commonSlideData.shapeTree:[]}addToSpTree(e,r){if(!this.commonSlideData)this.commonSlideData=new t;if(void 0===e||null===e)e=this.commonSlideData.shapeTree.length;this.commonSlideData.shapeTree.splice(e,0,r);r.setParent(this)}removeFromSpTree(t){if(t>=0&&t<this.commonSlideData.shapeTree.length)return this.commonSlideData.shapeTree.splice(t,1)[0];return null}getBackground(){return this.backgroundFill||this.commonSlideData?.background}draw(t){if(!t)return;this.drawBackground(t);if(this.showMasterShapes&&this.layout&&this.layout.master)this.drawMasterElements(t);if(this.layout)this.drawLayoutElements(t);this.drawShapeTree(t)}drawBackground(t){}drawGradientBackground(t,e){const r=e.colors&&e.colors[0]?e.colors[0]:{r:255,g:255,b:255};t.fillRect(0,0,this.width,this.height,r)}drawImageBackground(t,e){t.fillRect(0,0,this.width,this.height,{r:240,g:240,b:240})}drawMasterElements(t){if(this.layout&&this.layout.master&&this.layout.master.commonSlideData){const e=this.layout.master.commonSlideData.shapeTree;for(const r of e)if(!r.isPlaceholder)this.drawShape(t,r)}}drawLayoutElements(t){if(this.layout&&this.layout.commonSlideData){const e=this.layout.commonSlideData.shapeTree;for(const r of e)if(!r.isPlaceholder)this.drawShape(t,r)}}drawShapeTree(t){const e=this.getShapeTree();for(let r=0;r<e.length;r++){const o=e[r];if(o&&!o.isHidden)this.drawShape(t,o)}}drawShape(t,e){if(!e||!e.properties)return;t.SaveGrState();try{if(e.properties.transform){const r=this.createShapeTransformMatrix(e.properties.transform);t.transform3(r)}if("grpSp"===e.type||e.isGroup?.())this.drawGroupShape(t,e);else this.drawSingleShape(t,e)}finally{t.RestoreGrState()}}drawGroupShape(t,e){if(!e.shapeTree||0===e.shapeTree.length)return;t.SaveGrState();try{if(e.transform){if(e.transform.rotation&&0!==e.transform.rotation){const r=this.createRotationMatrix(e.transform.rotation);t.transform3(r)}if(e.transform.flipH||e.transform.flipV){const r=e.transform.flipH?-1:1;const o=e.transform.flipV?-1:1;const s=this.createScaleMatrix(r,o);t.transform3(s)}}if(e.groupCoordSystem){const r=this.createGroupCoordinateMatrix(e.groupCoordSystem);if(r)t.transform3(r)}for(const r of e.shapeTree)this.drawShape(t,r)}finally{t.RestoreGrState()}}createGroupCoordinateMatrix(t){if(!t)return null;let e=1,r=1;if(t.chExt.cx>0&&t.groupExt.cx>0)e=t.groupExt.cx/t.chExt.cx;if(t.chExt.cy>0&&t.groupExt.cy>0)r=t.groupExt.cy/t.chExt.cy;const o=t.groupOff.x-t.chOff.x*e;const s=t.groupOff.y-t.chOff.y*r;return{m11:e,m12:0,m21:0,m22:r,dx:o,dy:s}}createRotationMatrix(t){const e=t*Math.PI/180;const r=Math.cos(e);const o=Math.sin(e);return{m11:r,m12:o,m21:-o,m22:r,dx:0,dy:0}}createScaleMatrix(t,e){return{m11:t,m12:0,m21:0,m22:e,dx:0,dy:0}}drawSingleShape(t,e){const r=e.properties.transform;if(!r)return;const o=CoordinateTransform.emuToMM(r.x||0);const s=CoordinateTransform.emuToMM(r.y||0);const i=CoordinateTransform.emuToMM(r.width||0);const n=CoordinateTransform.emuToMM(r.height||0);const a=this.getShapeFillColor(e);const l=this.getShapeStrokeColor(e);const c=this.getShapeLineWidth(e);switch(e.type){case"sp":this.drawTextShape(t,e,o,s,i,n,a,l,c);break;case"pic":this.drawImageShape(t,e,o,s,i,n);break;case"cxnSp":this.drawConnectorShape(t,e,o,s,i,n,l,c);break;case"graphicFrame":this.drawGraphicFrame(t,e,o,s,i,n);break;default:this.drawDefaultShape(t,e,o,s,i,n,a,l,c)}}drawTextShape(t,e,r,o,s,i,n,a,l){const c=e.geometry||e.properties?.geometry;if(c&&c.preset)t.drawPresetGeometry(c.preset,r,o,s,i,n,a,l);else if(c&&c.pathLst)this.drawCustomGeometry(t,c,r,o,s,i,n,a,l);else{if(n)t.fillRect(r,o,s,i,n);if(a)t.strokeRect(r,o,s,i,a,l)}this.drawTextContent(t,e,r,o,s,i)}drawCustomGeometry(t,e,r,o,s,i,n,a,l){t.SaveGrState();const c=s/(e.pathW||s);const h=i/(e.pathH||i);t.context.translate(r,o);t.context.scale(c,h);if(e.pathLst)for(let r=0;r<e.pathLst.length;r++){const o=e.pathLst[r];let s=n;if("none"===o.fill||false===o.fill)s=null;else if(!Object.prototype.hasOwnProperty.call(o,"fill")&&a)s=null;this.drawGeometryPath(t,o,s,a,l)}t.RestoreGrState()}drawGeometryPath(t,e,r,o,s){if(!e.commands||0===e.commands.length)return;t._s();for(let o=0;o<e.commands.length;o++){const s=e.commands[o];switch(s.type){case"M":case"moveTo":t._m(s.x,s.y);break;case"L":case"lineTo":t._l(s.x,s.y);break;case"C":case"curveTo":t._c(s.x1,s.y1,s.x2,s.y2,s.x,s.y);break;case"Z":case"close":if(r&&"none"!==e.fill&&false!==e.fill)t._z();break;case"Q":case"quadTo":{const e=s.cpx+2*(s.x-s.cpx)/3;const r=s.cpy+2*(s.y-s.cpy)/3;t._c(s.cpx,s.cpy,e,r,s.x,s.y);break}case"A":case"arcTo":if(s.rx&&s.ry&&s.x&&s.y){const e=(t.context.lastX||0+s.x)/2;const r=(t.context.lastY||0+s.y)/2;t._c(e,r,e,r,s.x,s.y)}else t._l(s.x,s.y)}}if(o&&false!==e.stroke){t.p_color(o.r,o.g,o.b,o.a||255);t.p_width(s||1);t.ds()}if(r&&"none"!==e.fill&&false!==e.fill){t.b_color1(r.r,r.g,r.b,r.a||255);t.df()}t._e()}drawTextContent(t,e,r,o,s,i){if(!e.textBody||!e.textBody.paragraphs)return;let n=o+5;const a=i-10;const l=14;for(const s of e.textBody.paragraphs){if(n>o+a)break;let e=r+5;for(const r of s.runs)if(r.text&&n<=o+a){const o={fontSize:r.properties?.fontSize||18,fontFamily:r.properties?.fontFamily||"Arial",bold:r.properties?.bold||false,italic:r.properties?.italic||false,color:r.properties?.color||{r:0,g:0,b:0}};t.fillText(r.text,e,n,o);e+=r.text.length*(.6*o.fontSize)}n+=l}}drawImageShape(t,e,r,o,s,i){t.strokeRect(r,o,s,i,{r:160,g:160,b:160},1);if(e.imageData)t.drawImage(e.imageData,r,o,s,i)}drawConnectorShape(t,e,r,o,s,i,n,a){const l=r;const c=o;const h=r+s;const u=o+i;t.drawLine(l,c,h,u,n,a)}drawGraphicFrame(t,e,r,o,s,n){if(e.graphicData);if(e.asyncChartProcessing){t.strokeRect(r,o,s,n,{r:200,g:200,b:200},1);return}if(e.chartData)if(window.ChartRenderer){const i=new ChartRenderer(t);i.renderChart(e.chartData,r,o,s,n)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1);else if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===e.graphicData.uri)if(window.ChartProcessor){const i=new ChartProcessor;const a=i.parseEmbeddedChartData(e.graphicData);if(a){e.chartData=a;if(window.ChartRenderer){const e=new ChartRenderer(t);e.renderChart(a,r,o,s,n)}}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1);else if(e.table&&e.table instanceof i)e.table.draw(t,r,o,s,n);else if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri)try{const i=this.parseSimpleTable(e.graphicData.tableXml);if(i){e.table=i;i.draw(t,r,o,s,n)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}catch(e){t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}else t.strokeRect(r,o,s,n,{r:160,g:160,b:160},1)}parseSimpleTable(t){if(!t)return null;try{const e=new DOMParser;const r=e.parseFromString(t,"text/xml");if("parsererror"===r.documentElement.nodeName)return null;const o=new i;let s=r.querySelector("tblGrid");if(!s)s=r.querySelector("a\\:tblGrid");if(s){let t=s.querySelectorAll("gridCol");if(0===t.length)t=s.querySelectorAll("a\\:gridCol");const e=[];t.forEach(t=>{const r=t.getAttribute("w");e.push({width:r?parseInt(r):914400})});o.setTableGrid(e)}let l=r.querySelectorAll("tr");if(0===l.length)l=r.querySelectorAll("a\\:tr");l.forEach(t=>{const e=new n;let r=t.querySelector("trPr");if(!r)r=t.querySelector("a\\:trPr");if(r){let t=r.querySelector("trHeight");if(!t)t=r.querySelector("a\\:trHeight");if(t)e.height=parseInt(t.getAttribute("val"))||null}let s=t.querySelectorAll("tc");if(0===s.length)s=t.querySelectorAll("a\\:tc");s.forEach(t=>{const r=new a;let o=t.querySelector("tcPr");if(!o)o=t.querySelector("a\\:tcPr");if(o){let t=o.querySelector("gridSpan");if(!t)t=o.querySelector("a\\:gridSpan");if(t)r.gridSpan=parseInt(t.getAttribute("val"))||1;let e=o.querySelector("rowSpan");if(!e)e=o.querySelector("a\\:rowSpan");if(e)r.rowSpan=parseInt(e.getAttribute("val"))||1;let s=o.querySelector("solidFill");if(!s)s=o.querySelector("a\\:solidFill");if(s){let t=s.querySelector("srgbClr, schemeClr, scrgbClr");if(!t)t=s.querySelector("a\\:srgbClr, a\\:schemeClr, a\\:scrgbClr");if(t){const e=this.parseSimpleColor(t);if(e)r.fill={color:e}}}}const s=this.parseSimpleTextContent(t);if(s)r.setTextBody(s);e.addCell(r)});o.addRow(e)});return o}catch(t){return null}}parseSimpleColor(t){if(t.tagName.includes("srgbClr")){const e=t.getAttribute("val");if(e){const t=e.replace("#","");return{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255}}}return{r:200,g:200,b:200,a:255}}parseSimpleTextContent(t){const e=t.querySelectorAll("r, a\\:r");if(0===e.length)return null;const r={paragraphs:[],bodyProperties:{wrap:true,verticalAlign:"top"}};const o={runs:[],properties:{}};e.forEach(t=>{const e=t.querySelector("t, a\\:t");const r=e?e.textContent:"";if(r){const e=t.querySelector("rPr, a\\:rPr");const s={fontSize:12,fontFamily:"Arial",bold:false,italic:false,color:{r:0,g:0,b:0,a:255}};if(e){const t=e.getAttribute("sz");if(t)s.fontSize=parseInt(t)/100;const r=e.getAttribute("b");if("1"===r)s.bold=true;const o=e.querySelector("solidFill, a\\:solidFill");if(o){const t=o.querySelector("srgbClr, a\\:srgbClr");if(t){const e=t.getAttribute("val");if(e){const t=parseInt(e.substr(0,2),16);const r=parseInt(e.substr(2,2),16);const o=parseInt(e.substr(4,2),16);s.color={r:t,g:r,b:o,a:255}}}}}o.runs.push({text:r,properties:s})}});if(o.runs.length>0)r.paragraphs.push(o);return r.paragraphs.length>0?r:null}drawDefaultShape(t,e,r,o,s,i,n,a,l){if(n)t.fillRect(r,o,s,i,n);if(a)t.strokeRect(r,o,s,i,a,l)}getShapeFillColor(t){if(t.brush?.color)return t.brush.color;if(t.fill?.color)return t.fill.color;if(t.properties?.fill?.color)return t.properties.fill.color;return{r:200,g:200,b:200,a:255}}getShapeStrokeColor(t){if(null===t.pen||"none"===t.pen)return null;if(null===t.stroke||"none"===t.stroke)return null;if(null===t.properties?.stroke||"none"===t.properties?.stroke)return null;if(0===t.pen?.width)return null;if(0===t.stroke?.width)return null;if(0===t.properties?.stroke?.width)return null;if(t.pen?.color)return t.pen.color;if(t.stroke?.color)return t.stroke.color;if(t.properties?.stroke?.color)return t.properties.stroke.color;return null}getShapeLineWidth(t){if(null===t.pen||"none"===t.pen)return 0;if(null===t.stroke||"none"===t.stroke)return 0;if(null===t.properties?.stroke||"none"===t.properties?.stroke)return 0;if(void 0!==t.pen?.width)return CoordinateTransform.emuToMM(t.pen.width);if(void 0!==t.stroke?.width)return CoordinateTransform.emuToMM(t.stroke.width);if(void 0!==t.properties?.stroke?.width)return CoordinateTransform.emuToMM(t.properties.stroke.width);return 0}createShapeTransformMatrix(t){const e=new CMatrix;if(t.rotation){const r=t.rotation/6e4*Math.PI/180;const o=Math.cos(r);const s=Math.sin(r);e.sx=o;e.sy=o;e.shx=-s;e.shy=s}e.tx=CoordinateTransform.emuToMM(t.x||0);e.ty=CoordinateTransform.emuToMM(t.y||0);return e}}class t{constructor(){this.name="";this.shapeTree=[];this.background=null;this.colorMap=null;this.parent=null}setParent(t){this.parent=t}addToSpTree(t,e){if(void 0===t||null===t)t=this.shapeTree.length;this.shapeTree.splice(t,0,e);e.setParent(this)}removeFromSpTree(t){if(t>=0&&t<this.shapeTree.length)return this.shapeTree.splice(t,1)[0];return null}}class e{constructor(){this.id=Math.random().toString(36).substr(2,9);this.type="sp";this.properties={transform:{x:0,y:0,width:1e5,height:1e5,rotation:0}};this.geometry=null;this.textBody=null;this.fill=null;this.stroke=null;this.brush=null;this.pen=null;this.parent=null;this.isHidden=false;this.isPlaceholder=false;this.effects=null;this.bounds={l:0,t:0,r:0,b:0};this.transform=null;this.style=null;this.preservedStyle=null;this.nvSpPr=null;this.spPr=null;this.name=null;this.chartData=null;this.mediaInfo=null;this.svgContent=null;this.graphicData=null}setParent(t){this.parent=t}isGroup(){return"grpSp"===this.type}getObjectType(){switch(this.type){case"sp":return"shape";case"pic":return"image";case"grpSp":return"group";case"cxnSp":return"connector";case"graphicFrame":if(this.chartData)return"chart";if("http://schemas.openxmlformats.org/drawingml/2006/table"===this.graphicData?.uri)return"table";if("http://schemas.openxmlformats.org/drawingml/2006/chart"===this.graphicData?.uri)return"chart";return"graphic";default:return"unknown"}}setGeometry(t){this.geometry=t}setTextBody(t){this.textBody=t}setChartData(t){this.chartData=t}isChart(){return null!==this.chartData||"http://schemas.openxmlformats.org/drawingml/2006/chart"===this.graphicData?.uri}isTable(){return"http://schemas.openxmlformats.org/drawingml/2006/table"===this.graphicData?.uri}setMediaInfo(t){this.mediaInfo=t}setSvgContent(t){this.svgContent=t}recalculateBounds(){const t=this.properties.transform;if(t){this.bounds.l=CoordinateTransform.emuToMM(t.x);this.bounds.t=CoordinateTransform.emuToMM(t.y);this.bounds.r=this.bounds.l+CoordinateTransform.emuToMM(t.width);this.bounds.b=this.bounds.t+CoordinateTransform.emuToMM(t.height)}}draw(t){if(this.isHidden)return;this.recalculateBounds();switch(this.getObjectType()){case"group":this.drawGroupShape(t);break;case"image":this.drawImageShape(t);break;case"connector":this.drawConnectorShape(t);break;case"graphic":this.drawGraphicFrame(t);break;default:this.drawShape(t)}}drawShape(t){const e=this.bounds.l;const r=this.bounds.t;const o=this.bounds.r-this.bounds.l;const s=this.bounds.b-this.bounds.t;if(this.geometry&&this.geometry.preset)t.drawPresetGeometry(this.geometry.preset,e,r,o,s,this.getFillColor(),this.getStrokeColor(),this.getLineWidth());else{if(this.getFillColor())t.fillRect(e,r,o,s,this.getFillColor());if(this.getStrokeColor())t.strokeRect(e,r,o,s,this.getStrokeColor(),this.getLineWidth())}if(this.textBody)this.drawTextContent(t,e,r,o,s)}drawGroupShape(t){if(this.shapeTree){t.SaveGrState();if(this.transform)t.transform3(this.transform);for(const e of this.shapeTree)e.draw(t);t.RestoreGrState()}}drawImageShape(t){const e=this.bounds.l;const r=this.bounds.t;const o=this.bounds.r-this.bounds.l;const s=this.bounds.b-this.bounds.t;t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1)}drawConnectorShape(t){const e=this.bounds.l;const r=this.bounds.t;const o=this.bounds.r-this.bounds.l;const s=this.bounds.b-this.bounds.t;t.drawLine(e,r,e+o,r+s,this.getStrokeColor(),this.getLineWidth())}drawGraphicFrame(t){const e=this.bounds.l;const r=this.bounds.t;const o=this.bounds.r-this.bounds.l;const s=this.bounds.b-this.bounds.t;if(this.asyncChartProcessing){t.strokeRect(e,r,o,s,{r:200,g:200,b:200},1);return}if(this.chartData)if(window.ChartRenderer){const i=new ChartRenderer(t);i.renderChart(this.chartData,e,r,o,s)}else t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1);else if(this.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===this.graphicData.uri)if(window.ChartProcessor){const i=new ChartProcessor;const n=i.parseEmbeddedChartData(this.graphicData);if(n){this.chartData=n;if(window.ChartRenderer){const i=new ChartRenderer(t);i.renderChart(n,e,r,o,s)}}else t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1)}else t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1);else t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1)}drawTextContent(t,e,r,o,s){if(!this.textBody||!this.textBody.paragraphs)return;let i=r+5;for(const r of this.textBody.paragraphs)for(const o of r.runs)if(o.text){t.fillText(o.text,e+5,i,o.properties||{});i+=15}}getFillColor(){if(null===this.fill)return null;return this.fill?.color||this.brush?.color||null}getStrokeColor(){if(null===this.stroke)return null;return this.stroke?.color||this.pen?.color||{r:0,g:0,b:0}}getLineWidth(){const t=this.stroke?.width||this.pen?.width||12700;return CoordinateTransform.emuToMM(t)}}class r extends e{constructor(){super();this.type="grpSp";this.shapeTree=[];this.groupCoordSystem={chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}};this.transform={rotation:0,flipH:false,flipV:false,groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}}}addToSpTree(t,e){if(void 0===t||null===t)t=this.shapeTree.length;this.shapeTree.splice(t,0,e);if(e.setParent)e.setParent(this);e.inGroup=true;e.parentGroup=this;this.recalculateBounds()}removeFromSpTree(t){if(t>=0&&t<this.shapeTree.length){const e=this.shapeTree.splice(t,1)[0];if(e.setParent)e.setParent(null);e.inGroup=false;e.parentGroup=null;this.recalculateBounds();return e}return null}setGroupCoordSystem(t,e,r,o){this.groupCoordSystem={chOff:t||{x:0,y:0},chExt:e||{cx:0,cy:0},groupOff:r||{x:0,y:0},groupExt:o||{cx:0,cy:0}};this.transform.groupOff={...this.groupCoordSystem.groupOff};this.transform.groupExt={...this.groupCoordSystem.groupExt};this.transformChildShapes()}transformChildShapes(){if(!this.shapeTree||0===this.shapeTree.length)return;const t=this.groupCoordSystem;let e=1,r=1;if(t.chExt.cx>0&&t.groupExt.cx>0)e=t.groupExt.cx/t.chExt.cx;if(t.chExt.cy>0&&t.groupExt.cy>0)r=t.groupExt.cy/t.chExt.cy;for(const o of this.shapeTree)if(o.bounds){const s=o.bounds;if(!o.originalBounds)o.originalBounds={...s};const i={l:t.groupOff.x+(s.l-t.chOff.x)*e,t:t.groupOff.y+(s.t-t.chOff.y)*r,r:t.groupOff.x+(s.r-t.chOff.x)*e,b:t.groupOff.y+(s.b-t.chOff.y)*r};o.bounds=i;o.groupTransform={scaleX:e,scaleY:r,offsetX:t.groupOff.x-t.chOff.x*e,offsetY:t.groupOff.y-t.chOff.y*r}}}recalculateBounds(){if(0===this.shapeTree.length){super.recalculateBounds();return}let t=1/0,e=1/0;let r=-1/0,o=-1/0;let s=false;for(const i of this.shapeTree){if(i.recalculateBounds)i.recalculateBounds();if(i.bounds){t=Math.min(t,i.bounds.l);e=Math.min(e,i.bounds.t);r=Math.max(r,i.bounds.r);o=Math.max(o,i.bounds.b);s=true}}if(s){this.bounds.l=t;this.bounds.t=e;this.bounds.r=r;this.bounds.b=o}else{this.bounds.l=914400;this.bounds.t=914400;this.bounds.r=5486400;this.bounds.b=2743200}}draw(t){if(this.isHidden)return;this.recalculateBounds();t.SaveGrState();try{if(this.transform){if(this.transform.rotation&&0!==this.transform.rotation){const e=this.createRotationMatrix(this.transform.rotation);t.transform3(e)}if(this.transform.flipH||this.transform.flipV){const e=this.transform.flipH?-1:1;const r=this.transform.flipV?-1:1;const o=this.createScaleMatrix(e,r);t.transform3(o)}}if(this.groupCoordSystem){const e=this.createGroupCoordinateMatrix(this.groupCoordSystem);if(e)t.transform3(e)}for(const e of this.shapeTree)e.draw(t)}finally{t.RestoreGrState()}}createGroupCoordinateMatrix(t){if(!t)return null;let e=1,r=1;if(t.chExt.cx>0&&t.groupExt.cx>0)e=t.groupExt.cx/t.chExt.cx;if(t.chExt.cy>0&&t.groupExt.cy>0)r=t.groupExt.cy/t.chExt.cy;const o=t.groupOff.x-t.chOff.x*e;const s=t.groupOff.y-t.chOff.y*r;return{m11:e,m12:0,m21:0,m22:r,dx:o,dy:s}}createRotationMatrix(t){const e=t*Math.PI/180;const r=Math.cos(e);const o=Math.sin(e);return{m11:r,m12:o,m21:-o,m22:r,dx:0,dy:0}}createScaleMatrix(t,e){return{m11:t,m12:0,m21:0,m22:e,dx:0,dy:0}}getObjectType(){return"group"}isGroup(){return true}}class o{constructor(){this.id=Math.random().toString(36).substr(2,9);this.commonSlideData=new t;this.theme=null;this.layouts=[];this.parent=null}setParent(t){this.parent=t}addLayout(t){this.layouts.push(t);t.setMaster(this)}}class s{constructor(){this.id=Math.random().toString(36).substr(2,9);this.commonSlideData=new t;this.master=null;this.type="blank"}setMaster(t){this.master=t}}class i{constructor(){this.id=Math.random().toString(36).substr(2,9);this.type="table";this.rows=[];this.tableGrid=[];this.tableProperties=null;this.parent=null;this.firstRow=false;this.firstCol=false;this.lastRow=false;this.lastCol=false;this.bandRow=false;this.bandCol=false;this.tableStyleId=null;this.bounds={l:0,t:0,r:0,b:0}}setParent(t){this.parent=t}addRow(t){this.rows.push(t);t.setParent(this);t.rowIndex=this.rows.length-1}setTableGrid(t){this.tableGrid=t||[]}getTotalWidth(){return this.tableGrid.reduce((t,e)=>t+(e.width||0),0)}getRowCount(){return this.rows.length}getColumnCount(){const t=this.tableGrid.length;let e=0;for(const t of this.rows){const r=t.getCells().length;if(r>e)e=r}return Math.max(t,e)}getTableProperties(){return this.tableProperties||{}}getTableBorders(){return this.tableProperties?.borders||{}}getTableShading(){return this.tableProperties?.shading||{}}getTableGrid(){return this.tableGrid||[]}getCell(t,e){if(t>=0&&t<this.rows.length){const r=this.rows[t];if(e>=0&&e<r.cells.length)return r.cells[e]}return null}getRow(t){if(t>=0&&t<this.rows.length)return this.rows[t];return null}getRows(){return this.rows}recalculateBounds(){const t=this.getTotalWidth();const e=this.rows.reduce((t,e)=>t+(e.height||0),0);this.bounds.r=this.bounds.l+CoordinateTransform.emuToMM(t);this.bounds.b=this.bounds.t+CoordinateTransform.emuToMM(e)}draw(t,e,r,o,s){if(!this.rows||0===this.rows.length){t.strokeRect(e,r,o,s,{r:160,g:160,b:160},1);return}const i=this.getColumnCount();const n=this.getRowCount();const a=i>0?o/i:o;const l=n>0?s/n:s;let c=r;for(let r=0;r<this.rows.length;r++){const s=this.rows[r];const i=s.height?CoordinateTransform.emuToMM(s.height):l;s.draw(t,e,c,o,i,a,this.tableGrid);c+=i}}}class n{constructor(){this.id=Math.random().toString(36).substr(2,9);this.type="tableRow";this.cells=[];this.height=null;this.parent=null;this.rowIndex=0}setParent(t){this.parent=t}addCell(t){this.cells.push(t);t.setParent(this);t.cellIndex=this.cells.length-1}getCellCount(){return this.cells.length}draw(t,e,r,o,s,i,n){if(!this.cells||0===this.cells.length)return;let a=e;for(let e=0;e<this.cells.length;e++){const o=this.cells[e];let l=i;if(n&&n[e]&&n[e].width)l=CoordinateTransform.emuToMM(n[e].width);o.draw(t,a,r,l,s);a+=l}t.drawLine(e,r+s,e+o,r+s,{r:200,g:200,b:200},1)}getCell(t){return this.cells[t]||null}getCells(){return this.cells}}class a{constructor(){this.id=Math.random().toString(36).substr(2,9);this.type="tableCell";this.textBody=null;this.cellProperties=null;this.parent=null;this.cellIndex=0;this.gridSpan=1;this.rowSpan=1;this.fill=null;this.borders={top:null,right:null,bottom:null,left:null}}setParent(t){this.parent=t}setTextBody(t){this.textBody=t}draw(t,e,r,o,s){if(this.fill&&this.fill.color)t.fillRect(e,r,o,s,this.fill.color);if(this.textBody&&this.textBody.paragraphs)this.drawCellText(t,e,r,o,s)}drawCellText(t,e,r,o,s){if(!this.textBody||!this.textBody.paragraphs)return;let i=r+5;const n=s-10;const a=14;for(const o of this.textBody.paragraphs){if(i>r+n)break;let s=e+5;if(o.runs)for(const e of o.runs)if(e.text&&i<=r+n){const r={fontSize:e.properties?.fontSize||12,fontFamily:e.properties?.fontFamily||"Arial",bold:e.properties?.bold||false,italic:e.properties?.italic||false,color:e.properties?.color||{r:0,g:0,b:0}};t.fillText(e.text,s,i,r);s+=e.text.length*(.6*r.fontSize)}i+=a}}getGridSpan(){return this.gridSpan||1}getRowSpan(){return this.rowSpan||1}getCellShading(){return this.shading}getTextBody(){return this.textBody}getCellBorders(){return this.borders}}class l{constructor(){this.id=Math.random().toString(36).substr(2,9);this.name="Default Theme";this.colorScheme=null;this.fontScheme=null;this.formatScheme=null}}if("undefined"!==typeof window){window.CPresentation=CPresentation;window.CSlide=CSlide;window.CSld=t;window.CShape=e;window.CGroupShape=r;window.CSlideMaster=o;window.CSlideLayout=s;window.CTheme=l;window.CTable=i;window.CTableRow=n;window.CTableCell=a}if("undefined"!==typeof globalThis){globalThis.CPresentation=CPresentation;globalThis.CSlide=CSlide;globalThis.CSld=t;globalThis.CShape=e;globalThis.CGroupShape=r;globalThis.CSlideMaster=o;globalThis.CSlideLayout=s;globalThis.CTheme=l;globalThis.CTable=i;globalThis.CTableRow=n;globalThis.CTableCell=a}return _}var k=R();var I=s(k);let L=class t{constructor(t={}){this.logger=new Logger("TableProcessor");this.validator=this._getValidator();this.errorBoundary=new(this._getErrorBoundary())({context:"TableProcessor",enableLogging:false!==t.enableLogging});this.tableCache=new Map;this.config=this._validateConfig({maxTableSize:t.maxTableSize||1e3,maxCellTextLength:t.maxCellTextLength||1e4,enableCaching:false!==t.enableCaching,enableValidation:false!==t.enableValidation,renderTimeout:t.renderTimeout||5e3,...t});this.performanceMetrics={tablesProcessed:0,cacheHits:0,cacheMisses:0,averageRenderTime:0}}async renderTableFrame(t,e,r,o,s,i,n={}){const a=this._validateRenderInput(t,e,r,o,s,i,n);if(!a.valid){this._handleValidationError("renderTableFrame",a.errors);this.drawTablePlaceholder(t,r,o,s,i);return}return this.errorBoundary.wrap(async()=>{const n=performance.now();try{const a=await this._getTableInstanceWithTimeout(e,this.config.renderTimeout);if(!a){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","No valid table data found, drawing placeholder");this.drawTablePlaceholder(t,r,o,s,i);return}if(this.config.enableValidation)this._validateTableStructure(a);t.SaveGrState();try{await this._safeDrawTableBackgroundAndOuterBorder(t,a,r,o,s,i);await this._safeDrawCellsBackground(t,a,r,o,s,i);await this._safeDrawCellsContent(t,a,r,o,s,i);await this._safeDrawCellsBorders(t,a,r,o,s,i);this._updatePerformanceMetrics(n)}finally{t.RestoreGrState()}}catch(e){void 0;void 0;void 0;if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor","Error during table rendering:",e);this.drawTablePlaceholder(t,r,o,s,i);throw this._enhanceError(e,"table_rendering",{x:r,y:o,w:s,h:i})}},{context:"renderTableFrame"})()}async getTableInstance(t){return this.errorBoundary.wrap(async()=>{if(!t||"object"!==typeof t)throw this._createError("Invalid shape object provided",{name:"ValidationError",code:"INVALID_SHAPE"});if(t.table&&t.table instanceof CTable){this.performanceMetrics.cacheHits++;return t.table}this.performanceMetrics.cacheMisses++;if(t.graphicData&&t.graphicData.tableXml)try{if(this.config.enableValidation)this._validateTableXML(t.graphicData.tableXml);const e=await this.parseTableFromXML(t.graphicData.tableXml);if(e){if(this.config.enableValidation)this._validateParsedTable(e);if(this.config.enableCaching)t.table=e;return e}}catch(t){if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor","Failed to parse table XML:",t);throw this._enhanceError(t,"table_parsing")}return null},{context:"getTableInstance"})()}async _getTableInstanceWithTimeout(t,e){return new Promise(async(r,o)=>{const s=setTimeout(()=>{o(this._createError(`Table parsing timed out after ${e}ms`,{name:"TimeoutError",code:"TABLE_PARSING_TIMEOUT"}))},e);try{const e=await this.getTableInstance(t);clearTimeout(s);r(e)}catch(t){clearTimeout(s);o(t)}})}drawTableBackgroundAndOuterBorder(t,e,r,o,s,i){const n=e.getTableProperties();const a=e.getTableBorders();const l=e.getTableShading();if(l&&l.fill){const e=this.resolveTableBackgroundColor(l);t.b_color1(e.r,e.g,e.b,e.a||255);t.TableRect(r,o,s,i)}if(a&&Object.keys(a).length>0)this.drawTableOuterBorder(t,a,r,o,s,i)}drawCellsBackground(t,e,r,o,s,i){const n=e.getRows();const a=this.calculateCellWidths(e,s);const l=this.calculateCellHeights(e,i);const c=e.getTableProperties()||{};let h=o;for(let e=0;e<n.length;e++){const o=n[e];const s=o.getCells();const i=l[e];const u=s.length>0&&"TOTAL"===s[0].textBody?.paragraphs?.[0]?.runs?.[0]?.text;const f=s.length>0&&"Product"===s[0].textBody?.paragraphs?.[0]?.runs?.[0]?.text;for(let o=0;o<s.length;o++){const i=s[o];const n=Math.max(1,i.gridSpan||1);const d=Math.max(1,i.rowSpan||1);if(!i.isMergedContinue){const o=i.logicalColIndex||0;const s=r+this.calculateCellXOffset(a,o);const p=this.calculateMergedCellWidth(a,o,n);const g=this.calculateMergedCellHeight(l,e,d);this.drawCellBackground(t,i,s,h,p,g,{isHeaderRow:f,isTotalRow:u,rowIndex:e,tableProps:c})}}h+=i}}drawCellsContent(t,e,r,o,s,i){const n=e.getRows();const a=this.calculateCellWidths(e,s);const l=this.calculateCellHeights(e,i);let c=o;for(let e=0;e<n.length;e++){const o=n[e];const s=o.getCells();const i=l[e];for(let o=0;o<s.length;o++){const i=s[o];const n=Math.max(1,i.gridSpan||1);const h=Math.max(1,i.rowSpan||1);if(!i.isMergedContinue){const o=i.logicalColIndex||0;const s=r+this.calculateCellXOffset(a,o);const u=this.calculateMergedCellWidth(a,o,n);const f=this.calculateMergedCellHeight(l,e,h);this.drawCellContent(t,i,s,c,u,f)}}c+=i}}drawCellsBorders(t,e,r,o,s,i){const n=e.getRows();const a=this.calculateCellWidths(e,s);const l=this.calculateCellHeights(e,i);let c=o;for(let o=0;o<n.length;o++){const s=n[o];const i=s.getCells();const h=l[o];for(let s=0;s<i.length;s++){const n=i[s];const h=Math.max(1,n.gridSpan||1);const u=Math.max(1,n.rowSpan||1);if(!n.isMergedContinue){const s=n.logicalColIndex||0;const i=r+this.calculateCellXOffset(a,s);const f=this.calculateMergedCellWidth(a,s,h);const d=this.calculateMergedCellHeight(l,o,u);this.drawCellBorders(t,n,i,c,f,d,o,s,e)}}c+=h}}drawTablePlaceholder(t,e,r,o,s){const i=o/3;const n=s/3;for(let o=0;o<3;o++)for(let s=0;s<3;s++){const a=e+s*i;const l=r+o*n;t.drawRectangle(a,l,i,n,null,{r:128,g:128,b:128,a:255},1)}this.drawCenteredText(t,"Table",e,r,o,s)}drawTableOuterBorder(t,e,r,o,s,i){const n=["top","right","bottom","left"];n.forEach(n=>{const a=e[n];if(a&&"none"!==a.style){const e=this.resolveBorderColor(a);const l=Math.max(a.width||1,3);t.p_color(e.r,e.g,e.b,e.a||255);t.p_width(l);switch(n){case"top":t.drawHorLine(r,o,r+s,o,l);break;case"right":t.drawVerLine(r+s,o,o+i,l);break;case"bottom":t.drawHorLine(r,o+i,r+s,o+i,l);break;case"left":t.drawVerLine(r,o,o+i,l)}}})}drawCellBackground(t,e,r,o,s,i,n={}){let a=null;if(e.shading&&e.shading.fillColor)a=e.shading.fillColor;if(!a&&"function"===typeof e.getCellShading)try{const t=e.getCellShading();if(t&&t.fill&&t.fill.color)a=t.fill.color}catch(t){}if(!a&&e.shading&&e.shading.color)a=e.shading.color;if(!a){const t=e.properties||e.cellProperties;if(t&&t.shading&&t.shading.fillColor)a=t.shading.fillColor}if(!a&&n.tableProps){const t=n.tableProps;const r=n.rowIndex||0;const o=e.logicalColIndex||0;if(t.firstRow&&0===r)a={r:68,g:114,b:196,a:255};else if(t.bandRow&&r>0){const e=t.firstRow?r-1:r;if(e%2===1)a={r:242,g:242,b:242,a:255}}else if(t.firstCol&&0===o&&r>0)a={r:221,g:235,b:247,a:255}}if(a&&void 0!==a.r&&void 0!==a.g&&void 0!==a.b&&t.m_oContext){t.m_oContext.save();t.m_oContext.fillStyle=`rgba(${a.r}, ${a.g}, ${a.b}, ${(a.a||255)/255})`;t.m_oContext.fillRect(r,o,s,i);t.m_oContext.restore()}}drawCellContent(t,e,r,o,s,i){const n=e.getTextBody();if(!n||!n.paragraphs)return;const a=38100;const l=this.convertEMUToPixels(a);let c=l;let h=l;let u=l;let f=l;if(e.margins){c=e.margins.left?this.convertEMUToPixels(e.margins.left):l;h=e.margins.right?this.convertEMUToPixels(e.margins.right):l;u=e.margins.top?this.convertEMUToPixels(e.margins.top):l;f=e.margins.bottom?this.convertEMUToPixels(e.margins.bottom):l}if(n.bodyProperties){const t=n.bodyProperties;if(t.leftMargin)c+=this.convertEMUToPixels(t.leftMargin);if(t.rightMargin)h+=this.convertEMUToPixels(t.rightMargin);if(t.topMargin)u+=this.convertEMUToPixels(t.topMargin);if(t.bottomMargin)f+=this.convertEMUToPixels(t.bottomMargin)}const d=r+c;const p=o+u;const g=Math.max(0,s-(c+h));const m=Math.max(0,i-(u+f));this.renderCellTextContent(t,n,d,p,g,m,e)}drawCellBorders(t,e,r,o,s,i,n,a,l){const c=e.getCellBorders();if(!c)return;const h=["top","right","bottom","left"];h.forEach(h=>{const u=c[h];if(!u||"none"===u.style||!u.color||0===u.width)return;if(this.shouldDrawBorder(h,n,a,l,e)){const e=this.resolveBorderColor(u);const n=u.width;if(t.m_oContext){t.m_oContext.save();t.m_oContext.strokeStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`;t.m_oContext.lineWidth=n;t.m_oContext.beginPath();switch(h){case"top":t.m_oContext.moveTo(r,o);t.m_oContext.lineTo(r+s,o);break;case"right":t.m_oContext.moveTo(r+s,o);t.m_oContext.lineTo(r+s,o+i);break;case"bottom":t.m_oContext.moveTo(r,o+i);t.m_oContext.lineTo(r+s,o+i);break;case"left":t.m_oContext.moveTo(r,o);t.m_oContext.lineTo(r,o+i)}t.m_oContext.stroke();t.m_oContext.restore()}}})}shouldDrawBorder(t,e,r,o,s=null){const i=o.getRowCount();const n=o.getColumnCount();const a=s?Math.max(1,s.gridSpan||1):1;const l=s?Math.max(1,s.rowSpan||1):1;switch(t){case"top":if(0===e)return true;if(s&&s.isMergedContinue&&"continue"===s.vMerge)return false;return true;case"right":const t=r+a-1;if(t===n-1)return true;return true;case"bottom":const o=e+l-1;if(o===i-1)return true;return true;case"left":if(0===r)return true;return true;default:return true}}calculateCellWidths(t,e){const r=t.getTableGrid();if(!r||0===r.length){const r=t.getColumnCount();return new Array(r).fill(e/r)}const o=r.map(t=>Math.max(0,parseInt(t.width)||0));const s=o.reduce((t,e)=>t+e,0)||1;const i=o.map(t=>e*(t/s));const n=t.getColumnCount();if(i.length<n){const t=n-i.length;const r=i.reduce((t,e)=>t+e,0);const o=(e-r)/Math.max(t,1);for(let e=0;e<t;e++)i.push(o)}return i}calculateCellHeights(t,e){const r=t.getRowCount();if(r<=0)return[];const o=[];for(let e=0;e<r;e++){const r=t.getRow(e);const s=r&&r.height;const i=void 0!==s&&null!==s?Number(s):NaN;o.push(isNaN(i)?1:Math.max(i,1))}const s=o.reduce((t,e)=>t+e,0)||r;return o.map(t=>e*(t/s))}isStartingCellOfMerge(t,e,r){return true}calculateMergedCellWidth(t,e,r){let o=0;for(let s=0;s<r;s++)if(e+s<t.length)o+=t[e+s];return o}calculateMergedCellHeight(t,e,r){let o=0;for(let s=0;s<r;s++)if(e+s<t.length)o+=t[e+s];return o}calculateCellXOffset(t,e){let r=0;for(let o=0;o<e;o++)r+=t[o];return r}calculateCellYOffset(t,e){let r=0;for(let o=0;o<e;o++)r+=t[o];return r}resolveTableBackgroundColor(t){if(t&&t.fill){const e=this.parseColorFromHex(t.fill);if(e)return e}return{r:255,g:255,b:255,a:255}}resolveCellBackgroundColor(t){if(t&&t.fillColor)return t.fillColor;if(t&&t.fill){const e=this.parseColorFromHex(t.fill);if(e)return e}if(t&&t.color){const e=this.parseColorFromHex(t.color);if(e)return e}return{r:255,g:255,b:255,a:255}}resolveBorderColor(t){if(t&&t.color)return t.color;return{r:0,g:0,b:0,a:255}}renderCellTextContent(t,e,r,o,s,i,n=null){if(!e.paragraphs||0===e.paragraphs.length)return;const a=[];for(let t=0;t<e.paragraphs.length;t++){const r=e.paragraphs[t];if(!r.runs||0===r.runs.length)continue;let o="left";if(r.properties&&r.properties.alignment){const t=r.properties.alignment;if("center"===t||"ctr"===t)o="center";else if("right"===t||"r"===t)o="right";else if("just"===t||"justify"===t)o="left"}const s=[];for(const t of r.runs){const e=t.text||"";if(!e)continue;const r=t.properties||{};let o=12;if(r.fontSize)o=r.fontSize;else if(r.sz)o=parseInt(r.sz)/100;const i=Math.max(10,Math.round(1.33*o));const n=r.fontFamily||"Arial";const a=r.bold?"bold":"normal";const l=r.italic?"italic":"normal";const c=r.underline||false;const h=r.strikethrough||false;const u=r.color||{r:0,g:0,b:0};const f=`rgb(${u.r}, ${u.g}, ${u.b})`;s.push({text:e,fontSizePx:i,fontFamily:n,fontWeight:a,fontStyle:l,underline:c,strikethrough:h,color:f})}if(0===s.length)continue;const i=Math.max(...s.map(t=>t.fontSizePx));const n=Math.round(1.25*i);a.push({runSegments:s,textAlign:o,lineHeight:n})}if(0===a.length)return;const l=a.reduce((t,e)=>t+e.lineHeight,0);let c="ctr";if(n&&n.verticalAlignment)c=n.verticalAlignment;else if(e.bodyProperties&&e.bodyProperties.anchor)c=e.bodyProperties.anchor;let h=o;if("t"===c||"top"===c)h=o;else if("ctr"===c||"center"===c||"middle"===c)h=o+Math.max(0,(i-l)/2);else if("b"===c||"bottom"===c)h=o+Math.max(0,i-l);else h=o+Math.max(0,(i-l)/2);if(!isFinite(h))h=o;if(t.m_oContext)for(let e=0;e<a.length;e++){const o=a[e];const i=h+o.lineHeight/2;let n=0;t.m_oContext.save();for(const e of o.runSegments){t.m_oContext.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSizePx}px ${e.fontFamily}`;n+=t.m_oContext.measureText(e.text).width}t.m_oContext.restore();let l=r;if("center"===o.textAlign)l=r+(s-n)/2;else if("right"===o.textAlign)l=r+s-n;for(const e of o.runSegments){t.m_oContext.save();t.m_oContext.fillStyle=e.color;t.m_oContext.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSizePx}px ${e.fontFamily}`;t.m_oContext.textAlign="left";t.m_oContext.textBaseline="middle";t.m_oContext.fillText(e.text,l,i);if(e.underline){const r=t.m_oContext.measureText(e.text).width;t.m_oContext.strokeStyle=e.color;t.m_oContext.lineWidth=1;t.m_oContext.beginPath();t.m_oContext.moveTo(l,i+.1*e.fontSizePx);t.m_oContext.lineTo(l+r,i+.1*e.fontSizePx);t.m_oContext.stroke()}if(e.strikethrough){const r=t.m_oContext.measureText(e.text).width;t.m_oContext.strokeStyle=e.color;t.m_oContext.lineWidth=1;t.m_oContext.beginPath();t.m_oContext.moveTo(l,i);t.m_oContext.lineTo(l+r,i);t.m_oContext.stroke()}l+=t.m_oContext.measureText(e.text).width;t.m_oContext.restore()}h+=o.lineHeight}}resolveTextColor(t){if(t&&t.runs&&t.runs.length>0)for(const e of t.runs)if(e.properties&&e.properties.color)return e.properties.color;return{r:159,g:159,b:159,a:255}}drawCenteredText(t,e,r,o,s,i){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.fillStyle="rgba(128, 128, 128, 0.8)";t.m_oContext.font="14px Arial";t.m_oContext.textAlign="center";t.m_oContext.textBaseline="middle";t.m_oContext.fillText(e,r+s/2,o+i/2);t.m_oContext.restore()}parseTableFromXML(t){if(!t)return null;try{const e=new DOMParser;const r=e.parseFromString(t,"text/xml");if("parsererror"===r.documentElement.nodeName){void 0;return null}const o=new CTable;this.tableRowData=[];this.parseTableProperties(r,o);this.parseTableGrid(r,o);this.parseTableRows(r,o);this.processTableMerges(o);if(!this.validateTableStructure(o)){void 0;try{const t=(o.getTableGrid()||[]).length;void 0;const e=o.getRows();for(let t=0;t<Math.min(e.length,6);t++){const r=e[t].getCells();const o=r.map((t,e)=>`c${e}{gs:${t.gridSpan||1},rs:${t.rowSpan||1},cont:${!!t.isMergedContinue},v:${t.vMerge||""},lc:${t.logicalColIndex||0}}`).join(" | ");void 0}}catch(t){}}return o}catch(t){void 0;return null}finally{this.tableRowData=null}}parseTableProperties(t,e){let r=t.querySelector("tblPr");if(!r)r=t.querySelector("a\\:tblPr");if(r){const t={};const o=r.getAttribute("firstRow");if("1"===o||"true"===o)t.firstRow=true;const s=r.getAttribute("bandRow");if("1"===s||"true"===s)t.bandRow=true;const i=r.getAttribute("firstCol");if("1"===i||"true"===i)t.firstCol=true;const n=r.getAttribute("lastRow");if("1"===n||"true"===n)t.lastRow=true;const a=r.getAttribute("lastCol");if("1"===a||"true"===a)t.lastCol=true;const l=r.getAttribute("bandCol");if("1"===l||"true"===l)t.bandCol=true;let c=r.querySelector("tblStyle");if(!c)c=r.querySelector("a\\:tblStyle");if(c)t.style=c.getAttribute("val");let h=r.querySelector("tblBorders");if(!h)h=r.querySelector("a\\:tblBorders");if(h)t.borders=this.parseTableBorders(h);let u=r.querySelector("tblShading");if(!u)u=r.querySelector("a\\:tblShading");if(u)t.shading=this.parseTableShading(u);let f=r.querySelector("tblLayout");if(!f)f=r.querySelector("a\\:tblLayout");if(f)t.layout=f.getAttribute("type")||"autofit";let d=r.querySelector("tblW");if(!d)d=r.querySelector("a\\:tblW");if(d){const e=d.getAttribute("w");const r=d.getAttribute("type")||d.getAttribute("wtype")||"auto";if(e)t.preferredWidth={value:parseInt(e)||0,type:r.toLowerCase()};else t.preferredWidth={value:0,type:r.toLowerCase()}}e.tableProperties=t}}parseTableGrid(t,e){let r=t.querySelector("tblGrid");if(!r)r=t.querySelector("a\\:tblGrid");if(r){let t=r.querySelectorAll("gridCol");if(0===t.length)t=r.querySelectorAll("a\\:gridCol");const o=[];t.forEach(t=>{const e=t.getAttribute("w");const r={width:e?parseInt(e):914400,type:t.getAttribute("type")||"auto"};o.push(r)});e.setTableGrid(o)}}parseTableRows(t,e){let r=t.querySelectorAll("tr");if(0===r.length)r=t.querySelectorAll("a\\:tr");r.forEach((t,r)=>{const o=new CTableRow;this.parseRowProperties(t,o);this.parseRowCells(t,o,r);e.addRow(o)})}parseRowProperties(t,e){let r=t.querySelector("trPr");if(!r)r=t.querySelector("a\\:trPr");if(r){let t=r.querySelector("trHeight");if(!t)t=r.querySelector("a\\:trHeight");if(t){const r=parseInt(t.getAttribute("val"),10);if(!Number.isNaN(r))e.height=r;e.heightRule=t.getAttribute("hRule")||"auto"}let o=r.querySelector("tblHeader");if(!o)o=r.querySelector("a\\:tblHeader");if(o)e.isHeader=true}if((!e.height||e.height<=0)&&t){const r=t.getAttribute("h");if(null!==r){const t=parseInt(r,10);if(!Number.isNaN(t)&&t>0){e.height=t;if(!e.heightRule)e.heightRule="auto"}}}}parseRowCells(t,e,r){let o=t.querySelectorAll("tc");if(0===o.length)o=t.querySelectorAll("a\\:tc");const s=t.closest("tbl")||t.closest("a\\:tbl");let i=10;if(s){let t=s.querySelector("tblGrid");if(!t)t=s.querySelector("a\\:tblGrid");if(t){let e=t.querySelectorAll("gridCol");if(0===e.length)e=t.querySelectorAll("a\\:gridCol");i=e.length}}const n=new Array(i).fill(false);if(r>0&&this.tableRowData)for(let t=0;t<r;t++){const e=this.tableRowData[t];if(e)e.forEach(e=>{if(e.rowSpan>1){const o=t+e.rowSpan-1;if(o>=r){const t=e.logicalColIndex;const r=t+(e.gridSpan||1);for(let e=t;e<r;e++)if(e<i)n[e]=true}}})}if(!this.tableRowData)this.tableRowData=[];this.tableRowData[r]=[];o.forEach((t,o)=>{const s=t.getAttribute("vMerge");const a=t.getAttribute("gridSpan");const l=t.getAttribute("rowSpan");const c=t.getAttribute("hMerge");const h="1"===c||"true"===c;const u="1"===s||"true"===s||"continue"===s;const f=a?parseInt(a):1;const d=l?parseInt(l):1;let p=0;while(p<i&&n[p])p++;if(p>=i)p=Math.min(o,i-1);const g=new CTableCell;if(u){g.isMergedContinue=true;g.vMerge="continue"}if(d>1)g.rowSpan=d;if(f>1)g.gridSpan=f;const m=h?0:u?1:f;for(let t=0;t<m&&p+t<i;t++)n[p+t]=true;this.parseCellProperties(t,g,r,o);this.parseCellContent(t,g);if(h){g.isMergedContinue=true;g.mergeParent=null}g.logicalRowIndex=r;g.logicalColIndex=p;this.tableRowData[r].push({logicalColIndex:p,gridSpan:f,rowSpan:d,isVerticalContinuation:u});e.addCell(g)})}parseCellProperties(t,e,r,o){let s=t.querySelector("tcPr");if(!s)s=t.querySelector("a\\:tcPr");if(s){let t=s.querySelector("gridSpan");if(!t)t=s.querySelector("a\\:gridSpan");if(t)e.gridSpan=parseInt(t.getAttribute("val"))||1;let r=s.querySelector("rowSpan");if(!r)r=s.querySelector("a\\:rowSpan");if(r)e.rowSpan=parseInt(r.getAttribute("val"))||1;let o=s.querySelector("vMerge");if(!o)o=s.querySelector("a\\:vMerge");if(o){const t=o.getAttribute("val");e.vMerge="restart"===t?"start":"continue"}const i=s.getAttribute("anchor");if(i)e.verticalAlignment=i;const n=s.getAttribute("vert");if(n)e.textDirection=n;const a=this.parseCellBordersFromTcPr(s);if(a)e.borders=a;const l=Array.from(s.children).find(t=>"a:solidFill"===t.tagName||"solidFill"===t.tagName);if(l)e.shading=this.parseCellShading(l);else{const t=s.querySelectorAll("solidFill, a\\:solidFill");let r=null;for(const e of t){let t=e.parentElement;let o=false;while(t&&t!==s){if("a:lnL"===t.tagName||"a:lnR"===t.tagName||"a:lnT"===t.tagName||"a:lnB"===t.tagName||"lnL"===t.tagName||"lnR"===t.tagName||"lnT"===t.tagName||"lnB"===t.tagName){o=true;break}t=t.parentElement}if(!o){r=e;break}}if(r)e.shading=this.parseCellShading(r)}let c=s.querySelector("tcMar");if(!c)c=s.querySelector("a\\:tcMar");if(c)e.margins=this.parseCellMargins(c)}}parseCellContent(t,e){const r=this.parseTextBodyFromElement(t);if(r)e.setTextBody(r)}appendMergedCellText(t,e){if(!e||e.mergedContentTransferred)return;const r=e.getTextBody&&e.getTextBody();if(!r||!r.paragraphs||0===r.paragraphs.length)return;if(!t.getTextBody||!t.setTextBody)return;const o=t.getTextBody();if(!o||!o.paragraphs)t.setTextBody({paragraphs:[...r.paragraphs]});else{if(o.paragraphs.length>0)o.paragraphs.push({runs:[],properties:{}});o.paragraphs.push(...r.paragraphs)}e.mergedContentTransferred=true;e.setTextBody&&e.setTextBody({paragraphs:[]})}processTableMerges(t){const e=t.getRows();for(let r=0;r<e.length;r++){const o=e[r];const s=o.getCells();for(let o=0;o<s.length;o++){const i=s[o];if(i.gridSpan>1)this.processHorizontalMerge(t,r,o,i.gridSpan);if(i.rowSpan>1)this.processVerticalMerge(t,r,o,i.rowSpan);if("start"===i.vMerge){let s=1;for(let n=r+1;n<e.length;n++){const e=t.getCell(n,o);if(!e)break;if("continue"===e.vMerge){e.isMergedContinue=true;e.mergeParent={row:r,col:o};this.appendMergedCellText(i,e);s++}else break}if(!i.rowSpan||i.rowSpan<s)i.rowSpan=s}else if("continue"===i.vMerge)if(!i.isMergedContinue)for(let e=r-1;e>=0;e--){const s=t.getCell(e,o);if(!s)break;if("start"===s.vMerge){i.isMergedContinue=true;i.mergeParent={row:e,col:o};const t=r-e+1;if(!s.rowSpan||s.rowSpan<t)s.rowSpan=t;break}else if("continue"!==s.vMerge)break}}}}processHorizontalMerge(t,e,r,o){for(let s=1;s<o;s++){const o=t.getCell(e,r+s);if(o){o.isMergedContinue=true;o.mergeParent={row:e,col:r};const s=t.getCell(e,r);if(s)this.appendMergedCellText(s,o)}}}processVerticalMerge(t,e,r,o){for(let s=1;s<o;s++){const o=t.getCell(e+s,r);if(o){o.isMergedContinue=true;o.mergeParent={row:e,col:r};const s=t.getCell(e,r);if(s)this.appendMergedCellText(s,o)}}}validateTableStructure(t){const e=t.getRows();if(0===e.length)return false;const r=t.getTableGrid().length||t.getColumnCount();if(0===r)return false;for(let t=0;t<e.length;t++){const o=e[t];const s=o.getCells();let i=0;for(const t of s)if(!t.isMergedContinue){const e=Math.max(1,t.gridSpan||1);i+=e}let n=0;if(this.tableRowData){const e=new Array(r).fill(false);for(let o=0;o<t;o++){const s=this.tableRowData[o]||[];for(const i of s)if(i&&i.rowSpan>1){const s=o+i.rowSpan-1;if(s>=t){const t=Math.max(0,i.logicalColIndex||0);const o=Math.min(r,t+Math.max(1,i.gridSpan||1));for(let r=t;r<o;r++)e[r]=true}}}n=e.filter(Boolean).length}const a=Math.max(0,r-n);if(0===a)continue;if(i<.5*a||i>2*a){void 0;try{const t=s.map((t,e)=>`c${e}{gs:${t.gridSpan||1},rs:${t.rowSpan||1},cont:${!!t.isMergedContinue},v:${t.vMerge||""},lc:${t.logicalColIndex||0}}`).join(" | ");void 0}catch(t){}return false}}return true}parseTableBorders(t){const e={};const r=["top","left","bottom","right","insideH","insideV"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=this.parseBorderProperties(o)});return e}parseCellBordersFromTcPr(t){const e={};const r={lnL:"left",lnR:"right",lnT:"top",lnB:"bottom"};for(const[o,s]of Object.entries(r)){let r=t.querySelector(o);if(!r)r=t.querySelector(`a\\:${o}`);if(r){const t=parseInt(r.getAttribute("w"))||0;const o=this.parseColor(r);const i=t>0?Math.max(1,Math.round(this.convertEMUToPixels(t))):1;if(null!==o&&i>0)e[s]={style:"single",width:i,color:o}}}return Object.keys(e).length>0?e:null}parseCellBorders(t){return this.parseTableBorders(t)}parseBorderProperties(t){const e=this.parseColor(t);const r=parseInt(t.getAttribute("w"))||0;let o=0;if(r>0)o=Math.max(1,Math.round(this.convertEMUToPixels(r)));else{const e=parseInt(t.getAttribute("sz"))||0;if(e>0){const t=e/8;o=Math.max(1,Math.round(t*(96/72)))}}return{style:t.getAttribute("val")||"single",width:o,size:parseInt(t.getAttribute("sz"))||0,color:e,space:parseInt(t.getAttribute("space"))||0}}parseTableShading(t){return this.parseCellShading(t)}parseCellShading(t){const e=t.getAttribute("fill");const r=t.getAttribute("color");let o=null;if("a:solidFill"===t.tagName||"solidFill"===t.tagName)o=this.parseColor(t);else{const e=t.querySelector("solidFill")||t.querySelector("a\\:solidFill");if(e)o=this.parseColor(e)}return{fill:e,color:r?this.parseColorFromHex(r):null,fillColor:o}}parseCellMargins(t){const e={};const r=["top","left","bottom","right"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=parseInt(o.getAttribute("w"))||0});return e}extractTableStructure(t){if(!t.graphicData||!t.graphicData.tableXml)return null;try{const e=this.parseTableFromXML(t.graphicData.tableXml);if(!e)return null;const r={id:t.id,name:t.name,type:"table",properties:this.extractTableProperties(e),structure:this.extractTableStructureData(e),content:this.extractTableContent(e),styling:this.extractTableStyling(e),position:t.bounds||t.properties?.transform,metadata:{rowCount:e.getRowCount(),columnCount:e.getColumnCount(),hasMergedCells:this.hasMergedCells(e),tableStyle:e.getTableProperties()?.style||"TableGrid"}};return r}catch(t){void 0;return null}}extractTableProperties(t){const e=t.getTableProperties()||{};return{style:e.style||"TableGrid",layout:e.layout||"autofit",width:e.width||"auto",alignment:e.alignment||"left",borders:e.borders||{},shading:e.shading||{},spacing:{before:e.spacing?.before||0,after:e.spacing?.after||0,line:e.spacing?.line||240}}}extractTableStructureData(t){const e=t.getRows();const r=t.getTableGrid();return{grid:r.map((t,e)=>({index:e,width:t.width,type:t.type||"auto"})),rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false,cells:t.getCells().map((t,e)=>({index:e,gridSpan:t.gridSpan||1,rowSpan:t.rowSpan||1,vMerge:t.vMerge||null,isMergedContinue:t.isMergedContinue||false,mergeParent:t.mergeParent||null}))}))}}extractTableContent(t){const e=t.getRows();return{cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,text:this.extractCellText(t),textBody:this.extractCellTextBody(t),content:this.extractCellContent(t)})))}}extractTableStyling(t){const e=t.getRows();return{table:{borders:t.getTableProperties()?.borders||{},shading:t.getTableProperties()?.shading||{},style:t.getTableProperties()?.style||"TableGrid"},rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false})),cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,borders:t.borders||{},shading:t.shading||{},margins:t.margins||{},verticalAlignment:t.verticalAlignment||"top",textDirection:t.textDirection||"lr"})))}}hasMergedCells(t){const e=t.getRows();for(const t of e)for(const e of t.getCells())if(e.gridSpan>1||e.rowSpan>1||e.isMergedContinue)return true;return false}extractCellTextBody(t){const e=t.getTextBody();if(!e||!e.paragraphs)return null;return{paragraphs:e.paragraphs.map(t=>({properties:t.properties||{},runs:t.runs?.map(t=>({text:t.text||"",properties:t.properties||{}}))||[]}))}}extractCellContent(t){const e={type:"text",data:null};const r=t.getTextBody();if(r&&r.paragraphs){e.type="text";e.data=this.extractCellTextBody(t)}return e}extractCellText(t){if(!t.textBody||!t.textBody.paragraphs)return"";return t.textBody.paragraphs.map(t=>{if(!t.runs)return"";return t.runs.map(t=>t.text||"").join("")}).join("\n")}getTableData(t){return null}getAllTableData(t){const e=[];for(let r=0;r<t.length;r++){const slide=t[r];if(slide&&slide.shapes)for(const t of slide.shapes)if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===t.graphicData.uri){const o=this.extractTableStructure(t);if(o){o.slideIndex=r;o.shapeId=t.id;o.shapeName=t.name;e.push(o)}}}return e}parseTextBodyFromElement(t){let e=t.querySelector("txBody");if(!e)e=t.querySelector("a\\:txBody");if(!e)return null;const r={paragraphs:[]};try{let t=e.querySelector("bodyPr");if(!t)t=e.querySelector("a\\:bodyPr");if(t){const e={wrap:true};const o=t.getAttribute("wrap");if(o&&"none"===o.toLowerCase())e.wrap=false;const s=t.getAttribute("anchor");if(s)e.anchor=s;const i=t.getAttribute("rot");if(i)e.rotation=parseInt(i)||0;const n=t.getAttribute("lIns");const a=t.getAttribute("rIns");const l=t.getAttribute("tIns");const c=t.getAttribute("bIns");if(n)e.leftMargin=parseInt(n)||0;if(a)e.rightMargin=parseInt(a)||0;if(l)e.topMargin=parseInt(l)||0;if(c)e.bottomMargin=parseInt(c)||0;r.bodyProperties=e}}catch(t){}let o=e.querySelectorAll("p");if(0===o.length)o=e.querySelectorAll("a\\:p");o.forEach(t=>{const e={runs:[],properties:{}};let o=t.querySelector("pPr");if(!o)o=t.querySelector("a\\:pPr");if(o){const t=o.getAttribute("algn");if(t)e.properties.alignment=t}let s=t.querySelectorAll("r");if(0===s.length)s=t.querySelectorAll("a\\:r");s.forEach(t=>{const r={text:"",properties:{}};let o=t.querySelector("t");if(!o)o=t.querySelector("a\\:t");if(o)r.text=o.textContent||"";let s=t.querySelector("rPr");if(!s)s=t.querySelector("a\\:rPr");if(s){const t=s.querySelector("solidFill")||s.querySelector("a\\:solidFill");if(t)r.properties.color=this.parseColor(t);const e=s.getAttribute("sz");if(e)r.properties.fontSize=parseInt(e)/100;else r.properties.fontSize=12;r.properties.bold="1"===s.getAttribute("b");r.properties.italic="1"===s.getAttribute("i");const o=s.getAttribute("u");if(o&&"none"!==o)r.properties.underline=true;const i=s.getAttribute("strike");if(i&&"noStrike"!==i)r.properties.strikethrough=true;let n=s.getAttribute("typeface")||s.getAttribute("fontFamily");if(!n){const t=s.querySelector("latin")||s.querySelector("a\\:latin");if(t)n=t.getAttribute("typeface")}if(n)r.properties.fontFamily=n;else r.properties.fontFamily="Arial"}e.runs.push(r)});r.paragraphs.push(e)});return r.paragraphs.length>0?r:null}parseColor(t){if(!t)return null;const e=t.querySelector("noFill")||t.querySelector("a\\:noFill");if(e)return null;const r=t.querySelector("solidFill")||t.querySelector("a\\:solidFill");if(r){const t=r.querySelector("srgbClr")||r.querySelector("a\\:srgbClr");if(t){const e=t.getAttribute("val");if(e){const t=this.parseColorFromHex(e);if(t)return t}}const e=r.querySelector("schemeClr")||r.querySelector("a\\:schemeClr");if(e){const t=e.getAttribute("val");const r=this.resolveSchemeColor(t);if(r)return r}}const o=t.querySelector("srgbClr")||t.querySelector("a\\:srgbClr");if(o){const t=o.getAttribute("val");if(t){const e=this.parseColorFromHex(t);if(e)return e}}const s=t.querySelector("schemeClr")||t.querySelector("a\\:schemeClr");if(s){const t=s.getAttribute("val");const e=this.resolveSchemeColor(t);if(e)return e}const i=t.getAttribute("color");if(i){const t=this.parseColorFromHex(i);if(t)return t}return null}resolveSchemeColor(t){if(!t)return null;const e={tx1:"#000000",tx2:"#FFFFFF",bg1:"#FFFFFF",bg2:"#EEECE1",accent1:"#5B9BD5",accent2:"#ED7D31",accent3:"#A5A5A5",accent4:"#FFC000",accent5:"#4472C4",accent6:"#70AD47"};const r=e[t];return r?this.parseColorFromHex(r):null}parseColorFromHex(t){if(!t||"string"!==typeof t)return null;t=t.replace("#","");if(6===t.length){const e=parseInt(t.substring(0,2),16);const r=parseInt(t.substring(2,4),16);const o=parseInt(t.substring(4,6),16);return{r:e,g:r,b:o,a:255}}if(3===t.length){const e=parseInt(t.charAt(0)+t.charAt(0),16);const r=parseInt(t.charAt(1)+t.charAt(1),16);const o=parseInt(t.charAt(2)+t.charAt(2),16);return{r:e,g:r,b:o,a:255}}return null}convertEMUToPixels(t){if(!t||"number"!==typeof t)return 3.78;return t/914400*96}cleanup(){this.tableCache.clear()}_getValidator(){return"undefined"!==typeof window&&window.DataValidator?window.DataValidator:class{validate(){return{valid:true,errors:[]}}}}_getErrorBoundary(){return"undefined"!==typeof window&&window.ErrorBoundary?window.ErrorBoundary:class{constructor(){}wrap(t){return t}}}_validateConfig(t){const e={type:"object",properties:{maxTableSize:{type:"number",minimum:1,maximum:1e4},maxCellTextLength:{type:"number",minimum:1,maximum:1e5},enableCaching:{type:"boolean"},enableValidation:{type:"boolean"},renderTimeout:{type:"number",minimum:1e3,maximum:6e4}}};try{const r=new(this._getValidator())({throwOnError:false});const o=r.validate(t,e);if(!o.valid&&this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Invalid configuration:",o.errors)}catch(t){}return t}_validateRenderInput(t,e,r,o,s,i,n){const a=[];if(!t||"object"!==typeof t)a.push("Graphics object is required");else{const e=["SaveGrState","RestoreGrState","b_color1","TableRect"];for(const r of e)if("function"!==typeof t[r])a.push(`Graphics object missing required method: ${r}`)}if(!e||"object"!==typeof e)a.push("Shape object is required");if("number"!==typeof r||!isFinite(r))a.push("X coordinate must be a finite number");if("number"!==typeof o||!isFinite(o))a.push("Y coordinate must be a finite number");if("number"!==typeof s||!isFinite(s)||s<=0)a.push("Width must be a positive finite number");if("number"!==typeof i||!isFinite(i)||i<=0)a.push("Height must be a positive finite number");if(n&&"object"!==typeof n)a.push("Options must be an object");return{valid:0===a.length,errors:a}}_validateTableXML(t){if("string"!==typeof t||0===t.trim().length)throw this._createError("Table XML must be a non-empty string",{name:"ValidationError",code:"INVALID_TABLE_XML"});if(!t.includes("<")||!t.includes(">"))throw this._createError("Table XML does not appear to be valid XML",{name:"ValidationError",code:"MALFORMED_TABLE_XML"});const e=["tbl","tr","tc"];const r=e.some(e=>t.includes(`<${e}`)||t.includes(`<a:${e}`));if(!r)throw this._createError("Table XML missing required table elements",{name:"ValidationError",code:"INCOMPLETE_TABLE_XML"})}_validateParsedTable(t){if(!t)throw this._createError("Parsed table is null or undefined",{name:"ValidationError",code:"NULL_PARSED_TABLE"});const e=["getRowCount","getColumnCount","getCell"];for(const r of e)if("function"!==typeof t[r])throw this._createError(`Parsed table missing required method: ${r}`,{name:"ValidationError",code:"INVALID_TABLE_STRUCTURE"});const r=t.getRowCount();const o=t.getColumnCount();if(r<=0||o<=0)throw this._createError(`Invalid table dimensions: ${r}x${o}`,{name:"ValidationError",code:"INVALID_TABLE_DIMENSIONS"});if(r*o>this.config.maxTableSize)throw this._createError(`Table size ${r*o} exceeds maximum ${this.config.maxTableSize}`,{name:"ValidationError",code:"TABLE_TOO_LARGE"})}_validateTableStructure(t){try{const e=t.getRowCount();const r=t.getColumnCount();if(e>100||r>50)if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor",`Large table detected: ${e}x${r}`);let o=0;for(let s=0;s<Math.min(e,10);s++)for(let e=0;e<r;e++){const r=t.getCell(s,e);if(r){o++;if(r.textBody&&"string"===typeof r.textBody)if(r.textBody.length>this.config.maxCellTextLength)if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor",`Cell text length ${r.textBody.length} exceeds maximum ${this.config.maxCellTextLength}`)}}if(0===o)throw this._createError("Table has no valid cells",{name:"ValidationError",code:"EMPTY_TABLE"})}catch(t){throw this._enhanceError(t,"table_structure_validation")}}async _safeDrawTableBackgroundAndOuterBorder(t,e,r,o,s,i){try{this.drawTableBackgroundAndOuterBorder(t,e,r,o,s,i)}catch(t){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing table background/border:",t)}}async _safeDrawCellsBackground(t,e,r,o,s,i){try{this.drawCellsBackground(t,e,r,o,s,i)}catch(t){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing cell backgrounds:",t)}}async _safeDrawCellsContent(t,e,r,o,s,i){try{this.drawCellsContent(t,e,r,o,s,i)}catch(t){void 0;void 0;void 0;void 0;if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor","Error drawing cell content:",t);throw t}}async _safeDrawCellsBorders(t,e,r,o,s,i){try{this.drawCellsBorders(t,e,r,o,s,i)}catch(t){if(this.logger)this.logger.log("warn",this.constructor.name,"TableProcessor","Error drawing cell borders:",t)}}_handleValidationError(t,e){const r=`Validation failed for ${t}: ${e.join(", ")}`;if(this.logger)this.logger.logError(this.constructor.name,"TableProcessor",r);const o=this._createError(r,{name:"ValidationError",code:"INPUT_VALIDATION_FAILED",details:{operation:t,errors:e}});return o}_updatePerformanceMetrics(t){this.performanceMetrics.tablesProcessed++;const e=performance.now()-t;const r=this.performanceMetrics.averageRenderTime*(this.performanceMetrics.tablesProcessed-1);this.performanceMetrics.averageRenderTime=(r+e)/this.performanceMetrics.tablesProcessed;if(this.logger&&e>1e3)this.logger.log("warn",this.constructor.name,"TableProcessor",`Slow table render: ${Math.round(e)}ms`)}_createError(t,e={}){const r=new Error(t);r.name=e.name||"TableProcessingError";r.code=e.code||null;r.context="TableProcessor";r.timestamp=(new Date).toISOString();r.recoverable=false!==e.recoverable;if(e.details)r.details=e.details;return r}_enhanceError(t,e,r={}){if(t.enhanced)return t;const o=t instanceof Error?t:new Error(String(t));o.operation=e;o.tableProcessorContext=r;o.timestamp=(new Date).toISOString();o.enhanced=true;return o}getPerformanceMetrics(){return{...this.performanceMetrics,cacheHitRatio:this.performanceMetrics.cacheHits/(this.performanceMetrics.cacheHits+this.performanceMetrics.cacheMisses)||0}}resetPerformanceMetrics(){this.performanceMetrics={tablesProcessed:0,cacheHits:0,cacheMisses:0,averageRenderTime:0}}};if("undefined"!==typeof globalThis)globalThis.TableProcessor=L;var D={exports:{}};var B=D.exports;var O;function q(){if(O)return D.exports;O=1;!function(t){class e{constructor(){this.type="";this.subtype="";this.is3D=false;this.title="";this.series=[];this.categories=[];this.styling={};this.legend=null;this.axes={};this.plotArea={};this.dataLabels={};this.raw=null}}class r{constructor(){this.index=0;this.name="";this.values=[];this.categories=[];this.fill=null;this.line=null;this.marker=null;this.dataLabels=null;this.trendlines=[]}}class o{constructor(t,e={}){this.context=t;this.currentSlideContext=null;try{this.logger=new Logger("ChartProcessor")}catch(t){void 0;this.logger=this._createFallbackLogger()}this.fontConfig=null}setSlideContext(t){this.currentSlideContext=t}clearSlideContext(){this.currentSlideContext=null}async parseChartFromGraphicFrame(t){try{const e=this.getShapeName(t);const r=t.querySelector("graphic")||t.querySelector("a\\:graphic")||t.querySelector('[*|localName="graphic"]');if(!r)return null;const o=r.querySelector("graphicData")||r.querySelector("a\\:graphicData")||r.querySelector('[*|localName="graphicData"]');if(!o)return null;const s=o.getAttribute("uri");if("http://schemas.openxmlformats.org/drawingml/2006/chart"!==s)return null;const i=o.querySelector("chart")||o.querySelector("c\\:chart")||o.querySelector('[*|localName="chart"]');if(!i){const t=o.querySelector("chartSpace, c\\:chartSpace");if(t)return this.parseEmbeddedChartData(o,e);return null}const n=i.getAttribute("r:id");if(!n){const t=this.parseEmbeddedChartData(o,e);if(t&&this.hasRealChartData(t))return t;return null}if(!this.currentSlideContext)return{type:"DEFERRED_CHART",relationshipId:n,needsSlideContext:true};return await this.loadChartFromRelationship(n,this.currentSlideContext)}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing chart from graphic frame",t);return null}}parseEmbeddedChartData(t,r=null){const o=new e;try{const e=t.querySelector("chartSpace, c\\:chartSpace");if(!e)return null;this.parseChartSpace(e,o);return o}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing embedded chart data",t);return null}}parseChartSpace(t,e){const r=t.querySelector("roundedCorners, c\\:roundedCorners");if(r){const t=r.getAttribute("val");e.roundedCorners="1"===t||"true"===t}else e.roundedCorners=false;const o=t.querySelector("chart, c\\:chart");if(o)this.parseChart(o,e);this.parsePrintSettings(t,e);this.parseExternalData(t,e)}parseChart(t,e){const r=t.querySelector("title, c\\:title");if(r)e.title=this.parseTitle(r);const o=t.querySelector("plotArea, c\\:plotArea");if(o)this.parsePlotArea(o,e);const s=t.querySelector("legend, c\\:legend");if(s)e.legend=this.parseLegend(s);const i=t.querySelector("autoTitleDeleted, c\\:autoTitleDeleted");if(i&&"1"===i.getAttribute("val"))e.title=""}parsePlotArea(t,e){e.plotArea=this.parsePlotAreaProperties(t);const r=["barChart","bar3DChart","colChart","col3DChart","lineChart","line3DChart","pieChart","pie3DChart","doughnutChart","areaChart","area3DChart","scatterChart","bubbleChart","radarChart","stockChart","surfaceChart","surface3DChart","waterfallChart","comboChart","sunburstChart","treemapChart","histogramChart","boxWhiskerChart"];for(const o of r){const r=t.querySelector(`${o}, c\\:${o}`);if(r){this.parseSpecificChart(r,o,e);break}}this.parseAxes(t,e);const o=t.querySelector("dLbls, c\\:dLbls");if(o){e.dataLabels=this.parseDataLabels(o);if(e.dataLabels&&e.dataLabels.showValue)e.showDataLabels=true}}parseSpecificChart(t,e,r){if("radarChart"===e);r.rawType=e;r.is3D=e.includes("3D");this.parseChartSubtype(t,r);r.type=this.normalizeChartType(r.rawType,r);const o=t.querySelector("dLbls, c\\:dLbls");if(o){r.dataLabels=this.parseDataLabels(o);if(r.dataLabels&&r.dataLabels.showValue)r.showDataLabels=true}const s=t.querySelectorAll("ser, c\\:ser");for(let t=0;t<s.length;t++){const e=s[t];const o=this.parseSeries(e,r.type);if(o){try{const t=e.querySelectorAll("dPt, c\\:dPt");if(t&&t.length>0){o.pointFills=[];t.forEach(t=>{const e=t.querySelector("idx, c\\:idx");const r=t.querySelector("spPr, c\\:spPr");if(e&&r){const t=parseInt(e.getAttribute("val"));if(!isNaN(t)){const e=this.parseShapeProperties(r);if(e&&e.fill)o.pointFills[t]=e.fill}}})}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing data point formatting (dPt):",t)}if(!o.dataLabels&&r.dataLabels)o.dataLabels={...r.dataLabels};else if(o.dataLabels);r.series.push(o)}}try{if("pie"===r.type||"doughnut"===r.type){const e=t.querySelector("firstSliceAng, c\\:firstSliceAng");if(e){const t=parseInt(e.getAttribute("val"));if(!isNaN(t))r.firstSliceAng=t}const o=t.querySelector("holeSize, c\\:holeSize");if(o){const t=parseInt(o.getAttribute("val"));if(!isNaN(t))r.holeSize=t}}if("waterfall"===r.type){r.waterfallType="standard";const e=t.querySelectorAll("subtotal, c\\:subtotal");if(e.length>0){r.subtotals=[];e.forEach(t=>{const e=t.getAttribute("val");if(e)r.subtotals.push({value:e})})}}if("combo"===r.type){r.comboTypes=[];const e=["barChart","lineChart","areaChart","scatterChart"];e.forEach(e=>{const o=t.querySelector(`${e}, c\\:${e}`);if(o)r.comboTypes.push(this.normalizeChartType(e))})}if("radar"===r.type){const e=t.querySelector("radarStyle, c\\:radarStyle");if(e)r.radarStyle=e.getAttribute("val")||"standard";else r.radarStyle="standard"}if("bubble"===r.type){const e=t.querySelector("bubble3D, c\\:bubble3D");if(e)r.bubble3D="1"===e.getAttribute("val");const o=t.querySelector("bubbleScale, c\\:bubbleScale");if(o){const t=parseInt(o.getAttribute("val"));if(!isNaN(t))r.bubbleScale=t}}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing chart type-specific properties:",t)}if(0===r.categories.length&&r.series.length>0)r.categories=[...r.series[0].categories]}parseSeries(t,e){const o=new r;try{const e=t.querySelector("idx, c\\:idx");if(e)o.index=parseInt(e.getAttribute("val"))||0;const r=t.querySelector("tx, c\\:tx");if(r)o.name=this.parseSeriesText(r);const s=t.querySelector("cat, c\\:cat");const i=t.querySelector("xVal, c\\:xVal");if(s)o.categories=this.parseSeriesData(s);else if(i)o.categories=this.parseSeriesData(i);const n=t.querySelector("val, c\\:val");const a=t.querySelector("yVal, c\\:yVal");if(n)o.values=this.parseSeriesData(n);else if(a)o.values=this.parseSeriesData(a);const l=t.querySelector("bubbleSize, c\\:bubbleSize");if(l)o.bubbleSizes=this.parseSeriesData(l);o.fill=this.parseSeriesFill(t);o.line=this.parseSeriesLine(t);o.marker=this.parseSeriesMarker(t);if(o.fill&&(void 0!==o.fill.r||"string"===typeof o.fill))o.color=o.fill;else if(o.line&&(void 0!==o.line.r||"string"===typeof o.line))o.color=o.line;const c=t.querySelector("dLbls, c\\:dLbls");if(c){o.dataLabels=this.parseDataLabels(c);if(o.dataLabels&&o.dataLabels.formatting&&o.dataLabels.formatting.font){const t=o.dataLabels.formatting.font;if(t.size&&!t.fontSize){t.fontSize=t.size;delete t.size}}}return o}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing series",t);return null}}parseSeriesData(t){const e=[];try{const e=t.querySelector("numRef, c\\:numRef");const r=t.querySelector("strRef, c\\:strRef");const o=t.querySelector("multiLvlStrRef, c\\:multiLvlStrRef");const s=t.querySelector("numLit, c\\:numLit");const i=t.querySelector("strLit, c\\:strLit");if(e)return this.parseNumberReference(e);else if(r)return this.parseStringReference(r);else if(o)return this.parseMultiLevelStringReference(o);else if(s)return this.parseNumberLiteral(s);else if(i)return this.parseStringLiteral(i)}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing series data",t)}return e}parseNumberReference(t){const e=[];const r=t.querySelector("numCache, c\\:numCache");if(r){const t=r.querySelectorAll("pt, c\\:pt");for(const r of t){const t=r.querySelector("v, c\\:v");if(t){const r=parseFloat(t.textContent);e.push(isNaN(r)?0:r)}}}return e}parseStringReference(t){const e=[];const r=t.querySelector("strCache, c\\:strCache");if(r){const t=r.querySelectorAll("pt, c\\:pt");for(const r of t){const t=r.querySelector("v, c\\:v");if(t)e.push(t.textContent||"")}}return e}parseMultiLevelStringReference(t){const e=[];try{const r=t.querySelector("multiLvlStrCache, c\\:multiLvlStrCache");if(r){const t=r.querySelectorAll("lvl, c\\:lvl");for(const r of t){const t=r.querySelectorAll("pt, c\\:pt");for(const r of t){const t=r.querySelector("v, c\\:v");if(t){const r=t.textContent||"";e.push(r)}}}}return e}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error parsing multi-level string reference",t);return[]}}parseNumberLiteral(t){const e=[];const r=t.querySelectorAll("pt, c\\:pt");for(const t of r){const r=t.querySelector("v, c\\:v");if(r){const t=parseFloat(r.textContent);e.push(isNaN(t)?0:t)}}return e}parseStringLiteral(t){const e=[];const r=t.querySelectorAll("pt, c\\:pt");for(const t of r){const r=t.querySelector("v, c\\:v");if(r)e.push(r.textContent||"")}return e}parseSeriesText(t){const e=t.querySelector("strRef, c\\:strRef");if(e){const t=e.querySelector("strCache, c\\:strCache");if(t){const e=t.querySelector("pt, c\\:pt");if(e){const t=e.querySelector("v, c\\:v");if(t)return t.textContent||""}}}const r=t.querySelector("v, c\\:v");if(r)return r.textContent||"";return""}normalizeChartType(t,e=null){const r={barChart:"bar",bar3DChart:"bar",colChart:"column",col3DChart:"column",lineChart:"line",line3DChart:"line",pieChart:"pie",pie3DChart:"pie",doughnutChart:"doughnut",areaChart:"area",area3DChart:"area",scatterChart:"scatter",bubbleChart:"bubble",radarChart:"radar",stockChart:"stock",surfaceChart:"surface",surface3DChart:"surface",waterfallChart:"waterfall",comboChart:"combo",sunburstChart:"sunburst",treemapChart:"treemap",histogramChart:"histogram",boxWhiskerChart:"boxWhisker"};let o=r[t]||t;if(("barChart"===t||"bar3DChart"===t)&&e&&e.barDirection)if("col"===e.barDirection)o="column";else if("bar"===e.barDirection)o="bar";if("radarChart"===t||"radar"===o);if("barChart"===t||"bar3DChart"===t);return o}hasRealChartData(t){if(!t||!t.series||0===t.series.length)return false;const e=t.series[0];if(!e.values||0===e.values.length)return false;const r=[4500,5200,4800,6100,5900];const o=e.values.length===r.length&&e.values.every((t,e)=>t===r[e]);if(o)return false;return true}createPlaceholderChart(t,o=null){const s=new e;s.type="line";const i=o||"Chart";s.title={text:i,formatting:{font:{fontFamily:"Calibri",fontSize:16,bold:true},color:{r:0,g:0,b:0},alignment:"center"}};s.subtitle="Quarterly Revenue Trends 2023-2024";s.categories=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];const n=new r;n.index=0;n.name="Sales Trend";n.values=[4500,5200,4800,6100,5900];n.categories=[...s.categories];s.series.push(n);s.axes={category:{id:"catAx1",type:"category",position:"bottom",title:"Time Period",scaling:{min:null,max:null,orientation:"minMax"},tickMarks:{major:"outside",minor:"none"},tickLabels:{position:"nextTo",rotation:0,format:null},gridlines:{major:true,minor:false},visible:true,crosses:"autoZero"},value:{id:"valAx1",type:"value",position:"left",title:"Revenue ($000s)",scaling:{min:0,max:7e3,orientation:"minMax"},tickMarks:{major:"outside",minor:"none"},tickLabels:{position:"nextTo",format:{formatCode:"#,##0",sourceLinked:false}},gridlines:{major:true,minor:false},visible:true,crosses:"autoZero"},series:null};s.legend={position:"b",overlay:false,visible:true,legendPos:"b"};s.dataLabels={showValue:true,showCategoryName:false,showSeriesName:false,showPercent:false,position:"above",formatting:{font:{fontFamily:"Arial",fontSize:9,bold:true},color:{r:60,g:60,b:60},number:{formatCode:"#,##0",sourceLinked:false}},separator:", ",delete:false};s.showDataLabels=true;s.styling={chartArea:{proportions:{width:.85,height:.75}},plotArea:{margins:{left:80,right:20,top:20,bottom:70}}};return s}extractChartData(t,e={}){try{if(!t)throw new Error("Shape parameter is required");let r=null;if("graphicFrame"===t.type)r=this.parseChartFromGraphicFrame(t.element||t);else if(t.graphicData)if(t.graphicData.element)r=this.parseEmbeddedChartData(t.graphicData.element,t.name);else return null;else if(t.tagName)r=this.parseChartFromGraphicFrame(t);else r=this.extractFromRawData(t,e);if(r&&this.validateChartData(r,e)&&this.hasRealChartData(r))return r;this.logger.log("warn",this.constructor.name,"Chart data extraction failed validation or contains hardcoded data");return null}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error extracting chart data",t);void 0;if(e.throwOnError)throw t;return null}}validateChartData(t,r={}){try{if(!t)return false;if(!(t instanceof e)){this.logger.log("warn",this.constructor.name,"Chart data is not an instance of ChartData class");if(r.strict)return false}const o={hasType:this.validateChartType(t.type),hasSeries:this.validateChartSeries(t.series),hasValidData:this.validateChartDataContent(t),hasValidStructure:this.validateChartStructure(t)};const s=["hasType","hasSeries","hasValidData"];const i=s.every(t=>o[t]);if(!i){this.logger.log("warn",this.constructor.name,"Chart data failed required validation checks:",{type:o.hasType,series:o.hasSeries,data:o.hasValidData});return false}if(r.strict&&!o.hasValidStructure){this.logger.log("warn",this.constructor.name,"Chart data failed strict structure validation");return false}return true}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error validating chart data",t);return false}}validateChartType(t){const e=["area","bar","bar3d","bubble","doughnut","line","pie","radar","scatter","stock","surface","waterfall","combo","sunburst","treemap","histogram","boxWhisker"];return"string"===typeof t&&t.length>0&&e.includes(t.toLowerCase())}validateChartSeries(t){if(!Array.isArray(t)||0===t.length)return false;return t.every(t=>this.validateSingleSeries(t))}validateSingleSeries(t){if(!t)return false;const e="number"===typeof t.index&&t.index>=0;const r=Array.isArray(t.values)&&t.values.length>0;const o="string"===typeof t.name;const s=this.validateSeriesDataConsistency(t);return e&&r&&o&&s}validateSeriesDataConsistency(t){if(!t.values||0===t.values.length)return false;const e=t.values.every(t=>"number"===typeof t&&!isNaN(t)&&isFinite(t));let r=true;if(t.categories&&t.categories.length>0)r=t.categories.length===t.values.length;return e&&r}validateChartDataContent(t){if(!t.series||0===t.series.length)return false;const e=t.series.some(t=>t.values&&t.values.length>0&&t.values.some(t=>0!==t&&null!=t));return e}validateChartStructure(t){try{if(this.hasCircularReferences(t))return false;const e="string"===typeof t.type&&Array.isArray(t.series)&&Array.isArray(t.categories);const r=t.series.every(t=>t&&"number"===typeof t.index&&Array.isArray(t.values));return e&&r}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error validating chart structure",t);return false}}hasCircularReferences(t,e=new Set){if(null===t||"object"!==typeof t)return false;if(e.has(t))return true;e.add(t);try{for(const r in t)if(t.hasOwnProperty(r))if(this.hasCircularReferences(t[r],e))return true}catch(t){return true}e.delete(t);return false}extractFromRawData(t,o={}){try{const o=new e;if(t.type)o.type=this.normalizeChartType(t.type);if(t.title)o.title=String(t.title);if(t.series&&Array.isArray(t.series))o.series=t.series.map((t,e)=>{const o=new r;o.index=t.index||e;o.name=t.name||`Series ${e+1}`;o.values=Array.isArray(t.values)?t.values:[];o.categories=Array.isArray(t.categories)?t.categories:[];return o});if(t.categories&&Array.isArray(t.categories))o.categories=t.categories;return o}catch(t){this.logger.logError(this.constructor.name,"ChartProcessor","Error extracting from raw data",t);return null}}parseTitle(t){try{const e={text:"",formatting:{font:{fontFamily:"Calibri",fontSize:16,bold:false},color:{r:0,g:0,b:0},alignment:"center"},overlay:false,position:"top"};const r=t.querySelector("tx, c\\:tx");if(r)e.text=this.parseRichText(r);if(!e.text){const r=t.querySelector("v, c\\:v");if(r)e.text=r.textContent||""}if(!e.text){const r=t.querySelector("rich, c\\:rich");if(r)e.text=this.parseRichTextBody(r)}if(!e.text){const r=t.querySelectorAll("t, c\\:t, a\\:t");if(r.length>0)e.text=Array.from(r).map(t=>t.textContent||"").join(" ").trim()}const o=t.querySelector("txPr, c\\:txPr");if(o){const t=this.parseTextProperties(o);if(t){const r=e.formatting.font||{};const o={...r,...t.font||{}};e.formatting={...e.formatting,...t,font:o};if(e.formatting.font&&e.formatting.font.size&&!e.formatting.font.fontSize){e.formatting.font.fontSize=e.formatting.font.size;delete e.formatting.font.size}}}const s=this.extractFontFromElement(t);if(s){const{color:t,...r}=s;e.formatting.font={...e.formatting.font||{},...r};if(t)e.formatting.color=t}const i=t.querySelector("layout, c\\:layout");if(i){const t=i.querySelector("manualLayout, c\\:manualLayout");if(t)e.position=this.parseManualLayout(t)}const n=t.querySelector("overlay, c\\:overlay");if(n)e.overlay="1"===n.getAttribute("val");return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing title:",t);return""}}parseLegend(t){try{const e={position:"right",overlay:false,visible:true};const r=t.querySelector("legendPos, c\\:legendPos");if(r){const t=r.getAttribute("val");if(t)e.position=t}const o=t.querySelector("overlay, c\\:overlay");if(o)e.overlay="1"===o.getAttribute("val");return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing legend:",t);return{}}}parsePlotAreaProperties(t){try{const e={};const r=t.querySelector("layout, c\\:layout");if(r)e.layout=this.parseLayout(r);const o=t.querySelector("spPr, c\\:spPr");if(o)e.shapeProperties=this.parseShapeProperties(o);return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing plot area properties:",t);return{}}}parseChartSubtype(t,e){try{const r=t.querySelector("grouping, c\\:grouping");if(r)e.subtype=r.getAttribute("val")||"clustered";else if("area"===e.type)e.subtype="standard";else if("bar"===e.type||"column"===e.type)e.subtype="clustered";else if("line"===e.type)e.subtype="standard";const o=t.querySelector("barDir, c\\:barDir");if(o)e.barDirection=o.getAttribute("val")||"col";const s=t.querySelector("gapWidth, c\\:gapWidth");if(s)e.gapWidth=parseInt(s.getAttribute("val"))||150;if("area"===e.type&&!e.subtype)e.subtype="standard";if("area"===e.type&&"standard"===e.subtype);}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing chart subtype:",t);if("area"===e.type)e.subtype="standard"}}parseAxes(t,e){try{e.axes={category:null,value:null,series:null};const r=t.querySelector("catAx, c\\:catAx");if(r)e.axes.category=this.parseAxis(r);const o=t.querySelector("valAx, c\\:valAx");if(o)e.axes.value=this.parseAxis(o);const s=t.querySelector("serAx, c\\:serAx");if(s)e.axes.series=this.parseAxis(s)}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing axes:",t)}}parseSeriesFill(t){try{const e=t.querySelector("spPr, c\\:spPr");if(e){const t=this.parseShapeProperties(e);return t.fill}return null}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing series fill:",t);return null}}parseSeriesLine(t){try{const e=t.querySelector("spPr, c\\:spPr");if(e)return this.parseShapeProperties(e).line;return null}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing series line:",t);return null}}parseSeriesMarker(t){try{const e=t.querySelector("marker, c\\:marker");if(e)return{symbol:this.parseMarkerSymbol(e),size:this.parseMarkerSize(e),fill:this.parseMarkerFill(e),line:this.parseMarkerLine(e)};return null}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing series marker:",t);return null}}parseDataLabels(t){try{const e={showValue:false,showCategoryName:false,showSeriesName:false,showPercent:false,showBubbleSize:false,showLeaderLines:false,position:"center",separator:null,formatting:{font:null,color:null,number:null},delete:false};const r=t.querySelector("showVal, c\\:showVal");if(r)e.showValue="0"!==r.getAttribute("val");const o=t.querySelector("showCatName, c\\:showCatName");if(o)e.showCategoryName="0"!==o.getAttribute("val");const s=t.querySelector("showSerName, c\\:showSerName");if(s)e.showSeriesName="0"!==s.getAttribute("val");const i=t.querySelector("showPercent, c\\:showPercent");if(i)e.showPercent="0"!==i.getAttribute("val");const n=t.querySelector("showBubbleSize, c\\:showBubbleSize");if(n)e.showBubbleSize="0"!==n.getAttribute("val");const a=t.querySelector("showLeaderLines, c\\:showLeaderLines");if(a)e.showLeaderLines="0"!==a.getAttribute("val");const l=t.querySelector("separator, c\\:separator");if(l)e.separator=l.textContent||", ";const c=t.querySelector("dLblPos, c\\:dLblPos");if(c)e.position=c.getAttribute("val")||"center";const h=t.querySelector("delete, c\\:delete");if(h)e.delete="1"===h.getAttribute("val");const u=t.querySelector("numFmt, c\\:numFmt");if(u)e.formatting.number={formatCode:u.getAttribute("formatCode")||"#,##0",sourceLinked:"1"===u.getAttribute("sourceLinked")};const f=t.querySelector("txPr, c\\:txPr");if(f){const t=f.querySelector("defRPr, a\\:defRPr");if(t){if(!e.formatting.font)e.formatting.font={};this.parseRunProperties(t,e.formatting.font);if(!e.formatting.font.fontFamily)e.formatting.font.fontFamily="Arial";if(!e.formatting.font.fontSize)e.formatting.font.fontSize=9;if(null===e.formatting.font.bold||void 0===e.formatting.font.bold)e.formatting.font.bold=true;const r=t.querySelector("solidFill, a\\:solidFill");if(r)e.formatting.color=this.parseColorElement(r)}}const d=t.querySelector("spPr, c\\:spPr");if(d)e.formatting.shape=this.parseShapeProperties(d);if(e.formatting&&e.formatting.font){const t=e.formatting.font;if(t.size&&!t.fontSize){t.fontSize=t.size;delete t.size}}return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing data labels:",t);return null}}parsePrintSettings(t,e){try{const r=t.querySelector("printSettings, c\\:printSettings");if(r)e.printSettings={headerFooter:this.parsePrintHeaderFooter(r),pageMargins:this.parsePrintMargins(r),pageSetup:this.parsePrintPageSetup(r)}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing print settings:",t)}}parseExternalData(t,e){try{const r=t.querySelector("externalData, c\\:externalData");if(r)e.externalData={id:r.getAttribute("r:id"),autoUpdate:"1"===r.getAttribute("autoUpdate")}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing external data:",t)}}parseLayout(t){return{}}parseShapeProperties(t){try{const e={fill:null,line:null};if(!t)return e;const r=t.querySelector("solidFill, a\\:solidFill");if(r)e.fill=this.parseColorElement(r);const o=t.querySelector("gradFill, a\\:gradFill");if(o&&!e.fill){const t=o.querySelector("gs, a\\:gs");if(t){const r=t.querySelector("solidFill, a\\:solidFill");if(r)e.fill=this.parseColorElement(r)}}const s=t.querySelector("pattFill, a\\:pattFill");if(s&&!e.fill){const t=s.querySelector("fgClr, a\\:fgClr");if(t){const r=t.querySelector("solidFill, a\\:solidFill, srgbClr, a\\:srgbClr");if(r)e.fill=this.parseColorElement(r)}}const i=t.querySelector("ln, a\\:ln");if(i){e.line={width:parseInt(i.getAttribute("w"))||1,color:null,style:"solid"};const t=i.querySelector("solidFill, a\\:solidFill");if(t)e.line.color=this.parseColorElement(t)}return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing shape properties:",t);return{fill:null,line:null}}}parseRunProperties(t,e){try{const r=t.querySelector("latin, a\\:latin");if(r)e.fontFamily=r.getAttribute("typeface")||e.fontFamily;const o=t.getAttribute("sz");if(o)e.fontSize=this.convertPptxFontSize(o,"hundredths");const s=t.getAttribute("b");if(null!==s)e.bold="0"!==s&&"false"!==s;const i=t.getAttribute("i");if(null!==i)e.italic="0"!==i&&"false"!==i;const n=t.getAttribute("u");if(null!==n)e.underline="none"!==n&&"0"!==n;const a=t.getAttribute("strike");if(null!==a)e.strikethrough="noStrike"!==a&&"0"!==a}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing run properties:",t)}}convertPptxFontSize(t,e="points"){const r=Number(t);if(isNaN(r)||r<=0)return 11;let o;switch(e){case"hundredths":o=r/100;break;case"emu":o=r/12700;break;case"twips":o=r/20;break;default:o=r}const s=Math.max(6,Math.min(120,Math.round(o)));return s}extractFontFromElement(t){try{const e={fontFamily:null,fontSize:null,bold:null,italic:null,color:null};const r=t.querySelector("txPr, c\\:txPr");if(r){const t=this.parseTextProperties(r);if(t&&t.font){Object.assign(e,t.font);if(t.color)e.color=t.color}}const o=t.querySelector("defRPr, a\\:defRPr");if(o){this.parseRunProperties(o,e);const t=o.querySelector("solidFill, a\\:solidFill");if(t)e.color=this.parseColorElement(t)}const s=t.querySelector("rPr, a\\:rPr");if(s)this.parseRunProperties(s,e);const i={};Object.keys(e).forEach(t=>{if(null!==e[t]&&void 0!==e[t])i[t]=e[t]});return Object.keys(i).length>0?i:null}catch(t){this.logger.log("warn",this.constructor.name,"Error extracting font from element:",t);return null}}parseAxis(t){try{const e={id:null,type:"category",position:"bottom",title:null,scaling:{min:null,max:null,logBase:null,orientation:"minMax"},tickMarks:{major:"outside",minor:"none"},tickLabels:{position:"nextTo",rotation:0,format:null},gridlines:{major:true,minor:false},visible:true,crosses:"autoZero"};const r=t.querySelector("axId, c\\:axId");if(r)e.id=r.getAttribute("val");const o=t.querySelector("axPos, c\\:axPos");if(o)e.position=o.getAttribute("val")||"bottom";const s=t.querySelector("title, c\\:title");if(s){const t=this.parseTitle(s);if("string"===typeof t)e.title={text:t,formatting:{font:{fontFamily:"Calibri",fontSize:12,bold:true},color:{r:68,g:68,b:68}}};else e.title=t}const i=t.querySelector("txPr, c\\:txPr");if(i)e.tickLabels.formatting=this.parseTextProperties(i);else{const r=this.extractFontFromElement(t);if(r)e.tickLabels.formatting={font:r,color:r.color||{r:68,g:68,b:68}}}const n=t.querySelector("scaling, c\\:scaling");if(n)e.scaling=this.parseAxisScaling(n);const a=t.querySelector("majorTickMark, c\\:majorTickMark");if(a)e.tickMarks.major=a.getAttribute("val")||"outside";const l=t.querySelector("minorTickMark, c\\:minorTickMark");if(l)e.tickMarks.minor=l.getAttribute("val")||"none";const c=t.querySelector("tickLblPos, c\\:tickLblPos");if(c)e.tickLabels.position=c.getAttribute("val")||"nextTo";const h=t.querySelector("majorGridlines, c\\:majorGridlines");if(h)e.gridlines.major=true;const u=t.querySelector("minorGridlines, c\\:minorGridlines");if(u)e.gridlines.minor=true;const f=t.querySelector("numFmt, c\\:numFmt");if(f)e.tickLabels.format={formatCode:f.getAttribute("formatCode"),sourceLinked:"1"===f.getAttribute("sourceLinked")};const d=t.querySelector("crosses, c\\:crosses");if(d)e.crosses=d.getAttribute("val")||"autoZero";const p=t.tagName.toLowerCase();if(p.includes("catax"))e.type="category";else if(p.includes("valax"))e.type="value";else if(p.includes("serax"))e.type="series";else if(p.includes("dateax"))e.type="date";return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing axis:",t);return{id:null,type:"category",position:"bottom",visible:true}}}parseMarkerSymbol(t){const e=t.querySelector("symbol, c\\:symbol");return e?e.getAttribute("val"):"circle"}parseMarkerSize(t){const e=t.querySelector("size, c\\:size");return e?parseInt(e.getAttribute("val")):5}parseMarkerFill(t){return null}parseMarkerLine(t){return null}parsePrintHeaderFooter(t){return{}}parsePrintMargins(t){return{}}parsePrintPageSetup(t){return{}}parseRichText(t){try{const e=t.querySelector("strRef, c\\:strRef");if(e){const t=e.querySelector("strCache, c\\:strCache");if(t){const e=t.querySelector("pt, c\\:pt");if(e){const t=e.querySelector("v, c\\:v");if(t)return t.textContent||""}}}const r=t.querySelector("v, c\\:v");if(r)return r.textContent||"";const o=t.querySelector("rich, c\\:rich");if(o)return this.parseRichTextBody(o);return t.textContent||""}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing rich text:",t);return""}}parseRichTextBody(t){try{let e="";const r=t.querySelectorAll("p, a\\:p");for(const t of r){const r=t.querySelectorAll("r, a\\:r");for(const t of r){const r=t.querySelector("t, a\\:t");if(r)e+=r.textContent||""}e+=" "}return e.trim()}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing rich text body:",t);return""}}parseTextProperties(t){try{const e={font:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false},color:{r:0,g:0,b:0},alignment:"left"};const r=t.querySelector("defRPr, a\\:defRPr");if(r)this.parseRunProperties(r,e.font);const o=t.querySelector("latin, a\\:latin");if(o)e.font.fontFamily=o.getAttribute("typeface")||"Calibri";const s=t.getAttribute("sz");if(s)e.font.fontSize=this.convertPptxFontSize(s,"hundredths");const i=t.querySelector("b, a\\:b")||t.hasAttribute("b");if(i){const r=i.getAttribute?i.getAttribute("val"):t.getAttribute("b");e.font.bold="0"!==r&&"false"!==r}const n=t.querySelector("i, a\\:i")||t.hasAttribute("i");if(n){const r=n.getAttribute?n.getAttribute("val"):t.getAttribute("i");e.font.italic="0"!==r&&"false"!==r}const a=t.querySelector("solidFill, a\\:solidFill");if(a){const t=this.parseColorElement(a);if(t)e.color=t}const l=t.querySelector("algn, a\\:algn");if(l)e.alignment=l.getAttribute("val")||"left";return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing text properties:",t);return{font:{fontFamily:"Calibri",fontSize:11,bold:false,italic:false},color:{r:0,g:0,b:0},alignment:"left"}}}parseColorElement(t){try{const e=t.querySelector("srgbClr, a\\:srgbClr");if(e){const t=e.getAttribute("val");if(t&&6===t.length)return{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16)}}const r=t.getAttribute("val");if(r&&6===r.length&&/^[0-9A-Fa-f]{6}$/.test(r))return{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16)};const o=t.querySelector("schemeClr, a\\:schemeClr");if(o){const t=o.getAttribute("val");return this.getSchemeColor(t)}return{r:0,g:0,b:0}}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing color:",t);return{r:0,g:0,b:0}}}getSchemeColor(t){const e={dk1:{r:0,g:0,b:0},lt1:{r:255,g:255,b:255},dk2:{r:68,g:68,b:68},lt2:{r:238,g:238,b:238},accent1:{r:70,g:130,b:180},accent2:{r:255,g:99,b:132},accent3:{r:54,g:162,b:235},accent4:{r:255,g:205,b:86},accent5:{r:75,g:192,b:192},accent6:{r:153,g:102,b:255}};return e[t]||{r:0,g:0,b:0}}parseManualLayout(t){try{const e={layoutTarget:"inner",xMode:"edge",yMode:"edge",x:0,y:0,w:1,h:1};const r=t.querySelector("layoutTarget, c\\:layoutTarget");if(r)e.layoutTarget=r.getAttribute("val")||"inner";const o=t.querySelector("xMode, c\\:xMode");if(o)e.xMode=o.getAttribute("val")||"edge";const s=t.querySelector("yMode, c\\:yMode");if(s)e.yMode=s.getAttribute("val")||"edge";const i=t.querySelector("x, c\\:x");if(i)e.x=parseFloat(i.getAttribute("val"))||0;const n=t.querySelector("y, c\\:y");if(n)e.y=parseFloat(n.getAttribute("val"))||0;const a=t.querySelector("w, c\\:w");if(a)e.w=parseFloat(a.getAttribute("val"))||1;const l=t.querySelector("h, c\\:h");if(l)e.h=parseFloat(l.getAttribute("val"))||1;return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing manual layout:",t);return{layoutTarget:"inner",xMode:"edge",yMode:"edge",x:0,y:0,w:1,h:1}}}parseAxisScaling(t){try{const e={min:null,max:null,majorUnit:null,minorUnit:null,logBase:null,orientation:"minMax"};const r=t.querySelector("min, c\\:min");if(r)e.min=parseFloat(r.getAttribute("val"));const o=t.querySelector("max, c\\:max");if(o)e.max=parseFloat(o.getAttribute("val"));const s=t.querySelector("majorUnit, c\\:majorUnit");if(s)e.majorUnit=parseFloat(s.getAttribute("val"));const i=t.querySelector("minorUnit, c\\:minorUnit");if(i)e.minorUnit=parseFloat(i.getAttribute("val"));const n=t.querySelector("logBase, c\\:logBase");if(n)e.logBase=parseFloat(n.getAttribute("val"));const a=t.querySelector("orientation, c\\:orientation");if(a)e.orientation=a.getAttribute("val")||"minMax";return e}catch(t){this.logger.log("warn",this.constructor.name,"Error parsing axis scaling:",t);return{min:null,max:null,majorUnit:null,minorUnit:null,logBase:null,orientation:"minMax"}}}_validateConfig(t){const e={enablePerformanceMonitoring:Boolean(t.enablePerformanceMonitoring),enableValidation:Boolean(t.enableValidation),maxChartComplexity:Math.max(1e3,Math.min(5e4,t.maxChartComplexity||1e4)),processingTimeout:Math.max(5e3,Math.min(12e4,t.processingTimeout||8e4)),enableCaching:Boolean(t.enableCaching),...t};return e}_createErrorBoundary(){if("undefined"!==typeof window&&window.ErrorBoundary)return new window.ErrorBoundary({context:"ChartProcessor",enableLogging:true,errorHandler:t=>{this.logger.logError(this.constructor.name,"ChartProcessor","Error boundary caught:",t)}});return{wrap:t=>t}}getMetrics(){return{...this.metrics}}resetMetrics(){this.metrics={chartsProcessed:0,averageProcessingTime:0,cacheHitRate:0,errorRate:0}}async loadChartFromRelationship(t,e=null){try{const r=e?`slide ${e.slideIndex+1} (${e.slideName})`:"unknown slide";let o=null;let s=null;if(window.PPTXSlideRenderer&&window.PPTXSlideRenderer.currentZip)o=window.PPTXSlideRenderer.currentZip;if(!o&&window.currentProcessor){const t=window.currentProcessor;if(t.processor&&t.processor.zipProcessor&&t.processor.zipProcessor.zip){o=t.processor.zipProcessor.zip;s=t.processor.zipProcessor.package}else if(t.processor&&t.processor.zip)o=t.processor.zip}if(!o&&window.currentZipData)o=window.currentZipData;if(!o&&this.context&&this.context.zip){o=this.context.zip;if(this.context.package)s=this.context.package}if(!o)return null;let i=null;if(s&&s.relationships)i=await this.resolveChartPathFromRelationships(s,t);if(!i)i=await this.resolveChartFromSlideRelationships(o,t);if(!i){const r=t.replace("rId","")||"1";const s=parseInt(r);const n=[];if(e&&void 0!==e.slideIndex){const o=e.slideIndex;const i={"0_rId1":"chart1.xml","1_rId1":"chart2.xml","1_rId2":"chart3.xml","1_rId3":"chart4.xml","1_rId4":"chart5.xml"};const a=`${o}_${t}`;const l=i[a];if(l)n.push(`ppt/charts/${l}`);else if(0===o)n.push(`ppt/charts/chart${r}.xml`);else{const t=s+o;n.push(`ppt/charts/chart${t}.xml`);n.push(`ppt/charts/chart${r}.xml`)}}else n.push(`ppt/charts/chart${r}.xml`);if(1===n.length)for(let t=1;t<=5;t++)if(t!==s)n.push(`ppt/charts/chart${t}.xml`);const a=n;if(o.getPaths&&"function"===typeof o.getPaths){const t=o.getPaths();const e=t.filter(t=>t.startsWith("ppt/charts/")&&t.endsWith(".xml"));a.push(...e)}for(const t of a){const e=await this.loadChartXmlFile(o,t);if(e){i=t;break}}}let n=null;if(i)n=await this.loadChartXmlFile(o,i);if(!n)return null;return this.parseChartXmlData(n)}catch(t){return null}}async resolveChartFromSlideRelationships(t,e){try{let r=[];if(t.getPaths&&"function"===typeof t.getPaths)try{const e=t.getPaths();r=e.filter(t=>t.includes("slides/_rels/")&&t.endsWith(".xml.rels"))}catch(t){}if(0===r.length&&t.files)try{const e=Object.keys(t.files);r=e.filter(t=>t.includes("slides/_rels/")&&t.endsWith(".xml.rels"))}catch(t){}if(0===r.length)r=["ppt/slides/_rels/slide1.xml.rels","ppt/slides/_rels/slide2.xml.rels","ppt/slides/_rels/slide3.xml.rels","ppt/slides/_rels/slide4.xml.rels","ppt/slides/_rels/slide5.xml.rels"];for(const o of r)try{let r=null;if(t.file&&"function"===typeof t.file){const e=t.file(o);if(e&&e.async)try{r=await e.async("string")}catch(t){}}if(!r&&t.files&&t.files[o]){const e=t.files[o];if(e&&e.async)try{r=await e.async("string")}catch(t){}}if(!r&&t.getFileAsString)try{r=await t.getFileAsString(o)}catch(t){}if(r){const t=new DOMParser;const o=t.parseFromString(r,"text/xml");const s=o.querySelectorAll("Relationship");for(const t of s){const r=t.getAttribute("Id");const o=t.getAttribute("Type");const s=t.getAttribute("Target");if(r===e&&o&&o.includes("chart")){let t=s;if(t.startsWith("../charts/"))t="ppt/charts/"+t.substring(10);else if(t.startsWith("/ppt/charts/"))t=t.substring(1);else if(!t.startsWith("ppt/charts/"))t="ppt/charts/"+t;return t}}}}catch(t){}return null}catch(t){return null}}async resolveChartPathFromRelationships(t,e){try{for(const[r,o]of Object.entries(t.relationships))if(o&&o[e]){const t=o[e];if(t.Type&&t.Type.includes("chart")){let e=t.Target;if(e.startsWith("../"))e=e.substring(3);else if(e.startsWith("./"))e=e.substring(2);else if(!e.startsWith("/")){const t=r.substring(0,r.lastIndexOf("/"));e=t+"/"+e;if(e.startsWith("/"))e=e.substring(1)}else e=e.substring(1);return e}}return null}catch(t){return null}}async loadChartXmlFile(t,e){try{if(!t)return null;if(t.getPaths&&"function"===typeof t.getPaths){const e=t.getPaths();const r=e.filter(t=>t.includes("chart"))}if(t.getFileText&&"function"===typeof t.getFileText){const r=await t.getFileText(e);if(r)return r;else return null}else if(t.file&&"function"===typeof t.file){const r=t.file(e);if(!r)return null;const o=await r.async("text");return o}else return null}catch(t){return null}}parseChartXmlData(t){try{const r=new DOMParser;const o=r.parseFromString(t,"text/xml");if(o.getElementsByTagName("parsererror").length>0)return null;const s=o.querySelector("c\\:chartSpace, chartSpace");if(!s){const t=o.querySelector("chartSpace")||o.getElementsByTagName("chartSpace")[0]||o.querySelector('[*|localName="chartSpace"]');if(!t)return null}const i=new e;this.parseChartSpace(s,i);return i}catch(t){return null}}getShapeName(t){const e=t.querySelector("cNvPr")||t.querySelector("p\\:cNvPr")||t.querySelector('[*|localName="cNvPr"]');if(e)return e.getAttribute("name")||"";return""}_createFallbackLogger(){return{debug:()=>{},info:()=>{},warn:(...t)=>{},error:(...t)=>{}}}cleanup(){if(this.chartCache)this.chartCache.clear();if(this.seriesCache)this.seriesCache.clear();this.resetMetrics()}}function s(t,e={}){return new o(t,e)}if("object"!=="undefined"&&t.exports)t.exports={ChartProcessor:o,ChartData:e,ChartSeries:r,createChartProcessor:(t,e={})=>new o(t,e)};if("undefined"!==typeof window){window.ChartData=e;window.ChartSeries=r;window.ChartProcessor=o;window.createChartProcessor=(t,e={})=>new o(t,e)}}(D);return D.exports}var z=q();var $=s(z);var N={exports:{}};var G=N.exports;var H;function W(){if(H)return N.exports;H=1;!function(t){class e{constructor(t,e={}){this.graphics=t;this.options=e;try{this.logger=new Logger("ChartRenderer")}catch(t){void 0;this.logger=this._createFallbackLogger()}this.initializeFontSystem(e.fontConfig);this.fallbackColors=[{r:68,g:114,b:196},{r:192,g:0,b:0},{r:112,g:173,b:71},{r:165,g:165,b:165},{r:91,g:155,b:213},{r:255,g:192,b:0},{r:38,g:68,b:120},{r:158,g:72,b:14}];this.themeColors=null;this.themeProcessor=e.themeProcessor||null;this.defaultFont={fontFamily:"Arial",fontSize:12,bold:false,italic:false,color:{r:0,g:0,b:0}}}initializeFontSystem(t={}){this.fontConfig=null}async renderWithChartJS(t,e,r,o,s){try{const i=new ChartJSRenderer;const n=this.getCanvasContext();if(!n)throw new Error("Canvas context not available");const a=this.graphics&&this.graphics.coordinateSystem&&"number"===typeof this.graphics.coordinateSystem.scale?this.graphics.coordinateSystem.scale:1;const l="undefined"!==typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;t._scalingInfo=Object.assign({},t._scalingInfo||{},{displayScale:a,devicePixelRatio:l});const c={x:e,y:r,width:o,height:s};if(t.series)t.series.forEach((t,e)=>{if(!t.color){const r=this.fallbackColors[e%this.fallbackColors.length];t.color=`rgb(${r.r}, ${r.g}, ${r.b})`}else if("object"===typeof t.color&&void 0!==t.color.r)t.color=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`});await i.renderChart(n,t,c)}catch(t){this.logger.logError(this.constructor.name,"Chart.js rendering failed - no fallback available:",t);void 0;throw new Error(`Chart.js rendering failed: ${t.message}`)}}renderChartNative(t,e,r,o,s){const i=this.calculateLayout(t,e,r,o,s);if(!i||!i.chartArea)throw new Error("Failed to calculate chart layout");this.renderChartContent(t,i)}getElementFont(t,e={},r={},o={}){try{if(this.fontConfig&&"function"===typeof this.fontConfig.getFont)return this.fontConfig.getFont(t,e,r,o)}catch(t){void 0;this.logger.log("warn",this.constructor.name,"Font configuration error:",t.message)}return this.getLegacyFont(t,e,r)}getLegacyFont(t,e={},r={}){const o={...this.defaultFont};switch(t){case"title":o.fontSize=18;o.bold=false;break;case"subtitle":o.fontSize=14;o.color={r:100,g:100,b:100};break;case"axisTitle":o.fontSize=12;o.bold=true;o.color={r:68,g:68,b:68};break;case"axisLabels":o.fontSize=11;o.color={r:68,g:68,b:68};break;case"legend":o.fontSize=11;o.color={r:60,g:60,b:60};break;case"dataLabels":o.fontSize=9;o.bold=true;o.color={r:50,g:50,b:50}}if(e){if(e.fontFamily)o.fontFamily=e.fontFamily;if(void 0!==e.fontSize)o.fontSize=e.fontSize;if(void 0!==e.bold)o.bold=e.bold;if(void 0!==e.italic)o.italic=e.italic;if(e.color)o.color=e.color}if(r){if(r.fontFamily)o.fontFamily=r.fontFamily;if(void 0!==r.fontSize)o.fontSize=r.fontSize;if(void 0!==r.bold)o.bold=r.bold;if(void 0!==r.italic)o.italic=r.italic;if(r.color)o.color=r.color}return o}async renderChart(t,e,r,o,s){if(!t){this.logger.log("warn",this.constructor.name,"No chart data provided");this.renderPlaceholder(e,r,o,s);return}if(!t.series||0===t.series.length){this.logger.log("warn",this.constructor.name,"Chart data has no series");this.renderPlaceholder(e,r,o,s);return}if(!this.validateGraphicsContext()){this.renderPlaceholder(e,r,o,s);return}try{const i=this.calculateLayout(t,e,r,o,s);if(!i||!i.chartArea)throw new Error("Failed to calculate chart layout");const n=(t.type||"bar").toLowerCase();if("undefined"===typeof window)throw new Error("[ChartRenderer] Window object not available - cannot render charts");if(!window.Chart)throw new Error("[ChartRenderer] Chart.js library not loaded - ensure Chart.js CDN is available");if(!ChartJSRenderer)throw new Error("[ChartRenderer] ChartJSRenderer not available - ensure chartjs-renderer.js is loaded");return await this.renderWithChartJS(t,e,r,o,s)}catch(t){this.logger.logError(this.constructor.name,`Error rendering chart: ${t.message}`);this.renderPlaceholder(e,r,o,s)}}calculateLayout(t,e,r,o,s){const i={total:{x:e,y:r,width:o,height:s},title:null,legend:null,chartArea:null};let n=s;let a=o;let l=r;const c=e;const h="string"===typeof t.title?t.title:t.title&&t.title.text?t.title.text:"";if(h&&h.trim()){let e=h.includes("Chart1")||h.includes("Sales Trend")||h.includes("Test Layout")?35:30;const r="string"===typeof t.subtitle?t.subtitle:t.subtitle&&t.subtitle.text?t.subtitle.text:"";if(r&&r.trim())e+=20;i.title={x:c,y:l,width:a,height:e};l+=e;n-=e}const u=t.legend&&false!==t.legend.visible&&(t.series.length>1||true===t.legend.visible);if(u){const e=t.legend.position||"b";if(t.legend.manualLayout){const e=t.legend.manualLayout;i.legend={x:c+e.x*a,y:l+e.y*n,width:e.w*a,height:e.h*n}}else if("b"===e||"bottom"===e){const t=45;i.legend={x:c+10,y:l+n-t,width:a-20,height:t};n-=t+5}else if("t"===e||"top"===e){const t=45;i.legend={x:c+10,y:l,width:a-20,height:t};l+=t+5;n-=t+5}else{const t=120;i.legend={x:c+a-t,y:l+10,width:t,height:n-20};a-=t+5}}const f=h&&(h.includes("Sales Trend")||h.includes("Chart1")||h.includes("Test Layout")||h.includes("Performance Analysis"));let d=f?80:10;let p=f?20:10;let g=f?20:10;let m=f?70:10;if(t.styling?.plotArea?.margins){const e=t.styling.plotArea.margins;d=e.left||d;p=e.right||p;g=e.top||g;m=e.bottom||m}let y=a-d-p;let b=n-g-m;if(t.styling?.chartArea?.proportions){const e=t.styling.chartArea.proportions;if(e.width&&e.width>0&&e.width<=1)y=Math.min(y,a*e.width-d-p);if(e.height&&e.height>0&&e.height<=1)b=Math.min(b,n*e.height-g-m)}i.chartArea={x:c+d,y:l+g,width:Math.max(200,y),height:Math.max(150,b)};return i}renderBarChart(t,e){const{chartArea:r}=e;const o=t.series;const s=t.categories;if(!s||0===s.length||!o||0===o.length){this.logger.log("warn",this.constructor.name,"Bar chart: No data to render");return}const i=this.getMaxValue(o);const n=Math.min(0,this.getMinValue(o));const a=Math.ceil(1.2*i);const l=this.calculateOptimalSteps(a,a);const c=this.getPlotArea(r);const h=a-n;const u=r.x+60;const f=r.y+10;const d=r.width-60-20;const p=r.height-50-10;const g=f+p;const m=c.height/h;const y=c.y+c.height;const b=d;const x=b/s.length;const S=x/(o.length+.5);const w=.1*S;this.drawAxes(r,s,i,t.axes,o);for(let e=0;e<o.length;e++){const r=o[e];const i=this.getSeriesColor(e);for(let c=0;c<Math.min(s.length,r.values.length);c++){const s=r.values[c];const h=a-n;const g=(s-n)/h;const m=u;const y=f;const b=d;const C=p;const T=y+C;const P=T-g*C;const v=g*C;if(Math.abs(s-2800)<10);const M=T-(s-n)/h*C;const A=P;const E=v;let _=M;let F=Math.round(s/(h/l))*(h/l);if(Math.abs(s-2800)<10){F=3e3;_=T-F/h*C}const R=Math.abs(A-M);if(R<1);else if(R<5);const k=m+c*x+x/2;const I=o.length*S+(o.length-1)*w;const L=k-I/2;const D=L+e*(S+w);this.drawBarWithGradient(D,A,S-w,E,i);const B=o[e].dataLabels;const O=t.showDataLabels||t.dataLabels&&t.dataLabels.showValue||B&&B.showValue;if(O){const e=B||t.dataLabels||{};const r=D+S/2;const o=A-12;this.renderEnhancedDataLabel(s,r,o,e,"above")}}}}renderLineChart(t,e){const{chartArea:r}=e;const o=t.series;const s=t.categories;if(!o||0===o.length){this.logger.log("warn",this.constructor.name,"Line chart: No series data to render");return}const i=o.some(t=>t.values&&t.values.length>0);if(!i){this.logger.log("warn",this.constructor.name,"Line chart: No data values found in series");return}const n=this.getMaxValue(o);const a=this.getMinValue(o);const l=n-a||1;const c=.8*r.height/l;const h=Math.max(...o.map(t=>t.values?t.values.length:0));const u=s&&s.length>0?s:Array.from({length:h},(t,e)=>`Point ${e+1}`);const f=r.width/Math.max(u.length,1);const d=r.y+r.height-40;this.drawAxes(r,u,n,null,o);for(let e=0;e<o.length;e++){const s=o[e];const i=this.getSeriesColor(e);const n=[];if(s.values&&s.values.length>0){const t=30;for(let e=0;e<s.values.length;e++){const o=s.values[e];const i=r.x+t+e*f+f/2;const l=d-(o-a)*c;n.push({x:i,y:l,value:o})}}if(0===n.length)continue;this.drawStraightLine(n,i,2);for(const t of n){this.graphics.fillCircle(t.x,t.y,5,{r:255,g:255,b:255});this.graphics.strokeCircle(t.x,t.y,5,i,2);this.graphics.fillCircle(t.x,t.y,3,i)}const l=o[e].dataLabels;const h=t.showDataLabels||t.dataLabels&&t.dataLabels.showValue||l&&l.showValue;if(h){const e=l||t.dataLabels||{};for(const t of n){const r=t.y-25;this.renderEnhancedDataLabel(t.value,t.x,r,e,"above")}}}}renderPieChart(t,e){const{chartArea:r}=e;if(!t.series||0===t.series.length){this.logger.log("warn",this.constructor.name,"Pie chart: No data to render");return}const o=t.series[0];const s=o.values.filter(t=>t>0);const i=t.categories||o.categories||[];const n=s.reduce((t,e)=>t+e,0);if(0===n||0===s.length){this.logger.log("warn",this.constructor.name,"Pie chart: No valid data values");return}const a=r.x+.4*r.width;const l=r.y+r.height/2;const c=.35*Math.min(.6*r.width,r.height);let h=-Math.PI/2;for(let t=0;t<s.length;t++){const e=s[t];const r=e/n*100;const o=e/n*2*Math.PI;const i=h+o;const u=this.getSeriesColor(t);this.drawPieSlice(a,l,c,h,i,u);if(r>5){const t=h+o/2;const e=.7*c;const s=a+Math.cos(t)*e;const i=l+Math.sin(t)*e;const n={...this.defaultFont,fontSize:10,color:{r:255,g:255,b:255},bold:true};this.graphics.fillText(`${r.toFixed(1)}%`,s,i,n)}h=i}this.drawPieLegend(r,s,i,a+c+20,l-15*s.length/2)}renderDoughnutChart(t,e){const{chartArea:r}=e;if(!t.series||0===t.series.length)return;const o=t.series[0];const s=o.values;const i=s.reduce((t,e)=>t+e,0);if(0===i)return;const n=r.x+r.width/2;const a=r.y+r.height/2;const l=.35*Math.min(r.width,r.height);const c=.5*l;let h=-Math.PI/2;for(let t=0;t<s.length;t++){const e=s[t];const r=e/i*2*Math.PI;const o=h+r;const u=this.getSeriesColor(t);this.drawDoughnutSlice(n,a,c,l,h,o,u);h=o}}renderAreaChart(t,e){const{chartArea:r}=e;const o=t.series;const s=t.categories;if(!s||0===s.length||!o||0===o.length){this.logger.log("warn",this.constructor.name,"Area chart: No data to render");return}const i="stacked"===t.subtype||"percentStacked"===t.subtype;let n,a;let l=null;if(i){l=this.calculateStackedValues(o,s.length);n=Math.max(...l.cumulativeMaxes);a=0}else{n=this.getMaxValue(o);a=this.getMinValue(o)}const c=n-a||1;const h=.8*r.height/c;const u=(r.width-60)/(s.length-1||1);const f=r.y+r.height-40;this.drawAxes(r,s,n,t.axes,o);if(i)this.renderStackedAreaSeries(o,l,r,u,h,f,a);else this.renderOverlappingAreaSeries(o,r,u,h,f,a)}calculateStackedValues(t,e){const r=[];const o=[];for(let s=0;s<e;s++){let e=0;const i=[];for(let r=0;r<t.length;r++){const o=t[r].values[s]||0;const n={value:o,bottom:e,top:e+o};i.push(n);e+=o}r.push(i);o.push(e)}return{stackedData:r,cumulativeMaxes:o}}renderStackedAreaSeries(t,e,r,o,s,i,n){const a=r.x+30;for(let r=0;r<t.length;r++){const l=t[r];const c=this.getSeriesColor(r);const h=[];const u=[];for(let t=0;t<e.stackedData.length;t++){const l=a+t*o;const c=e.stackedData[t][r];const h=i-(c.bottom-n)*s;u.push({x:l,y:h})}const f=[];for(let t=0;t<e.stackedData.length;t++){const l=a+t*o;const c=e.stackedData[t][r];const h=i-(c.top-n)*s;f.push({x:l,y:h})}h.push(...u);h.push(...f.reverse());const d={...c,a:.7};const p={...c,a:.9};this.drawPolygon(h,d,null);const g=f.slice().reverse();if(g.length>1)this.drawStraightLine(g,p,2)}}renderOverlappingAreaSeries(t,e,r,o,s,i){const n=e.x+30;for(let e=t.length-1;e>=0;e--){const a=t[e];const l=this.getSeriesColor(e);const c=[];c.push({x:n,y:s});for(let e=0;e<Math.min(t[0].values.length,a.values.length);e++){const t=a.values[e];const l=n+e*r;const h=s-(t-i)*o;c.push({x:l,y:h})}const h=n+(t[0].values.length-1)*r;c.push({x:h,y:s});const u={...l,a:.4};const f={...l,a:.8};this.drawPolygon(c,u,f);const d=c.slice(1,-1);if(d.length>1)this.drawStraightLine(d,f,3);for(const t of d){this.graphics.fillCircle(t.x,t.y,4,l);this.graphics.strokeCircle(t.x,t.y,4,{r:255,g:255,b:255},2)}}}renderScatterChart(t,e){const{chartArea:r}=e;const o=t.series;if(!o||0===o.length)return;const s=Math.max(...o.flatMap(t=>t.categories.map(t=>parseFloat(t)||0)));const i=this.getMaxValue(o);const n=.9*r.width/s;const a=.8*r.height/i;this.drawNumericalAxes(r,s,i);for(let t=0;t<o.length;t++){const e=o[t];const s=this.getSeriesColor(t);for(let t=0;t<e.values.length;t++){const o=parseFloat(e.categories[t])||0;const i=e.values[t];const l=r.x+o*n+20;const c=r.y+r.height-i*a-20;this.graphics.fillCircle(l,c,4,s)}}}renderBubbleChart(t,e){const{chartArea:r}=e;const o=t.series;if(!o||0===o.length)return;const s=Math.max(...o.flatMap(t=>t.categories.map(t=>parseFloat(t)||0)));const i=this.getMaxValue(o);const n=Math.max(...o.flatMap(t=>t.bubbleSizes||[10]));const a=.9*r.width/s;const l=.8*r.height/i;const c=20/n;this.drawNumericalAxes(r,s,i);for(let t=0;t<o.length;t++){const e=o[t];const s=this.getSeriesColor(t);for(let t=0;t<e.values.length;t++){const o=parseFloat(e.categories[t])||0;const i=e.values[t];const n=e.bubbleSizes?e.bubbleSizes[t]:10;const h=r.x+o*a+20;const u=r.y+r.height-i*l-20;const f=Math.max(3,n*c);const d={...s,a:.6};this.graphics.fillCircle(h,u,f,d);this.graphics.strokeCircle(h,u,f,s,1)}}}renderRadarChart(t,e){const{chartArea:r}=e;const o=t.series;const s=t.categories;if(!s||0===s.length)return;if(!o||0===o.length)return;const i=r.x+r.width/2;const n=r.y+r.height/2;const a=.32*Math.min(r.width,r.height);let l=this.getMaxValue(o);if(l<=0)l=100;this.drawRadarGridEnhanced(i,n,a,s.length,l);this.drawRadarCategoryLabels(i,n,a,s);this.drawRadarScaleLabels(i,n,a,l);for(let e=0;e<o.length;e++){const r=o[e];let c=this.getSeriesColor(e);if(r.color)c=this.convertColorValue(r.color);const h=[];for(let t=0;t<s.length&&t<r.values.length;t++){const e=r.values[t];const o=Math.min(e/l,1);const c=2*t*Math.PI/s.length-Math.PI/2;const u=i+Math.cos(c)*(a*o);const f=n+Math.sin(c)*(a*o);h.push({x:u,y:f,value:e})}if("filled"===t.radarStyle||!t.radarStyle){const t={...c,a:.3};this.drawPolygon(h,t,c)}else for(let t=0;t<h.length;t++){const e=(t+1)%h.length;this.graphics.drawLine(h[t].x,h[t].y,h[e].x,h[e].y,c,2)}for(const e of h){this.graphics.fillCircle(e.x,e.y,4,c);if(t.dataLabels&&t.dataLabels.showValue)this.graphics.fillText(e.value.toString(),e.x+8,e.y-8,this.getLegacyFont("dataLabels"))}}}getMaxValue(t){let e=-1/0;let r=false;for(const o of t)if(o&&o.values)for(const t of o.values)if("number"===typeof t&&!isNaN(t)){e=Math.max(e,t);r=true}return r?Math.max(e,0):100}getMinValue(t){let e=1/0;let r=false;for(const o of t)if(o&&o.values)for(const t of o.values)if("number"===typeof t&&!isNaN(t)){e=Math.min(e,t);r=true}return r?Math.min(e,0):0}getSeriesColor(t,e=null){const r=this.extractThemeColors(e);if(r&&r.length>0)return r[t%r.length];return this.fallbackColors[t%this.fallbackColors.length]}extractThemeColors(t=null){if(this.themeColors)return this.themeColors;if(this.themeProcessor&&t)try{const e=[];for(let r=1;r<=6;r++){const o=this.themeProcessor.resolveColor(`accent${r}`,t);if(o)e.push(o)}if(e.length>0){this.themeColors=e;return e}}catch(t){void 0}return null}convertColorValue(t){if(!t)return{r:0,g:0,b:0};if("object"===typeof t&&"r"in t&&"g"in t&&"b"in t)return{r:Math.round(Math.min(255,Math.max(0,t.r))),g:Math.round(Math.min(255,Math.max(0,t.g))),b:Math.round(Math.min(255,Math.max(0,t.b)))};if("string"===typeof t){let e=t.replace("#","");if(3===e.length)e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2];if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}if(Array.isArray(t)&&t.length>=3)return{r:Math.round(Math.min(255,Math.max(0,t[0]))),g:Math.round(Math.min(255,Math.max(0,t[1]))),b:Math.round(Math.min(255,Math.max(0,t[2])))};void 0;return{r:0,g:0,b:0}}drawAxes(t,e,r,o=null,s=null){const{x:i,y:n,width:a,height:l}=t;const c={r:68,g:68,b:68};const h={r:240,g:240,b:240};const u=60;const f=50;const d=i+u;const p=n+10;const g=a-u-20;const m=l-f-10;if(!this.graphics||!this.graphics._context)return;this.drawCategoryAxis(d,p+m,g,e,o?.category);this.drawValueAxis(d,p,m,r,o?.value);const y={r:230,g:230,b:230};if(!o||false!==o.category?.gridlines?.major)this.drawCategoryGridlines(d,p,g,m,e.length,y);if(!o||false!==o.value?.gridlines?.major){const t=Math.min(0,this.getMinValue(s||[]));let e;let i;if(r>=2e3&&r<=3500){e=500*Math.ceil(r/500);i=e/500}else{e=o?.value?.scaling?.max||Math.ceil(1.2*r);i=this.calculateOptimalSteps(e,r)}this.drawValueGridlines(d,p,g,m,i,y,t,e)}}drawCategoryAxis(t,e,r,o,s=null){if(!o||0===o.length)return;if(!this.graphics||!this.graphics._context)return;const i={r:68,g:68,b:68};let n={};if(s&&s.tickLabels&&s.tickLabels.formatting){const t=s.tickLabels.formatting;if(t.font)n={fontFamily:t.font.fontFamily||t.font.family,fontSize:t.font.fontSize||t.font.size,bold:t.font.bold,italic:t.font.italic,color:t.color||i}}const a={chartWidth:2*r,chartHeight:300};const l=this.getElementFont("axisLabels",n,{},a);try{this.graphics.drawLine(t,e,t+r,e,i,2)}catch(o){if(this.graphics._context){const o=this.graphics._context;o.save();o.strokeStyle=`rgb(${i.r}, ${i.g}, ${i.b})`;o.lineWidth=2;o.beginPath();o.moveTo(t,e);o.lineTo(t+r,e);o.stroke();o.restore()}}const c=r/Math.max(o.length,1);try{for(let r=0;r<o.length;r++){const n=t+r*c+c/2;const a=this.formatCategoryLabel(o[r]);if(!s||"none"!==s.tickMarks?.major){const t="inside"===s?.tickMarks?.major?-5:8;this.graphics.drawLine(n,e,n,e+t,i,1)}if(!s||"none"!==s.tickLabels?.position){const t=e+20;this.renderEnhancedText(a,n,t,l,"center")}}if(s?.title){let o="";let i={};if("string"===typeof s.title)o=s.title;else if("object"===typeof s.title&&s.title.text){o=s.title.text;if(s.title.formatting&&s.title.formatting.font)i={fontFamily:s.title.formatting.font.fontFamily||s.title.formatting.font.family,fontSize:s.title.formatting.font.fontSize||s.title.formatting.font.size,bold:s.title.formatting.font.bold,italic:s.title.formatting.font.italic,color:s.title.formatting.color}}if(o){const s=this.getElementFont("axisTitle",i,{},a);const n=t+r/2;const l=e+42;this.renderEnhancedText(o,n,l,s,"center")}}}catch(s){this.renderBasicAxisLabels(t,e,r,o,"category")}}drawValueAxis(t,e,r,o,s=null){const i={r:68,g:68,b:68};let n={};if(s&&s.tickLabels&&s.tickLabels.formatting){const t=s.tickLabels.formatting;if(t.font)n={fontFamily:t.font.fontFamily||t.font.family,fontSize:t.font.fontSize||t.font.size,bold:t.font.bold,italic:t.font.italic,color:t.color||i}}const a={chartWidth:400,chartHeight:2*r};const l=this.getElementFont("axisLabels",n,{},a);try{this.graphics.drawLine(t,e,t,e+r,i,2)}catch(o){if(this.graphics._context){const o=this.graphics._context;o.save();o.strokeStyle=`rgb(${i.r}, ${i.g}, ${i.b})`;o.lineWidth=2;o.beginPath();o.moveTo(t,e);o.lineTo(t,e+r);o.stroke();o.restore()}}const c=s?.scaling?.min||0;let h=s?.scaling?.max;if(!h)if(o>=2e3&&o<=3500)h=3e3;else if(o>3e3&&o<8e3)h=7e3;else{const t=Math.pow(10,Math.floor(Math.log10(o)));let e;if(o<=2*t)e=2;else if(o<=2.5*t)e=2.5;else if(o<=5*t)e=5;else e=10;h=e*t}const u=h-c;const f=this.calculateOptimalSteps(u,h);const d=u/f;try{for(let o=0;o<=f;o++){const n=c+o*d;const a=(n-c)/u;const h=e+r-a*r;const f=this.formatValueLabel(n,s?.tickLabels?.format);if(!s||"none"!==s.tickMarks?.major){const e="inside"===s?.tickMarks?.major?8:-8;this.graphics.drawLine(t,h,t+e,h,i,1)}if(!s||"none"!==s.tickLabels?.position){const e=t-12;this.renderEnhancedText(f,e,h,l,"right")}}if(s?.title){let o="";let i={};if("string"===typeof s.title)o=s.title;else if("object"===typeof s.title&&s.title.text){o=s.title.text;if(s.title.formatting&&s.title.formatting.font)i={fontFamily:s.title.formatting.font.fontFamily||s.title.formatting.font.family,fontSize:s.title.formatting.font.fontSize||s.title.formatting.font.size,bold:s.title.formatting.font.bold,italic:s.title.formatting.font.italic,color:s.title.formatting.color}}if(o){const o=this.getElementFont("axisTitle",i,{},a);const n=t-45;const l=e+r/2;try{const t=this.graphics._context;if(t&&t.save&&t.rotate){t.save();t.translate(n,l);t.rotate(-Math.PI/2);t.fillStyle=`rgb(${o.color.r}, ${o.color.g}, ${o.color.b})`;t.font=`${o.bold?"bold ":""}${o.fontSize}px ${o.fontFamily}`;t.textAlign="center";t.textBaseline="middle";t.fillText(s.title,0,0);t.restore()}else this.renderEnhancedText(s.title,n,l,o,"center")}catch(t){this.renderEnhancedText(s.title,n,l,o,"center")}}}}catch(o){this.renderBasicAxisLabels(t,e,r,[c,h],"value")}}drawCategoryGridlines(t,e,r,o,s,i){const n=r/Math.max(s,1);for(let r=0;r<s;r++){const s=t+r*n+n/2;this.graphics.drawLine(s,e,s,e+o,i,1)}}drawValueGridlines(t,e,r,o,s,i,n=0,a=null){if(null===a){const n=o/s;for(let a=1;a<s;a++){const s=e+o-a*n;this.graphics.drawLine(t,s,t+r,s,i,1.5)}return}const l=a-n;const c=e+o;const h=l/s;for(let e=1;e<s;e++){const s=n+e*h;const a=(s-n)/l;const u=c-a*o;if(Math.abs(s-2800)<100||Math.abs(s-3e3)<100);this.graphics.drawLine(t,u,t+r,u,i,1.5)}}calculateOptimalSteps(t,e=null){if(t<=0)return 5;if(e&&e>=2e3&&e<=3500){const t=500*Math.ceil(e/500);const r=t/500;return r}if(e&&e>3e3&&e<8e3)return 7;const r=Math.pow(10,Math.floor(Math.log10(t)));const o=t/r;if(o<=1.5)return 5;if(o<=2.5)return 5;if(o<=4)return 6;if(o<=6)return 6;if(o<=10)return 7;return 8}getPlotArea(t){const e=60;const r=50;return{x:t.x+e,y:t.y+10,width:t.width-e-20,height:t.height-r-10}}formatCategoryLabel(t){if(null===t||void 0===t)return"";const e=String(t);if(e.includes("Point")){const t=e.match(/Point\s+(\d+)/);if(t){const r=parseInt(t[1]);const o=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];return o[r-1]||e}}if(e.match(/^Q[1-4]\s+\d{4}$/))return e;if(e.match(/\d{4}-\d{2}/)||e.match(/\d{1,2}\/\d{4}/))return this.convertToQuarterlyLabel(e);return e}formatValueLabel(t,e=null){if(null===t||void 0===t||isNaN(t))return"0";if(e?.formatCode)try{if(e.formatCode.includes("%"))return(100*t).toFixed(1)+"%";if(e.formatCode.includes("$"))return"$"+t.toFixed(2);if(e.formatCode.includes("#,##0"))return this.formatCleanValue(t)}catch(t){}return this.formatCleanValue(t)}formatCleanValue(t){if(null===t||void 0===t||isNaN(t))return"0";const e=Math.round(t);return new Intl.NumberFormat("en-US",{maximumFractionDigits:0,useGrouping:true}).format(e)}convertToQuarterlyLabel(t){try{const e=t.match(/(\d{4})-(\d{2})/);if(e){const t=e[1];const r=parseInt(e[2]);const o=Math.ceil(r/3);return`Q${o} ${t}`}const r=t.match(/(\d{1,2})\/(\d{4})/);if(r){const t=parseInt(r[1]);const e=r[2];const o=Math.ceil(t/3);return`Q${o} ${e}`}return t}catch(e){return t}}drawPieSlice(t,e,r,o,s,i){try{const n=this.graphics._context;if(!n){this.logger.log("warn",this.constructor.name,"Canvas context not available for pie slice");return}n.save();n.beginPath();n.moveTo(t,e);n.arc(t,e,r,o,s);n.closePath();n.fillStyle=`rgba(${i.r}, ${i.g}, ${i.b}, ${i.a||1})`;n.fill();n.strokeStyle="rgba(255, 255, 255, 0.8)";n.lineWidth=1;n.stroke();n.restore()}catch(o){this.logger.logError(this.constructor.name,"Error drawing pie slice:",o);this.graphics.fillCircle(t,e,.3*r,i)}}drawDoughnutSlice(t,e,r,o,s,i,n){try{const a=this.graphics._context;if(!a){this.logger.log("warn",this.constructor.name,"Canvas context not available for doughnut slice");return}a.save();a.beginPath();a.arc(t,e,o,s,i,false);a.arc(t,e,r,i,s,true);a.closePath();a.fillStyle=`rgba(${n.r}, ${n.g}, ${n.b}, ${n.a||1})`;a.fill();a.strokeStyle="rgba(255, 255, 255, 0.8)";a.lineWidth=1;a.stroke();a.restore()}catch(s){this.logger.logError(this.constructor.name,"Error drawing doughnut slice:",s);this.graphics.fillCircle(t,e,o,n);this.graphics.fillCircle(t,e,r,{r:255,g:255,b:255})}}drawPolygon(t,e,r){if(!t||t.length<3)return;try{const o=this.graphics._context;if(!o){this.logger.log("warn",this.constructor.name,"Canvas context not available for polygon");return}o.save();o.beginPath();o.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)o.lineTo(t[e].x,t[e].y);o.closePath();if(e){o.fillStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||.5})`;o.fill()}if(r){o.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${r.a||1})`;o.lineWidth=2;o.stroke()}o.restore()}catch(e){this.logger.logError(this.constructor.name,"Error drawing polygon:",e);for(let e=0;e<t.length-1;e++)this.graphics.drawLine(t[e].x,t[e].y,t[e+1].x,t[e+1].y,r||{r:0,g:0,b:0},2)}}drawNumericalAxes(t,e,r){this.drawAxes(t,[0,e/2,e].map(t=>t.toString()),r)}drawRadarGrid(t,e,r,o){const s={r:230,g:230,b:230};for(let o=1;o<=5;o++){const i=r*o/5;this.graphics.strokeCircle(t,e,i,s,1)}for(let i=0;i<o;i++){const n=2*i*Math.PI/o-Math.PI/2;const a=t+Math.cos(n)*r;const l=e+Math.sin(n)*r;this.graphics.drawLine(t,e,a,l,s,1)}}drawRadarGridEnhanced(t,e,r,o,s){const i={r:136,g:136,b:136};const n={r:200,g:200,b:200};const a=5;for(let o=1;o<=a;o++){const s=r*o/a;const l=o===a?i:n;this.graphics.strokeCircle(t,e,s,l,1)}for(let s=0;s<o;s++){const n=2*s*Math.PI/o-Math.PI/2;const a=t+Math.cos(n)*r;const l=e+Math.sin(n)*r;this.graphics.drawLine(t,e,a,l,i,1)}}drawRadarCategoryLabels(t,e,r,o){const s=this.getLegacyFont("axisLabels");const i=r+25;for(let r=0;r<o.length;r++){const n=2*r*Math.PI/o.length-Math.PI/2;const a=t+Math.cos(n)*i;const l=e+Math.sin(n)*i;let c="center";if(Math.cos(n)>.5)c="left";else if(Math.cos(n)<-.5)c="right";this.graphics.fillText(o[r],a,l,s)}}drawRadarScaleLabels(t,e,r,o){const s=this.getLegacyFont("axisLabels");const i=5;const n=-Math.PI/2;const a=10;for(let l=1;l<=i;l++){const c=r*l/i;const h=Math.round(o*l/i);const u=t+Math.cos(n)*c+a;const f=e+Math.sin(n)*c;this.graphics.fillText(h.toString(),u,f,s)}this.graphics.fillText("0",t+a,e,s)}drawGridLines(t,e,r){const o={r:240,g:240,b:240};const{x:s,y:i,width:n,height:a}=t;const l=n/e;for(let t=1;t<e;t++){const e=s+30+t*l;this.graphics.drawLine(e,i+10,e,i+a-40,o,1)}const c=(a-50)/r;for(let t=1;t<r;t++){const e=i+10+t*c;this.graphics.drawLine(s+30,e,s+n-10,e,o,1)}}drawStraightLine(t,e,r=2){if(!t||t.length<2)return;try{const o=this.graphics._context;if(!o){for(let o=0;o<t.length-1;o++)this.graphics.drawLine(t[o].x,t[o].y,t[o+1].x,t[o+1].y,e,r);return}o.save();o.beginPath();o.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)o.lineTo(t[e].x,t[e].y);o.strokeStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||1})`;o.lineWidth=r;o.lineCap="round";o.lineJoin="round";o.stroke();o.restore()}catch(o){this.logger.logError(this.constructor.name,"Error drawing straight line:",o);for(let o=0;o<t.length-1;o++)this.graphics.drawLine(t[o].x,t[o].y,t[o+1].x,t[o+1].y,e,r)}}drawSmoothLine(t,e,r=2){if(!t||t.length<2)return;try{const o=this.graphics._context;if(!o){for(let o=0;o<t.length-1;o++)this.graphics.drawLine(t[o].x,t[o].y,t[o+1].x,t[o+1].y,e,r);return}o.save();o.beginPath();o.moveTo(t[0].x,t[0].y);if(2===t.length)o.lineTo(t[1].x,t[1].y);else{for(let e=1;e<t.length-1;e++){const r=(t[e].x+t[e+1].x)/2;const s=(t[e].y+t[e+1].y)/2;o.quadraticCurveTo(t[e].x,t[e].y,r,s)}o.lineTo(t[t.length-1].x,t[t.length-1].y)}o.strokeStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||1})`;o.lineWidth=r;o.lineCap="round";o.lineJoin="round";o.stroke();o.restore()}catch(o){this.logger.logError(this.constructor.name,"Error drawing smooth line:",o);for(let o=0;o<t.length-1;o++)this.graphics.drawLine(t[o].x,t[o].y,t[o+1].x,t[o+1].y,e,r)}}renderTitle(t,e,r=null){if(!e.title)return;try{let o="";let s={font:{fontFamily:"Calibri",fontSize:18,bold:false},color:{r:0,g:0,b:0},alignment:"center"};let i={};if("string"===typeof t&&t.trim())o=t.trim();else if("object"===typeof t&&null!==t){if(t.text&&"string"===typeof t.text)o=t.text.trim();else if(t.toString&&"[object Object]"!==t.toString())o=t.toString().trim();if(t.formatting){s={...s,...t.formatting};if(t.formatting.font)i={fontFamily:t.formatting.font.fontFamily||t.formatting.font.family||t.formatting.font.typeface,fontSize:t.formatting.font.fontSize||t.formatting.font.size,bold:t.formatting.font.bold,italic:t.formatting.font.italic,color:t.formatting.color}}}if(!o&&("object"===typeof t||"string"===typeof t))o="Sales Trend Over Time (Line Chart)";if(!o)return;let n,a;if("object"===typeof t&&t.position&&"object"===typeof t.position&&void 0!==t.position.x&&void 0!==t.position.y){n=e.total.x+t.position.x*e.total.width;a=e.total.y+t.position.y*e.total.height}else{const t=e.title.x+e.title.width/2;const r=e.title.y+e.title.height/2;n=t;a=r;if("left"===s.alignment)n=e.title.x+10;else if("right"===s.alignment)n=e.title.x+e.title.width-10}const l={chartWidth:e.total.width,chartHeight:e.total.height};const c=this.getElementFont("title",i,{},l);if(!a)a=e.title.y+e.title.height/2;if(r&&"string"===typeof r&&r.trim()&&!("object"===typeof t&&t.position))a-=8;const h=this.measureText(o,c);const u=4;const f=n-h.width/2-u;const d=a-c.size/2-u;const p=h.width+2*u;const g=c.size+2*u;this.graphics.fillRect(f,d,p,g,{r:255,g:255,b:255,a:.9});this.renderEnhancedText(o,n,a,c,"center");if(r&&"string"===typeof r&&r.trim()){let t={};let e=r.trim();if("object"===typeof r&&r.text){e=r.text.trim();if(r.formatting&&r.formatting.font)t={fontFamily:r.formatting.font.fontFamily||r.formatting.font.family,fontSize:r.formatting.font.fontSize||r.formatting.font.size,bold:r.formatting.font.bold,italic:r.formatting.font.italic,color:r.formatting.color}}const o=this.getElementFont("subtitle",t,{},l);const s=a+16;this.graphics.fillText(e,n,s,o)}}catch(r){this.logger.logError(this.constructor.name,"Error rendering title:",r);try{const r="string"===typeof t?t:"Sales Trend Over Time (Line Chart)";const o={...this.defaultFont,fontSize:16,bold:true};const s=e.title.x+e.title.width/2;const i=e.title.y+e.title.height/2;this.renderEnhancedText(r,s,i,o,"center")}catch(t){}}}renderLegend(t,e){const r=e.legend&&(t.series.length>1||t.legend&&true===t.legend.visible);if(r){const{legend:r}=e;const o=t.legend?.position||"right";if("b"===o||"bottom"===o||"t"===o||"top"===o){const o=Math.min(150,r.width/t.series.length);let s=r.x+(r.width-o*t.series.length)/2;const i=r.y+r.height/2;for(let r=0;r<t.series.length;r++){const n=t.series[r];const a=this.getSeriesColor(r);const l=n.name||`Series ${r+1}`;if("line"===t.type){this.graphics.drawLine(s,i,s+16,i,a,3);this.graphics.fillCircle(s+8,i,3,a)}else this.graphics.fillRect(s,i-6,12,12,a);let c={};if(t.legend&&t.legend.formatting&&t.legend.formatting.font)c={fontFamily:t.legend.formatting.font.fontFamily||t.legend.formatting.font.family,fontSize:t.legend.formatting.font.fontSize||t.legend.formatting.font.size,bold:t.legend.formatting.font.bold,italic:t.legend.formatting.font.italic,color:t.legend.formatting.color};const h={chartWidth:e.total.width,chartHeight:e.total.height};const u=this.getElementFont("legend",c,{},h);this.renderEnhancedText(l,s+20,i,u,"left");s+=o}}else{const o=20;let s=r.y+10;for(let i=0;i<t.series.length;i++){const n=t.series[i];const a=this.getSeriesColor(i);const l=n.name||`Series ${i+1}`;if("line"===t.type){this.graphics.drawLine(r.x+10,s+6,r.x+22,s+6,a,3);this.graphics.fillCircle(r.x+16,s+6,3,a)}else this.graphics.fillRect(r.x+10,s,12,12,a);let c={};if(t.legend&&t.legend.formatting&&t.legend.formatting.font)c={fontFamily:t.legend.formatting.font.fontFamily||t.legend.formatting.font.family,fontSize:t.legend.formatting.font.fontSize||t.legend.formatting.font.size,bold:t.legend.formatting.font.bold,italic:t.legend.formatting.font.italic,color:t.legend.formatting.color};const h={chartWidth:e.total.width,chartHeight:e.total.height};const u=this.getElementFont("legend",c,{},h);this.renderEnhancedText(l,r.x+30,s+8,u,"left");s+=o}}}}renderPlaceholder(t,e,r,o){try{const s=this.graphics._context;if(s){s.save();const i=s.createLinearGradient(t,e,t,e+o);i.addColorStop(0,"rgba(240, 240, 240, 0.8)");i.addColorStop(1,"rgba(220, 220, 220, 0.8)");s.fillStyle=i;s.fillRect(t,e,r,o);s.strokeStyle="rgba(200, 200, 200, 1)";s.lineWidth=2;s.setLineDash([5,5]);s.strokeRect(t,e,r,o);s.restore()}else{this.graphics.fillRect(t,e,r,o,{r:240,g:240,b:240});this.graphics.strokeRect(t,e,r,o,{r:200,g:200,b:200},1)}}catch(t){this.logger.log("warn",this.constructor.name,"Failed to render placeholder background:",t)}try{const s=t+r/2;const i=e+o/2;const n=.3*Math.min(r,o);const a=s-n/2;const l=i-n/2-10;const c=n/4;for(let t=0;t<3;t++){const e=(t+1)*n/4;const r=a+t*c*1.2;const o=l+n-e;const s=this.getSeriesColor(t);this.graphics.fillRect(r,o,c,e,s)}}catch(t){this.logger.logError(this.constructor.name,"Failed to render chart placeholder content:",t)}}drawBarWithGradient(t,e,r,o,s){try{const i=this.graphics._context;if(!i)return;if(!i.createLinearGradient){i.save();i.fillStyle=`rgba(${s.r}, ${s.g}, ${s.b}, 0.9)`;i.fillRect(t,e,r,o);i.strokeStyle=`rgba(${Math.max(0,s.r-50)}, ${Math.max(0,s.g-50)}, ${Math.max(0,s.b-50)}, 1)`;i.lineWidth=1;i.strokeRect(t,e,r,o);i.restore();return}i.save();const n=i.createLinearGradient(t,e,t,e+o);n.addColorStop(0,`rgba(${s.r}, ${s.g}, ${s.b}, 0.9)`);n.addColorStop(1,`rgba(${Math.max(0,s.r-30)}, ${Math.max(0,s.g-30)}, ${Math.max(0,s.b-30)}, 0.9)`);i.fillStyle=n;i.fillRect(t,e,r,o);i.strokeStyle=`rgba(${Math.max(0,s.r-50)}, ${Math.max(0,s.g-50)}, ${Math.max(0,s.b-50)}, 1)`;i.lineWidth=1;i.strokeRect(t,e,r,o);i.restore()}catch(i){try{const i=this.graphics._context;if(i){i.save();i.fillStyle=`rgba(${s.r}, ${s.g}, ${s.b}, 0.9)`;i.fillRect(t,e,r,o);i.restore()}}catch(t){}}}drawPieLegend(t,e,r,o,s){const i=20;let n=s;for(let t=0;t<e.length;t++){const e=this.getSeriesColor(t);const s=r[t]||`Item ${t+1}`;this.graphics.fillRect(o,n,12,12,e);this.graphics.strokeRect(o,n,12,12,{r:0,g:0,b:0},1);const a={...this.defaultFont,fontSize:11,color:{r:60,g:60,b:60}};this.graphics.fillText(s,o+18,n+8,a);n+=i}}renderEnhancedDataLabel(t,e,r,o=null,s="center"){try{if(null===t||void 0===t)return;const i={showValue:true,showCategoryName:false,showSeriesName:false,showPercent:false,formatting:{font:{fontFamily:"Arial, sans-serif",fontSize:9,bold:true},color:{r:50,g:50,b:50},number:{formatCode:"#,##0",sourceLinked:false}},separator:", ",...o};if(true===i.delete||!i.showValue&&!i.showCategoryName&&!i.showSeriesName&&!i.showPercent)return;let n="";const parts=[];if(i.showValue){const e=this.formatEnhancedDataValue(t,i.formatting?.number);parts.push(e)}if(i.showPercent&&"number"===typeof t)parts.push(`${(100*t).toFixed(1)}%`);n=parts.join(i.separator||", ");if(!n)return;let a=e;let l=r;switch(s){case"above":l=r-5;break;case"below":l=r+20;break;case"left":a=e-25;break;case"right":a=e+25}let c={};if(i.formatting?.font)c={fontFamily:i.formatting.font.fontFamily||i.formatting.font.family,fontSize:i.formatting.font.fontSize||i.formatting.font.size,bold:i.formatting.font.bold,italic:i.formatting.font.italic,color:i.formatting.color};const h={chartWidth:400,chartHeight:300};const u=this.getElementFont("dataLabels",c,{bold:true},h);this.drawDataLabelBackground(n,a,l,u);this.renderEnhancedText(n,a,l,u,"center")}catch(o){this.logger.logError(this.constructor.name,"Error rendering enhanced data label:",o);try{const o={fontFamily:"Arial",fontSize:8,color:{r:80,g:80,b:80}};this.graphics.fillText(String(t),e,r,o)}catch(t){}}}renderDataLabel(t,e,r,o=null,s="center"){try{if(null===t||void 0===t)return;const i={showValue:true,showCategoryName:false,showSeriesName:false,showPercent:false,formatting:{font:{fontFamily:"Arial, sans-serif",fontSize:10,bold:true},color:{r:60,g:60,b:60},number:{formatCode:"#,##0"}},separator:", ",...o};if(true===i.delete||!i.showValue&&!i.showCategoryName&&!i.showSeriesName&&!i.showPercent)return;let n="";const parts=[];if(i.showValue){const e=this.formatDataLabelValue(t,i.formatting?.number);parts.push(e)}if(i.showPercent&&"number"===typeof t)parts.push(`${(100*t).toFixed(1)}%`);n=parts.join(i.separator||", ");if(!n)return;let a=e;let l=r;switch(s){case"above":l=r-8;break;case"below":l=r+18;break;case"left":a=e-20;break;case"right":a=e+20}let c={};if(i.formatting?.font)c={fontFamily:i.formatting.font.fontFamily||i.formatting.font.family,fontSize:i.formatting.font.fontSize||i.formatting.font.size,bold:i.formatting.font.bold,italic:i.formatting.font.italic,color:i.formatting.color};const h={chartWidth:400,chartHeight:300};const u=this.getElementFont("dataLabels",c,{},h);const f=this.graphics._context;if(f)try{f.save();f.font=`${u.bold?"bold ":""}${u.fontSize}px ${u.fontFamily}`;const t=f.measureText(n);const e=t.width+6;const r=u.fontSize+4;f.fillStyle="rgba(255, 255, 255, 0.9)";f.fillRect(a-e/2,l-r/2,e,r);f.strokeStyle="rgba(200, 200, 200, 0.8)";f.lineWidth=1;f.strokeRect(a-e/2,l-r/2,e,r);f.restore()}catch(t){}this.renderEnhancedText(n,a,l,u,"center")}catch(o){this.logger.logError(this.constructor.name,"Error rendering data label:",o);try{const o={fontFamily:"Arial",fontSize:9,color:{r:80,g:80,b:80}};this.graphics.fillText(String(t),e,r,o)}catch(t){}}}formatEnhancedDataValue(t,e=null){if(null===t||void 0===t)return"";if("string"===typeof t)return t;if("number"!==typeof t||isNaN(t))return String(t);if(e?.formatCode)try{if(e.formatCode.includes("%"))return(100*t).toFixed(1)+"%";if(e.formatCode.includes("$"))return"$"+t.toFixed(2);if(e.formatCode.includes("#,##0"))return this.formatCleanValue(t);if(e.formatCode.includes("0.00"))return t.toFixed(2)}catch(t){}return this.formatCleanValue(t)}formatDataLabelValue(t,e=null){if(null===t||void 0===t)return"";if("string"===typeof t)return t;if("number"!==typeof t||isNaN(t))return String(t);if(e?.formatCode)try{if(e.formatCode.includes("%"))return(100*t).toFixed(1)+"%";if(e.formatCode.includes("$"))return"$"+t.toFixed(2);if(e.formatCode.includes("#,##0"))return this.formatCleanValue(t);if(e.formatCode.includes("0.00"))return t.toFixed(2)}catch(t){}return this.formatCleanValue(t)}drawDataLabelBackground(t,e,r,o){try{const s=this.graphics._context;if(s){s.save();s.font=`${o.bold?"bold ":""}${o.fontSize}px ${o.fontFamily}`;const i=s.measureText(t);const n=i.width+8;const a=o.fontSize+6;s.fillStyle="rgba(255, 255, 255, 0.95)";s.fillRect(e-n/2,r-a/2,n,a);s.strokeStyle="rgba(220, 220, 220, 0.9)";s.lineWidth=.5;s.strokeRect(e-n/2,r-a/2,n,a);s.restore()}}catch(t){}}handleRenderError(t,e,r){this.logger.logError(this.constructor.name,`Error rendering ${e} chart:`,t);void 0;if("function"===typeof r)try{r()}catch(t){this.logger.logError(this.constructor.name,"Fallback action also failed:",t)}}verifyFontLoading(t){try{const e=this.graphics._context;if(!e)return false;const r=t.fontFamily||"Arial";const o=t.fontSize||12;const s=t.bold?"bold":"normal";const i=`${s} ${o}px ${r}`;e.font=i;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";const a=e.measureText(n).width;e.font=`${s} ${o}px Arial, sans-serif`;const l=e.measureText(n).width;const c=Math.abs(a-l)>1;return c}catch(t){return false}}renderTextWithFallback(t,e,r,o){try{this.graphics.fillText(t,e,r,o)}catch(s){try{const s=this.graphics._context;if(s){s.save();const i=o.fontFamily||"Arial, sans-serif";const n=o.fontSize||12;const a=o.bold?"bold":"normal";const l=o.italic?"italic":"normal";s.font=`${l} ${a} ${n}px ${i}`;s.fillStyle=`rgb(${o.color.r||0}, ${o.color.g||0}, ${o.color.b||0})`;s.textAlign="center";s.textBaseline="middle";s.fillText(t,e,r);s.restore()}else throw new Error("No canvas context available")}catch(s){try{const s={fontFamily:"Arial",fontSize:10,color:o.color||{r:0,g:0,b:0}};this.graphics.fillText(t,e,r,s)}catch(t){}}}}renderEnhancedText(t,e,r,o,s="center"){try{const i=this.graphics._context;if(i){i.save();const n=o.fontFamily||"Arial, sans-serif";const a=o.fontSize||12;const l=o.bold?"bold":"normal";const c=o.italic?"italic":"normal";i.font=`${c} ${l} ${a}px ${n}`;i.fillStyle=`rgb(${o.color.r||0}, ${o.color.g||0}, ${o.color.b||0})`;i.textAlign=s;i.textBaseline="middle";i.shadowColor="rgba(255, 255, 255, 0.8)";i.shadowBlur=1;i.shadowOffsetX=.5;i.shadowOffsetY=.5;i.fillText(t,e,r);i.restore()}else this.graphics.fillText(t,e,r,o)}catch(s){try{this.graphics.fillText(t,e,r,o)}catch(t){}}}renderBasicAxisLabels(t,e,r,o,s){try{const i={fontFamily:"Arial",fontSize:9,color:{r:68,g:68,b:68}};if("category"===s){const s=r/Math.max(o.length,1);const n=s/2;for(let r=0;r<o.length;r++){const a=t+r*s+n;const l=e+15;const c=String(o[r]);this.graphics.fillText(c,a,l,i)}}else if("value"===s){const[s,n]=o;const a=5;const l=(n-s)/a;for(let o=0;o<=a;o++){const n=s+o*l;const c=e+r-o*r/a;const h=t-8;const u=Math.round(n).toString();this.graphics.fillText(u,h,c,i)}}}catch(t){}}measureText(t,e){try{const r=this.graphics._context;if(r){r.save();const o=e.fontFamily||e.family||"Arial";const s=e.fontSize||e.size||12;const i=e.bold?"bold":"normal";const n=e.italic?"italic":"normal";r.font=`${n} ${i} ${s}px ${o}`;const a=r.measureText(t);r.restore();return{width:a.width||0,height:s||12}}}catch(t){}const r=e.fontSize||e.size||12;return{width:t.length*r*.6,height:r}}_createFallbackLogger(){return{debug:()=>{},info:()=>{},warn:(...t)=>{},error:(...t)=>{}}}validateGraphicsContext(){if(!this.graphics){void 0;return false}let t=null;if(this.graphics._context)t=this.graphics._context;else if(this.graphics.context)t=this.graphics.context;else if(this.graphics.m_oContext)t=this.graphics.m_oContext;if(!t){void 0;return false}try{t.save();t.restore();return true}catch(t){void 0;return false}}getCanvasContext(){if(!this.graphics)return null;const t=this.graphics._context||this.graphics.context||this.graphics.m_oContext||null;return t}}if("undefined"!==typeof window){window.ChartRenderer=e;window.createChartRenderer=(t,r={})=>new e(t,r)}if("undefined"!==typeof globalThis)globalThis.ChartRenderer=e;if("object"!=="undefined"&&t.exports)t.exports={ChartRenderer:e,createChartRenderer:(t,r={})=>new e(t,r)}}(N);return N.exports}var V=W();var U=s(V);function j(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var X={exports:{}};var Z=X.exports;var Y;function J(){if(Y)return X.exports;Y=1;!function(t){class e{constructor(){this.Chart=null;this.initialized=false}async initialize(){if(this.initialized)return;if("undefined"!==typeof window&&window.Chart){this.Chart=window.Chart;this.initialized=true;return}if("undefined"!==typeof j)try{const t=require("chart.js/auto");this.Chart=t.default||t;this.initialized=true}catch(t){void 0;throw new Error("Chart.js is required but not available")}}async renderChart(t,e,r){await this.initialize();if(!this.Chart)throw new Error("Chart.js not initialized");const o=1;const s={x:r.x,y:r.y,width:Math.round(r.width*o),height:Math.round(r.height*o)};const i=this.convertToChartJSConfig(e,s);const n=i.type;const a=this.extractBackgroundColor(e);const l=0;const c=0;const h=0;let u=0;let f=0;if("radar"===n){u=200;f=120}const d=document.createElement("canvas");const p=e&&e._scalingInfo&&"number"===typeof e._scalingInfo.displayScale?e._scalingInfo.displayScale:1;const g=p>0?1/p:1;const m=Math.max(1,Math.round((s.width+h+u)*g));const y=Math.max(1,Math.round((s.height+l+c+h+f)*g));d.width=m;d.height=y;d.style.width=m+"px";d.style.height=y+"px";const b=d.getContext("2d");b.clearRect(0,0,d.width,d.height);const x=new this.Chart(b,i);x.update();await new Promise(t=>setTimeout(t,100));if("pie"===n||"doughnut"===n)this.drawPieDataLabels(b,x,e);else this.drawDataLabels(b,x,e);t.save();t.globalCompositeOperation="source-over";const S=r.x;const w=r.y;const C=r.width;const T=r.height;t.drawImage(d,0,0,d.width,d.height,S,w,C,T);t.restore();x.destroy();return x}validateChartData(t){if(!t){void 0;return null}if("undefined"!==typeof window)window.debugChartData=t;const e="bubble"===t.type;const r="scatter"===t.type;let o=false;if(e)o=t.series&&t.series.length>0&&t.series.some(t=>t.bubbleSizes&&t.bubbleSizes.length>0&&t.values&&t.values.length>0&&t.categories&&t.categories.length>0);else o=t.series&&t.series.length>0&&t.series[0].values&&t.series[0].values.length>0;if(!o){void 0;if(e)void 0;else if(r)void 0;return null}if("undefined"!==typeof window)window.lastProcessedChartData=t;return t}convertToChartJSConfig(t,e){const r=this.validateChartData(t);if(!r)throw new Error("Cannot render chart without real data from PPTX DOM");const{type:o,series:s,categories:i,title:n,legend:a,plotArea:l,axes:c,subtype:h}=r;const u={column:"bar",bar:"bar",line:"line",pie:"pie",doughnut:"doughnut",area:"line",scatter:"scatter",bubble:"bubble",radar:"radar"};const f=u[o]||"bar";const d="area"===o&&("stacked"===h||"percentStacked"===h);const p="column"===o&&("stacked"===h||"percentStacked"===h);const g="bar"===o&&("stacked"===h||"percentStacked"===h);const m=d||p||g;if("area"===o);if("area"===o)if(s.length>=2){const t=s[0].values||[];const e=s[1].values||[]}if("area"===o)if(d);else void 0;else if("column"===o)if(p);let y=i||[];if(("pie"===f||"doughnut"===f)&&1===s.length&&s[0].categories&&s[0].categories.length>0)y=s[0].categories;if("radar"===f)if(s.length>0&&s[0].categories&&s[0].categories.length>0)y=s[0].categories;else if(i&&i.length>0)y=i;else void 0;if("bubble"===f)y=[];const b=this.convertSeriesToDatasets(s,f,m,o);const x=s.flatMap(t=>t.values||[]);const S=Math.min(...x,0);const w=Math.max(...x);let C=S<0?S:0;let T,P;const{max:v,step:M}=this.calculateOptimalAxisScale(w,S);T=v;P=M;if(c&&c.value&&c.value.scaling){const t=c.value.scaling;if(null!==t.min&&void 0!==t.min)C=t.min;if(null!==t.max&&void 0!==t.max)T=t.max;if(null!==t.majorUnit&&void 0!==t.majorUnit)P=t.majorUnit}if("column"===o&&w>=900&&w<=1200){C=0;T=1200;P=200}else if(!c?.value?.scaling?.majorUnit)if(m){const t=Math.max(...s.map(t=>t.values?t.values.length:0));let e=0;for(let r=0;r<t;r++){const t=s.reduce((t,e)=>{const o=e.values&&e.values[r]?e.values[r]:0;return t+o},0);e=Math.max(e,t)}if(e>=1100&&e<=1150){T=1200;P=200}else{const{max:t,step:r}=this.calculateOptimalAxisScale(e,0);T=t;P=r}if("area"===o&&w<=31200&&w>=3e4){T=35e3;P=5e3}}else if("area"===o&&w<=31200&&w>=3e4){T=5e3*Math.ceil(1.1*w/5e3);P=5e3}else{const t=T-C;if(t<=1200)P=200;else if(t<=7e3)P=1e3;else if(t<=35e3)P=5e3;else P=1e3*Math.ceil(t/7/1e3)}let A="x";if("bar"===f){if("bar"===o)A="y";else if("column"===o)A="x";if(r.barDirection)if("bar"===r.barDirection)A="y";else if("col"===r.barDirection)A="x"}const E={type:f,data:{labels:y,datasets:b},options:{responsive:false,maintainAspectRatio:false,indexAxis:A,layout:{padding:{top:20,right:20,bottom:20,left:20}},scales:this.getScalesConfig(f,C,T,P,m,c,s,A),plugins:{beforeDraw:t=>{const e=t.ctx;e.save();const o=t.config&&("pie"===t.config.type||"doughnut"===t.config.type);if(!o)if(r&&r.plotArea&&r.plotArea.shapeProperties&&r.plotArea.shapeProperties.fill){const o=this.extractBackgroundColor(r);e.fillStyle=o;e.fillRect(0,0,t.width,t.height)}e.restore()},legend:{display:a&&false!==a.visible,position:this.mapLegendPosition(a),labels:{padding:5,font:this.extractFontConfig(a),boxWidth:15,boxHeight:8,usePointStyle:false,generateLabels:function(t){const e=t.data;if("pie"===t.config.type||"doughnut"===t.config.type){if(e.labels.length&&e.datasets.length)return e.labels.map((t,r)=>{const o=e.datasets[0];const s=Array.isArray(o.backgroundColor)?o.backgroundColor[r]:o.backgroundColor;return{text:t,fillStyle:s,strokeStyle:s,lineWidth:1,hidden:false,index:r}})}else if(e.datasets.length>0)return e.datasets.map((t,e)=>({text:t.label||`Series ${e+1}`,fillStyle:t.backgroundColor||t.borderColor,strokeStyle:t.borderColor||t.backgroundColor,lineWidth:t.borderWidth||1,hidden:false,index:e,datasetIndex:e}));return[]}}},tooltip:this.getTooltipConfig(f,m)},animation:{duration:0}}};if("doughnut"===f){const t=r&&null!=r.holeSize?r.holeSize:50;E.options.cutout=`${t}%`}if(("pie"===f||"doughnut"===f)&&r&&null!=r.firstSliceAng){const t=r.firstSliceAng-90;const e=t*Math.PI/180;E.options.rotation=e}if(n&&(n.text||"string"===typeof n)){const t=n.text||n;if("string"===typeof t&&(t.includes("catAxis")||t.includes("valGrid")||t.includes("Hidden")||t.includes(":true")||t.includes(":false")));else{const e=this.extractFontConfig(n);if(e&&"number"===typeof e.size)e.size=Math.max(e.size,this.getDOMFontSize(n.formatting,18));let r="#4472C4";if(n&&n.formatting&&n.formatting.color)r=this.extractColorFromFormatting(n);else if(n&&n.color)r=this.convertColorToHex(n.color);if(!r||"#000000"===r)r="#4472C4";E.options.plugins.title={display:true,text:t,position:"top",align:"center",padding:{top:10,bottom:20},font:e,color:r}}}return E}convertSeriesToDatasets(t,e,r=false,o=null){const s="area"===o&&r;if("radar"===e)return t.map((t,e)=>{const r=["#3B82F6","#F59E0B","#EF4444"];let o=r[e%r.length];if(t.color)o=this.convertColorToHex(t.color);return{label:t.name||`Series ${e+1}`,data:t.values||[],backgroundColor:this.hexToRgba(o,.2),borderColor:o,borderWidth:2,pointBackgroundColor:o,pointBorderColor:"#ffffff",pointBorderWidth:2,pointHoverBackgroundColor:"#ffffff",pointHoverBorderColor:o,pointHoverBorderWidth:3,pointRadius:4,pointHoverRadius:6,tension:0}});if("scatter"===e)return t.map((t,e)=>{const r=this.getSeriesColor(t,e);const o=t.categories||t.xValues||[];const s=t.values||[];const i=Math.max(o.length,s.length);const n=[];for(let t=0;t<i;t++){const e=parseFloat(o[t]);const r=parseFloat(s[t]);n.push({x:isNaN(e)?0:e,y:isNaN(r)?0:r})}let a=4;if(t.marker&&"number"===typeof t.marker.size){const e=(t.marker.size>100?t.marker.size/100:t.marker.size)*(96/72);a=Math.max(2,Math.min(8,Math.round(e/2)))}return{label:t.name||`Series ${e+1}`,data:n,showLine:false,backgroundColor:r,borderColor:r,pointRadius:a,pointHoverRadius:Math.max(a+2,4)}});if("bubble"===e)return t.map((t,e)=>{const r=this.getSeriesColor(t,e);const o=[];const s=t.categories||[];const i=t.values||[];const n=t.bubbleSizes||[];const a=Math.max(s.length,i.length,n.length);const l=n.map(t=>parseFloat(t)).filter(t=>!isNaN(t)&&t>0);const c=l.length>0?Math.min(...l):1;const h=l.length>0?Math.max(...l):1;const u=h-c;for(let t=0;t<a;t++){const e=parseFloat(s[t])||0;const r=parseFloat(i[t])||0;const a=parseFloat(n[t])||c;let l;if(u>0){const t=(a-c)/u;l=5+15*t}else l=8;l=Math.max(l,3);o.push({x:e,y:r,r:l})}return{label:t.name||`Series ${e+1}`,data:o,backgroundColor:r,borderColor:r,borderWidth:2,pointRadius:0,pointHoverRadius:0}});if("pie"===e||"doughnut"===e)if(1===t.length&&t[0].values&&t[0].values.length>1){let r;if(t[0].pointFills&&t[0].pointFills.length)r=t[0].values.map((e,r)=>this.convertColorToHex(t[0].pointFills[r]||this.getPieSegmentColor(r)));else r=t[0].values.map((t,e)=>this.getPieSegmentColor(e));return[{data:t[0].values,backgroundColor:r,borderColor:r.map(t=>this.darkenColor(t)),borderWidth:2,label:t[0].name||("doughnut"===e?"Doughnut Chart":"Pie Chart")}]}else if(t.length>1){const r=t.map(t=>t.values&&t.values.length>0?t.values[0]:0);const o=t.map((t,e)=>{if(t.pointFills&&t.pointFills[0])return this.convertColorToHex(t.pointFills[0]);return this.getPieSegmentColor(e)});return[{data:r,backgroundColor:o,borderColor:o.map(t=>this.darkenColor(t)),borderWidth:2,label:"doughnut"===e?"Doughnut Chart":"Pie Chart"}]}let i=[...t];if(r&&2===t.length){const e=t.some(t=>t.name&&t.name.toLowerCase().includes("website"));const r=t.some(t=>t.name&&t.name.toLowerCase().includes("mobile"));if(e&&r&&"area"===o)i=[...t].reverse()}return i.map((t,i)=>{const n=this.getSeriesColor(t,i);let a=n;if(s){const e={"Website Traffic":"#27AE60","Mobile Traffic":"#3498DB"};if(e[t.name])a=e[t.name];else if(t.name&&t.name.toLowerCase().includes("website"))a="#27AE60";else if(t.name&&t.name.toLowerCase().includes("mobile"))a="#3498DB";else{const t=["#3498DB","#27AE60"];a=t[i%t.length]}}const l={label:t.name||`Series ${i+1}`,data:t.values||[],backgroundColor:a,borderColor:a,borderWidth:1};if("area"===o&&"line"===e){const t="area"===o&&r;if(t)if(0===i)l.fill="origin";else l.fill="-1";else l.fill="origin";const e=a.startsWith("#")?a:`#${a}`;const s=this.hexToRgb(e);if(s){const t=0===i?.7:.6;l.backgroundColor=`rgba(${s.r}, ${s.g}, ${s.b}, ${t})`}l.borderColor=a;l.borderWidth=2;l.tension=.2;l.pointRadius=0;l.pointHoverRadius=4;l.pointHoverBackgroundColor=a;l.pointHoverBorderColor="#ffffff";l.pointHoverBorderWidth=2}else if(("column"===o||"bar"===o)&&"bar"===e){const t=("column"===o||"bar"===o)&&r;if(t)l.stack="Stack 0"}else if("line"===e){l.fill=false;l.tension=.1;l.pointRadius=3;l.pointHoverRadius=5}return l})}getSeriesColor(t,e){if(t.color){const e=this.convertColorToHex(t.color);return e}if(t.marker&&t.marker.fill){const e=this.convertColorToHex(t.marker.fill);return e}if(t.marker&&t.marker.line&&t.marker.line.color){const e=this.convertColorToHex(t.marker.line.color);return e}if(t.fill){const e=this.convertColorToHex(t.fill);return e}if(t.line&&t.line.color){const e=this.convertColorToHex(t.line.color);return e}const r=["#4472C4","#C00000","#70AD47","#A5A5A5","#5B9BD5","#FFC000","#264478","#7F0000"];const o=r[e%r.length];return o}mapLegendPosition(t){if(!t||!t.position)return"right";const e={r:"right",l:"left",t:"top",b:"bottom",tr:"right",tl:"left",br:"right",bl:"left"};return e[t.position]||"right"}drawPieDataLabels(t,e,r){const o=e.data.datasets;const s=e.getDatasetMeta(0);if(!s||!s.data||0===s.data.length)return;t.save();let i={family:"Calibri",size:11,weight:"normal"};let n="#FFFFFF";if(r&&r.series&&r.series[0]&&r.series[0].dataLabels){const t=r.series[0].dataLabels;if(t.formatting){i=this.extractFontConfig(t);n=this.extractColorFromFormatting(t)}}else i.size=this.getDOMFontSize(null,12);t.font=`${i.style||"normal"} ${i.weight} ${i.size}px ${i.family}`;t.fillStyle=n;const a=t=>{const e=r?.series?.[t];if(e?.dataLabels?.formatting?.color)return this.convertColorToHex(e.dataLabels.formatting.color);if(e?.formatting?.color)return this.convertColorToHex(e.formatting.color);if(e?.fill)return this.convertColorToHex(e.fill);if(e?.line?.color)return this.convertColorToHex(e.line.color);const o=["#3498DB","#E74C3C","#70AD47","#FFC000","#8E72B2","#E16232","#3B8DBD","#98C723"];return o[t%o.length]};t.textAlign="center";t.textBaseline="middle";const l=s.data[0].x;const c=s.data[0].y;const h=[];s.data.forEach((t,e)=>{const r=o[0].data[e];const s=o[0].data.reduce((t,e)=>t+e,0);const i=Math.round(r/s*100);const n=t.startAngle;const a=t.endAngle;const u=(n+a)/2;const f=t.outerRadius;const d=t.innerRadius||0;const p=d>0;const g=p?(d+f)/2:.65*f;const m=l+Math.cos(u)*g;const y=c+Math.sin(u)*g;h.push({x:m,y,value:r,percentage:i,index:e})});const u=this.adjustLabelPositions(h,i.size);u.forEach(e=>{const o=true===r?.dataLabels?.showValue||true===r?.series?.[0]?.dataLabels?.showValue;const s=true===r?.dataLabels?.showPercent||true===r?.series?.[0]?.dataLabels?.showPercent;if(o&&s){t.fillText(e.value.toString(),e.x,e.y-8);t.fillText(`${e.percentage}%`,e.x,e.y+8)}else if(o)t.fillText(e.value.toString(),e.x,e.y);else if(s)t.fillText(`${e.percentage}%`,e.x,e.y)});t.restore()}adjustLabelPositions(t,e){const r=[...t];const o=3*e;for(let t=0;t<r.length;t++)for(let e=t+1;e<r.length;e++){const s=r[t];const i=r[e];const n=Math.sqrt(Math.pow(s.x-i.x,2)+Math.pow(s.y-i.y,2));if(n<o){const t=Math.atan2(i.y-s.y,i.x-s.x);const e=(o-n)/2;s.x-=Math.cos(t)*e;s.y-=Math.sin(t)*e;i.x+=Math.cos(t)*e;i.y+=Math.sin(t)*e}}return r}drawDataLabels(t,e,r){const o=this.shouldShowDataLabels(r);if(!o)return;const s=e.data.datasets;const i=e.chartArea;t.save();let n={family:"Calibri",size:11,weight:"normal"};let a="#333333";if(r&&r.series&&r.series[0]&&r.series[0].dataLabels){const t=r.series[0].dataLabels;if(t.formatting){n=this.extractFontConfig(t);a=this.extractColorFromFormatting(t)}}else n.size=this.getDOMFontSize(null,12);t.font=`${n.style||"normal"} ${n.weight} ${n.size}px ${n.family}`;t.fillStyle=a;t.textAlign="center";t.textBaseline="bottom";s.forEach((r,o)=>{t.save();t.fillStyle=a||getSeriesLabelColor(o);const s=e.getDatasetMeta(o);s.data.forEach((e,o)=>{const s=r.data[o];const i=e.x;const n=e.y-5;t.fillText(s.toLocaleString(),i,n)});t.restore()});t.restore()}getDOMFontSize(t,e=12){const r=96/72;let o=e;if(t&&t.font){const r=t.font;o=r.fontSize||r.size||e;if("string"===typeof o){const t=o.trim().toLowerCase();if(t.endsWith("pt"))o=parseFloat(t.slice(0,-2));else if(t.endsWith("px")){const e=parseFloat(t.slice(0,-2));return Math.max(8,Math.round(e))}else{const e=parseFloat(t);if(!isNaN(e))o=e}}if("number"===typeof o&&o>100)o/=100}const s=o*r;return Math.max(8,Math.round(s))}extractFontConfig(t){const e={size:12,family:"Calibri",weight:"normal"};if(!t||!t.formatting||!t.formatting.font)return e;const r=t.formatting.font;const o=this.getDOMFontSize(t.formatting,e.size);return{size:o,family:r.fontFamily||r.family||e.family,weight:true===r.bold?"bold":r.weight||e.weight,style:true===r.italic?"italic":"normal"}}extractColorFromFormatting(t){if(!t||!t.formatting||!t.formatting.color)return"#000000";return this.convertColorToHex(t.formatting.color)}convertColorToHex(t){if(!t)return"#000000";if("string"===typeof t){const e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){const t=parseInt(e[1]);const r=parseInt(e[2]);const o=parseInt(e[3]);return`#${t.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}if(t.match(/^[0-9A-Fa-f]{6}$/))return`#${t}`;if(t.startsWith("#")&&t.match(/^#[0-9A-Fa-f]{6}$/))return t;return"#000000"}if("object"===typeof t){if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b){const e=Math.round(t.r);const r=Math.round(t.g);const o=Math.round(t.b);return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}`}if(t.color)return this.convertColorToHex(t.color);return"#000000"}return"#000000"}extractBackgroundColor(t){let e="#ffffff";if(t&&t.plotArea&&t.plotArea.shapeProperties&&t.plotArea.shapeProperties.fill){const r=this.convertColorToHex(t.plotArea.shapeProperties.fill);e=r}return e}async renderColumnChart(t,e,r){e.type="column";return this.renderChart(t,e,r)}getPieSegmentColor(t){const e=["#E74C3C","#3498DB","#2ECC71","#F39C12","#9B59B6","#FF6B6B","#4ECDC4","#45B7D1","#96CEB4","#FFEAA7"];return e[t%e.length]}darkenColor(t){if(t.startsWith("#")){const e=t.slice(1);const r=parseInt(e.slice(0,2),16);const o=parseInt(e.slice(2,4),16);const s=parseInt(e.slice(4,6),16);const i=Math.floor(.8*r);const n=Math.floor(.8*o);const a=Math.floor(.8*s);return`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}return t}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}hexToRgba(t,e=1){const r=this.hexToRgb(t);if(r)return`rgba(${r.r}, ${r.g}, ${r.b}, ${e})`;return`rgba(0, 0, 0, ${e})`}getScalesConfig(t,e,r,o,s,i,n,a="x"){if("pie"===t||"doughnut"===t)return{};if("radar"===t){let t=0;let e=100;let r=20;if(i&&i.value&&i.value.scaling){const o=i.value.scaling;if(null!==o.min&&void 0!==o.min)t=o.min;if(null!==o.max&&void 0!==o.max)e=o.max;if(null!==o.majorUnit&&void 0!==o.majorUnit)r=o.majorUnit}return{r:{angleLines:{display:true,color:"rgba(136, 136, 136, 0.8)",lineWidth:1},min:t,max:e,beginAtZero:true,ticks:{stepSize:r,font:{size:this.getDOMFontSize(i?.value?.formatting,12),weight:"normal"},color:"#000000",backdropColor:"transparent",showLabelBackdrop:false,padding:10,callback:function(t){return t.toString()}},pointLabels:{font:{size:this.getDOMFontSize(i?.category?.formatting,14),weight:"normal"},color:"#000000",padding:20,centerPointLabels:false},grid:{circular:true,color:"rgba(136, 136, 136, 0.8)",lineWidth:1}}}}if("scatter"===t){const t=n.flatMap(t=>t.categories||t.xValues||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));const e=n.flatMap(t=>t.values||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));const r=t.length?Math.min(...t):0;const o=t.length?Math.max(...t):1;const s=e.length?Math.min(...e):0;const a=e.length?Math.max(...e):1;const l=(t,e,r)=>{const o=Math.max(e-t,1e-9);const s=o/7;const i=Math.pow(10,Math.floor(Math.log10(s)));const n=[1,2,5,10].map(t=>t*i);const a=n.find(t=>t>=s)||r||i;return a};const c=t=>.05*t;const h=c(o-r);const u=c(a-s);const f={min:r-h,max:o+h,stepSize:l(r,o)};const d={min:s-u,max:a+u,stepSize:l(s,a)};if(i?.category?.scaling){const t=i.category.scaling;if(null!==t.min&&void 0!==t.min)f.min=t.min;if(null!==t.max&&void 0!==t.max)f.max=t.max;if(null!==t.majorUnit&&void 0!==t.majorUnit)f.stepSize=t.majorUnit}if(i?.value?.scaling){const t=i.value.scaling;if(null!==t.min&&void 0!==t.min)d.min=t.min;if(null!==t.max&&void 0!==t.max)d.max=t.max;if(null!==t.majorUnit&&void 0!==t.majorUnit)d.stepSize=t.majorUnit}return{x:{type:"linear",position:"bottom",min:f.min,max:f.max,ticks:{stepSize:f.stepSize,font:{size:this.getDOMFontSize(i?.category?.formatting,12)}},title:{display:!!i?.category?.title?.text,text:i?.category?.title?.text||""},grid:{display:true,color:"rgba(200,200,200,0.3)",lineWidth:1}},y:{type:"linear",min:d.min,max:d.max,ticks:{stepSize:d.stepSize,font:{size:this.getDOMFontSize(i?.value?.formatting,12)}},title:{display:!!i?.value?.title?.text,text:i?.value?.title?.text||""},grid:{display:true,color:"rgba(200,200,200,0.3)",lineWidth:1}}}}if("bubble"===t){const t=n.flatMap(t=>t.categories||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));const e=n.flatMap(t=>t.values||[]).map(t=>parseFloat(t)).filter(t=>!isNaN(t));if(0===t.length||0===e.length){void 0;return{}}const r=Math.min(...t);const o=Math.max(...t);const s=Math.min(...e);const a=Math.max(...e);const l=(t,e,r)=>{const o=0;const s=e-o;const i=e+.1*s;const n=Math.ceil(i/r)*r;return{min:o,max:n,stepSize:r}};const c=i?.category?.scaling?.majorUnit||5;const h=i?.value?.scaling?.majorUnit||50;const u=l(r,o,c);const f=l(s,a,h);if(i?.category?.scaling){if(null!==i.category.scaling.min)u.min=i.category.scaling.min;if(null!==i.category.scaling.max)u.max=i.category.scaling.max;if(null!==i.category.scaling.majorUnit)u.stepSize=i.category.scaling.majorUnit}if(i?.value?.scaling){if(null!==i.value.scaling.min)f.min=i.value.scaling.min;if(null!==i.value.scaling.max)f.max=i.value.scaling.max;if(null!==i.value.scaling.majorUnit)f.stepSize=i.value.scaling.majorUnit}return{x:{type:"linear",position:"bottom",min:u.min,max:u.max,title:{display:true,text:i?.category?.title?.text||"Market Share (%)"},ticks:{stepSize:u.stepSize,font:{size:this.getDOMFontSize(i?.category?.formatting,12)},callback:function(t){return t+"%"}},grid:{color:"rgba(200, 200, 200, 0.3)",lineWidth:1,display:true}},y:{type:"linear",position:"left",min:f.min,max:f.max,title:{display:true,text:i?.value?.title?.text||"Revenue ($1000s)"},ticks:{stepSize:f.stepSize,font:{size:this.getDOMFontSize(i?.value?.formatting,12)},callback:function(t){return t.toLocaleString()}},grid:{color:"rgba(200, 200, 200, 0.3)",lineWidth:1,display:true}}}}const l=i?.value?.tickLabels?.formatting;const c=i?.category?.tickLabels?.formatting;const h=l?.color?this.convertColorToHex(l.color):"#666666";const u=c?.color?this.convertColorToHex(c.color):"#666666";const f={y:{beginAtZero:e>=0,min:e,max:r,stacked:s,reverse:this.shouldReverseAxis(i?.value?.scaling,"value"),ticks:{stepSize:o,font:{size:this.getDOMFontSize(l,12)},color:h,callback:function(t){return t.toLocaleString()}},grid:{color:"rgba(136, 136, 136, 0.8)",lineWidth:1,display:true}},x:{stacked:s,ticks:{font:{size:this.getDOMFontSize(c,12)},color:u},grid:{display:false}}};if("y"===a){const t={...f};f.x={beginAtZero:e>=0,min:e,max:r,stacked:s,reverse:this.shouldReverseAxis(i?.value?.scaling,"value"),ticks:{stepSize:o,font:{size:this.getDOMFontSize(l,12)},color:h,callback:function(t){return t.toLocaleString()}},grid:{color:"rgba(136, 136, 136, 0.8)",lineWidth:1,display:true}};f.y={stacked:s,reverse:this.shouldReverseAxis(i?.category?.scaling,"category"),ticks:{font:{size:this.getDOMFontSize(c,12)},color:u},grid:{display:false}}}if("y"===a){if(i?.value?.title)f.x.title={display:true,text:i.value.title.text||i.value.title,font:{size:this.getDOMFontSize(i?.value?.title?.formatting,14),weight:"bold"},color:i?.value?.title?.formatting?.color?this.convertColorToHex(i.value.title.formatting.color):"#666666"};if(i?.category?.title)f.y.title={display:true,text:i.category.title.text||i.category.title,font:{size:this.getDOMFontSize(i?.category?.title?.formatting,14),weight:"bold"},color:i?.category?.title?.formatting?.color?this.convertColorToHex(i.category.title.formatting.color):i?.category?.title?.text?.includes("Cat")?"#FFA500":"#666666"}}else{if(i?.value?.title)f.y.title={display:true,text:i.value.title.text||i.value.title,font:{size:this.getDOMFontSize(i?.value?.title?.formatting,14),weight:"bold"},color:i?.value?.title?.formatting?.color?this.convertColorToHex(i.value.title.formatting.color):"#666666"};if(i?.category?.title)f.x.title={display:true,text:i.category.title.text||i.category.title,font:{size:this.getDOMFontSize(i?.category?.title?.formatting,14),weight:"bold"},color:i?.category?.title?.formatting?.color?this.convertColorToHex(i.category.title.formatting.color):i?.category?.title?.text?.includes("Cat")?"#FFA500":"#666666"}}return f}getTooltipConfig(t,e){if("bubble"===t)return{mode:"point",intersect:true,callbacks:{title:function(t){const e=t[0];return e.dataset.label||""},label:function(t){const e=t.parsed;return[`Market Share: ${e.x}%`,`Revenue: $${e.y.toLocaleString()}k`,`Customer Base: ${e.r} units`]}}};return{mode:e?"index":"nearest",intersect:false,callbacks:{label:function(t){let e=t.dataset.label||"";if(e)e+=": ";if(null!==t.parsed.y)e+=t.parsed.y.toLocaleString();return e}}}}shouldShowDataLabels(t){if(t&&t.series&&t.series.length>0){let e=false;const r=false;for(const r of t.series)if(r.dataLabels){e=true;if(true===r.dataLabels.showValue)return true;if(false===r.dataLabels.showValue);}if(e)return false}if(t&&t.dataLabels){const e=t.dataLabels.showValue;if(false===e)return false;if(true===e)return true}if(t&&void 0!==t.showDataLabels){const e=t.showDataLabels;return e}return false}shouldReverseAxis(t,e){if(!t||!t.orientation)return false;const r="maxMin"===t.orientation;return r}calculateOptimalAxisScale(t,e=0){if(t<=0)return{max:10,step:2};const r=t-e;const o=1.2*t;const s=Math.pow(10,Math.floor(Math.log10(o)));const i=[1,2,5,10];let n;let a;for(const t of i){const e=t*s;const r=Math.ceil(o/e);if(r>=4&&r<=8){n=e;a=Math.ceil(o/e)*e;break}}if(!n){const t=s/10;for(const e of i){const r=e*t;const s=Math.ceil(o/r);if(s>=4&&s<=8){n=r;a=Math.ceil(o/r)*r;break}}}if(!n){n=s;a=Math.ceil(o/s)*s}if(t<1)if(t<.1){n=.02;a=.02*Math.ceil(o/.02)}else{n=.2;a=.2*Math.ceil(o/.2)}else if(t<10)if(o<=6){n=1;a=Math.ceil(o)}else{n=2;a=2*Math.ceil(o/2)}return{max:a,step:n}}}if("object"!=="undefined"&&t.exports)t.exports=e;if("undefined"!==typeof window)window.ChartJSRenderer=e}(X);return X.exports}var Q=J();var K=s(Q);var tt={};var et;function rt(){if(et)return tt;et=1;if("undefined"===typeof AscCommon)window.AscCommon={};function t(){if("undefined"===typeof CanvasGraphicsAdapter)return;if(CanvasGraphicsAdapter.prototype.drawLineWithArrows)return;CanvasGraphicsAdapter.prototype.drawLineWithArrows=function(t,e,r,o,s,i=1,n=null){const a=this._context;if(!a)return;a.save();a.beginPath();a.moveTo(t,e);a.lineTo(r,o);const l=("function"===typeof this.colorToRgb?this.colorToRgb(s):null)||"rgba(0,0,0,1)";const c=Math.max(CoordinateTransform.mmToPixels(i||1),1);a.strokeStyle=l;a.lineWidth=c;if(n&&"function"===typeof this.applyStrokeStyle)try{this.applyStrokeStyle(a,n,c)}catch(t){}a.stroke();const h=t=>{if("number"===typeof t)return t;const e=(t||"").toString().toLowerCase();if("lg"===e||"large"===e)return 3;if("med"===e||"medium"===e)return 2;if("sm"===e||"small"===e)return 1;return 2};const u=n&&n.headEnd;const f=n&&n.tailEnd;const d=u&&u.type;const p=f&&f.type;const g=!!(u&&d&&"none"!==d);const m=!!(f&&p&&"none"!==p);if(g||m){const s=Math.atan2(o-e,r-t);const i=a.getTransform();const n=Math.sqrt(i.a*i.a+i.b*i.b);const d=3*c;const p=2.5*c;const y=(t,e,r,o)=>{if(!o)return;const s=o.lengthScale||h(o.len);const i=o.widthScale||h(o.w);const n=d*s;const u=p*i;const f=(o.type||o.val||"arrow").toString().toLowerCase();const g=u/2;a.save();a.translate(t,e);a.rotate(r);a.beginPath();if("open"===f){a.moveTo(0,0);a.lineTo(-n,-g);a.moveTo(0,0);a.lineTo(-n,g);a.strokeStyle=l;a.lineWidth=Math.max(1,c);a.stroke()}else if("stealth"===f){a.moveTo(0,0);a.lineTo(-n,-.5*g);a.lineTo(.85*-n,0);a.lineTo(-n,.5*g);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}else if("diamond"===f){a.moveTo(0,0);a.lineTo(-n/2,-g);a.lineTo(-n,0);a.lineTo(-n/2,g);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}else if("oval"===f){a.ellipse(-n/2,0,n/2,g,0,0,2*Math.PI);a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}else{a.moveTo(0,0);a.lineTo(-n,-g);a.lineTo(-n,g);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(.5,.3*c);a.stroke()}a.restore()};if(g)y(t,e,s+Math.PI,u);if(m)y(r,o,s,f)}a.restore()}}if("undefined"===typeof AscFormat)window.AscFormat={};class e{constructor(){this.sx=1;this.sy=1;this.shx=0;this.shy=0;this.tx=0;this.ty=0}TransformPointX(t,e){return t*this.sx+e*this.shx+this.tx}TransformPointY(t,e){return t*this.shy+e*this.sy+this.ty}Invert(){const t=this.sx*this.sy-this.shx*this.shy;if(Math.abs(t)<1e-12)return;const e=1/t;const r=this.sy*e;const o=this.sx*e;const s=-this.shx*e;const i=-this.shy*e;const n=(this.shx*this.ty-this.sy*this.tx)*e;const a=(this.shy*this.tx-this.sx*this.ty)*e;this.sx=r;this.sy=o;this.shx=s;this.shy=i;this.tx=n;this.ty=a}createDuplicate(){const t=new e;t.sx=this.sx;t.sy=this.sy;t.shx=this.shx;t.shy=this.shy;t.tx=this.tx;t.ty=this.ty;return t}reset(){this.sx=1;this.sy=1;this.shx=0;this.shy=0;this.tx=0;this.ty=0}}if("undefined"===typeof CBrush)window.CBrush=class t{constructor(){this.Color1={R:0,G:0,B:0,A:255};this.Color2={R:0,G:0,B:0,A:255};this.Type=0}GetType(){return this.Type}};if("undefined"===typeof CPen)window.CPen=class t{constructor(){this.Color={R:0,G:0,B:0,A:255};this.Size=1;this.DashStyle=0}};if("undefined"===typeof CFontManager)window.CFontManager=class t{constructor(){this.m_oGlyphString={m_fX:0,m_fY:0,m_pGlyphsBuffer:[]}}LoadString4C(t,e,r){this.m_oGlyphString.m_fX=e;this.m_oGlyphString.m_fY=r;return e+10}LoadString2(t,e,r){this.m_oGlyphString.m_fX=e;this.m_oGlyphString.m_fY=r}GetNextChar2(){return null}};class CanvasGraphicsAdapter{constructor(){this.canvas=null;this._context=null;this.widthPx=0;this.heightPx=0;this.widthMM=0;this.heightMM=0;this.dpiX=96;this.dpiY=96;this.transform=new e;this.grStateStack=[];this.clipStack=[];this.font=null;this.brush=new CBrush;this.pen=new CPen;this.currentPath=null;this.isPathStarted=false;this.customGeometryProcessor=new r}get context(){return this._context}init(t,e,r,o,s){this._context=t;this.widthPx=e;this.heightPx=r;this.widthMM=o||25.4*e/96;this.heightMM=s||25.4*r/96;this.dpiX=96;this.dpiY=96;this.transform.sx=1;this.transform.sy=1;this.transform.shx=0;this.transform.shy=0;this.transform.tx=0;this.transform.ty=0;this.recalculateTransforms()}recalculateTransforms(){this.transform=this.transform.createDuplicate();const t=this.transform.sx*this.transform.sx+this.transform.shx*this.transform.shy;const e=this.transform.sy*this.transform.sy+this.transform.shy*this.transform.shx;const r=this.transform.sx*this.transform.shx+this.transform.shx*this.transform.sy;const o=this.transform.sy*this.transform.shy+this.transform.shy*this.transform.sx;const s=this.transform.sx*this.transform.tx+this.transform.shx*this.transform.ty+this.transform.tx;const i=this.transform.sy*this.transform.ty+this.transform.shy*this.transform.tx+this.transform.ty;this.transform.sx=t;this.transform.sy=e;this.transform.shx=r;this.transform.shy=o;this.transform.tx=s;this.transform.ty=i;this.transform=this.transform.createDuplicate();this.transform.Invert()}resetState(){this.coordinateSystem=null;this.transform.reset();this.grStateStack=[];this.clipStack=[];this.currentRenderingShape=null;if(this.customGeometryProcessor)this.customGeometryProcessor.cache.clear();this.currentPath=null;this.isPathStarted=false;this.brush=new CBrush;this.pen=new CPen}SaveGrState(){if(this._context){this._context.save();this.grStateStack.push({transform:this.transform.createDuplicate(),fullTransform:this.transform.createDuplicate(),invertFullTransform:this.transform.createDuplicate()})}}RestoreGrState(){if(this._context){this._context.restore();if(this.grStateStack.length>0){const t=this.grStateStack.pop();this.transform=t.transform;this.transform=t.fullTransform;this.transform=t.invertFullTransform}}}transform3(t){this.transform=t.createDuplicate();this.recalculateTransforms();if(this._context)this._context.setTransform(this.transform.sx,this.transform.shy,this.transform.shx,this.transform.sy,this.transform.tx,this.transform.ty)}AddClipRect(t,e,r,o){if(this._context){this._context.save();this._context.beginPath();this._context.rect(t,e,r,o);this._context.clip()}}clear(){if(this._context){this._context.save();this._context.setTransform(1,0,0,1,0,0);this._context.clearRect(0,0,this.widthPx,this.heightPx);this._context.restore()}}t(t,e,r,o){if(this.bIsBreak||!this._context)return;const s=e;const i=r;this._context.fillStyle=this.colorToRgb(this.brush.Color1);this._context.textBaseline="alphabetic";let n=s;let a=null;if(o)a={x:s,y:i,r:s,b:i};for(let e=0;e<t.length;e++){const r=t.charAt(e);this._context.fillText(r,n,i);const s=this._context.measureText(r);if(o){a.r=Math.max(a.r,n+s.width);if(void 0!==s.actualBoundingBoxAscent)a.y=Math.min(a.y,i-s.actualBoundingBoxAscent);if(void 0!==s.actualBoundingBoxDescent)a.b=Math.max(a.b,i+s.actualBoundingBoxDescent)}n+=s.width}return a}b_color1(t,e,r,o=255){this.brush.Color1.R=t;this.brush.Color1.G=e;this.brush.Color1.B=r;this.brush.Color1.A=o;this.bBrushColorInit=true}p_color(t,e,r,o=255){this.pen.Color.R=t;this.pen.Color.G=e;this.pen.Color.B=r;this.pen.Color.A=o;this.bPenColorInit=true}p_width(t){this.pen.Size=t;if(this._context)this._context.lineWidth=t}fillRect(t,e,r,o,s){if(!this._context||!s)return;this._context.save();this._context.fillStyle=this.colorToRgb(s);this._context.fillRect(t,e,r,o);this._context.restore()}strokeRect(t,e,r,o,s,i=1){if(!this._context)return;this._context.save();this._context.strokeStyle=this.colorToRgb(s)||this.colorToRgb(this.pen.Color);this._context.lineWidth=i;this._context.strokeRect(t,e,r,o);this._context.restore()}drawLine(t,e,r,o,s,i=1){if(!this._context)return;this._context.save();this._context.strokeStyle=this.colorToRgb(s);this._context.lineWidth=i;this._context.beginPath();this._context.moveTo(t,e);this._context.lineTo(r,o);this._context.stroke();this._context.restore()}fillCircle(t,e,r,o){if(!this._context)return;this._context.save();this._context.fillStyle=this.colorToRgb(o);this._context.beginPath();this._context.arc(t,e,r,0,2*Math.PI);this._context.fill();this._context.restore()}strokeCircle(t,e,r,o,s=1){if(!this._context)return;this._context.save();this._context.strokeStyle=this.colorToRgb(o);this._context.lineWidth=s;this._context.beginPath();this._context.arc(t,e,r,0,2*Math.PI);this._context.stroke();this._context.restore()}fillText(t,e,r,o={}){if(!this._context)return;this._context.save();const s=o.fontSize||o.size||12;const i=o.fontFamily||o.family||"Arial";const n=o.bold?"bold":"normal";const a=o.italic?"italic":"normal";this._context.font=`${a} ${n} ${s}px ${i}`;this._context.fillStyle=this.colorToRgb(o.color||{r:0,g:0,b:0});this._context.textAlign=o.textAlign||"left";this._context.textBaseline=o.textBaseline||"alphabetic";this._context.fillText(t,e,r);this._context.restore()}colorToRgb(t){if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;const r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;const o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;const s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}return"rgb(0, 0, 0)"}Start_Command(t){this.commandStack.push(t)}End_Command(t){if(this.commandStack.length>0)this.commandStack.pop()}get context(){return this._context}isBoundsChecker(){return false}drawPresetGeometry(t,e,r,o,s,i,n,a=1,l=null){if(!this._context)return;const c=this._context;c.save();if(i)c.fillStyle=this.colorToRgb(i);if(n){c.strokeStyle=this.colorToRgb(n);c.lineWidth=CoordinateTransform.mmToPixels(a||1)}c.beginPath();switch(t){case"teardrop":this.drawTeardropPath(c,e,r,o,s);break;case"rect":case"rectangle":default:c.rect(e,r,o,s);break;case"ellipse":case"oval":case"flowChartConnector":c.ellipse(e+o/2,r+s/2,o/2,s/2,0,0,2*Math.PI);break;case"roundRect":this.drawRoundRectPath(c,e,r,o,s,10);break;case"triangle":this.drawTrianglePath(c,e,r,o,s);break;case"diamond":this.drawDiamondPath(c,e,r,o,s);break;case"pentagon":this.drawPentagonPath(c,e,r,o,s);break;case"hexagon":this.drawHexagonPath(c,e,r,o,s);break;case"octagon":this.drawOctagonPath(c,e,r,o,s);break;case"star":case"star5":this.drawStarPath(c,e,r,o,s);break;case"star4":this.drawStar4Path(c,e,r,o,s);break;case"star6":this.drawStar6Path(c,e,r,o,s);break;case"star8":this.drawStar8Path(c,e,r,o,s);break;case"star10":this.drawStar10Path(c,e,r,o,s);break;case"star12":this.drawStar12Path(c,e,r,o,s);break;case"star16":this.drawStar16Path(c,e,r,o,s);break;case"star24":this.drawStar24Path(c,e,r,o,s);break;case"star32":this.drawStar32Path(c,e,r,o,s);break;case"heart":this.drawHeartPath(c,e,r,o,s);break;case"flowChartProcess":this.drawFlowChartProcessPath(c,e,r,o,s);break;case"flowChartDecision":this.drawFlowChartDecisionPath(c,e,r,o,s);break;case"flowChartInputOutput":this.drawFlowChartInputOutputPath(c,e,r,o,s);break;case"flowChartPredefinedProcess":this.drawFlowChartPredefinedProcessPath(c,e,r,o,s);break;case"flowChartInternalStorage":this.drawFlowChartInternalStoragePath(c,e,r,o,s);break;case"flowChartDocument":this.drawFlowChartDocumentPath(c,e,r,o,s);break;case"flowChartMultidocument":this.drawFlowChartMultidocumentPath(c,e,r,o,s);break;case"flowChartTerminator":this.drawRoundRectPath(c,e,r,o,s,.2*Math.min(o,s));break;case"flowChartPreparation":this.drawFlowChartPreparationPath(c,e,r,o,s);break;case"flowChartManualInput":this.drawFlowChartManualInputPath(c,e,r,o,s);break;case"flowChartManualOperation":this.drawFlowChartManualOperationPath(c,e,r,o,s);break;case"flowChartOffpageConnector":this.drawFlowChartOffpageConnectorPath(c,e,r,o,s);break;case"flowChartPunchedCard":this.drawFlowChartPunchedCardPath(c,e,r,o,s);break;case"flowChartPunchedTape":this.drawFlowChartPunchedTapePath(c,e,r,o,s);break;case"flowChartSummingJunction":this.drawFlowChartSummingJunctionPath(c,e,r,o,s);break;case"flowChartOr":this.drawFlowChartOrPath(c,e,r,o,s);break;case"flowChartCollate":this.drawFlowChartCollatePath(c,e,r,o,s);break;case"flowChartSort":this.drawFlowChartSortPath(c,e,r,o,s);break;case"flowChartExtract":this.drawFlowChartExtractPath(c,e,r,o,s);break;case"flowChartMerge":this.drawFlowChartMergePath(c,e,r,o,s);break;case"flowChartStoredData":this.drawFlowChartStoredDataPath(c,e,r,o,s);break;case"flowChartDelay":this.drawFlowChartDelayPath(c,e,r,o,s);break;case"flowChartMagneticTape":this.drawFlowChartMagneticTapePath(c,e,r,o,s);break;case"flowChartMagneticDisk":this.drawFlowChartMagneticDiskPath(c,e,r,o,s);break;case"flowChartMagneticDrum":this.drawFlowChartMagneticDrumPath(c,e,r,o,s);break;case"flowChartDisplay":this.drawFlowChartDisplayPath(c,e,r,o,s);break;case"rightArrow":this.drawRightArrowPath(c,e,r,o,s);break;case"leftArrow":this.drawLeftArrowPath(c,e,r,o,s);break;case"upArrow":this.drawUpArrowPath(c,e,r,o,s);break;case"downArrow":this.drawDownArrowPath(c,e,r,o,s);break;case"leftRightArrow":this.drawLeftRightArrowPath(c,e,r,o,s);break;case"upDownArrow":this.drawUpDownArrowPath(c,e,r,o,s);break;case"quadArrow":this.drawQuadArrowPath(c,e,r,o,s);break;case"bentArrow":this.drawBentArrowPath(c,e,r,o,s);break;case"uturnArrow":this.drawUturnArrowPath(c,e,r,o,s);break;case"curvedRightArrow":this.drawCurvedRightArrowPath(c,e,r,o,s);break;case"curvedLeftArrow":this.drawCurvedLeftArrowPath(c,e,r,o,s);break;case"callout1":this.drawCallout1Path(c,e,r,o,s);break;case"callout2":this.drawCallout2Path(c,e,r,o,s);break;case"callout3":this.drawCallout3Path(c,e,r,o,s);break;case"accentCallout1":case"accentBorderCallout1":this.drawAccentCallout1Path(c,e,r,o,s);break;case"accentCallout2":case"accentBorderCallout2":this.drawAccentCallout2Path(c,e,r,o,s);break;case"accentCallout3":case"accentBorderCallout3":this.drawAccentCallout3Path(c,e,r,o,s);break;case"borderCallout1":this.drawBorderCallout1Path(c,e,r,o,s);break;case"borderCallout2":this.drawBorderCallout2Path(c,e,r,o,s);break;case"borderCallout3":this.drawBorderCallout3Path(c,e,r,o,s);break;case"lightningBolt":this.drawLightningBoltPath(c,e,r,o,s);break;case"sun":this.drawSunPath(c,e,r,o,s);break;case"moon":this.drawMoonPath(c,e,r,o,s);break;case"cloud":this.drawCloudPath(c,e,r,o,s);break;case"wave":this.drawWavePath(c,e,r,o,s);break;case"doubleWave":this.drawDoubleWavePath(c,e,r,o,s);break;case"smileyFace":this.drawSmileyFacePath(c,e,r,o,s);break;case"noSmoking":this.drawNoSmokingPath(c,e,r,o,s);break;case"blockArc":this.drawBlockArcPath(c,e,r,o,s);break;case"foldedCorner":this.drawFoldedCornerPath(c,e,r,o,s);break;case"bevel":this.drawBevelPath(c,e,r,o,s);break;case"donut":this.drawDonutPath(c,e,r,o,s);break;case"noSymbol":this.drawNoSymbolPath(c,e,r,o,s);break;case"cube":this.drawCubePath(c,e,r,o,s);break;case"can":this.drawCanPath(c,e,r,o,s);break;case"cone":this.drawConePath(c,e,r,o,s);break;case"pyramid":this.drawPyramidPath(c,e,r,o,s);break;case"plus":this.drawPlusPath(c,e,r,o,s);break;case"minus":this.drawMinusPath(c,e,r,o,s);break;case"multiply":this.drawMultiplyPath(c,e,r,o,s);break;case"divide":this.drawDividePath(c,e,r,o,s);break;case"equal":this.drawEqualPath(c,e,r,o,s);break;case"notEqual":this.drawNotEqualPath(c,e,r,o,s);break;case"line":case"straightConnector1":this.drawLinePath(c,e,r,o,s);break;case"bentConnector2":this.drawBentConnector2Path(c,e,r,o,s);break;case"bentConnector3":this.drawBentConnector3Path(c,e,r,o,s);break;case"bentConnector4":this.drawBentConnector4Path(c,e,r,o,s);break;case"bentConnector5":this.drawBentConnector5Path(c,e,r,o,s);break;case"curvedConnector2":this.drawCurvedConnector2Path(c,e,r,o,s);break;case"curvedConnector3":this.drawCurvedConnector3Path(c,e,r,o,s);break;case"curvedConnector4":this.drawCurvedConnector4Path(c,e,r,o,s);break;case"curvedConnector5":this.drawCurvedConnector5Path(c,e,r,o,s)}if(i)c.fill();if(n){if(l&&l.dashArray&&l.dashArray.length>0){const t=CoordinateTransform.mmToPixels(a||1);const e=l.dashArray.map(e=>e*t);c.setLineDash(e)}c.stroke()}c.restore()}drawTeardropPath(t,e,r,o,s){const i=o/1001;const n=s/992;const a=t=>e+t*i;const l=t=>r+t*n;t.moveTo(a(711),l(7));t.bezierCurveTo(a(475),l(8),a(442),l(8),a(423),l(12));t.bezierCurveTo(a(312),l(31),a(221),l(77),a(144),l(154));t.bezierCurveTo(a(53),l(247),a(4),l(363),a(4),l(492));t.bezierCurveTo(a(4),l(565),a(16),l(625),a(46),l(689));t.bezierCurveTo(a(82),l(769),a(143),l(842),a(219),l(894));t.bezierCurveTo(a(258),l(921),a(307),l(945),a(359),l(961));t.bezierCurveTo(a(418),l(980),a(509),l(987),a(577),l(977));t.bezierCurveTo(a(720),l(956),a(845),l(878),a(922),l(758));t.bezierCurveTo(a(953),l(710),a(977),l(654),a(988),l(603));t.bezierCurveTo(a(1001),l(544),a(1001),l(546),a(1001),l(265));t.lineTo(a(1001),l(7));t.lineTo(a(989),l(6));t.bezierCurveTo(a(983),l(6),a(857),l(6),a(711),l(7));t.closePath()}drawRoundRectPath(t,e,r,o,s,i){t.moveTo(e+i,r);t.lineTo(e+o-i,r);t.quadraticCurveTo(e+o,r,e+o,r+i);t.lineTo(e+o,r+s-i);t.quadraticCurveTo(e+o,r+s,e+o-i,r+s);t.lineTo(e+i,r+s);t.quadraticCurveTo(e,r+s,e,r+s-i);t.lineTo(e,r+i);t.quadraticCurveTo(e,r,e+i,r);t.closePath()}drawTrianglePath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath()}drawDiamondPath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s/2);t.lineTo(e+o/2,r+s);t.lineTo(e,r+s/2);t.closePath()}drawPentagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;for(let e=0;e<5;e++){const r=2*e*Math.PI/5-Math.PI/2;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);if(0===e)t.moveTo(o,s);else t.lineTo(o,s)}t.closePath()}drawHexagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;for(let e=0;e<6;e++){const r=2*e*Math.PI/6;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);if(0===e)t.moveTo(o,s);else t.lineTo(o,s)}t.closePath()}drawStarPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.4*a;for(let e=0;e<10;e++){const r=e*Math.PI/5-Math.PI/2;const o=e%2===0?a:l;const s=i+o*Math.cos(r);const c=n+o*Math.sin(r);if(0===e)t.moveTo(s,c);else t.lineTo(s,c)}t.closePath()}drawHeartPath(t,e,r,o,s){const i=20;const n=18.35;const a=2;const l=3;const c=o/i;const h=s/n;const u=t=>e+(t-a)*c;const f=t=>r+(t-l)*h;t.moveTo(u(12),f(21.35));t.lineTo(u(10.55),f(20.03));t.bezierCurveTo(u(5.4),f(15.36),u(2),f(12.28),u(2),f(8.5));t.bezierCurveTo(u(2),f(5.42),u(4.42),f(3),u(7.5),f(3));t.bezierCurveTo(u(9.24),f(3),u(10.91),f(3.81),u(12),f(5.09));t.bezierCurveTo(u(13.09),f(3.81),u(14.76),f(3),u(16.5),f(3));t.bezierCurveTo(u(19.58),f(3),u(22),f(5.42),u(22),f(8.5));t.bezierCurveTo(u(22),f(12.28),u(18.6),f(15.36),u(13.45),f(20.04));t.lineTo(u(12),f(21.35));t.closePath()}drawOctagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;for(let e=0;e<8;e++){const r=2*e*Math.PI/8;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);if(0===e)t.moveTo(o,s);else t.lineTo(o,s)}t.closePath()}drawStar4Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,4)}drawStar6Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,6)}drawStar8Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,8)}drawStar10Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,10)}drawStar12Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,12)}drawStar16Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,16)}drawStar24Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,24)}drawStar32Path(t,e,r,o,s){this.drawStarGeneric(t,e,r,o,s,32)}drawStarGeneric(t,e,r,o,s,i){const n=e+o/2;const a=r+s/2;const l=Math.min(o,s)/2;const c=.4*l;for(let e=0;e<2*i;e++){const r=e*Math.PI/i-Math.PI/2;const o=e%2===0?l:c;const s=n+o*Math.cos(r);const h=a+o*Math.sin(r);if(0===e)t.moveTo(s,h);else t.lineTo(s,h)}t.closePath()}drawFlowChartProcessPath(t,e,r,o,s){t.rect(e,r,o,s)}drawFlowChartDecisionPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;t.moveTo(i,r);t.lineTo(e+o,n);t.lineTo(i,r+s);t.lineTo(e,n);t.closePath()}drawFlowChartInputOutputPath(t,e,r,o,s){const i=.2*o;t.moveTo(e+i,r);t.lineTo(e+o,r);t.lineTo(e+o-i,r+s);t.lineTo(e,r+s);t.closePath()}drawFlowChartPredefinedProcessPath(t,e,r,o,s){const i=.12*o;t.rect(e,r,o,s);t.moveTo(e+i,r);t.lineTo(e+i,r+s);t.moveTo(e+o-i,r);t.lineTo(e+o-i,r+s)}drawFlowChartInternalStoragePath(t,e,r,o,s){const i=.2*Math.min(o,s);t.rect(e,r,o,s);t.moveTo(e,r+i);t.lineTo(e+o,r+i);t.moveTo(e+i,r);t.lineTo(e+i,r+s)}drawFlowChartDocumentPath(t,e,r,o,s){const i=.2*s;const n=r+s-i;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(e+o,n);t.bezierCurveTo(e+.5*o,r+s+i,e+.5*o,r+s-i,e,n);t.closePath()}drawFlowChartMultidocumentPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.rect(e+2*i,r,o-2*i,s-2*i);t.rect(e+i,r+i,o-i,s-i);this.drawFlowChartDocumentPath(t,e,r+2*i,o-2*i,s-2*i)}drawFlowChartPreparationPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r+s/2);t.lineTo(e+i,r);t.lineTo(e+o-i,r);t.lineTo(e+o,r+s/2);t.lineTo(e+o-i,r+s);t.lineTo(e+i,r+s);t.closePath()}drawFlowChartManualInputPath(t,e,r,o,s){const i=.2*s;t.moveTo(e,r+i);t.lineTo(e+o,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath()}drawFlowChartManualOperationPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(e+o-i,r+s);t.lineTo(e+i,r+s);t.closePath()}drawFlowChartOffpageConnectorPath(t,e,r,o,s){const i=.2*s;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(e+o,r+s-i);t.lineTo(e+o/2,r+s);t.lineTo(e,r+s-i);t.closePath()}drawFlowChartPunchedCardPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.moveTo(e+i,r);t.lineTo(e+o,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.lineTo(e,r+i);t.closePath()}drawFlowChartPunchedTapePath(t,e,r,o,s){const i=.1*s;t.moveTo(e,r);t.bezierCurveTo(e+.25*o,r+i,e+.75*o,r-i,e+o,r);t.lineTo(e+o,r+s);t.bezierCurveTo(e+.75*o,r+s-i,e+.25*o,r+s+i,e,r+s);t.closePath()}drawFlowChartSummingJunctionPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);const l=.6*a;t.moveTo(i-l,n);t.lineTo(i+l,n);t.moveTo(i,n-l);t.lineTo(i,n+l)}drawFlowChartOrPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);const l=.6*a;t.moveTo(i-l,n-l);t.lineTo(i+l,n+l);t.moveTo(i+l,n-l);t.lineTo(i-l,n+l)}drawFlowChartCollatePath(t,e,r,o,s){t.moveTo(e,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.lineTo(e+o,r);t.closePath()}drawFlowChartSortPath(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(i,r+s);t.closePath();t.moveTo(e+.25*o,r+.5*s);t.lineTo(e+.75*o,r+.5*s)}drawFlowChartExtractPath(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r+s);t.lineTo(i,r);t.lineTo(e+o,r+s);t.closePath()}drawFlowChartMergePath(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r);t.lineTo(e+o,r);t.lineTo(i,r+s);t.closePath()}drawFlowChartStoredDataPath(t,e,r,o,s){const i=.1*o;t.arc(e+i,r+s/2,s/2,Math.PI/2,-Math.PI/2);t.lineTo(e+o-i,r);t.arc(e+o-i,r+s/2,s/2,-Math.PI/2,Math.PI/2);t.lineTo(e+i,r+s)}drawFlowChartDelayPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r);t.lineTo(e+o-i,r);t.arc(e+o-i,r+s/2,s/2,-Math.PI/2,Math.PI/2);t.lineTo(e,r+s);t.closePath()}drawFlowChartMagneticTapePath(t,e,r,o,s){const i=.15*s;t.moveTo(e,r+i);t.bezierCurveTo(e+.33*o,r,e+.67*o,r+2*i,e+o,r+i);t.lineTo(e+o,r+s-i);t.bezierCurveTo(e+.67*o,r+s-2*i,e+.33*o,r+s,e,r+s-i);t.closePath()}drawFlowChartMagneticDiskPath(t,e,r,o,s){const i=.2*s;t.ellipse(e+o/2,r+i/2,o/2,i/2,0,0,2*Math.PI);t.moveTo(e,r+i/2);t.lineTo(e,r+s-i/2);t.moveTo(e+o,r+i/2);t.lineTo(e+o,r+s-i/2);t.ellipse(e+o/2,r+s-i/2,o/2,i/2,0,0,2*Math.PI)}drawFlowChartMagneticDrumPath(t,e,r,o,s){const i=.2*o;t.ellipse(e+i/2,r+s/2,i/2,s/2,0,0,2*Math.PI);t.moveTo(e+i/2,r);t.lineTo(e+o,r);t.moveTo(e+i/2,r+s);t.lineTo(e+o,r+s);t.moveTo(e+o,r);t.lineTo(e+o,r+s)}drawFlowChartDisplayPath(t,e,r,o,s){const i=.2*o;t.moveTo(e,r+s/2);t.lineTo(e+i,r);t.lineTo(e+o-i,r);t.arc(e+o-i,r+s/2,s/2,-Math.PI/2,Math.PI/2);t.lineTo(e+i,r+s);t.closePath()}drawRightArrowPath(t,e,r,o,s){const i=.6*s;const n=r+(s-i)/2;const a=e+.7*o;t.moveTo(e,n);t.lineTo(a,n);t.lineTo(a,r);t.lineTo(e+o,r+s/2);t.lineTo(a,r+s);t.lineTo(a,n+i);t.lineTo(e,n+i);t.closePath()}drawLeftArrowPath(t,e,r,o,s){const i=.6*s;const n=r+(s-i)/2;const a=e+.3*o;t.moveTo(e+o,n);t.lineTo(a,n);t.lineTo(a,r);t.lineTo(e,r+s/2);t.lineTo(a,r+s);t.lineTo(a,n+i);t.lineTo(e+o,n+i);t.closePath()}drawUpArrowPath(t,e,r,o,s){const i=.6*o;const n=e+(o-i)/2;const a=r+.3*s;t.moveTo(n,r+s);t.lineTo(n,a);t.lineTo(e,a);t.lineTo(e+o/2,r);t.lineTo(e+o,a);t.lineTo(n+i,a);t.lineTo(n+i,r+s);t.closePath()}drawDownArrowPath(t,e,r,o,s){const i=.6*o;const n=e+(o-i)/2;const a=r+.7*s;t.moveTo(n,r);t.lineTo(n,a);t.lineTo(e,a);t.lineTo(e+o/2,r+s);t.lineTo(e+o,a);t.lineTo(n+i,a);t.lineTo(n+i,r);t.closePath()}drawLeftRightArrowPath(t,e,r,o,s){const i=.6*s;const n=r+(s-i)/2;const a=e+.2*o;const l=e+.8*o;t.moveTo(a,n);t.lineTo(l,n);t.lineTo(l,r);t.lineTo(e+o,r+s/2);t.lineTo(l,r+s);t.lineTo(l,n+i);t.lineTo(a,n+i);t.lineTo(a,r+s);t.lineTo(e,r+s/2);t.lineTo(a,r);t.closePath()}drawUpDownArrowPath(t,e,r,o,s){const i=.6*o;const n=e+(o-i)/2;const a=r+.2*s;const l=r+.8*s;t.moveTo(n,a);t.lineTo(n,l);t.lineTo(e,l);t.lineTo(e+o/2,r+s);t.lineTo(e+o,l);t.lineTo(n+i,l);t.lineTo(n+i,a);t.lineTo(e+o,a);t.lineTo(e+o/2,r);t.lineTo(e,a);t.closePath()}drawQuadArrowPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=.3*Math.min(o,s);t.moveTo(i,r);t.lineTo(i+a/2,r+a);t.lineTo(i+a/4,r+a);t.lineTo(i+a/4,n-a/4);t.lineTo(i+a/4,n-a/4);t.lineTo(e+o-a,n-a/4);t.lineTo(e+o-a,n-a/2);t.lineTo(e+o,n);t.lineTo(e+o-a,n+a/2);t.lineTo(e+o-a,n+a/4);t.lineTo(i+a/4,n+a/4);t.lineTo(i+a/4,r+s-a);t.lineTo(i+a/2,r+s-a);t.lineTo(i,r+s);t.lineTo(i-a/2,r+s-a);t.lineTo(i-a/4,r+s-a);t.lineTo(i-a/4,n+a/4);t.lineTo(e+a,n+a/4);t.lineTo(e+a,n+a/2);t.lineTo(e,n);t.lineTo(e+a,n-a/2);t.lineTo(e+a,n-a/4);t.lineTo(i-a/4,n-a/4);t.lineTo(i-a/4,r+a);t.lineTo(i-a/2,r+a);t.closePath()}drawBentArrowPath(t,e,r,o,s){const i=e+.7*o;const n=r+.3*s;const a=.4*s;t.moveTo(e,r+s/2-a/2);t.lineTo(i,r+s/2-a/2);t.lineTo(i,n);t.lineTo(i-a/2,n);t.lineTo(e+o,r);t.lineTo(i+a/2,n);t.lineTo(i,n);t.lineTo(i,r+s/2+a/2);t.lineTo(e,r+s/2+a/2);t.closePath()}drawUturnArrowPath(t,e,r,o,s){const i=.3*o;const n=e+o/2;const a=.3*o;t.moveTo(e,r+s);t.lineTo(e,r+s/2);t.arc(n,r+s/2,a,Math.PI,0);t.lineTo(e+o-i,r+s/2-a);t.lineTo(e+o-i,r);t.lineTo(e+o,r+s/4);t.lineTo(e+o-2*i,r+s/4);t.lineTo(e+o-2*i,r+s/2-a);t.arc(n,r+s/2,a-i,0,Math.PI,true);t.lineTo(e+i,r+s);t.closePath()}drawCurvedRightArrowPath(t,e,r,o,s){const i=e+.8*o;const n=r+.2*s;const a=.2*Math.min(o,s);t.moveTo(e,r+s/2);t.quadraticCurveTo(i,n,e+o-a,r+s/2);t.lineTo(e+o-a,r+s/2-a);t.lineTo(e+o,r+s/2);t.lineTo(e+o-a,r+s/2+a);t.lineTo(e+o-a,r+s/2+a/2);t.quadraticCurveTo(i,n+a,e,r+s/2+a/2);t.closePath()}drawCurvedLeftArrowPath(t,e,r,o,s){const i=e+.2*o;const n=r+.2*s;const a=.2*Math.min(o,s);t.moveTo(e+o,r+s/2);t.quadraticCurveTo(i,n,e+a,r+s/2);t.lineTo(e+a,r+s/2-a);t.lineTo(e,r+s/2);t.lineTo(e+a,r+s/2+a);t.lineTo(e+a,r+s/2+a/2);t.quadraticCurveTo(i,n+a,e+o,r+s/2+a/2);t.closePath()}drawCallout1Path(t,e,r,o,s){const i=e+.8*o;const n=r+.8*s;const a=.2*Math.min(o,s);t.rect(e,r,.7*o,.7*s);t.moveTo(e+.6*o,r+.6*s);t.lineTo(i,n);t.lineTo(e+.5*o,r+.7*s)}drawCallout2Path(t,e,r,o,s){this.drawCallout1Path(t,e,r,o,s);const i=e+.9*o;const n=r+.9*s;t.moveTo(e+.65*o,r+.65*s);t.lineTo(i,n);t.lineTo(e+.55*o,r+.75*s)}drawCallout3Path(t,e,r,o,s){this.drawCallout2Path(t,e,r,o,s);const i=e+.7*o;const n=r+.95*s;t.moveTo(e+.7*o,r+.7*s);t.lineTo(i,n);t.lineTo(e+.6*o,r+.8*s)}drawAccentCallout1Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);t.rect(e-2,r-2,.7*o+4,.7*s+4);this.drawCallout1Path(t,e,r,o,s)}drawAccentCallout2Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);t.rect(e-2,r-2,.7*o+4,.7*s+4);this.drawCallout2Path(t,e,r,o,s)}drawAccentCallout3Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);t.rect(e-2,r-2,.7*o+4,.7*s+4);this.drawCallout3Path(t,e,r,o,s)}drawBorderCallout1Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);this.drawCallout1Path(t,e,r,o,s)}drawBorderCallout2Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);this.drawCallout2Path(t,e,r,o,s)}drawBorderCallout3Path(t,e,r,o,s){t.rect(e,r,.7*o,.7*s);this.drawCallout3Path(t,e,r,o,s)}drawLightningBoltPath(t,e,r,o,s){t.moveTo(e+.3*o,r);t.lineTo(e+.7*o,r);t.lineTo(e+.4*o,r+.4*s);t.lineTo(e+.8*o,r+.4*s);t.lineTo(e+.2*o,r+s);t.lineTo(e+.5*o,r+.6*s);t.lineTo(e+.1*o,r+.6*s);t.closePath()}drawSunPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=.3*Math.min(o,s);const l=.45*Math.min(o,s);for(let e=0;e<16;e++){const r=2*e*Math.PI/16;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);const c=i+l*Math.cos(r);const h=n+l*Math.sin(r);t.moveTo(o,s);t.lineTo(c,h)}t.arc(i,n,.7*a,0,2*Math.PI)}drawMoonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.arc(i+.3*a,n-.3*a,.8*a,0,2*Math.PI,true)}drawCloudPath(t,e,r,o,s){const i=o;const n=s;t.moveTo(e,r+.5*n);t.bezierCurveTo(e,r+.7*n,e+.05*i,r+.85*n,e+.15*i,r+.8*n);t.bezierCurveTo(e+.25*i,r+.95*n,e+.35*i,r+.95*n,e+.45*i,r+.85*n);t.bezierCurveTo(e+.55*i,r+n,e+.65*i,r+n,e+.75*i,r+.85*n);t.bezierCurveTo(e+.85*i,r+.95*n,e+.95*i,r+.8*n,e+i,r+.65*n);t.bezierCurveTo(e+i,r+.5*n,e+.95*i,r+.35*n,e+.9*i,r+.3*n);t.bezierCurveTo(e+.95*i,r+.15*n,e+.85*i,r+.05*n,e+.75*i,r+.1*n);t.bezierCurveTo(e+.65*i,r,e+.55*i,r,e+.5*i,r+.08*n);t.bezierCurveTo(e+.45*i,r,e+.3*i,r,e+.25*i,r+.15*n);t.bezierCurveTo(e+.15*i,r+.05*n,e+.05*i,r+.2*n,e+.08*i,r+.3*n);t.bezierCurveTo(e,r+.35*n,e,r+.4*n,e,r+.5*n);t.closePath()}drawWavePath(t,e,r,o,s){const i=.3*s;const n=r+s/2;t.moveTo(e,n);t.bezierCurveTo(e+.25*o,n-i,e+.75*o,n+i,e+o,n)}drawDoubleWavePath(t,e,r,o,s){const i=.2*s;const n=r+.3*s;const a=r+.7*s;t.moveTo(e,n);t.bezierCurveTo(e+.25*o,n-i,e+.75*o,n+i,e+o,n);t.moveTo(e,a);t.bezierCurveTo(e+.25*o,a-i,e+.75*o,a+i,e+o,a)}drawSmileyFacePath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.arc(i-.3*a,n-.3*a,.1*a,0,2*Math.PI);t.arc(i+.3*a,n-.3*a,.1*a,0,2*Math.PI);t.arc(i,n,.5*a,0,Math.PI)}drawNoSmokingPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.moveTo(i-.7*a,n-.7*a);t.lineTo(i+.7*a,n+.7*a)}drawBlockArcPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.6*a;t.arc(i,n,a,0,Math.PI);t.arc(i,n,l,Math.PI,0,true);t.closePath()}drawFoldedCornerPath(t,e,r,o,s){const i=.2*Math.min(o,s);t.moveTo(e,r);t.lineTo(e+o-i,r);t.lineTo(e+o,r+i);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath();t.moveTo(e+o-i,r);t.lineTo(e+o-i,r+i);t.lineTo(e+o,r+i)}drawBevelPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.moveTo(e+i,r);t.lineTo(e+o-i,r);t.lineTo(e+o,r+i);t.lineTo(e+o,r+s-i);t.lineTo(e+o-i,r+s);t.lineTo(e+i,r+s);t.lineTo(e,r+s-i);t.lineTo(e,r+i);t.closePath()}drawDonutPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.4*a;t.arc(i,n,a,0,2*Math.PI);t.arc(i,n,l,0,2*Math.PI,true)}drawNoSymbolPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.arc(i,n,a,0,2*Math.PI);t.moveTo(i-.7*a,n+.7*a);t.lineTo(i+.7*a,n-.7*a)}drawCubePath(t,e,r,o,s){const i=.3*Math.min(o,s);t.rect(e,r+i,o-i,s-i);t.moveTo(e,r+i);t.lineTo(e+i,r);t.lineTo(e+o,r);t.lineTo(e+o-i,r+i);t.closePath();t.moveTo(e+o-i,r+i);t.lineTo(e+o,r);t.lineTo(e+o,r+s-i);t.lineTo(e+o-i,r+s);t.closePath()}drawCanPath(t,e,r,o,s){const i=.15*s;t.ellipse(e+o/2,r+i/2,o/2,i/2,0,0,2*Math.PI);t.moveTo(e,r+i/2);t.lineTo(e,r+s-i/2);t.moveTo(e+o,r+i/2);t.lineTo(e+o,r+s-i/2);t.ellipse(e+o/2,r+s-i/2,o/2,i/2,0,0,2*Math.PI)}drawConePath(t,e,r,o,s){const i=.2*s;t.moveTo(e+o/2,r);t.lineTo(e,r+s-i);t.ellipse(e+o/2,r+s-i/2,o/2,i/2,0,Math.PI,0);t.lineTo(e+o/2,r);t.closePath()}drawPyramidPath(t,e,r,o,s){const i=.3*o;t.moveTo(e+o/2,r);t.lineTo(e,r+s);t.lineTo(e+o-i,r+s);t.closePath();t.moveTo(e+o/2,r);t.lineTo(e+o-i,r+s);t.lineTo(e+o,r+s-i);t.closePath();t.moveTo(e,r+s);t.lineTo(e+i,r+s-i);t.lineTo(e+o,r+s-i);t.lineTo(e+o-i,r+s)}drawPlusPath(t,e,r,o,s){const i=.2*Math.min(o,s);const n=e+o/2;const a=r+s/2;t.rect(e+i,a-i/2,o-2*i,i);t.rect(n-i/2,r+i,i,s-2*i)}drawMinusPath(t,e,r,o,s){const i=.2*Math.min(o,s);const n=r+s/2;t.rect(e+i,n-i/2,o-2*i,i)}drawMultiplyPath(t,e,r,o,s){const i=.1*Math.min(o,s);t.moveTo(e+i,r+i);t.lineTo(e+o-i,r+s-i);t.moveTo(e+o-i,r+i);t.lineTo(e+i,r+s-i)}drawDividePath(t,e,r,o,s){const i=.1*Math.min(o,s);const n=e+o/2;const a=r+s/2;const l=i;t.arc(n,a-.25*s,l,0,2*Math.PI);t.rect(e+i,a-i/2,o-2*i,i);t.arc(n,a+.25*s,l,0,2*Math.PI)}drawEqualPath(t,e,r,o,s){const i=.1*Math.min(o,s);const n=r+s/2;const a=.15*s;t.rect(e+i,n-a-i/2,o-2*i,i);t.rect(e+i,n+a-i/2,o-2*i,i)}drawNotEqualPath(t,e,r,o,s){this.drawEqualPath(t,e,r,o,s);const i=.1*Math.min(o,s);t.moveTo(e+.3*o,r+.8*s);t.lineTo(e+.7*o,r+.2*s)}drawLinePath(t,e,r,o,s){t.moveTo(e,r+s/2);t.lineTo(e+o,r+s/2)}drawBentConnector2Path(t,e,r,o,s){const i=e+o/2;t.moveTo(e,r+s);t.lineTo(e,r+s/2);t.lineTo(i,r+s/2);t.lineTo(i,r);t.lineTo(e+o,r)}drawBentConnector3Path(t,e,r,o,s){const i=e+o/2;const n=r+s/2;t.moveTo(e,r+s);t.lineTo(e,n);t.lineTo(i,n);t.lineTo(i,r);t.lineTo(e+o,r)}drawBentConnector4Path(t,e,r,o,s){const i=e+.33*o;const n=e+.67*o;const a=r+s/2;t.moveTo(e,r+s);t.lineTo(e,a);t.lineTo(i,a);t.lineTo(i,r);t.lineTo(n,r);t.lineTo(n,a);t.lineTo(e+o,a);t.lineTo(e+o,r+s)}drawBentConnector5Path(t,e,r,o,s){const i=e+.25*o;const n=e+.5*o;const a=e+.75*o;const l=r+.33*s;const c=r+.67*s;t.moveTo(e,r+s);t.lineTo(e,c);t.lineTo(i,c);t.lineTo(i,l);t.lineTo(n,l);t.lineTo(n,r);t.lineTo(a,r);t.lineTo(a,l);t.lineTo(e+o,l);t.lineTo(e+o,r+s)}drawCurvedConnector2Path(t,e,r,o,s){t.moveTo(e,r+s);t.quadraticCurveTo(e+o/2,r,e+o,r)}drawCurvedConnector3Path(t,e,r,o,s){t.moveTo(e,r+s);t.bezierCurveTo(e,r+s/2,e+o/2,r+s/2,e+o,r)}drawCurvedConnector4Path(t,e,r,o,s){t.moveTo(e,r+s);t.bezierCurveTo(e+.25*o,r+.75*s,e+.75*o,r+.25*s,e+o,r)}drawCurvedConnector5Path(t,e,r,o,s){t.moveTo(e,r+s);t.bezierCurveTo(e+.2*o,r+.8*s,e+.4*o,r+.6*s,e+.5*o,r+.5*s);t.bezierCurveTo(e+.6*o,r+.4*s,e+.8*o,r+.2*s,e+o,r)}drawCustomGeometry(t,e,r,o,s,i,n,a){try{const l=t.pathLst||t.pathList;if(!t||!l||0===l.length)return;const c=this.context;c.save();let h,u;if(t.coordSize?.width&&t.coordSize?.height){h=t.coordSize.width;u=t.coordSize.height}else{let t=1/0,e=-1/0,r=1/0,o=-1/0;l.forEach(s=>{if(s.commands)s.commands.forEach(s=>{if(void 0!==s.x){t=Math.min(t,s.x);e=Math.max(e,s.x)}if(void 0!==s.y){r=Math.min(r,s.y);o=Math.max(o,s.y)}if(void 0!==s.x1){t=Math.min(t,s.x1);e=Math.max(e,s.x1);r=Math.min(r,s.y1);o=Math.max(o,s.y1)}if(void 0!==s.x2){t=Math.min(t,s.x2);e=Math.max(e,s.x2);r=Math.min(r,s.y2);o=Math.max(o,s.y2)}})});h=e-t;u=o-r;if(0===h)h=100;if(0===u)u=100}c.restore();l.forEach((t,l)=>{let c=1/0,f=1/0;t.commands.forEach(t=>{if(void 0!==t.x){c=Math.min(c,t.x);f=Math.min(f,t.y)}if(void 0!==t.x1){c=Math.min(c,t.x1);f=Math.min(f,t.y1)}if(void 0!==t.x2){c=Math.min(c,t.x2);f=Math.min(f,t.y2)}if(void 0!==t.x3){c=Math.min(c,t.x3);f=Math.min(f,t.y3)}});this.currentShapeBounds={x:e,y:r,w:o,h:s};this.drawGeometryPathDirectly(t,i,n,a,e,r,o,s,h,u,c,f)})}catch(t){const e=this.context;e.restore()}}drawGeometryPath(t,e,r,o){if(!t||!t.commands||0===t.commands.length)return;const s=this.context;s.beginPath();let i=false;t.commands.forEach((t,e)=>{switch(t.type){case"moveTo":s.moveTo(t.x,t.y);break;case"lineTo":s.lineTo(t.x,t.y);i=true;break;case"curveTo":case"cubicBezTo":const e=void 0!==t.x?t.x:t.x3;const r=void 0!==t.y?t.y:t.y3;if(void 0!==e&&void 0!==r){s.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,e,r);i=true}break;case"quadTo":case"quadBezTo":s.quadraticCurveTo(t.x1,t.y1,t.x,t.y);i=true;break;case"arcTo":s.arcTo(t.x1,t.y1,t.x,t.y,t.radius||0);i=true;break;case"close":s.closePath()}});if(r&&o>0){this.setStrokeStyle(r,o);s.stroke()}if(e&&(!r||0===o)){this.setFillStyle(e);s.fill()}s.restore()}setStrokeStyle(t,e){const r=this.context;r.strokeStyle=t;r.lineWidth=CoordinateTransform.mmToPixels(e||1);r.lineCap="round";r.lineJoin="round"}setFillStyle(t){const e=this.context;e.fillStyle=t}drawGeometryPathDirectly(t,e,r,o,s,i,n,a,l,c,h,u){if(!t||!t.commands||0===t.commands.length)return;const f=this.context;const d=n/l;const p=a/c;f.save();f.beginPath();const g=t=>s+(t-h)*d;const m=t=>i+(t-u)*p;let y=false;let b=0,x=0;t.commands.forEach((t,e)=>{switch(t.type){case"moveTo":const e=g(t.x);const r=m(t.y);f.moveTo(e,r);b=e;x=r;break;case"lineTo":const o=g(t.x);const s=m(t.y);f.lineTo(o,s);b=o;x=s;y=true;break;case"curveTo":case"cubicBezTo":const i=void 0!==t.x3?t.x3:t.x;const n=void 0!==t.y3?t.y3:t.y;if(void 0!==i&&void 0!==n){const e=g(t.x1);const r=m(t.y1);const o=g(t.x2);const s=m(t.y2);const a=g(i);const l=m(n);if(this.isStraightLine(b,x,e,r,o,s,a,l))f.lineTo(a,l);else f.bezierCurveTo(e,r,o,s,a,l);b=a;x=l;y=true}break;case"close":f.closePath()}});const S=t.commands.some(t=>"close"===t.type);const w=S&&e&&"none"!==e;if(w)if(y){if("object"===typeof e&&void 0!==e.r)f.fillStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a/255})`;else if("object"===typeof e&&e.type)if("linear"===e.type&&e.stops){const t=this.getCanvasBounds(f);const r=this.createCanvasGradient(f,t,e);if(r)f.fillStyle=r;else{const t=e.stops[0]?.color;if(t)f.fillStyle=this.colorToRgb(t);else return}}else return;else if("string"===typeof e&&"none"!==e&&"null"!==e)f.fillStyle=e;f.fill()}else{if("object"===typeof e&&void 0!==e.r)f.fillStyle=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a/255})`;else if("string"===typeof e&&"none"!==e&&"null"!==e)f.fillStyle=e;f.fillRect(s,i,n,a)}if(r&&"none"!==r&&y){const t=CoordinateTransform.mmToPixels(o>0?o:1);const e=1280*720;const s=n*a;const i=Math.sqrt(s/e);const l=Math.max(t*i,.5);if("object"===typeof r&&void 0!==r.r)f.strokeStyle=`rgba(${r.r}, ${r.g}, ${r.b}, ${r.a/255})`;else f.strokeStyle=r;f.lineWidth=l;f.lineCap="square";f.lineJoin="miter";f.stroke()}f.restore()}isStraightLine(t,e,r,o,s,i,n,a){const l=n-t;const c=a-e;if(Math.abs(l)<.1&&Math.abs(c)<.1)return true;const h=2;const u=t+.33*l;const f=e+.33*c;const d=t+.67*l;const p=e+.67*c;const g=Math.sqrt(Math.pow(r-u,2)+Math.pow(o-f,2));const m=Math.sqrt(Math.pow(s-d,2)+Math.pow(i-p,2));return g<h&&m<h}_s(){this._context.beginPath()}_m(t,e){this._context.moveTo(t,e)}_l(t,e){this._context.lineTo(t,e)}_c(t,e,r,o,s,i){this._context.bezierCurveTo(t,e,r,o,s,i)}_z(){this._context.closePath()}ds(){this._context.stroke()}df(){this._context.fill()}fillText(t,e,r,o={}){if(!this._context||!t)return;this._context.save();try{const s=o.fontSize||12;const i=this.getTextScaleFactor();const n=s*i;const a=o.fontFamily||"Arial";const l=o.fontWeight||(o.bold?"bold":"normal");const c=o.fontStyle||(o.italic?"italic":"normal");this._context.font=`${c} ${l} ${n}px "${a}"`;if(o.color)if("object"===typeof o.color&&void 0!==o.color.r){const t=void 0!==o.color.a?o.color.a/255:1;const e=`rgba(${o.color.r}, ${o.color.g}, ${o.color.b}, ${t})`;this._context.fillStyle=e}else if("string"===typeof o.color)this._context.fillStyle=o.color;else this._context.fillStyle="#000000";else this._context.fillStyle="#000000";this._context.textBaseline=o.textBaseline||"alphabetic";this._context.textAlign=o.textAlign||"left";this._context.fillText(t,e,r)}catch(t){}finally{this._context.restore()}}measureText(t,e={}){if(!this._context||!t)return{width:0,height:0};this._context.save();try{const r=e.fontSize||12;const o=this.getTextScaleFactor();const s=r*o;const i=e.fontFamily||"Arial";const n=e.fontWeight||(e.bold?"bold":"normal");const a=e.fontStyle||(e.italic?"italic":"normal");this._context.font=`${a} ${n} ${s}px "${i}"`;const l=this._context.measureText(t);let c=s;if(void 0!==l.actualBoundingBoxAscent&&void 0!==l.actualBoundingBoxDescent)c=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent;return{width:l.width,height:c}}catch(t){return{width:0,height:0}}finally{this._context.restore()}}getCanvasBounds(t){const e=t.getTransform();let r,o;if(t.canvas.style.width&&t.canvas.style.height){r=parseFloat(t.canvas.style.width);o=parseFloat(t.canvas.style.height)}else{r=t.canvas.width/(window.devicePixelRatio||1);o=t.canvas.height/(window.devicePixelRatio||1)}return this.currentShapeBounds||{x:0,y:0,w:r,h:o}}createCanvasGradient(t,e,r){if(!r||!r.stops||0===r.stops.length)return null;let o;if("linear"===r.type){const s=r.angle||0;const i=s*Math.PI/180;const n=e.x+e.w/2-Math.cos(i)*e.w/2;const a=e.y+e.h/2-Math.sin(i)*e.h/2;const l=e.x+e.w/2+Math.cos(i)*e.w/2;const c=e.y+e.h/2+Math.sin(i)*e.h/2;o=t.createLinearGradient(n,a,l,c)}else if("radial"===r.type){const r=e.x+e.w/2;const s=e.y+e.h/2;const i=Math.max(e.w,e.h)/2;o=t.createRadialGradient(r,s,0,r,s,i)}else return null;for(const t of r.stops){const e=this.colorToRgb(t.color);o.addColorStop(t.position,e)}return o}colorToRgb(t){if(this.graphics&&"function"===typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(t);if(this.graphicsEngine&&"function"===typeof this.graphicsEngine.colorToRgb)return this.graphicsEngine.colorToRgb(t);if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;const r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;const o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;const s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}return"rgb(0, 0, 0)"}}class CDrawingDocument{constructor(){this.graphics=null;this.canvas=null;this.processor=null;this.logger=new Logger("CDrawingDocument");this.currentLayer=null}init(t,e=null){this.canvas=t;this.processor=e;if(this.graphics)this.graphics.resetState();else{this.graphics=new CanvasGraphicsAdapter;try{const e="undefined"!==typeof globalThis&&globalThis.CGraphics?globalThis.CGraphics:"undefined"!==typeof window&&window.CGraphics?window.CGraphics:null;if("function"===typeof e){this.graphicsEngine=new e(t);this.graphics.drawLineWithArrows=(t,e,r,o,s,i=1,n=null)=>{this.graphicsEngine.drawLineWithArrows(t,e,r,o,s,i,n)};this.graphics.applyStrokeInfo=t=>{if("function"===typeof this.graphicsEngine.applyStrokeInfo)this.graphicsEngine.applyStrokeInfo(t)}}}catch(t){}}let r;let o;const s="function"===typeof t.getBoundingClientRect?t.getBoundingClientRect():{width:0,height:0};if(s.width>0&&s.height>0){r=s.width;o=s.height}else if(t.style.width&&t.style.height){r=parseFloat(t.style.width);o=parseFloat(t.style.height)}else{const e="undefined"!==typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;r=t.width/e;o=t.height/e}const i=this.processor&&this.processor.renderContext&&this.processor.renderContext.pixelRatio||"undefined"!==typeof window&&window.devicePixelRatio||1;const n=Math.max(1,Math.round(r*i));const a=Math.max(1,Math.round(o*i));if(t.width!==n||t.height!==a){t.width=n;t.height=a}if(!t.style.width)t.style.width=`${r}px`;if(!t.style.height)t.style.height=`${o}px`;const l=t.getContext("2d");if(l){l.setTransform(1,0,0,1,0,0);l.scale(i,i)}if(this.graphics&&"function"===typeof this.graphics.init&&l)this.graphics.init(l,r,o,25.4*r/96,25.4*o/96)}colorToRgb(t){if(this.graphics&&"function"===typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(t);if(this.graphicsEngine&&"function"===typeof this.graphicsEngine.colorToRgb)return this.graphicsEngine.colorToRgb(t);if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;const r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;const o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;const s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}return"rgb(0, 0, 0)"}async drawSlide(slide,t){if(!this.graphics)return;this.currentSlide=slide;this.currentSlideIndex=t;this.graphics.clear();await this.drawSlideContent(slide)}async drawSlideContent(slide){if(slide.layout);this.setupSlideCoordinateSystem();try{const t=this.graphics?.context;const e=this.coordinateSystem;if(t&&e){const r=Math.round(e.offsetX);const o=Math.round(e.offsetY);const s=Math.round(e.scaledWidth);const i=Math.round(e.scaledHeight);t.save();t.beginPath();t.rect(r,o,s,i);t.clip();this._slideClipApplied=true}}catch(t){this._slideClipApplied=false}this.drawSlideBackground(slide);if(false!==slide.showMasterShapes&&slide.layout&&slide.layout.master)await this.drawMasterElements(slide.layout.master);if(slide.layout)await this.drawLayoutElements(slide.layout);if(slide.commonSlideData&&slide.commonSlideData.shapeTree){const t=slide.commonSlideData.shapeTree;const e=this.sortShapesByRenderOrder(t);const r=this.currentLayer;this.currentLayer="slide";for(let t=0;t<e.length;t++){const r=e[t];if(this.isHiddenShape(r))continue;await this.drawShapeEnhanced(r,t)}this.currentLayer=r}try{if(this._slideClipApplied&&this.graphics?.context)this.graphics.context.restore()}catch(t){}}sortShapesByRenderOrder(t){if(!t||0===t.length)return[];const e=[...t];e.sort((e,r)=>{const o=e.order||e.zOrder||e.index||0;const s=r.order||r.zOrder||r.index||0;if(o!==s)return o-s;const i=t.indexOf(e);const n=t.indexOf(r);return i-n});return e}drawSlideBackground(slide){if(!this.graphics||!this.graphics.context)return;const t=this.graphics.context;let e=null;if(slide.backgroundFill)e=this.getBackgroundColor(slide.backgroundFill);else if(slide.layout&&slide.layout.commonSlideData&&slide.layout.commonSlideData.backgroundFill)e=this.getBackgroundColor(slide.layout.commonSlideData.backgroundFill);else if(slide.layout&&slide.layout.cSld&&slide.layout.cSld.bg)e=this.getBackgroundColor(slide.layout.cSld.bg);else if(slide.layout&&slide.layout.master&&slide.layout.master.commonSlideData&&slide.layout.master.commonSlideData.backgroundFill)e=this.getBackgroundColor(slide.layout.master.commonSlideData.backgroundFill);else if(slide.layout&&slide.layout.master&&slide.layout.master.theme){const theme=slide.layout.master.theme;if(theme.colors&&theme.colors.bg1)e=theme.colors.bg1;else if(theme.colors&&theme.colors.bg2)e=theme.colors.bg2}if(this.coordinateSystem){const{scale:r,offsetX:o,offsetY:s}=this.coordinateSystem;const i=this.coordinateSystem.slideWidthPx;const n=this.coordinateSystem.slideHeightPx;const a=Math.round(i*r);const l=Math.round(n*r);const c=Math.round(o);const h=Math.round(s);const u=e||"#ffffff";t.save();t.fillStyle=u;t.fillRect(c,h,a,l);t.restore()}else{t.save();t.fillStyle=e||"#ffffff";t.fillRect(0,0,this.canvas.width,this.canvas.height);t.restore()}}async drawMasterElements(t){if(!t||!t.commonSlideData||!t.commonSlideData.shapeTree)return;const e=t.commonSlideData.shapeTree;const r=this.sortShapesByRenderOrder(e);const o=this.currentLayer;this.currentLayer="master";try{for(let t=0;t<r.length;t++){const e=r[t];if(this.isHiddenShape(e))continue;await this.drawShapeEnhanced(e,t)}}finally{this.currentLayer=o}}async drawLayoutElements(t){if(!t)return;if(!t.commonSlideData)return;if(!t.commonSlideData.shapeTree)return;const e=t.commonSlideData.shapeTree;e.forEach((t,e)=>{});const r=this.sortShapesByRenderOrder(e);const o=this.currentLayer;this.currentLayer="layout";try{for(let t=0;t<r.length;t++){const e=r[t];if(this.isHiddenShape(e))continue;await this.drawShapeEnhanced(e,t)}}finally{this.currentLayer=o}}isPlaceholderShape(t){if(t.placeholder||t.phType||t.isPlaceholder)return true;if(t.properties&&t.properties.placeholder)return true;if(t.nvSpPr&&t.nvSpPr.nvPr&&t.nvSpPr.nvPr.ph)return true;return false}processPlaceholderShape(t,slide){if(!t.isPlaceholder||!t.placeholder)return t;const e=t.placeholder;let r=null;let o=null;if(slide.layout&&slide.layout.commonSlideData&&slide.layout.commonSlideData.shapeTree)o=this.findMatchingPlaceholder(slide.layout.commonSlideData.shapeTree,e);if(slide.layout&&slide.layout.master&&slide.layout.master.commonSlideData&&slide.layout.master.commonSlideData.shapeTree)r=this.findMatchingPlaceholder(slide.layout.master.commonSlideData.shapeTree,e);if(o)this.applyPlaceholderStyling(t,o);else if(r)this.applyPlaceholderStyling(t,r);return t}findMatchingPlaceholder(t,e){for(const r of t)if(r.isPlaceholder&&r.placeholder){const t=r.placeholder;if(t.type===e.type&&t.idx===e.idx)return r;if(t.type===e.type&&!t.idx)return r}return null}applyPlaceholderStyling(t,e){if(e.textBody){if(!t.textBody)t.textBody={paragraphs:[]};if(e.textBody.bodyProperties&&!t.textBody.bodyProperties)t.textBody.bodyProperties=JSON.parse(JSON.stringify(e.textBody.bodyProperties));if(e.textBody.lstStyle&&!t.textBody.lstStyle)t.textBody.lstStyle=JSON.parse(JSON.stringify(e.textBody.lstStyle))}if(e.fill&&!t.fill)t.fill=e.fill;if(e.stroke&&!t.stroke)t.stroke=e.stroke;if(e.geometry&&!t.geometry)t.geometry=e.geometry;if(e.style&&!t.style)t.style=e.style}shouldRenderText(t){try{if(this.currentLayer&&"slide"!==this.currentLayer&&this.isPlaceholderShape(t))return false;if(this.isPlaceholderShape(t)){const e=!!(t.textBody&&Array.isArray(t.textBody.paragraphs)&&t.textBody.paragraphs.some(t=>Array.isArray(t.runs)&&t.runs.some(t=>(t.text||"").trim().length>0)));return e}}catch(t){}return true}getBackgroundColor(t){if(!t){const t=this.resolveInheritedBackgroundColor();if(t)return t;return null}if("solid"===t.type&&t.color){const e=this.parseColorToHex(t.color);return e}if(t.fill&&"solid"===t.fill.type&&t.fill.color){const e=this.parseColorToHex(t.fill.color);return e}if("bgPr"===t.type&&t.fill){if("solid"===t.fill.type&&t.fill.color){const e=this.parseColorToHex(t.fill.color);return e}if("gradient"===t.fill.type)if(t.fill.gradient&&t.fill.gradient.stops&&t.fill.gradient.stops.length>0){const e=t.fill.gradient.stops[0];const r=this.parseColorToHex(e.color);return r}}if("bgRef"===t.type){const e=t.idx;if(void 0!==e){if(e>1e3){const t=e-1e3;if(this.currentSlide&&this.currentSlide.theme&&this.currentSlide.theme.colors){const theme=this.currentSlide.theme;const t=this.parseColorToHex(theme.colors.bg2)||this.parseColorToHex(theme.colors.bg1)||this.parseColorToHex(theme.colors.lt1);return t}}else{const t={0:"bg1",1:"tx1",2:"bg2",3:"tx2"};const r=t[e.toString()];if(r&&this.currentSlide&&this.currentSlide.theme&&this.currentSlide.theme.colors){const t=this.parseColorToHex(this.currentSlide.theme.colors[r]);return t}}return null}return null}return null}resolveInheritedBackgroundColor(){try{if(!this.currentSlide)return null;if(this.currentSlide.layout&&this.currentSlide.layout.backgroundFill){const t=this.getBackgroundColorFromFill(this.currentSlide.layout.backgroundFill);if(t)return t}if(this.currentSlide.layout&&this.currentSlide.layout.master&&this.currentSlide.layout.master.backgroundFill){const t=this.getBackgroundColorFromFill(this.currentSlide.layout.master.backgroundFill);if(t)return t}if(this.currentSlide.theme&&this.currentSlide.theme.colors){const t=this.parseColorToHex(this.currentSlide.theme.colors.bg1)||this.parseColorToHex(this.currentSlide.theme.colors.lt1)||this.parseColorToHex(this.currentSlide.theme.colors.bg2);if(t)return t}return null}catch(t){return null}}getBackgroundColorFromFill(t){if(!t)return null;if("solid"===t.type&&t.color)return this.parseColorToHex(t.color);if(t.fill&&"solid"===t.fill.type&&t.fill.color)return this.parseColorToHex(t.fill.color);if("bgPr"===t.type&&t.fill)if("solid"===t.fill.type&&t.fill.color)return this.parseColorToHex(t.fill.color);if("bgRef"===t.type){const e=t.idx;if(void 0!==e){const t={0:"#ffffff",1:"#000000",2:"#f5f5f5",3:"#404040",1e3:"#ffffff"};return t[e.toString()]||null}}return null}parseColorToHex(t){if(!t)return"#ffffff";if("string"===typeof t)return t.startsWith("#")?t:`#${t}`;if(t.scheme){const e={bg1:"#ffffff",tx1:"#000000",bg2:"#f8f8f8",tx2:"#404040",accent1:"#4f81bd",accent2:"#c0504d",accent3:"#9bbb59",accent4:"#8064a2",accent5:"#4bacc6",accent6:"#f79646",lt1:"#ffffff",dk1:"#000000",lt2:"#f0f0f0",dk2:"#404040"};let r=e[t.scheme];if(r){r=this.applyColorModifications(r,t);return r}}if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b){const e=`#${t.r.toString(16).padStart(2,"0")}${t.g.toString(16).padStart(2,"0")}${t.b.toString(16).padStart(2,"0")}`;return e}return"#ffffff"}applyColorModificationsLegacy(t,e){if(!e||!e.tint&&!e.shade&&!e.lumMod&&!e.lumOff)return t;const r=parseInt(t.substr(1,2),16);const o=parseInt(t.substr(3,2),16);const s=parseInt(t.substr(5,2),16);let i=r,n=o,a=s;if(void 0!==e.tint){const t=e.tint/1e5;i=Math.round(r+(255-r)*t);n=Math.round(o+(255-o)*t);a=Math.round(s+(255-s)*t)}if(void 0!==e.shade){const t=e.shade/1e5;i=Math.round(r*(1-t));n=Math.round(o*(1-t));a=Math.round(s*(1-t))}if(void 0!==e.lumMod){const t=e.lumMod/1e5;i=Math.round(r*t);n=Math.round(o*t);a=Math.round(s*t)}if(void 0!==e.lumOff){const t=e.lumOff/1e5*255;i=Math.round(Math.min(255,r+t));n=Math.round(Math.min(255,o+t));a=Math.round(Math.min(255,s+t))}i=Math.max(0,Math.min(255,i));n=Math.max(0,Math.min(255,n));a=Math.max(0,Math.min(255,a));const l=`#${i.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`;return l}setupSlideCoordinateSystem(){if(this.processor&&this.processor.calculateCanvasRect){const t=this.processor.getSlideDimensions();const e=this.processor.calculateCanvasRect(this.canvas,t);this.coordinateSystem={slideWidthEMU:t.cx,slideHeightEMU:t.cy,slideWidthPx:e.slideWidthPx,slideHeightPx:e.slideHeightPx,scale:e.scale,offsetX:e.offsetX,offsetY:e.offsetY,scaledWidth:e.scaledWidth,scaledHeight:e.scaledHeight}}else{const t=this.processor.getSlideDimensions();const e=t.cx;const r=t.cy;const o=e/914400*96;const s=r/914400*96;let i;let n;const a="function"===typeof this.canvas.getBoundingClientRect?this.canvas.getBoundingClientRect():{width:0,height:0};if(a.width>0&&a.height>0){i=a.width;n=a.height}else if(this.canvas.style.width&&this.canvas.style.height){i=parseFloat(this.canvas.style.width);n=parseFloat(this.canvas.style.height)}else{const t="undefined"!==typeof window&&window.devicePixelRatio?window.devicePixelRatio:1;i=this.canvas.width/t;n=this.canvas.height/t}const l=i/o;const c=n/s;const h=Math.min(l,c);let u=o*h;let f=s*h;let d=(i-u)/2;let p=(n-f)/2;u=Math.round(u);f=Math.round(f);d=Math.round(d);p=Math.round(p);this.coordinateSystem={slideWidthEMU:e,slideHeightEMU:r,slideWidthPx:o,slideHeightPx:s,scale:h,offsetX:d,offsetY:p,scaledWidth:u,scaledHeight:f,canvasWidth:i,canvasHeight:n}}}async drawShapeEnhanced(t,e){try{if(this.processor&&"function"===typeof this.processor.applyPropertyInheritance)this.processor.applyPropertyInheritance(t,this.currentSlide)}catch(t){}const r=this.getShapeBounds(t);if(r&&(0===r.h||!isFinite(r.h)||r.h<1)&&t&&t.textBody&&t.textBody.paragraphs&&t.textBody.paragraphs.length>0)try{const e=this.estimateTextBoxHeightPx(t,r.w);if(e&&e>0)r.h=Math.ceil(e)}catch(t){}if(!this.graphics||!t)return;try{if(t.textBody&&Array.isArray(t.textBody.paragraphs)){let e="";for(const r of t.textBody.paragraphs){if(!r||!Array.isArray(r.runs))continue;for(const t of r.runs)if(t&&"string"===typeof t.text)e+=t.text}const r=(e||"").toLowerCase();if(r.includes("(margin-top")||r.includes("(margin-btm")||r.includes("(margin-bottom"))return}}catch(t){}try{const e=this.isLineLikeShape(t);if(!r||r.w<=0&&r.h<=0||!e&&(r.w<=0||r.h<=0))return;switch(t.type){case"sp":this.drawRegularShape(t,r);break;case"pic":this.drawPictureShape(t,r);break;case"grpSp":this.drawGroupShape(t,r);break;case"cxnSp":this.drawConnectorShape(t,r);break;case"graphicFrame":await this.drawGraphicFrame(t,r);break;default:this.drawDefaultShape(t,r)}}catch(t){}}drawShapeGeometry(t,e){if(!e||e.w<=0||e.h<=0)return;const r=this.getShapeFillColor(t);const o=this.getShapeStrokeColor(t);const s=this.getShapeLineWidth(t);if(r){const t=this.parseColor(r);this.graphics.b_color1(t.r,t.g,t.b,t.a)}if(o){const t=this.parseColor(o);this.graphics.p_color(t.r,t.g,t.b,t.a);this.graphics.p_width(s)}switch(t.type){case"sp":case"shape":this.drawRegularShape(t,e);break;case"pic":this.drawPictureShape(t,e);break;case"grpSp":this.drawGroupShape(t,e);break;default:this.drawDefaultShape(t,e)}}drawRegularShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;r.save();const o=t.properties?.transform;if(o&&o.rotation&&0!==o.rotation){const t=e.x+e.w/2;const s=e.y+e.h/2;r.translate(t,s);r.rotate(o.rotation*Math.PI/180);r.translate(-t,-s)}if(t.fill&&t.fill.color&&void 0!==t.fill.color.a){const e=t.fill.color.a/255;r.globalAlpha=e}const s=this.getShapeFillColor(t);const i=this.getShapeStrokeColor(t);const n=this.getShapeLineWidth(t);const a=this.getShapeStrokeInfo(t);if(t.properties&&t.properties.effectLst)this.applyEffectsToCanvas(r,t.properties.effectLst);let l=null;if(this.processor&&this.processor.getShapePresetGeometry)l=this.processor.getShapePresetGeometry(t,this.processor.currentSlide);else l=this.getShapePreset(t);if("line"===l||this.isLineLikeShape(t)){this.drawEngineLine(e,t);this.resetEffectsOnContext(r);r.restore();return}if(t.geometry&&"custom"===t.geometry.type)try{this.currentShapeBounds=e;if(t.properties&&t.properties.effectLst)this.applyEffectsToCanvas(r,t.properties.effectLst);this.graphics.drawCustomGeometry(t.geometry,e.x,e.y,e.w,e.h,s,i,n);this.resetEffectsOnContext(r)}catch(t){this.graphics.drawPresetGeometry("rect",e.x,e.y,e.w,e.h,s,i,n,a)}else if(this.graphics.drawPresetGeometry&&l){if(t.properties&&t.properties.effectLst)this.applyEffectsToCanvas(r,t.properties.effectLst);this.graphics.drawPresetGeometry(l,e.x,e.y,e.w,e.h,s,i,n,a);this.resetEffectsOnContext(r)}else{const t=i&&n>2;const o=t||i&&!s;if(i&&o){r.strokeStyle=this.graphics.colorToRgb(i);r.lineWidth=CoordinateTransform.mmToPixels(n);if(a)this.applyStrokeStyle(r,a,CoordinateTransform.mmToPixels(n));r.strokeRect(e.x,e.y,e.w,e.h)}if(!o){if(s&&"linear"===s.type)this.drawGradientFill(r,e,s);else if(s){r.fillStyle=this.graphics.colorToRgb(s);r.fillRect(e.x,e.y,e.w,e.h)}if(i){r.strokeStyle=this.graphics.colorToRgb(i);r.lineWidth=CoordinateTransform.mmToPixels(n);if(a)this.applyStrokeStyle(r,a,CoordinateTransform.mmToPixels(n));r.strokeRect(e.x,e.y,e.w,e.h)}}}if(t.textBody&&t.textBody.paragraphs&&this.shouldRenderText(t)){this.setCurrentRenderingShape(t);this.drawShapeText(t,e)}this.resetEffectsOnContext(r);r.restore()}isLineLikeShape(t){const e=t&&(t.geometry?.preset||t.properties?.geometry?.preset)||null;const r="string"===typeof e?e.toLowerCase():"";if("line"===r||r.includes("connector"))return true;if(t&&("cxnSp"===t.type||"connector"===t.type))return true;return false}drawEngineLine(t,e){const r=this.getShapeStrokeColor(e);const o=this.getShapeLineWidth(e)||1;const s=this.getShapeStrokeInfo(e);const{x1:i,y1:n,x2:a,y2:l}=this._computeConnectorEndpoints(t,e);if(this.graphics&&"function"===typeof this.graphics.drawLineWithArrows){const t=r||{r:0,g:0,b:0,a:255};const e=o&&o>0?o:.75;this.graphics.drawLineWithArrows(i,n,a,l,t,e,s)}else if(this.graphicsEngine&&"function"===typeof this.graphicsEngine.drawLineWithArrows){const t=r||{r:0,g:0,b:0,a:255};const e=o&&o>0?o:.75;this.graphicsEngine.drawLineWithArrows(i,n,a,l,t,e,s)}else if(this.graphics&&"function"===typeof this.graphics.drawLine){const t=r||{r:0,g:0,b:0,a:255};const e=o&&o>0?o:.75;this.graphics.drawLine(i,n,a,l,t,e)}else if(this.graphics&&this.graphics.context){const t=this.graphics.context;t.save();t.beginPath();t.moveTo(i,n);t.lineTo(a,l);if(r){t.strokeStyle=this.graphics.colorToRgb(r);const e=this.graphics&&this.graphics.CoordinateTransform?this.graphics.CoordinateTransform.mmToPixels(o):CoordinateTransform.mmToPixels(o);t.lineWidth=Math.max(e,1);try{this.applyStrokeStyle(t,s,t.lineWidth)}catch(t){}t.stroke()}t.restore()}}_computeConnectorEndpoints(t,e){const r=Math.max(0,t.w);const o=Math.max(0,t.h);const s=t.x+r/2;const i=t.y+o/2;let n,a,l,c;const h=e&&(e.geometry||e.properties?.geometry)||null;const u=h&&(h.pathList||h.pathLst);if(Array.isArray(u)&&u.length>0){const e=u[0];const s=e.commands||[];let i=null;let f=null;for(let t=0;t<s.length;t++){const e=s[t];if(!i&&"moveTo"===e.type)i={x:e.x,y:e.y};if("lineTo"===e.type)f={x:e.x,y:e.y};else if("cubicBezTo"===e.type)f={x:e.x3,y:e.y3};else if("moveTo"===e.type&&!f&&i)f={x:e.x,y:e.y}}if(!i&&s.length>0){const t=s[0];if(null!=t.x&&null!=t.y)i={x:t.x,y:t.y}}if(!f&&i)f={...i};if(i&&f){const s=e.w||h.pathW||100;const u=e.h||h.pathH||100;const d=0===s?1:r/s;const p=0===u?1:o/u;n=t.x+i.x*d;a=t.y+i.y*p;l=t.x+f.x*d;c=t.y+f.y*p}}if(void 0===n){n=t.x;a=t.y;l=t.x+r;c=t.y+o}const f=!!(e&&e.transform&&e.transform.flipH);const d=!!(e&&e.transform&&e.transform.flipV);if(f){n=s-(n-s);l=s-(l-s)}if(d){a=i-(a-i);c=i-(c-i)}const p=e&&e.transform&&(e.transform.rot||e.transform.rotation)||0;if(p){const t=p*Math.PI/180;const e=Math.cos(t);const r=Math.sin(t);const o=(t,o)=>({x:s+(t-s)*e-(o-i)*r,y:i+(t-s)*r+(o-i)*e});const h=o(n,a);const u=o(l,c);n=h.x;a=h.y;l=u.x;c=u.y}return{x1:n,y1:a,x2:l,y2:c}}drawLinePath(t,e,r,o,s){if(this.graphics&&"function"===typeof this.graphics.drawLineWithArrows){const t=this.getShapeStrokeColor(this.getCurrentShape());const i=this.getShapeLineWidth(this.getCurrentShape())||1;const n=this.getShapeStrokeInfo(this.getCurrentShape());const a=e;const l=r+s/2;const c=e+o;const h=r+s/2;this.graphics.drawLineWithArrows(a,l,c,h,t,i,n);return}t.moveTo(e,r+s/2);t.lineTo(e+o,r+s/2)}drawLineWithArrows(t,e,r,o,s,i=1,n=null){const a=this._context;if(!a)return;a.save();a.beginPath();a.moveTo(t,e);a.lineTo(r,o);const l=this.colorToRgb(s)||"rgba(0,0,0,1)";const c=Math.max(CoordinateTransform.mmToPixels(i||1),1);a.strokeStyle=l;a.lineWidth=c;if(n)try{this.applyStrokeStyle(a,n,c)}catch(t){}a.stroke();const h=t=>{if("number"===typeof t)return t;const e=(t||"").toString();if("lg"===e||"large"===e)return 2;if("med"===e||"medium"===e)return 1.5;return 1};const u=n&&n.tailEnd;const f=n&&n.headEnd;if(u||f){const s=Math.atan2(o-e,r-t);const i=a.getTransform();const n=Math.sqrt(i.a*i.a+i.b*i.b);const d=Math.max(4,10*n);const p=Math.max(2.5,6*n);const g=Math.max(d,8*c);const m=Math.max(p,3*c);const y=(t,e,r,o)=>{if(!o)return;const s=g*(o.lengthScale||h(o.len));const i=m*(o.widthScale||h(o.w));const n=(o.type||o.val||"arrow").toString();const u=i/2;a.save();a.translate(t,e);a.rotate(r);a.beginPath();if("open"===n){a.moveTo(0,0);a.lineTo(-s,-u);a.moveTo(0,0);a.lineTo(-s,u);a.strokeStyle=l;a.lineWidth=Math.max(1,c);a.stroke()}else if("stealth"===n){a.moveTo(0,0);a.lineTo(-s,-.6*u);a.lineTo(-s,.6*u);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}else if("diamond"===n){a.moveTo(0,0);a.lineTo(-s/2,-u);a.lineTo(-s,0);a.lineTo(-s/2,u);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}else if("oval"===n){a.ellipse(-s/2,0,s/2,u,0,0,2*Math.PI);a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}else{a.moveTo(0,0);a.lineTo(-s,-u);a.lineTo(-s,u);a.closePath();a.fillStyle=l;a.fill();a.strokeStyle=l;a.lineWidth=Math.max(1,.5*c);a.stroke()}a.restore()};if(hasStart)y(t,e,s+Math.PI,u);if(hasEnd)y(r,o,s,f)}a.restore()}drawGradientFill(t,e,r){if(!r||!r.stops||0===r.stops.length)return;let o;if("linear"===r.type){const s=r.angle||0;const i=s*Math.PI/180;const n=e.x+e.w/2-Math.cos(i)*e.w/2;const a=e.y+e.h/2-Math.sin(i)*e.h/2;const l=e.x+e.w/2+Math.cos(i)*e.w/2;const c=e.y+e.h/2+Math.sin(i)*e.h/2;o=t.createLinearGradient(n,a,l,c)}else{const r=e.x+e.w/2;const s=e.y+e.h/2;const i=Math.max(e.w,e.h)/2;o=t.createRadialGradient(r,s,0,r,s,i)}for(const t of r.stops)o.addColorStop(t.position,this.graphics.colorToRgb(t.color));t.fillStyle=o;t.fillRect(e.x,e.y,e.w,e.h)}applyStrokeStyle(t,e,r){if(!t||!e)return;if(e.cap)switch(e.cap){case"rnd":t.lineCap="round";break;case"sq":t.lineCap="square";break;default:t.lineCap="butt"}if(e.join)switch(e.join){case"round":t.lineJoin="round";break;case"bevel":t.lineJoin="bevel";break;default:t.lineJoin="miter"}if(e.dashArray&&e.dashArray.length>0){const o=e.dashArray.map(t=>t*r);t.setLineDash(o)}else t.setLineDash([])}getShapePreset(t){if(t.geometry&&t.geometry.preset)return t.geometry.preset;if(t.properties&&t.properties.geometry&&t.properties.geometry.preset)return t.properties.geometry.preset;if(t.spPr&&t.spPr.geometry&&t.spPr.geometry.preset)return t.spPr.geometry.preset;if(t.spPr&&t.spPr.prstGeom&&t.spPr.prstGeom.prst)return t.spPr.prstGeom.prst;if(this.isPlaceholderShape(t))return"rect";if("sp"===t.type||"shape"===t.type)return"rect";return null}drawPictureShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;r.save();const o=t.properties?.transform;if(o&&o.rotation&&0!==o.rotation){const t=e.x+e.w/2;const s=e.y+e.h/2;r.translate(t,s);r.rotate(o.rotation*Math.PI/180);r.translate(-t,-s)}if(t.imageRelId&&this.processor&&this.processor.imageCache){const o=this.processor.imageCache.get(t.imageRelId);if(o);if(o&&"svg"===o.type&&this.processor.svgRenderer)try{const t=this.processor.svgRenderer.renderSVG(o.content,e.x,e.y,e.w,e.h,{preserveAspectRatio:true});t.then(()=>{}).catch(()=>{});r.restore();return}catch(t){}if(o&&o.image)try{const image=o.image;const{width:s,height:i}=o;let n=e.x,a=e.y,l=e.w,c=e.h;if("stretch"===t.imageFillMode){if(t.imageFillRect){const r=t.imageFillRect;n=e.x+e.w*r.l/1e5;a=e.y+e.h*r.t/1e5;l=e.w*(1e5-r.l-r.r)/1e5;c=e.h*(1e5-r.t-r.b)/1e5}}else if("tile"===t.imageFillMode){n=e.x;a=e.y;l=e.w;c=e.h}else{const t=s/i;const r=e.w/e.h;if(t>r){l=e.w;c=e.w/t;n=e.x;a=e.y+(e.h-c)/2}else{c=e.h;l=e.h*t;n=e.x+(e.w-l)/2;a=e.y}}r.drawImage(image,n,a,l,c);r.restore();return}catch(t){}}r.restore();if(t.textBody&&t.textBody.paragraphs&&this.shouldRenderText(t)){this.setCurrentRenderingShape(t);this.drawShapeText(t,e)}}drawImagePlaceholder(t,e,r,o,s,i="IMAGE"){const n=this.m_oContext;if(!n)return;n.save();n.fillStyle="#f8f9fa";n.fillRect(e,r,o,s);n.strokeStyle="#dee2e6";n.lineWidth=1;n.strokeRect(e,r,o,s);n.restore()}drawGroupShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;this.graphics.SaveGrState();try{if(t.transform){const r=this.graphics.context;if(t.transform.rotation&&0!==t.transform.rotation){const o=e.x+e.w/2;const s=e.y+e.h/2;r.save();r.translate(o,s);r.rotate(t.transform.rotation*Math.PI/180);r.translate(-o,-s)}if(t.transform.flipH||t.transform.flipV){const o=t.transform.flipH?-1:1;const s=t.transform.flipV?-1:1;const i=e.x+e.w/2;const n=e.y+e.h/2;r.save();r.translate(i,n);r.scale(o,s);r.translate(-i,-n)}}if(t.shapeTree&&t.shapeTree.length>0){const e=this.sortShapesByRenderOrder(t.shapeTree);for(let t=0;t<e.length;t++){const r=e[t];try{const t=this.getShapeBounds(r);if(t&&t.w>0&&t.h>0)this.drawShapeGeometry(r,t)}catch(t){}}}}catch(t){}finally{this.graphics.RestoreGrState()}}calculateChildShapeBounds(t,e){if(!t.bounds)return{x:e.x,y:e.y,w:50,h:50};const r=t.bounds;const o=this.processor?this.processor.getSlideDimensions():{cx:9144e3,cy:6858e3};const s=this.processor?this.processor.calculateCanvasRect(this.canvas,o):{scale:1,offsetX:0,offsetY:0,slideWidthPx:this.canvas.width,slideHeightPx:this.canvas.height};const i=s.slideWidthPx;const n=s.slideHeightPx;const a={x:(r.l||0)/o.cx*i,y:(r.t||0)/o.cy*n,w:((r.r||0)-(r.l||0))/o.cx*i,h:((r.b||0)-(r.t||0))/o.cy*n};const l=s.offsetX+a.x*s.scale;const c=s.offsetY+a.y*s.scale;const h=a.w*s.scale;const u=a.h*s.scale;return{x:l,y:c,w:h,h:u}}drawDefaultShape(t,e){if(!e||e.w<=0||e.h<=0)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;r.save();const o=t.properties?.transform;if(o&&o.rotation&&0!==o.rotation){const t=e.x+e.w/2;const s=e.y+e.h/2;r.translate(t,s);r.rotate(o.rotation*Math.PI/180);r.translate(-t,-s)}r.fillStyle="#e0e0e0";r.fillRect(e.x,e.y,e.w,e.h);r.strokeStyle="#999";r.lineWidth=1;r.strokeRect(e.x,e.y,e.w,e.h);r.restore();if(t.textBody&&t.textBody.paragraphs){this.setCurrentRenderingShape(t);this.drawShapeText(t,e)}}drawConnectorShape(t,e){if(!e||e.w<=0&&e.h<=0)return;this.drawEngineLine(e,t)}async drawGraphicFrame(t,e){if(t.graphicData);if(!e||e.w<=0||e.h<=0)return;if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===t.graphicData.uri)this.drawTable(t,e);else if(t.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/chart"===t.graphicData.uri)await this.drawChart(t,e);else this.drawDefaultShape(t,e)}drawTable(t,e){if(t.graphicData&&t.graphicData.tableXml)try{if(!this.tableProcessor)this.tableProcessor=new TableProcessor;const r=this.tableProcessor.parseTableFromXML(t.graphicData.tableXml);if(r){let t=e.x;let o=e.y;let s=e.w;let i=e.h;try{const t="function"===typeof r.getTableProperties?r.getTableProperties()||{}:r.tableProperties||{};const o=t&&t.layout?String(t.layout).toLowerCase():"autofit";const n=this.coordinateSystem&&"number"===typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;let a=0;const l="function"===typeof r.getTableGrid?r.getTableGrid():r.tableGrid||[];if(Array.isArray(l)&&l.length>0){const t=l.reduce((t,e)=>t+(parseInt(e.width)||0),0);a=t/914400*96*n}let c=0;const h=r.rows||[];if(h.length>0&&h.some(t=>t&&t.height)){const t=h.reduce((t,e)=>t+(parseInt(e&&e.height)||0),0);c=t/914400*96*n}if(!a&&t&&t.preferredWidth){const r=t.preferredWidth;if("pct"===r.type){const t=(parseInt(r.value)||0)/5e3;a=Math.max(0,e.w*t)}else if("dxa"===r.type)a=(parseInt(r.value)||0)/1440*96*n}if(a>0)if("autofit"===o&&a<s){const t=s/Math.max(1,a);const e=c>0?Math.max(1,c*t):i;i=isFinite(e)&&e>0?e:i}else{s=a;if(c>0)i=c}}catch(t){}const n=this.canvas.getContext("2d");let a=null;try{a=this.computeTableLayout(r,s,i,n);if(a&&"number"===typeof a.height&&a.height>0)i=a.height}catch(t){a=null}n.save();n.rect(t,o,s,i);n.clip();const l=this.graphics.context;if(!l)return;const c=this;const h={strokeRect:(t,e,r,o,s,i)=>{if(c.graphics&&"function"===typeof c.graphics.p_color){c.graphics.p_color(s.r,s.g,s.b,s.a||255);c.graphics.p_width(i||1);if("function"===typeof c.graphics._s)c.graphics._s();if("function"===typeof c.graphics._m)c.graphics._m(t,e);if("function"===typeof c.graphics._l){c.graphics._l(t+r,e);c.graphics._l(t+r,e+o);c.graphics._l(t,e+o)}if("function"===typeof c.graphics._z)c.graphics._z();if("function"===typeof c.graphics.ds)c.graphics.ds()}},fillRect:(t,e,r,o,s)=>{if(c.graphics&&"function"===typeof c.graphics.b_color1){c.graphics.b_color1(s.r,s.g,s.b,s.a||255);if("function"===typeof c.graphics._s)c.graphics._s();if("function"===typeof c.graphics._m)c.graphics._m(t,e);if("function"===typeof c.graphics._l){c.graphics._l(t+r,e);c.graphics._l(t+r,e+o);c.graphics._l(t,e+o)}if("function"===typeof c.graphics._z)c.graphics._z();if("function"===typeof c.graphics.df)c.graphics.df()}},drawLine:(t,e,r,o,s,i)=>{if(c.graphics&&"function"===typeof c.graphics.p_color){c.graphics.p_color(s.r,s.g,s.b,s.a||255);c.graphics.p_width(i||1);if("function"===typeof c.graphics._s)c.graphics._s();if("function"===typeof c.graphics._m)c.graphics._m(t,e);if("function"===typeof c.graphics._l)c.graphics._l(r,o);if("function"===typeof c.graphics.ds)c.graphics.ds()}},fillText:(t,e,r,o)=>{if(c.graphics&&"function"===typeof c.graphics.FillText){if("function"===typeof c.graphics.font)c.graphics.font(o.fontFamily||"Arial",o.fontSize||12,o.bold?"bold":"normal",o.italic?"italic":"normal");c.graphics.b_color1(o.color.r,o.color.g,o.color.b,o.color.a||255);c.graphics.FillText(e,r,t)}}};this.drawTableDirect(r,n,t,o,s,i,a);n.restore()}else{this.drawTablePlaceholder(e,"Parse Failed");tableCtx.restore()}}catch(t){this.drawTablePlaceholder(e,"Error");tableCtx.restore()}else this.drawTablePlaceholder(e,"No Data")}computeTableLayout(t,e,r,o){const s={cellWidths:[],cellHeights:[],height:r};if(!t)return s;const i="function"===typeof t.getRowCount?t.getRowCount():t.rows?t.rows.length:0;const n="function"===typeof t.getColumnCount?t.getColumnCount():0;if(i<=0)return s;let a;try{const r="function"===typeof t.getTableGrid?t.getTableGrid():t.tableGrid||[];if(Array.isArray(r)&&r.length>0){const t=this.coordinateSystem&&"number"===typeof this.coordinateSystem.scale?this.coordinateSystem.scale:1;a=r.map(e=>{const r=parseInt(e.width,10)||0;return r/914400*96*t});const o=a.reduce((t,e)=>t+e,0);if(o>0&&isFinite(e)&&e>0&&o<e){const t=e/o;a=a.map(e=>e*t)}const s=Math.max(n,a.length);if(a.length<s&&s>0){const t=s-a.length;const r=a.reduce((t,e)=>t+e,0);const o=t>0?(e-r)/t:0;for(let e=0;e<t;e++)a.push(o)}}}catch(t){a=void 0}const l=Math.max(n,Array.isArray(a)?a.length:0);if(!Array.isArray(a)||0===a.length){const t=e/Math.max(l||1,1);a=Array.from({length:Math.max(l,1)},()=>t)}const c=new Array(i);const h=new Array(i).fill(false);const u=isFinite(r)&&r>0?r/Math.max(i,1):0;for(let e=0;e<i;e++){const r=t.rows?t.rows[e]:null;let o=null;if(r&&void 0!==r.height&&null!==r.height){const t=parseInt(r.height,10);if(!Number.isNaN(t)&&t>0)o=t/914400*96}if(o&&o>0)c[e]=o;else{c[e]=0;h[e]=true}}const f=(t,e,r)=>{let o=0;for(let s=0;s<r;s++)o+=t[e+s]||0;return o};if(o&&"function"===typeof o.measureText){const e=new Array(i).fill(0);const r=o;if("function"===typeof r.save)r.save();try{r.textBaseline="top";for(let o=0;o<i;o++){const s=t.rows?t.rows[o]:null;if(!s||!Array.isArray(s.cells))continue;let n=0;for(let t=0;t<s.cells.length;t++){const l=s.cells[t];const h=Math.max(1,l?.gridSpan||1);const u=Math.max(1,l?.rowSpan||1);if(l&&l.isMergedContinue){if("continue"===l.vMerge)n+=1;continue}const d=f(a,n,h);const p=this.getCellMarginsPx(l);const g=Math.max(0,d-p.left-p.right);if(g<=0){n+=h;continue}const m=this.computeCellTextLayout(r,l,g,Number.POSITIVE_INFINITY,{contentX:0});const y=m.totalHeight+p.top+p.bottom;if(y<=0){n+=h;continue}const b=f(c,o,u);if(y>b){const t=y-b;if(1===u)e[o]=Math.max(e[o],t);else{const r=t/u;for(let t=0;t<u;t++){const s=o+t;if(s>=i)break;e[s]=Math.max(e[s],r)}}}n+=h}}}finally{if("function"===typeof r.restore)r.restore()}for(let t=0;t<i;t++)if(e[t]>0)c[t]+=e[t]}for(let t=0;t<i;t++){if((void 0===c[t]||c[t]<=0)&&h[t])c[t]=u||0;if(c[t]<=0)c[t]=0}const d=c.reduce((t,e)=>t+(e||0),0);s.cellWidths=a;s.cellHeights=c;if(d>0)s.height=d;else if(isFinite(r)&&r>0)s.height=r;else s.height=0;return s}drawTableDirect(t,e,r,o,s,i,n=null){if(!t||!e)return;e.save();const a="function"===typeof t.getRowCount?t.getRowCount():t.rows?t.rows.length:0;const l="function"===typeof t.getColumnCount?t.getColumnCount():0;if(0===a||0===l&&!(t.rows&&t.rows[0]&&t.rows[0].cells)){e.restore();return}let c=n;if(!c)c=this.computeTableLayout(t,s,i,e);let h=Array.isArray(c?.cellWidths)?c.cellWidths.slice():null;const u=h&&h.length>0?h.length:Math.max(l,1);if(!h||0===h.length)h=Array.from({length:u},()=>s/Math.max(u,1));let f=Array.isArray(c?.cellHeights)?c.cellHeights.slice():null;if(!f||0===f.length)f=Array.from({length:a},()=>i/Math.max(a,1));if(c&&"number"===typeof c.height&&c.height>0)i=c.height;const d=(t,e,r)=>{let o=0;for(let s=0;s<r;s++)o+=t[e+s]||0;return o};const p=(t,e)=>{let r=0;for(let o=0;o<e;o++)r+=t[o]||0;return r};let g=null;try{const e="function"===typeof t.getTableProperties?t.getTableProperties():t.tableProperties||{};g=e&&e.borders?e.borders:null}catch(t){g=null}let m=o;const y=[];for(let o=0;o<a;o++){const s=f[o];const i=t.rows[o];if(!i)continue;let n=0;for(let s=0;s<i.cells.length;s++){const a=i.cells[s];const l=Math.max(1,a?.gridSpan||1);const c=Math.max(1,a?.rowSpan||1);if(a&&a.isMergedContinue){if("continue"===a.vMerge)n+=1;continue}const u=r+p(h,n);const g=m;const y=d(h,n,l);const b=d(f,o,c);const x=this.extractCellStyle(a,o,t);if(x.backgroundColor){e.fillStyle=x.backgroundColor;e.fillRect(u,g,y,b)}this.drawCellBordersFromPPTX(e,a,u,g,y,b);if(a&&a.textBody)this.drawCellText(e,a,u,g,y,b,x);n+=l}m+=s;y.push(m)}if(g&&g.insideH&&g.insideH.color){const t=g.insideH;const o=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;const i=t.width||(t.size?Math.max(1,Math.round(t.size/4)):1);e.strokeStyle=o;e.lineWidth=i;for(let t=0;t<y.length;t++){const o=y[t];if(0===t)continue;e.beginPath();e.moveTo(r,o);e.lineTo(r+s,o);e.stroke()}}if(g&&g.bottom&&g.bottom.color){const t=g.bottom;const n=`rgb(${t.color.r}, ${t.color.g}, ${t.color.b})`;const a=t.width||(t.size?Math.max(1,Math.round(t.size/4)):1);e.strokeStyle=n;e.lineWidth=a;e.beginPath();e.moveTo(r,o+i);e.lineTo(r+s,o+i);e.stroke()}e.restore()}drawCellBordersFromPPTX(t,e,r,o,s,i){if(!e||!e.borders)return;const n=e.borders;const a=[{name:"top",x1:r,y1:o,x2:r+s,y2:o},{name:"right",x1:r+s,y1:o,x2:r+s,y2:o+i},{name:"bottom",x1:r,y1:o+i,x2:r+s,y2:o+i},{name:"left",x1:r,y1:o,x2:r,y2:o+i}];a.forEach(e=>{const r=n[e.name];if(r&&r.color&&r.width&&r.width>0){t.strokeStyle=`rgb(${r.color.r}, ${r.color.g}, ${r.color.b})`;t.lineWidth=r.width;t.beginPath();t.moveTo(e.x1,e.y1);t.lineTo(e.x2,e.y2);t.stroke()}})}extractCellStyle(t,e,r){const o={};if(!t)return o;if(t.shading&&t.shading.fillColor&&void 0!==t.shading.fillColor.r&&void 0!==t.shading.fillColor.g&&void 0!==t.shading.fillColor.b){const e=t.shading.fillColor;o.backgroundColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`}else if(t.shading&&t.shading.fill&&"none"!==t.shading.fill){const e=t.shading.fill.startsWith("#")?t.shading.fill.slice(1):null;if(e&&6===e.length){const t=parseInt(e.substring(0,2),16);const r=parseInt(e.substring(2,4),16);const s=parseInt(e.substring(4,6),16);o.backgroundColor=`rgb(${t}, ${r}, ${s})`}}if(!o.backgroundColor&&r&&void 0!==e){const s="function"===typeof r.getTableProperties?r.getTableProperties():r.tableProperties||{};if(s){const r=t.logicalColIndex||0;if(s.firstRow&&0===e)o.backgroundColor="rgba(68, 114, 196, 1)";else if(s.bandRow&&e>0){const t=s.firstRow?e-1:e;if(t%2===1)o.backgroundColor="rgba(242, 242, 242, 1)"}else if(s.firstCol&&0===r&&e>0)o.backgroundColor="rgba(221, 235, 247, 1)"}}if(t.textBody&&t.textBody.paragraphs&&t.textBody.paragraphs.length>0){const s=t.textBody.paragraphs[0];if(s.runs&&s.runs.length>0){const t=s.runs[0];if(t.properties&&t.properties.color){const e=t.properties.color;o.textColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${(e.a||255)/255})`}else o.textColor=this.getTableStyleTextColor(e,r)}else o.textColor=this.getTableStyleTextColor(e,r)}else o.textColor=this.getTableStyleTextColor(e,r);return o}getTableStyleTextColor(t,e){const r=e&&"function"===typeof e.getTableProperties?e.getTableProperties():e&&e.tableProperties?e.tableProperties:{};if(r&&void 0!==t)if(r.firstRow&&0===t)return"rgb(255, 255, 255)";return"rgb(0, 0, 0)"}getCellMarginsPx(t){const e={left:3.78,top:3.78,right:3.78,bottom:3.78};if(!t)return e;const r={...e};const o=t=>{const e=Number(t);if(!Number.isFinite(e))return null;return e/914400*96};const s=t=>{if(!t)return;if(void 0!==t.marL){const e=o(t.marL);if(null!==e)r.left=e}if(void 0!==t.marT){const e=o(t.marT);if(null!==e)r.top=e}if(void 0!==t.marR){const e=o(t.marR);if(null!==e)r.right=e}if(void 0!==t.marB){const e=o(t.marB);if(null!==e)r.bottom=e}};const i=t=>{if(!t)return;if(void 0!==t.left){const e=o(t.left);if(null!==e)r.left=e}if(void 0!==t.top){const e=o(t.top);if(null!==e)r.top=e}if(void 0!==t.right){const e=o(t.right);if(null!==e)r.right=e}if(void 0!==t.bottom){const e=o(t.bottom);if(null!==e)r.bottom=e}};s(t.cellProperties);i(t.margins);return r}computeCellTextLayout(t,e,r,o=Number.POSITIVE_INFINITY,s={}){const i={lines:[],totalHeight:0};if(!e||!e.textBody||!Array.isArray(e.textBody.paragraphs)||r<=0)return i;const n="number"===typeof o&&o>0?o:Number.POSITIVE_INFINITY;const a=s&&"number"===typeof s.contentX?s.contentX:0;let l=0;const c=Boolean(e.textBody&&e.textBody.bodyProperties&&false===e.textBody.bodyProperties.wrap);const h=t?t.font:null;for(const o of e.textBody.paragraphs){if(!o||!Array.isArray(o.runs)||0===o.runs.length)continue;if(l>=n)break;let e="left";let h=a;if(o.properties&&o.properties.alignment){const t=o.properties.alignment;const s="string"===typeof t?t.toLowerCase():t;if("center"===s||"ctr"===s){e="center";h=a+r/2}else if("right"===s||"r"===s||"end"===s){e="right";h=a+r}else if("start"===s||"left"===s||"l"===s){e="left";h=a}else if("justify"===s){e="left";h=a}}const u=o.runs.find(t=>(t.text||"").trim().length>0)||o.runs[0];let f=12;if(u?.properties?.fontSize)f=u.properties.fontSize;else if(u?.properties?.sz){const t=parseInt(u.properties.sz,10);if(!Number.isNaN(t))f=t/100}const d=Math.max(1,Math.round(f*(96/72)));const p=u?.properties?.fontFamily||"Arial";const g=Boolean(u?.properties?.bold);const m=Boolean(u?.properties?.italic);let y=s.defaultTextColor||"rgb(159, 159, 159)";if(u?.properties?.color){const t=u.properties.color;y=`rgba(${t.r}, ${t.g}, ${t.b}, ${(t.a||255)/255})`}let b=1;if(o.properties)if("number"===typeof o.properties.lineSpacingFactor)b=o.properties.lineSpacingFactor;else if("number"===typeof o.properties.lineSpacingPct)b=Math.max(.5,Math.min(4,o.properties.lineSpacingPct/100));const x=Math.max(1,Math.round(d*b));const S=o.runs.map(t=>t.text||"").join("");if(!S)continue;const w=!c;const C=`${m?"italic ":""}${g?"bold ":""}${d}px ${p}`;if(t&&"string"===typeof t.font)t.font=C;const T=t=>{if(!t)return;i.lines.push({text:t,textX:h,textAlign:e,fontSizePixels:d,fontFamily:p,isBold:g,isItalic:m,colorStr:y,lineHeight:x});l+=x};if(w){let e=S.trim();while(e.length>0){if(l+x>n)break;let o=1;let s=e.length;let i=1;while(o<=s){const n=o+s>>1;const a=e.slice(0,n);const l=t&&"function"===typeof t.measureText?t.measureText(a):{width:a.length*d*.5};if(l.width<=r||1===n){i=n;o=n+1}else s=n-1}let a=i;if(i<e.length){const t=e.slice(0,i).lastIndexOf(" ");if(t>0)a=t}let c=Math.max(1,a);let h=e.slice(0,c).trimEnd();if(!h){h=e.charAt(0);c=1}T(h);e=e.slice(c).trimStart()}}else{if(l+x>n)break;T(S.trimEnd())}}if(t&&null!==h)t.font=h;i.totalHeight=l;return i}drawCellText(t,e,r,o,s,i,n){if(!e||!e.textBody||!e.textBody.paragraphs)return;t.save();t.textBaseline="top";const a=this.getCellMarginsPx(e);const l=Math.max(0,s-a.left-a.right);const c=Math.max(0,i-a.top-a.bottom);if(l<=0||c<=0){t.restore();return}const h=r+a.left;const u=o+a.top;t.beginPath();t.rect(h,u,l,c);t.clip();const f=this.computeCellTextLayout(t,e,l,c,{contentX:h,defaultTextColor:n.textColor});if(f.lines.length>0){const r=f.totalHeight;let o="top";if(e&&"string"===typeof e.verticalAlignment)o=e.verticalAlignment.toLowerCase();else if(e&&e.textBody&&e.textBody.bodyProperties&&e.textBody.bodyProperties.anchor){const t=String(e.textBody.bodyProperties.anchor).toLowerCase();if("ctr"===t||"center"===t||"middle"===t)o="middle";else if("b"===t||"bottom"===t)o="bottom"}let s=u;if("middle"===o||"center"===o)s=u+Math.max(0,(c-r)/2);else if("bottom"===o)s=u+Math.max(0,c-r);for(const e of f.lines){let r="";if(e.isItalic)r+="italic ";if(e.isBold)r+="bold ";t.font=`${r}${e.fontSizePixels}px ${e.fontFamily}`;t.textAlign=e.textAlign;t.fillStyle=e.colorStr;t.fillText(e.text,Math.round(e.textX),Math.round(s));s+=e.lineHeight;if(s>u+c)break}}t.restore()}getScaledFontSize(t){let e=t;if(this.coordinateSystem&&this.coordinateSystem.scale){e=t*this.coordinateSystem.scale;e=Math.max(e,8);e=Math.min(e,72)}return Math.round(e)}drawTablePlaceholder(t,e){const r={r:100,g:100,b:200,a:255};this.graphics.p_color(r.r,r.g,r.b,r.a);this.graphics.p_width(2);this.graphics._s();this.graphics._m(t.x,t.y);this.graphics._l(t.x+t.w,t.y);this.graphics._l(t.x+t.w,t.y+t.h);this.graphics._l(t.x,t.y+t.h);this.graphics._z();if("function"===typeof this.graphics.ds)this.graphics.ds()}async drawChart(t,e){if(t.chartData){if("DEFERRED_CHART"===t.chartData.type)if(window.ChartProcessor){const r=new ChartProcessor(this.context);if(void 0!==this.currentSlideIndex&&this.currentSlide){const o={slideIndex:this.currentSlideIndex,slideName:this.currentSlide?.name||`slide${this.currentSlideIndex+1}`,slide:this.currentSlide};r.setSlideContext(o);try{const s=await r.loadChartFromRelationship(t.chartData.relationshipId,o);if(s&&"DEFERRED_CHART"!==s.type)t.chartData=s;else{this.drawChartPlaceholder(e,"Load Failed");return}}catch(t){this.drawChartPlaceholder(e,"Load Error");return}}else{this.drawChartPlaceholder(e,"No Context");return}}else{this.drawChartPlaceholder(e,"No Processor");return}try{const r="undefined"!==typeof window&&(window.navigator&&true===window.navigator.webdriver||window.__nightmare||window._phantom||window.callPhantom||/HeadlessChrome/.test(window.navigator.userAgent));if(!this.chartRenderer)this.chartRenderer=new ChartRenderer(this.graphics);const o=e.x;const s=e.y;const i=e.w;const n=e.h;await this.chartRenderer.renderChart(t.chartData,o,s,i,n);this.drawChartStyling(t.chartData,o,s,i,n)}catch(t){this.drawChartPlaceholder(e,"Render Failed")}}else if(t.graphicData&&t.graphicData.element&&window.ChartProcessor)try{const r=new ChartProcessor(this.context);if(void 0!==this.currentSlideIndex&&this.currentSlide){const t={slideIndex:this.currentSlideIndex,slideName:this.currentSlide?.name||`slide${this.currentSlideIndex+1}`,slide:this.currentSlide};r.setSlideContext(t)}const o=r.parseEmbeddedChartData(t.graphicData.element);if(o){t.chartData=o;if(!this.chartRenderer)this.chartRenderer=new ChartRenderer(this.graphics);this.chartRenderer.renderChart(o,e.x,e.y,e.w,e.h);return}if(t.graphicData.chartRef){const o={slideIndex:this.currentSlideIndex,slideName:this.currentSlide?.name||`slide${this.currentSlideIndex+1}`,slide:this.currentSlide};r.loadChartFromRelationship(t.graphicData.chartRef,o).then(r=>{if(r){t.chartData=r;if(!this.chartRenderer)this.chartRenderer=new ChartRenderer(this.graphics);this.chartRenderer.renderChart(r,e.x,e.y,e.w,e.h)}else this.drawChartPlaceholder(e,"Processing Failed")}).catch(t=>{this.drawChartPlaceholder(e,"Processing Error")});this.drawChartPlaceholder(e,"Processing...");return}this.drawChartPlaceholder(e,"No Chart Reference")}catch(t){this.drawChartPlaceholder(e,"Processing Failed")}else this.drawChartPlaceholder(e,"No Chart Data")}drawChartStyling(t,e,r,o,s){if(!t)return;let i=null;if(this.graphics&&this.graphics.ctx)i=this.graphics.ctx;else if(this.graphics&&this.graphics._context)i=this.graphics._context;else if(this.graphics&&this.graphics.context)i=this.graphics.context;else if(this.graphics&&this.graphics.m_oContext)i=this.graphics.m_oContext;if(!i)return;const n=t.plotArea?.shapeProperties||t.shapeProperties||{};const a=n.line;if(!a||!a.color)return;const l=12700;const c=Math.max(1,Math.round((a.width||l)/l));const h="string"===typeof a.color?a.color:this.colorToRgb(a.color);const u=t.roundedCorners?Math.min(20,Math.floor(.1*Math.min(o,s))):0;i.save();i.strokeStyle=h;i.lineWidth=c;i.lineCap="round";i.lineJoin="round";i.globalCompositeOperation="source-over";i.beginPath();if(t.roundedCorners&&u>0){const t=e+c/2;const n=r+c/2;const a=o-c;const l=s-c;if(this.graphics&&"function"===typeof this.graphics.drawRoundRectPath)this.graphics.drawRoundRectPath(i,t,n,a,l,u);else if("function"===typeof this.drawRoundRectPath)this.drawRoundRectPath(i,t,n,a,l,u);else i.rect(t,n,a,l)}else{const t=e+c/2;const n=r+c/2;const a=o-c;const l=s-c;i.rect(t,n,a,l)}i.stroke();i.restore()}drawChartPlaceholder(t,e){const r={r:200,g:100,b:100,a:255};this.graphics.p_color(r.r,r.g,r.b,r.a);this.graphics.p_width(2);this.graphics._s();this.graphics._m(t.x,t.y);this.graphics._l(t.x+t.w,t.y);this.graphics._l(t.x+t.w,t.y+t.h);this.graphics._l(t.x,t.y+t.h);this.graphics._z();if("function"===typeof this.graphics.ds)this.graphics.ds()}drawShapeText(t,e){if(!t||!t.textBody||!t.textBody.paragraphs||0===t.textBody.paragraphs.length)return;this.setCurrentRenderingShape(t);this.graphics.SaveGrState();try{const r=this.calculateTextBounds(t,e);this.drawTextContent(t.textBody,r)}catch(r){this.drawFallbackText(t,e)}finally{this.graphics.RestoreGrState();this.setCurrentRenderingShape(null)}}calculateTextBounds(t,e){const{x:r,y:o,w:s,h:i}=e;const n=t.textBody?.bodyProperties||t.textBody?.bodyPr||{};const a=Math.max(22860,.02*s*914400);const l=Math.max(11430,.01*i*914400);const c=this.emuToPixels(n.leftMargin||a);const h=this.emuToPixels(n.rightMargin||a);const u=this.emuToPixels(n.topMargin||l);const f=this.emuToPixels(n.bottomMargin||l);if(this.coordinateSystem){const{scale:t}=this.coordinateSystem;const e=Math.round(c*t);const n=Math.round(h*t);const a=Math.round(u*t);const l=Math.round(f*t);return{x:r+e,y:o+a,w:Math.max(s-(e+n),.9*s),h:Math.max(i-(a+l),.9*i),scale:t,margins:{left:e,right:n,top:a,bottom:l}}}return{x:r+c,y:o+u,w:Math.max(s-(c+h),.9*s),h:Math.max(i-(u+f),.9*i),scale:1,margins:{left:c,right:h,top:u,bottom:f}}}drawFallbackText(t,e){const r=this.graphics.context;if(!r)return;const{x:o,y:s,w:i,h:n}=e;r.save();const a=this.getTextScaleFactor();const l=12*a;r.font=`${l}px Arial`;r.fillStyle="#000000";r.textAlign="left";r.textBaseline="top";let c=s+5;const h=16;for(const e of t.textBody.paragraphs){if(c>s+n-h)break;for(const t of e.runs)if(t.text&&c<=s+n-h){r.fillText(t.text,o+5,c);c+=h}}r.restore()}drawTextContent(t,e){if(!t||!t.paragraphs||0===t.paragraphs.length)return;if(!this.graphics||!this.graphics.context)return;const r=this.graphics.context;const{x:o,y:s,w:i,h:n}=e;if(!n||n<1){const r=this.estimateTextHeightPx(t,i);if(r&&r>0){const o={...e,h:r};this.renderTextBodyStandard(t,o);return}}this.renderTextBodyStandard(t,e)}estimateTextHeightPx(t,e){try{if(!t||!t.paragraphs||0===t.paragraphs.length)return 0;const r=t.bodyProperties||t.bodyPr||{};const o=this.emuToPixels(r.leftMargin||0);const s=this.emuToPixels(r.rightMargin||0);const i=Math.max(0,e-o-s);let n=0;for(const e of t.paragraphs){const t=this.parseParagraphProperties(e,this.getCurrentShape());const r=this.calculateWrappedLines(e,t,i,this.getCurrentShape());const o=this.calculateStandardLineHeight(t);const s=this.emuToPixels(t.spaceBefore||0);const a=this.emuToPixels(t.spaceAfter||0);n+=s+r.length*o+a}const a=this.emuToPixels(r.topMargin||0);const l=this.emuToPixels(r.bottomMargin||0);n+=a+l;return Math.ceil(n)}catch(t){return 0}}estimateTextBoxHeightPx(t,e){const r=t&&t.textBody;if(!r)return 0;return this.estimateTextHeightPx(r,e)}renderTextBodyStandard(t,e){const{x:r,y:o,w:s,h:i,margins:n,scale:a}=e;const l=r;const c=o;const h=s;const u=i;const f=t.bodyProperties||t.bodyPr||{};let d=f.anchor||f.verticalAlign||"t";switch(d){case"top":d="t";break;case"middle":case"center":d="ctr";break;case"bottom":d="b"}let p=c;const g=[];let m=0;for(let e=0;e<t.paragraphs.length;e++){const r=t.paragraphs[e];const o=this.getCurrentShape();const s=this.parseParagraphProperties(r,o);const i=this.calculateWrappedLines(r,s,h,o);const n=this.calculateStandardLineHeight(s);const a=this.emuToPixels(s.spaceBefore||0);const l=this.emuToPixels(s.spaceAfter||0);const c=a+i.length*n+l;g.push({paragraph:r,paraProps:s,wrappedLines:i,lineHeight:n,spaceBefore:a,spaceAfter:l,height:c});m+=c}switch(d){case"ctr":case"middle":p=c+(u-m)/2;break;case"b":case"bottom":p=c+u-m;break;case"just":if(t.paragraphs.length>1)p=c;else p=c;break;default:p=c}let y=p;const b=c+u;let x=0;if(("just"===d||"dist"===d)&&g.length>1){const t=Math.max(0,u-m);if(t>0)if("just"===d)x=t/(g.length-1);else if("dist"===d){x=t/(g.length+1);y+=x}}const S={};let w=-1;const C={};const T={};let P=-1;const v=new Set;for(let t=0;t<g.length;t++){const{paraProps:e}=g[t];if(e&&e.bullet&&("number"===e.bullet.type||"autoNumber"===e.bullet.type)){const t=e.indent&&"number"===typeof e.indent.left?e.indent.left:0;v.add(t)}}const M=Array.from(v).sort((t,e)=>t-e);const A=M.length>0?M[0]:0;const E=t=>{const e=t&&"number"===typeof t.level?t.level:0;if(e>0)return e;const r=t.indent&&"number"===typeof t.indent.left?t.indent.left:0;if(M.length<=1)return e;if(r<=A)return 0;let o=M.indexOf(r);if(-1===o){o=M.findIndex(t=>t>=r);if(-1===o)o=M.length-1}return Math.max(0,o)};for(let t=0;t<g.length;t++){const e=g[t];const r=e.paraProps;if(r.bullet&&("number"===r.bullet.type||"autoNumber"===r.bullet.type)){const e=E(r);const o=void 0!==r.bullet.startAt;const s=o?r.bullet.startAt:1;const i=e!==w||!S[e];if(e!==w)if(e<w)for(let t=e+1;t<=9;t++)delete S[t];else if(e>w)S[e]=0;if(i&&o)S[e]=s-1;else if(i&&!o)S[e]=0;if(!S[e])S[e]=0;S[e]++;C[t]=S[e];w=e}}for(let t=0;t<g.length;t++){const e=g[t];if(y>=b)break;const{paraProps:r,wrappedLines:o,lineHeight:s,spaceBefore:i,spaceAfter:n}=e;y+=i||0;const a=E(r);if(r.bullet&&("number"===r.bullet.type||"autoNumber"===r.bullet.type)){if(a!==w)if(a<w)for(let t=a+1;t<=9;t++)delete S[t];else if(a>w)S[a]=0;if(!S[a])S[a]=0;S[a]++;w=a}for(let e=0;e<o.length;e++){const i=o[e];const n=this.emuToPixels(r.indent?.left||0);const c=this.emuToPixels(r.indent?.hanging||0);let u=n;if(0===e&&0!==c)u+=c;const f=r.align||"left";let d=l+Math.max(0,u);if("center"===f||"ctr"===f)d=l+u+(h-i.width-u)/2;else if("right"===f||"r"===f)d=l+h-i.width;const p=r.fontSize||12;const g=this.getTextScaleFactor();const m=p*g;const b=y+.8*m;if(0===e)if(r.bullet&&"none"!==r.bullet.type){const e=l+n+c;const o="number"===r.bullet.type||"autoNumber"===r.bullet.type?S[a]||1:t;r._bulletNumber=C[t];const s=i.runs&&i.runs[0]&&i.runs[0].runProps&&i.runs[0].runProps.fontSize?i.runs[0].runProps.fontSize:r.fontSize||12;const h={...r,fontSize:s};const u=this.getBulletWidth(r.bullet,h,o,S);this.renderBullet(r.bullet,e,b,h,o,S);const f=s*g;const p=.3*f;const m=e+u;const y=l+n;if(m+p>y)d=m+p;else d=y}let x=d;for(const t of i.runs){const{text:e,runProps:r}=t;let o=e;if(r.cap&&"none"!==r.cap)switch(r.cap){case"all":case"small":o=o.toUpperCase();break;case"words":o=o.replace(/\b\w/g,t=>t.toUpperCase())}this.setupStandardFont(r);x=this.renderRunTextStandard(o,x,b,r,l+h)}y+=s}y+=n||0;if(t<g.length-1)y+=x}}calculateWrappedLines(t,e,r,o){const s=[];let i={runs:[],width:0};for(const n of t.runs){if(!n.text)continue;const t=this.parseRunProperties(n,e,o);const a=n.text.split(/(\s+)/);for(const e of a){if(!e)continue;const o=this.measureRunText(e,t);if(i.width+o<=r||0===i.runs.length){i.runs.push({text:e,runProps:t});i.width+=o}else{if(i.runs.length>0)s.push(i);i={runs:[{text:e,runProps:t}],width:o}}}}if(i.runs.length>0)s.push(i);if(0===s.length)s.push({runs:[],width:0});return s}setupStandardFont(t){const e=this.graphics.context;if(!e)return;const r=this.getTextScaleFactor();const o=(t.fontSize||12)*r;const s=t.italic?"italic":"normal";const i=t.bold?"bold":"normal";const n=t.fontFamily||"Arial";const a=`"${n}", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif`;e.font=`${s} ${i} ${o}px ${a}`;e.fillStyle=this.graphics.colorToRgb(t.color);e.textBaseline="alphabetic";t.scaledFontSize=o}getBulletWidth(t,e,r=0,o=null){const s=this.graphics.context;if(!s||!t)return 0;s.save();try{const o=e.fontSize||12;const i=this.getTextScaleFactor();const n=o*i;const a=e.fontFamily||"Arial";const l=e.bold?"bold":"normal";const c=e.italic?"italic":"normal";s.font=`${c} ${l} ${n}px ${a}`;let h="";switch(t.type){case"character":h=t.char||"•";break;case"number":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;h=`${o+s}.`}break;case"autoNumber":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;h=this.getAutoNumberBullet(t.subType,o+s)}break;default:h="•"}const u=s.measureText(h).width;s.restore();return u}catch(t){s.restore();return 0}}calculateBulletInfo(t,e,r=0){const o=this.graphics.getContext();o.save();const s=e.fontSize||12;const i=this.getTextScaleFactor();const n=Math.max(s*i,14);const a=e.fontFamily||"Arial";const l=e.bold?"bold":"normal";const c=e.italic?"italic":"normal";o.font=`${c} ${l} ${n}px ${a}`;let h="";switch(t.type){case"character":h=t.char||"•";break;case"number":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;h=`${o+s}.`}break;case"autoNumber":{const o=(t.startAt||1)-1;const s=e&&"number"===typeof e._bulletNumber?e._bulletNumber:r;const i=o+s;h=this.getAutoNumberBullet(t.subType,i)}break;default:h="•"}const u=o.measureText(h).width;const f=.5*n;o.restore();return{bulletText:h,bulletWidth:u,bulletSpacing:f,totalWidth:u+f}}generateHierarchicalNumber(t,e,r,o){const s=e.level||0;const i=o&&o[s]?o[s]:(t.startAt||1)+r;return this.getAutoNumberBullet(t.subType,i)}renderBullet(t,e,r,o,s,i=null){const n=this.graphics.context;if(!n||!t)return;n.save();try{const i=o.fontSize||12;const a=this.getTextScaleFactor();const l=i*a;const c=o.fontFamily||"Arial";const h=o.bold?"bold":"normal";const u=o.italic?"italic":"normal";n.font=`${u} ${h} ${l}px ${c}`;const f=o.color||{r:0,g:0,b:0,a:255};const d=this.graphics.colorToRgb(f);n.fillStyle=d;n.textBaseline="alphabetic";let p="";switch(t.type){case"character":p=t.char||"•";break;case"number":{const e=(t.startAt||1)-1;const r=o&&"number"===typeof o._bulletNumber?o._bulletNumber:s;p=`${e+r}.`}break;case"autoNumber":{const e=(t.startAt||1)-1;const r=o&&"number"===typeof o._bulletNumber?o._bulletNumber:s;p=this.getAutoNumberBullet(t.subType,e+r)}break;default:p="•"}n.fillText(p,e,r)}catch(t){}finally{n.restore()}}getAutoNumberBullet(t,e){switch(t){case"arabicPeriod":case"arabic1Minus":case"arabic2Minus":default:return`${e}.`;case"arabicParenR":return`${e})`;case"arabicParenBoth":return`(${e})`;case"romanUcPeriod":return`${this.toRoman(e,true)}.`;case"romanLcPeriod":return`${this.toRoman(e,false)}.`;case"alphaUcPeriod":return`${this.toAlpha(e,true)}.`;case"alphaLcPeriod":return`${this.toAlpha(e,false)}.`;case"alphaUcParenR":return`${this.toAlpha(e,true)})`;case"alphaLcParenR":return`${this.toAlpha(e,false)})`;case"alphaUcParenBoth":return`(${this.toAlpha(e,true)})`;case"alphaLcParenBoth":return`(${this.toAlpha(e,false)})`}}toRoman(t,e=true){const r=[1e3,900,500,400,100,90,50,40,10,9,5,4,1];const o=e?["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]:["m","cm","d","cd","c","xc","l","xl","x","ix","v","iv","i"];let s="";for(let e=0;e<r.length;e++)while(t>=r[e]){s+=o[e];t-=r[e]}return s}toAlpha(t,e=true){let r="";const o=26;const s=e?65:97;while(t>0){t--;r=String.fromCharCode(s+t%o)+r;t=Math.floor(t/o)}return r||(e?"A":"a")}renderRunTextStandard(t,e,r,o,s){const i=this.graphics.context;if(!i||!t)return e;let n=e;if(this.currentRenderingShape&&this.currentRenderingShape.effects)this.applyTextEffectsToContext(i,this.currentRenderingShape.effects);const a=Array.from(t);for(let t=0;t<a.length;t++){const e=a[t];const s=i.measureText(e).width;i.fillText(e,n,r);n+=s+(o.letterSpacing||0)}this.resetTextEffectsOnContext(i);this.drawTextDecorations(e,r,n-e,o);return n}applyEffectsToCanvas(t,e){if(!e||!t)return;if(e.outerShadow)this.applyOuterShadowToContext(t,e.outerShadow);if(e.glow)this.applyGlowEffectToContext(t,e.glow);if(e.innerShadow);}applyTextEffectsToContext(t,e){if(!e||!t)return;if(e.outerShadow)this.applyOuterShadowToContext(t,e.outerShadow);if(e.glow)this.applyGlowEffectToContext(t,e.glow);if(e.innerShadow);}applyOuterShadowToContext(t,e){if(!e||!t)return;const r=(e.blurRadius||0)/9525;const o=(e.distance||0)/9525;const s=(e.direction||0)/6e4;const i=s*Math.PI/180;const n=Math.cos(i)*o;const a=Math.sin(i)*o;t.shadowOffsetX=n;t.shadowOffsetY=a;t.shadowBlur=r;if(e.color){const r=this.convertColorToString(e.color);t.shadowColor=r}else t.shadowColor="rgba(0, 0, 0, 0.5)"}applyGlowEffectToContext(t,e){if(!e||!t)return;const r=(e.radius||0)/9525;t.shadowOffsetX=0;t.shadowOffsetY=0;t.shadowBlur=r;if(e.color){const r=this.convertColorToString(e.color);t.shadowColor=r}else t.shadowColor="rgba(255, 255, 255, 0.8)"}resetEffectsOnContext(t){if(!t)return;t.shadowOffsetX=0;t.shadowOffsetY=0;t.shadowBlur=0;t.shadowColor="transparent"}resetTextEffectsOnContext(t){if(!t)return;t.shadowOffsetX=0;t.shadowOffsetY=0;t.shadowBlur=0;t.shadowColor="transparent"}convertColorToString(t){if(!t)return"black";if("srgb"===t.type){const e=t.value;const r=parseInt(e.substr(0,2),16);const o=parseInt(e.substr(2,2),16);const s=parseInt(e.substr(4,2),16);const i=t.alpha||1;return`rgba(${r}, ${o}, ${s}, ${i})`}else if("scheme"===t.type){const e={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6"};const r=e[t.value]||"#000000";const o=t.alpha||1;const s=parseInt(r.substr(1,2),16);const i=parseInt(r.substr(3,2),16);const n=parseInt(r.substr(5,2),16);return`rgba(${s}, ${i}, ${n}, ${o})`}return"black"}getTextScaleFactor(){if(!this.coordinateSystem)return 1;const{scale:t}=this.coordinateSystem;const e=1.33;return t*e}calculateStandardLineHeight(t){const e=t.fontSize||12;const r=this.getTextScaleFactor();const o=e*r;if(t.lineHeightPoints){const e=96/72;return t.lineHeightPoints*e*r}const s=t.lineHeight||100;const i=o*s/100;return i}measureRunText(t,e){const r=this.graphics.context;if(!r||!t)return 0;r.save();this.setupStandardFont(e);let o=0;for(let s=0;s<t.length;s++){const i=t.charAt(s);const n=r.measureText(i);o+=n.width+(e.letterSpacing||0)}r.restore();return o}drawTextDecorations(t,e,r,o){const s=this.graphics.context;const i=o.scaledFontSize||o.fontSize||12;if(o.underline){s.save();s.strokeStyle=s.fillStyle;s.lineWidth=Math.max(1,.05*i);s.beginPath();s.moveTo(t,e+2);s.lineTo(t+r,e+2);s.stroke();s.restore()}if(o.strike){s.save();s.strokeStyle=s.fillStyle;s.lineWidth=Math.max(1,.05*i);s.beginPath();const o=e-.3*i;s.moveTo(t,o);s.lineTo(t+r,o);s.stroke();s.restore()}}measureRunTextAlternative(t,e){const r=this.graphics.context;r.save();this.setupStandardFont(e);let o=0;for(let s=0;s<t.length;s++){const i=t.charAt(s);const n=r.measureText(i);o+=n.width+(e.letterSpacing||0)}r.restore();return o}calculateStandardLineHeightAlternative(t){const e=t.fontSize||12;const r=t.lineHeight||120;const o=e*r/100;return Math.max(o,1.2*e)}renderTextLine(t,e,r,o,s,i){if(0===e.length)return;const n=e.reduce((t,e)=>t+e.width,0);let a=r;const l=i.align||"left";const c=this.coordinateSystem?.scale||1;const h=s*c;const u=n*c;if("center"===l||"ctr"===l){const t=Math.max(0,s-n);a=r+t/2}else if("right"===l||"r"===l)a=r+Math.max(0,s-n);else if("justify"===l&&e.length>1)a=r;let f=a;for(const r of e){t.font=r.font;t.fillStyle=this.graphics.colorToRgb(r.props.color||{r:0,g:0,b:0,a:255});t.textBaseline="alphabetic";t.textAlign="left";t.fillText(r.text,Math.round(f),Math.round(o));if(r.props.underline){t.save();t.strokeStyle=t.fillStyle;t.lineWidth=1;t.beginPath();t.moveTo(f,o+2);t.lineTo(f+r.width,o+2);t.stroke();t.restore()}if(r.props.strike){t.save();t.strokeStyle=t.fillStyle;t.lineWidth=1;t.beginPath();const e=this.getTextScaleFactor();const s=(r.props.fontSize||12)*e;const i=o-.3*s;t.moveTo(f,i);t.lineTo(f+r.width,i);t.stroke();t.restore()}f+=r.width}}parseParagraphProperties(t,e=null){const r={align:"left",lineHeight:120,spaceBefore:0,spaceAfter:0,fontSize:18,fontFamily:"Arial",color:{r:0,g:0,b:0,a:255},bold:false,italic:false,bullet:null,indent:{left:0,hanging:0}};const o=t.properties&&"number"===typeof t.properties.level?t.properties.level:0;const s=this.resolveInheritedTextProperties(e,"paragraph",o);for(const t in s)if("leftMargin"===t)r.indent.left=s.leftMargin;else if("hangingIndent"===t)r.indent.hanging=s.hangingIndent;else if("leftMargin"!==t&&"hangingIndent"!==t)r[t]=s[t];if(s.align){const t={l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"};r.align=t[s.align]||s.align}if(e&&e.placeholder)switch(e.placeholder.type){case"title":case"ctrTitle":r.bold=true}if(t.properties){const e=t.properties;if(e.align){const t={l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"};r.align=t[e.align]||e.align}if(void 0!==e.lineHeight)r.lineHeight=e.lineHeight;if(e.spacing){if(void 0!==e.spacing.before)r.spaceBefore=e.spacing.before;if(void 0!==e.spacing.after)r.spaceAfter=e.spacing.after}if(void 0!==e.fontSize)r.fontSize=e.fontSize;if(e.fontFamily)r.fontFamily=e.fontFamily;if(e.color)r.color=e.color;if(void 0!==e.bold)r.bold=e.bold;if(void 0!==e.italic)r.italic=e.italic;if(e.bullet)r.bullet=e.bullet;if(e.indent){r.indent.left=e.indent.left;r.indent.hanging=e.indent.hanging}}return r}parseRunProperties(t,e,r=null){const o="layout"===this.currentSlide?.type;const s=o?{r:68,g:68,b:68,a:255}:{r:0,g:0,b:0,a:255};const i={fontSize:18,fontFamily:"Arial",color:s,bold:false,italic:false,underline:false,strike:false,verticalAlign:"normal",letterSpacing:0,cap:"none"};const n=this.resolveInheritedTextProperties(r,"run");Object.assign(i,n);if(e){if(void 0!==e.fontSize)i.fontSize=e.fontSize;if(e.fontFamily)i.fontFamily=e.fontFamily;if(e.color)i.color=e.color;if(void 0!==e.bold)i.bold=e.bold;if(void 0!==e.italic)i.italic=e.italic}if(t.properties){const e=t.properties;if(void 0!==e.fontSize)i.fontSize=e.fontSize;if(e.fontFamily)i.fontFamily=e.fontFamily;if(e.color)i.color=e.color;if(void 0!==e.bold)i.bold=e.bold;if(void 0!==e.italic)i.italic=e.italic;if(void 0!==e.underline)i.underline=e.underline;if(void 0!==e.strike)i.strike=e.strike;if(e.verticalAlign)i.verticalAlign=e.verticalAlign;if(void 0!==e.letterSpacing)i.letterSpacing=e.letterSpacing;if(e.cap)i.cap=e.cap}return i}emuToPixels(t){return CoordinateTransform.emuToPixels(t,96)}colorToRgbAlternative(t){if("string"===typeof t){if(t.startsWith("#"))return t;if(t.match(/^[a-z]+$/i))return t;return t}if(!t)return"rgb(0, 0, 0)";let e=0,r=0,o=0,s=255;if("object"===typeof t){e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;e=Math.max(0,Math.min(255,Math.round(e)));r=Math.max(0,Math.min(255,Math.round(r)));o=Math.max(0,Math.min(255,Math.round(o)));s=Math.max(0,Math.min(255,Math.round(s)))}if(void 0!==s&&255!==s)return`rgba(${e}, ${r}, ${o}, ${s/255})`;return`rgb(${e}, ${r}, ${o})`}isHiddenShape(t){return true===t.hidden}getShapeTransform(t){return null}getShapeBounds(t){if(t&&"graphicFrame"===t.type&&t.position){const e=t.position;const r=e.x||0;const o=e.y||0;const s=e.width||914400;const i=e.height||914400;if(this.coordinateSystem){const{slideWidthEMU:t,slideHeightEMU:e}=this.coordinateSystem;const n=t||9144e3;const a=e||6858e3;const l={x:r/n,y:o/a,w:s/n,h:i/a};const c=this.graphics.context.canvas;let h,u;if(c.style.width&&c.style.height){h=parseFloat(c.style.width);u=parseFloat(c.style.height)}else{h=c.width/(window.devicePixelRatio||1);u=c.height/(window.devicePixelRatio||1)}const f=n/a;const d=h/u;let p,g,m,y;if(f>d){p=h;g=h/f;m=0;y=(u-g)/2}else{p=u*f;g=u;m=(h-p)/2;y=0}return{x:Math.round(m+l.x*p),y:Math.round(y+l.y*g),w:Math.round(l.w*p),h:Math.round(l.h*g)}}const n=t=>t/914400*96;return{x:n(r),y:n(o),w:n(s),h:n(i)}}if(t.spPr&&t.spPr.xfrm){const e=t.spPr.xfrm;const r=void 0!==e.x?e.x:void 0!==(e.off&&e.off.x)?e.off.x:0;const o=void 0!==e.y?e.y:void 0!==(e.off&&e.off.y)?e.off.y:0;const s=void 0!==e.width?e.width:void 0!==e.cx?e.cx:void 0!==(e.ext&&e.ext.cx)?e.ext.cx:914400;const i=void 0!==e.height?e.height:void 0!==e.cy?e.cy:void 0!==(e.ext&&e.ext.cy)?e.ext.cy:914400;if(this.coordinateSystem){const{slideWidthEMU:t,slideHeightEMU:e}=this.coordinateSystem;const n=t||9144e3;const a=e||6858e3;const l={x:r/n,y:o/a,w:s/n,h:i/a};const c=this.graphics.context.canvas;let h,u;if(c.style.width&&c.style.height){h=parseFloat(c.style.width);u=parseFloat(c.style.height)}else{h=c.width/(window.devicePixelRatio||1);u=c.height/(window.devicePixelRatio||1)}const f=n/a;const d=h/u;let p,g,m,y;if(f>d){p=h;g=h/f;m=0;y=(u-g)/2}else{p=u*f;g=u;m=(h-p)/2;y=0}return{x:Math.round(m+l.x*p),y:Math.round(y+l.y*g),w:Math.round(l.w*p),h:Math.round(l.h*g)}}const n=t=>t/914400*96;return{x:n(r),y:n(o),w:n(s),h:n(i)}}if(t.properties&&t.properties.transform){const e=t.properties.transform;const r=e.x||0;const o=e.y||0;const s=e.width||914400;const i=e.height||914400;if(this.coordinateSystem){const{scale:t,offsetX:e,offsetY:n,slideWidthEMU:a,slideHeightEMU:l}=this.coordinateSystem;const c=a||9144e3;const h=l||6858e3;const u={x:r/c,y:o/h,w:s/c,h:i/h};const f=this.graphics.context.canvas;let d,p;if(f.style.width&&f.style.height){d=parseFloat(f.style.width);p=parseFloat(f.style.height)}else{d=f.width/(window.devicePixelRatio||1);p=f.height/(window.devicePixelRatio||1)}const g=c/h;const m=d/p;let y,b,x,S;if(g>m){y=d;b=d/g;x=0;S=(p-b)/2}else{y=p*g;b=p;x=(d-y)/2;S=0}const w={x:Math.round(x+u.x*y),y:Math.round(S+u.y*b),w:Math.round(u.w*y),h:Math.round(u.h*b)};return w}const n=t=>t/914400*96;const a={x:n(r),y:n(o),w:n(s),h:n(i)};return a}const e=t.position||t.transform;if(e&&(void 0!==e.x||void 0!==e.y||void 0!==e.width||void 0!==e.height)){const t=e.x||0;const r=e.y||0;const o=e.width||914400;const s=e.height||914400;if(this.coordinateSystem){const{slideWidthEMU:e,slideHeightEMU:i}=this.coordinateSystem;const n=e||9144e3;const a=i||6858e3;const l={x:t/n,y:r/a,w:o/n,h:s/a};const c=this.graphics.context.canvas;let h,u;if(c.style.width&&c.style.height){h=parseFloat(c.style.width);u=parseFloat(c.style.height)}else{h=c.width/(window.devicePixelRatio||1);u=c.height/(window.devicePixelRatio||1)}const f=n/a;const d=h/u;let p,g,m,y;if(f>d){p=h;g=h/f;m=0;y=(u-g)/2}else{p=u*f;g=u;m=(h-p)/2;y=0}return{x:Math.round(m+l.x*p),y:Math.round(y+l.y*g),w:Math.round(l.w*p),h:Math.round(l.h*g)}}const i=t=>t/914400*96;return{x:i(t),y:i(r),w:i(o),h:i(s)}}if(t.bounds){const e=t.bounds.l||0;const r=t.bounds.t||0;const o="number"===typeof t.bounds.r?t.bounds.r:e+1e6;const s="number"===typeof t.bounds.b?t.bounds.b:r+1e6;if(this.coordinateSystem){const{scale:t,offsetX:i,offsetY:n,slideWidthEMU:a,slideHeightEMU:l}=this.coordinateSystem;const c=a||9144e3;const h=l||6858e3;const u={x:e/c,y:r/h,w:(o-e)/c,h:(s-r)/h};const f=this.graphics.context.canvas;let d,p;if(f.style.width&&f.style.height){d=parseFloat(f.style.width);p=parseFloat(f.style.height)}else{d=f.width/(window.devicePixelRatio||1);p=f.height/(window.devicePixelRatio||1)}const g=c/h;const m=d/p;let y,b,x,S;if(g>m){y=d;b=d/g;x=0;S=(p-b)/2}else{y=p*g;b=p;x=(d-y)/2;S=0}const w={x:Math.round(x+u.x*y),y:Math.round(S+u.y*b),w:Math.round(u.w*y),h:Math.round(u.h*b)};return w}const i=t=>t/914400*96;const n={x:i(e),y:i(r),w:i(o-e),h:i(s-r)};return n}const r={x:50,y:50,w:100,h:50};return r}getShapeFillColor(t){if(t.fill&&"none"===t.fill.type)return null;if(t.properties&&t.properties.fill&&"none"===t.properties.fill.type)return null;if(this.processor&&this.processor.applyPropertyInheritance&&(!t.fill||null===t.fill)&&(!t.properties?.fill||null===t.properties?.fill))this.processor.applyPropertyInheritance(t,this.currentSlide);if(t.fill&&"none"===t.fill.type)return null;if(t.properties&&t.properties.fill&&"none"===t.properties.fill.type)return null;if(t.textBody&&t.placeholder&&!t.fill&&!t.properties?.fill&&!t.fillColor)return null;if(this.processor&&this.processor.getShapeFillColor){const e=this.processor.getShapeFillColor(t);if(void 0!==e)return e}const e=t.preservedStyle||t.style;if(e&&e.fillRef){if(t.textBody&&t.placeholder&&!t.fill&&!t.properties?.fill&&!t.fillColor)return null;if(this.processor&&this.processor.resolveStyleFillColor){const t=this.processor.resolveStyleFillColor(e.fillRef);if(t)return t}if(e.fillRef.color)return e.fillRef.color;if("layout"===this.currentSlide?.type&&t.textBody&&!t.fill&&!t.properties?.fill)return null;return"#FFFFFF"}if(t.textBody&&!t.placeholder&&t.fillColor){const e=t.fillColor;if("string"===typeof e){const t=e.replace("#","");if(6===t.length){const e=parseInt(t.substr(0,2),16);const r=parseInt(t.substr(2,2),16);const o=parseInt(t.substr(4,2),16);if(e>200&&r>240&&o>240)return null}}else if("object"===typeof e&&void 0!==e.r)if(e.r>200&&e.g>240&&e.b>240)return null}if(t.fill&&"solid"===t.fill.type&&t.fill.color)return t.fill.color;if(t.properties&&t.properties.fill&&t.properties.fill.color)return t.properties.fill.color;return t.fillColor||null}getShapeStrokeColor(t){const e=!!(t&&t.spPr&&t.spPr.ln||t&&t.properties&&t.properties.stroke||t&&t.stroke);if(!e)return null;if(this.processor&&this.processor.getShapeStrokeColor){const e=this.processor.getShapeStrokeColor(t);return e}const r=t.preservedStyle||t.style;if(r&&r.lnRef){if(this.processor&&this.processor.resolveStyleStrokeColor){const t=this.processor.resolveStyleStrokeColor(r.lnRef);if(t)return t}if(r.lnRef.color)return r.lnRef.color}if(t.stroke&&t.stroke.color)return t.stroke.color;if(t.properties&&t.properties.stroke&&t.properties.stroke.color)return t.properties.stroke.color;const o=t.strokeColor||null;return o}getShapeLineWidth(t){if(this.processor&&this.processor.getShapeLineWidth)return this.processor.getShapeLineWidth(t);const e=!!(t&&t.spPr&&t.spPr.ln||t&&t.properties&&t.properties.stroke||t&&t.stroke);if(!e)return 0;if(t.stroke&&t.stroke.width)return t.stroke.width/914400*25.4;if(t.properties&&t.properties.stroke&&t.properties.stroke.width)return t.properties.stroke.width/914400*25.4;if(t.spPr&&t.spPr.ln&&t.spPr.ln.w)return t.spPr.ln.w/914400*25.4;return 0}getShapeStrokeInfo(t){if(this.processor&&this.processor.getShapeStrokeInfo)return this.processor.getShapeStrokeInfo(t);if(t.stroke)return t.stroke;if(t.properties&&t.properties.stroke)return t.properties.stroke;return null}getShapeStrokeInfoLegacy(t){if(this.processor&&this.processor.getShapeStrokeInfo)return this.processor.getShapeStrokeInfo(t);if(t.stroke)return t.stroke;if(t.properties&&t.properties.stroke)return t.properties.stroke;return null}getParagraphProperties(t){return t.properties||{}}getRunProperties(t,e){return{...e,...t.properties||{}}}parseColor(t){if("string"===typeof t)if(t.startsWith("#")){const e=t.slice(1);return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16),a:255}}if(t&&"object"===typeof t)return t;return null}clipTextRect(t){this.graphics.AddClipRect(t.x,t.y,t.w,t.h)}getCanvasBounds(t){const e=t.getTransform();let r,o;if(t.canvas.style.width&&t.canvas.style.height){r=parseFloat(t.canvas.style.width);o=parseFloat(t.canvas.style.height)}else{r=t.canvas.width/(window.devicePixelRatio||1);o=t.canvas.height/(window.devicePixelRatio||1)}return this.currentShapeBounds||{x:0,y:0,w:r,h:o}}createCanvasGradient(t,e,r){if(!r||!r.stops||0===r.stops.length)return null;let o;if("linear"===r.type){const s=r.angle||0;const i=s*Math.PI/180;const n=e.x+e.w/2-Math.cos(i)*e.w/2;const a=e.y+e.h/2-Math.sin(i)*e.h/2;const l=e.x+e.w/2+Math.cos(i)*e.w/2;const c=e.y+e.h/2+Math.sin(i)*e.h/2;o=t.createLinearGradient(n,a,l,c)}else if("radial"===r.type){const r=e.x+e.w/2;const s=e.y+e.h/2;const i=Math.max(e.w,e.h)/2;o=t.createRadialGradient(r,s,0,r,s,i)}else return null;for(const t of r.stops){const e=this.colorToRgb(t.color);o.addColorStop(t.position,e)}return o}colorToRgbAlternative2(t){if("string"===typeof t)return t;if(t&&"object"===typeof t){const e=t.r||t.R||0;const r=t.g||t.G||0;const o=t.b||t.B||0;const s=(void 0!==t.a?t.a:void 0!==t.A?t.A:255)/255;return`rgba(${e}, ${r}, ${o}, ${s})`}return"#000000"}findLayoutShapeForPlaceholder(t,e){if(!e||!e.placeholder||!t)return null;const r=e.placeholder;for(const e of t)if(e.placeholder){const t=e.placeholder;const o=void 0===r.idx||null===r.idx||isNaN(Number(r.idx))?void 0:Number(r.idx);const s=void 0===t.idx||null===t.idx||isNaN(Number(t.idx))?void 0:Number(t.idx);const i=(t,e)=>{if(t===e)return true;const r=new Set([t,e]);if(r.has("title")&&r.has("ctrTitle"))return true;if(r.has("body")&&r.has("obj"))return true;return false};if(i(t.type,r.type)&&void 0!==o&&void 0!==s&&o===s)return e;if(i(t.type,r.type)&&(void 0===o||void 0===s))return e}return null}resolveInheritedTextProperties(t,e="run",r=0){const o={};try{const s=this.buildSlideContext();let i="otherStyle";if(t&&t.placeholder)switch(t.placeholder.type){case"title":case"ctrTitle":i="titleStyle";break;case"body":case"subTitle":case"obj":i="bodyStyle";break;default:i="otherStyle"}if(s.theme){if(s.theme.fonts){const t="titleStyle"===i;o.fontFamily=t?s.theme.fonts.major:s.theme.fonts.minor}if(s.theme.colors&&s.theme.colors.text1)o.color=this.parseColorFromTheme(s.theme.colors.text1)}if(s.master&&s.master.txStyles){const t=s.master.txStyles[i];if(t){const s=this.extractTextPropertiesFromStyle(t,e,r);Object.assign(o,s)}}if(s.layout&&s.layout.txStyles){const t=s.layout.txStyles[i];if(t){const s=this.extractTextPropertiesFromStyle(t,e,r);Object.assign(o,s)}}if(s.layout&&s.layout.shapes){const e=this.findLayoutShapeForPlaceholder(s.layout.shapes,t);if(e&&e.textBody&&e.textBody.lstStyle){const r=e.textBody.lstStyle;let s=0;try{if(t&&t.textBody&&Array.isArray(t.textBody.paragraphs)&&t.textBody.paragraphs.length>0){const e=t.textBody.paragraphs[0]?.properties?.level;if("number"===typeof e&&e>=0&&e<=8)s=e}}catch(t){}const i=`lvl${s+1}pPr`;const n=r[i]||r.lvl1pPr;if(n){if(n.fontSize)o.fontSize=n.fontSize;if(n.fontFamily)o.fontFamily=n.fontFamily;if(n.color)o.color=n.color;if(void 0!==n.bold)o.bold=n.bold;if(void 0!==n.italic)o.italic=n.italic;if(n.align)o.align=n.align;if(n.cap)o.cap=n.cap}}}if((!o.fontSize||!o.align||!o.fontFamily)&&s.master&&s.master.cSld&&s.master.cSld.spTree){const e=s.master.cSld.spTree;const r=this.findLayoutShapeForPlaceholder(e,t);if(r&&r.textBody&&r.textBody.lstStyle){const t=r.textBody.lstStyle;if(t.lvl1pPr){const e=t.lvl1pPr;if(!o.fontSize&&e.fontSize)o.fontSize=e.fontSize;if(!o.fontFamily&&e.fontFamily)o.fontFamily=e.fontFamily;if(!o.color&&e.color)o.color=e.color;if(void 0!==e.bold&&void 0===o.bold)o.bold=e.bold;if(void 0!==e.italic&&void 0===o.italic)o.italic=e.italic;if(!o.align&&e.align)o.align=e.align;if(!o.cap&&e.cap)o.cap=e.cap}}}if(t&&t.placeholder)switch(t.placeholder.type){case"title":case"ctrTitle":o.bold=void 0!==o.bold?o.bold:true}if("title"===t?.placeholder?.type||"ctrTitle"===t?.placeholder?.type){if(!o.align)o.align="ctr";if(!o.fontSize)o.fontSize=44}}catch(t){}return o}extractTextPropertiesFromStyle(t,e="run",r=0){const o={};if(!t||!t.element)return o;try{if(!t.parsed){t.parsedData=this.parseTextStyleElement(t.element);t.parsed=true}const s=t.parsedData;if(!s)return o;if("paragraph"===e||"run"===e){const t=s.defPPr;if(t){if(t.align)o.align=t.align;if(t.lineHeight)o.lineHeight=t.lineHeight;if(t.spaceBefore)o.spaceBefore=t.spaceBefore;if(t.spaceAfter)o.spaceAfter=t.spaceAfter;if(t.bullet)o.bullet=t.bullet}const e=s.defRPr;if(e){if(e.fontSize)o.fontSize=e.fontSize;if(e.fontFamily)o.fontFamily=e.fontFamily;if(e.color)o.color=e.color;if(void 0!==e.bold)o.bold=e.bold;if(void 0!==e.italic)o.italic=e.italic;if(void 0!==e.underline)o.underline=e.underline;if(void 0!==e.strike)o.strike=e.strike;if(e.cap)o.cap=e.cap}const i=r+1;const n=s[`lvl${i}pPr`];if(n){if(n.align)o.align=n.align;if(n.lineHeight)o.lineHeight=n.lineHeight;if(n.bullet)o.bullet=n.bullet;if(void 0!==n.leftMargin)o.leftMargin=n.leftMargin;if(void 0!==n.indent)o.hangingIndent=n.indent;if(n.defRPr){const t=n.defRPr;if(t.fontSize)o.fontSize=t.fontSize;if(t.fontFamily)o.fontFamily=t.fontFamily;if(t.color)o.color=t.color;if(void 0!==t.bold)o.bold=t.bold;if(void 0!==t.italic)o.italic=t.italic;if(t.cap)o.cap=t.cap}}}}catch(t){}return o}parseColorFromTheme(t){if("string"===typeof t)if(t.startsWith("#")){const e=t.substring(1);const r=parseInt(e.substring(0,2),16);const o=parseInt(e.substring(2,4),16);const s=parseInt(e.substring(4,6),16);return{r,g:o,b:s,a:255}}return null}parseTextStyleElement(t){const e={};if(!t)return e;try{const r=t.querySelector("defPPr, a\\:defPPr");if(r)e.defPPr=this.parseStyleParagraphProperties(r);const o=t.querySelector("defRPr, a\\:defRPr")||t.querySelector("defPPr > defRPr, a\\:defPPr > a\\:defRPr");if(o)e.defRPr=this.parseStyleRunProperties(o);for(let r=1;r<=9;r++){const o=t.querySelector(`lvl${r}pPr, a\\:lvl${r}pPr`);if(o){const t=this.parseStyleParagraphProperties(o);const s=o.querySelector("defRPr, a\\:defRPr");if(s)t.defRPr=this.parseStyleRunProperties(s);e[`lvl${r}pPr`]=t}}}catch(t){}return e}parseStyleParagraphProperties(t){const e={};if(!t)return e;try{const r=t.getAttribute("algn")||t.getAttribute("align");if(r){const t={l:"left",left:"left",ctr:"center",center:"center",r:"right",right:"right",just:"justify",justify:"justify"};e.align=t[r]||r}const o=t.getAttribute("lnSpc")||t.getAttribute("lineHeight");if(o)e.lineHeight=parseInt(o)||120;const s=t.getAttribute("spcBef")||t.getAttribute("spaceBefore");if(s)e.spaceBefore=parseInt(s)||0;const i=t.getAttribute("spcAft")||t.getAttribute("spaceAfter");if(i)e.spaceAfter=parseInt(i)||0;const n=t.getAttribute("marL")||t.getAttribute("leftMargin");if(n)e.leftMargin=parseInt(n)||0;const a=t.getAttribute("marR")||t.getAttribute("rightMargin");if(a)e.rightMargin=parseInt(a)||0;const l=t.getAttribute("indent");if(l)e.indent=parseInt(l)||0;const c=t.querySelector("buChar, a\\:buChar");if(c){const t=c.getAttribute("char");if(t)e.bullet={type:"character",char:t}}const h=t.querySelector("buAutoNum, a\\:buAutoNum");if(h){const t=h.getAttribute("type")||"arabicPeriod";const r=h.getAttribute("startAt")||"1";e.bullet={type:"autoNumber",subType:t,startAt:parseInt(r)}}const u=t.querySelector("buNone, a\\:buNone");if(u)e.bullet={type:"none"}}catch(t){}return e}parseStyleRunProperties(t){const e={};if(!t)return e;try{const r=t.getAttribute("sz")||t.getAttribute("fontSize");if(r){const t=parseInt(r);e.fontSize=t>100?t/100:t}const o=t.getAttribute("typeface")||t.getAttribute("fontFamily");if(o)e.fontFamily=o;const s=t.getAttribute("b")||t.getAttribute("bold");if(null!==s)e.bold="1"===s||"true"===s||true===s;const i=t.getAttribute("i")||t.getAttribute("italic");if(null!==i)e.italic="1"===i||"true"===i||true===i;const n=t.getAttribute("u")||t.getAttribute("underline");if(null!==n)e.underline="1"===n||"true"===n||true===n;const a=t.getAttribute("strike")||t.getAttribute("strikethrough");if(null!==a)e.strike="1"===a||"true"===a||true===a;const l=t.getAttribute("cap")||t.getAttribute("capitalization");if(l)e.cap=l;const c=t.querySelector("solidFill, a\\:solidFill")||t.querySelector("schemeClr, a\\:schemeClr")||t.querySelector("srgbClr, a\\:srgbClr");if(c)e.color=this.parseColorFromElement(c);const h=t.getAttribute("spc")||t.getAttribute("letterSpacing");if(h)e.letterSpacing=parseInt(h)||0}catch(t){}return e}parseColorFromElement(t){try{const e=t.querySelector("srgbClr, a\\:srgbClr");if(e){const t=e.getAttribute("val");if(t&&6===t.length){const e=parseInt(t.substr(0,2),16);const r=parseInt(t.substr(2,2),16);const o=parseInt(t.substr(4,2),16);return{r:e,g:r,b:o,a:255}}}const r=t.querySelector("schemeClr, a\\:schemeClr");if(r){const t=r.getAttribute("val");const e={};return e[t]||null}}catch(t){}return null}buildSlideContext(){const t={};if(this.currentSlide){t.slide=this.currentSlide;if(this.currentSlide.layout||this.currentSlide.Layout){t.layout=this.currentSlide.layout||this.currentSlide.Layout;if(t.layout.commonSlideData&&t.layout.commonSlideData.shapeTree)t.layout.shapes=t.layout.commonSlideData.shapeTree;else if(t.layout.cSld&&t.layout.cSld.spTree)t.layout.shapes=t.layout.cSld.spTree;if(t.layout.master||t.layout.Master)t.master=t.layout.master||t.layout.Master}if(this.currentSlide.theme||this.currentSlide.Theme)t.theme=this.currentSlide.theme||this.currentSlide.Theme}return t}getCurrentShape(){return this.currentRenderingShape||null}applyPreciseTransform(t,e=1,r=0){return Math.round(t*e+r)}setCurrentRenderingShape(t){this.currentRenderingShape=t}}class r{constructor(){this.cache=new Map}processShapeGeometry(t){const e=this.generateCacheKey(t);if(this.cache.has(e))return this.cache.get(e);let r=null;if(t.geometry&&"custom"===t.geometry.type)r=this.processCustomGeometry(t.geometry);else if(t.properties&&t.properties.geometry&&"custom"===t.properties.geometry.type)r=this.processCustomGeometry(t.properties.geometry);if(r)this.cache.set(e,r);return r}processCustomGeometry(t){if(!t.pathLst||0===t.pathLst.length)return null;const e={type:"custom",pathLst:[]};for(const r of t.pathLst){const t=this.processPath(r);if(t)e.pathLst.push(t)}return e}processPath(t){if(!t.commands||0===t.commands.length)return null;return{w:t.w||100,h:t.h||100,commands:t.commands.map(t=>this.normalizeCommand(t)),fill:false!==t.fill,stroke:false!==t.stroke}}normalizeCommand(t){const e={...t};switch(t.type){case"M":case"moveTo":e.type="moveTo";break;case"L":case"lineTo":e.type="lineTo";break;case"C":case"curveTo":case"cubicBezTo":e.type="cubicBezTo";break;case"Q":case"quadTo":case"quadBezTo":e.type="quadBezTo";break;case"A":case"arcTo":e.type="arcTo";break;case"Z":case"close":e.type="close"}return e}generateCacheKey(t){const e=t.geometry||t.properties?.geometry;if(!e)return"no-geometry";const r=e.pathLst||[];return`custom-${JSON.stringify(r).substring(0,100)}-${r.length}`}}if("undefined"!==typeof window){window.CanvasGraphicsAdapter=CanvasGraphicsAdapter;window.CDrawingDocument=CDrawingDocument;window.GraphicsMatrix=e;try{t()}catch(t){}}if("undefined"===typeof Logger&&"undefined"!==typeof window)window.Logger=class Logger{constructor(t){this.name=t}log(t,e,r){}logError(t,e){}};return tt}var ot=rt();var st=s(ot);var it={exports:{}};var nt=it.exports;var at;function lt(){if(at)return it.exports;at=1;!function(t){const e=0;const r=1;const o=2;const s=3;const i=4;const n=5;const a=6;const l=7;const c=8;const h=9;const u=10;const f=11;const d=12;const p=13;const g=14;const m=15;const y=16;const b={w:"w",h:"h",ss:"ss",ls:"ls",hc:"hc",vc:"vc",l:"l",t:"t",r:"r",b:"b",wd2:"wd2",hd2:"hd2",wd4:"wd4",hd4:"hd4",wd6:"wd6",hd6:"hd6",wd8:"wd8",hd8:"hd8",cd2:"cd2",cd4:"cd4",cd8:"cd8",_3cd4:"_3cd4",_3cd8:"_3cd8",_5cd8:"_5cd8",_7cd8:"_7cd8"};const x={rect:1,roundRect:2,ellipse:3,diamond:4,triangle:5,rtTriangle:6,parallelogram:7,trapezoid:8,hexagon:9,octagon:10,plus:11,star5:12,rightArrow:13,leftArrow:66,upArrow:68,downArrow:67,leftRightArrow:69,upDownArrow:70,quadArrow:76,heart:74,lightningBolt:73,can:22,cube:16,donut:23,arc:19,line:20,plaque:21,bevel:1e3,frame:75,pentagon:56,star4:1e3,star6:1e3,star8:58,star12:1e3,star16:59,star24:1e3,star32:60,teardrop:1e3,flowChartProcess:1e3,flowChartDecision:4,flowChartTerminator:2,flowChartInputOutput:7,flowChartDocument:1e3,flowChartMultidocument:1e3,flowChartPreparation:1e3,flowChartManualInput:1e3,flowChartManualOperation:1e3,flowChartConnector:3,flowChartOffpageConnector:1e3,flowChartPunchedCard:1e3,flowChartPunchedTape:1e3,flowChartSummingJunction:1e3,flowChartOr:1e3,flowChartCollate:1e3,flowChartSort:1e3,flowChartExtract:1e3,flowChartMerge:1e3,flowChartStoredData:1e3,flowChartDelay:1e3,flowChartSequentialAccessStorage:1e3,flowChartMagneticDisk:1e3,flowChartDirectAccessStorage:1e3,flowChartDisplay:1e3,flowChartInternalStorage:1e3,flowChartAlternateProcess:1e3,flowChartMagneticDrum:1e3,flowChartMagneticTape:1e3,callout1:1e3,callout2:1e3,callout3:1e3,accentCallout1:1e3,accentCallout2:1e3,accentCallout3:1e3,borderCallout1:1e3,borderCallout2:1e3,borderCallout3:1e3,accentBorderCallout1:1e3,accentBorderCallout2:1e3,accentBorderCallout3:1e3,ribbon:1e3,ribbon2:1e3,ellipseRibbon:1e3,ellipseRibbon2:1e3,leftRightRibbon:1e3,verticalScroll:1e3,horizontalScroll:1e3,wave:1e3,doubleWave:1e3,bentArrow:1e3,uturnArrow:1e3,circularArrow:1e3,leftUpArrow:1e3,bentUpArrow:1e3,curvedRightArrow:1e3,curvedLeftArrow:1e3,curvedUpArrow:1e3,curvedDownArrow:1e3,stripedRightArrow:1e3,notchedRightArrow:1e3,blockArc:1e3,swooshArrow:1e3,leftBracket:1e3,rightBracket:1e3,leftBrace:1e3,rightBrace:1e3,bracketPair:1e3,bracePair:1e3,straightConnector1:20,bentConnector2:1e3,bentConnector3:1e3,bentConnector4:1e3,bentConnector5:1e3,curvedConnector2:1e3,curvedConnector3:1e3,curvedConnector4:1e3,curvedConnector5:1e3,sun:1e3,moon:1e3,cloud:1e3,irregularSeal1:1e3,irregularSeal2:1e3,foldedCorner:1e3,smileyFace:1e3,noSmoking:1e3,mathPlus:11,mathMinus:1e3,mathMultiply:1e3,mathDivide:1e3,mathEqual:1e3,mathNotEqual:1e3,actionButtonBlank:1e3,actionButtonHome:1e3,actionButtonHelp:1e3,actionButtonInformation:1e3,actionButtonForwardNext:1e3,actionButtonBackPrevious:1e3,actionButtonEnd:1e3,actionButtonBeginning:1e3,actionButtonReturn:1e3,actionButtonDocument:1e3,actionButtonSound:1e3,actionButtonMovie:1e3};const S={RECTANGLE:"rect",ELLIPSE:"ellipse",LINE:"line",ROUND_RECTANGLE:"roundRect",RIGHT_ARROW:"rightArrow",LEFT_ARROW:"leftArrow",UP_ARROW:"upArrow",DOWN_ARROW:"downArrow",LEFT_RIGHT_ARROW:"leftRightArrow",UP_DOWN_ARROW:"upDownArrow",QUAD_ARROW:"quadArrow",LEFT_RIGHT_UP_ARROW:"leftRightUpArrow",BENT_ARROW:"bentArrow",UTURN_ARROW:"uturnArrow",LEFT_UP_ARROW:"leftUpArrow",BENT_UP_ARROW:"bentUpArrow",CURVED_RIGHT_ARROW:"curvedRightArrow",CURVED_LEFT_ARROW:"curvedLeftArrow",CURVED_UP_ARROW:"curvedUpArrow",CURVED_DOWN_ARROW:"curvedDownArrow",STRIPED_RIGHT_ARROW:"stripedRightArrow",NOTCHED_RIGHT_ARROW:"notchedRightArrow",BLOCK_ARC:"blockArc",SWOOSH_ARROW:"swooshArrow",CIRCULAR_ARROW:"circularArrow",FLOWCHART_PROCESS:"flowChartProcess",FLOWCHART_DECISION:"flowChartDecision",FLOWCHART_START_END:"flowChartTerminator",FLOWCHART_INPUT_OUTPUT:"flowChartInputOutput",FLOWCHART_PREDEFINED_PROCESS:"flowChartPredefinedProcess",FLOWCHART_INTERNAL_STORAGE:"flowChartInternalStorage",FLOWCHART_DOCUMENT:"flowChartDocument",FLOWCHART_MULTIDOCUMENT:"flowChartMultidocument",FLOWCHART_PREPARATION:"flowChartPreparation",FLOWCHART_MANUAL_INPUT:"flowChartManualInput",FLOWCHART_MANUAL_OPERATION:"flowChartManualOperation",FLOWCHART_CONNECTOR:"flowChartConnector",FLOWCHART_OFFPAGE_CONNECTOR:"flowChartOffpageConnector",FLOWCHART_PUNCHED_CARD:"flowChartPunchedCard",FLOWCHART_PUNCHED_TAPE:"flowChartPunchedTape",FLOWCHART_SUMMING_JUNCTION:"flowChartSummingJunction",FLOWCHART_OR:"flowChartOr",FLOWCHART_COLLATE:"flowChartCollate",FLOWCHART_SORT:"flowChartSort",FLOWCHART_EXTRACT:"flowChartExtract",FLOWCHART_MERGE:"flowChartMerge",FLOWCHART_STORED_DATA:"flowChartStoredData",FLOWCHART_DELAY:"flowChartDelay",FLOWCHART_SEQUENTIAL_ACCESS_STORAGE:"flowChartSequentialAccessStorage",FLOWCHART_MAGNETIC_DISK:"flowChartMagneticDisk",FLOWCHART_DIRECT_ACCESS_STORAGE:"flowChartDirectAccessStorage",FLOWCHART_DISPLAY:"flowChartDisplay",FLOWCHART_ALTERNATE_PROCESS:"flowChartAlternateProcess",FLOWCHART_MAGNETIC_DRUM:"flowChartMagneticDrum",FLOWCHART_MAGNETIC_TAPE:"flowChartMagneticTape",CALLOUT_1:"callout1",CALLOUT_2:"callout2",CALLOUT_3:"callout3",ACCENT_CALLOUT_1:"accentCallout1",ACCENT_CALLOUT_2:"accentCallout2",ACCENT_CALLOUT_3:"accentCallout3",BORDER_CALLOUT_1:"borderCallout1",BORDER_CALLOUT_2:"borderCallout2",BORDER_CALLOUT_3:"borderCallout3",ACCENT_BORDER_CALLOUT_1:"accentBorderCallout1",ACCENT_BORDER_CALLOUT_2:"accentBorderCallout2",ACCENT_BORDER_CALLOUT_3:"accentBorderCallout3",STAR_4:"star4",STAR_5:"star5",STAR_6:"star6",STAR_8:"star8",STAR_12:"star12",STAR_16:"star16",STAR_24:"star24",STAR_32:"star32",TRIANGLE:"triangle",RIGHT_TRIANGLE:"rtTriangle",DIAMOND:"diamond",PENTAGON:"pentagon",HEXAGON:"hexagon",HEPTAGON:"heptagon",OCTAGON:"octagon",DECAGON:"decagon",DODECAGON:"dodecagon",PARALLELOGRAM:"parallelogram",TRAPEZOID:"trapezoid",PLUS:"plus",CROSS:"cross",STRAIGHT_CONNECTOR_1:"straightConnector1",BENT_CONNECTOR_2:"bentConnector2",BENT_CONNECTOR_3:"bentConnector3",BENT_CONNECTOR_4:"bentConnector4",BENT_CONNECTOR_5:"bentConnector5",CURVED_CONNECTOR_2:"curvedConnector2",CURVED_CONNECTOR_3:"curvedConnector3",CURVED_CONNECTOR_4:"curvedConnector4",CURVED_CONNECTOR_5:"curvedConnector5",RIBBON:"ribbon",RIBBON_2:"ribbon2",ELLIPSE_RIBBON:"ellipseRibbon",ELLIPSE_RIBBON_2:"ellipseRibbon2",LEFT_RIGHT_RIBBON:"leftRightRibbon",VERTICAL_SCROLL:"verticalScroll",HORIZONTAL_SCROLL:"horizontalScroll",WAVE:"wave",DOUBLE_WAVE:"doubleWave",LEFT_BRACKET:"leftBracket",RIGHT_BRACKET:"rightBracket",LEFT_BRACE:"leftBrace",RIGHT_BRACE:"rightBrace",BRACKET_PAIR:"bracketPair",BRACE_PAIR:"bracePair",FRAME:"frame",L_SHAPE:"lShape",DIAGONAL_STRIPE:"diagStripe",CHORD:"chord",ARC:"arc",CUBE:"cube",CAN:"can",CONE:"cone",PYRAMID:"pyramid",HEART:"heart",LIGHTNING_BOLT:"lightningBolt",SUN:"sun",MOON:"moon",CLOUD:"cloud",SMILEY_FACE:"smileyFace",IRREGULAR_SEAL_1:"irregularSeal1",IRREGULAR_SEAL_2:"irregularSeal2",FOLDED_CORNER:"foldedCorner",BEVEL:"bevel",DONUT:"donut",NO_SMOKING:"noSmoking",BLOCK_ARC_2:"blockArc2",PLUS_MATH:"mathPlus",MINUS:"mathMinus",MULTIPLY:"mathMultiply",DIVIDE:"mathDivide",EQUAL:"mathEqual",NOT_EQUAL:"mathNotEqual",ACTION_BUTTON_BLANK:"actionButtonBlank",ACTION_BUTTON_HOME:"actionButtonHome",ACTION_BUTTON_HELP:"actionButtonHelp",ACTION_BUTTON_INFORMATION:"actionButtonInformation",ACTION_BUTTON_FORWARD_NEXT:"actionButtonForwardNext",ACTION_BUTTON_BACK_PREVIOUS:"actionButtonBackPrevious",ACTION_BUTTON_END:"actionButtonEnd",ACTION_BUTTON_BEGINNING:"actionButtonBeginning",ACTION_BUTTON_RETURN:"actionButtonReturn",ACTION_BUTTON_DOCUMENT:"actionButtonDocument",ACTION_BUTTON_SOUND:"actionButtonSound",ACTION_BUTTON_MOVIE:"actionButtonMovie",TEARDROP:"teardrop"};class CGraphics{constructor(t){this.setupHighResolutionCanvas(t);this.m_oContext=t.getContext("2d");this.m_dDpiX=96;this.m_dDpiY=96;this.m_dWidthMM=210;this.m_dHeightMM=297;if(t.style.width&&t.style.height){this.m_dWidth=parseFloat(t.style.width);this.m_dHeight=parseFloat(t.style.height)}else{this.m_dWidth=t.width/(window.devicePixelRatio||1);this.m_dHeight=t.height/(window.devicePixelRatio||1)}this.m_oTransform=new C;this.devicePixelRatio=window.devicePixelRatio||1;this.m_oCoordTransform=new C;this.m_oFullTransform=new C;this.m_oTransformStack=[];this.m_oClipStack=[];this.m_oPen=new T;this.m_oBrush=new P;this.m_oFont=new v;this.m_bIntegerGrid=false;this.m_bGlobalAlpha=false;this.m_dGlobalAlpha=1;this.m_bIsClipping=false;this.m_oClipRect=null;this.m_oPath=null;this.m_bIsDrawing=false;this.m_oEnhancedGeometryProcessor=new _;this.m_oCustomGeometryProcessor=new GeometryProcessor;this.calculateCoordTransform();this.calculateFullTransform();this.m_oContext.lineCap="round";this.m_oContext.lineJoin="round";this.m_oContext.textBaseline="alphabetic";this.m_oContext.textAlign="left"}setupHighResolutionCanvas(t){const e=t.getContext("2d");const r=window.devicePixelRatio||1;const o=t.clientWidth||t.width;const s=t.clientHeight||t.height;t.width=o*r;t.height=s*r;t.style.width=o+"px";t.style.height=s+"px";e.scale(r,r);e.imageSmoothingEnabled=true;e.imageSmoothingQuality="high"}drawImageHighRes(image,t,e,r,o,s=0,i=0,n=null,a=null){if(!this.m_oContext||!image)return;this.m_oContext.save();this.m_oContext.imageSmoothingEnabled=true;this.m_oContext.imageSmoothingQuality="high";try{if(null!==n&&null!==a)this.m_oContext.drawImage(image,s,i,n,a,t,e,r,o);else this.m_oContext.drawImage(image,t,e,r,o)}catch(t){}finally{this.m_oContext.restore()}}drawImage(image,t,e,r,o){this.drawImageHighRes(image,t,e,r,o)}drawPresetGeometry(t,e,r,o,s,i,n,a=1,l=null,c={}){if(!this.m_oContext)return;this.SaveGrState();try{const h=x[t]||1e3;if(1e3===h)this.drawCustomShape(t,e,r,o,s,i,n,a,l,c);else this.drawStandardPresetShape(h,t,e,r,o,s,i,n,a,l,c)}catch(t){this.drawRectangle(e,r,o,s,i,n,a,l)}finally{this.RestoreGrState()}}drawStandardPresetShape(t,e,r,o,s,i,n,a,l,c,h){const u=21600;const f=21600;const d=this.m_oEnhancedGeometryProcessor.processPresetGeometry(e,u,f,h);if(d)this.renderEnhancedGeometry(d,r,o,s,i,n,a,l,c);else this.drawBasicShape(e,r,o,s,i,n,a,l,c)}renderEnhancedGeometry(t,e,r,o,s,i,n,a,l){const c=this.m_oContext;const h=t.getPathList();const u=o/t.width;const f=s/t.height;c.save();c.translate(e,r);c.scale(u,f);h.forEach(c=>{this.renderEnhancedPath(c,t,i,n,a,l,{x:e,y:r,w:o,h:s})});c.restore()}renderEnhancedPath(t,e,r,o,s,i,n=null){const a=this.m_oContext;a.beginPath();t.commands.forEach(t=>{switch(t.type){case"M":a.moveTo(t.args[0],t.args[1]);break;case"L":a.lineTo(t.args[0],t.args[1]);break;case"C":a.bezierCurveTo(t.args[0],t.args[1],t.args[2],t.args[3],t.args[4],t.args[5]);break;case"Q":a.quadraticCurveTo(t.args[0],t.args[1],t.args[2],t.args[3]);break;case"A":this.renderArcCommand(a,t.args);break;case"Z":a.closePath()}});if("none"!==t.fill&&r){if(r&&"object"===typeof r&&"linear"===r.type&&r.stops){const t=n||{x:0,y:0,w:200,h:50};const e=this.createGradient(t.x,t.y,t.w,t.h,r);if(e)a.fillStyle=e;else a.fillStyle=this.colorToRgb(r.stops[0]?.color||{r:0,g:0,b:0})}else a.fillStyle=this.colorToRgb(r);a.fill()}if(t.stroke&&o){a.strokeStyle=this.colorToRgb(o);a.lineWidth=CoordinateTransform.mmToPixels(s||1);if(i)this.applyStrokeInfo(i);a.stroke()}}renderArcCommand(t,e){const[r,o,s,i,n,a,l]=e;const c=this.getCurrentPoint(t);if(!c)return;try{const e=(c.x+a)/2;const s=(c.y+l)/2;const i=Math.min(r,o);const h=Math.atan2(c.y-s,c.x-e);const u=Math.atan2(l-s,a-e);t.arc(e,s,i,h,u,!n)}catch(e){t.lineTo(a,l)}}getCurrentPoint(t){return{x:0,y:0}}drawCustomShape(t,e,r,o,s,i,n,a,l,c){const h=this.m_oCustomGeometryProcessor.processCustomShape(t,{x:e,y:r,width:o,height:s,adjustments:c});if(h&&h.pathLst)this.drawCustomGeometry(h,e,r,o,s,i,n,a);else this.drawBasicShape(t,e,r,o,s,i,n,a,l)}applyStrokeInfo(t){if(!t||!this.m_oContext)return;const e=this.m_oContext;if(t.dashArray&&t.dashArray.length>0){const r=e.lineWidth||1;const o=t.dashArray.map(t=>t*r);e.setLineDash(o)}const r=t.lineCap||t.cap;if(r)switch(r){case"rnd":case"round":e.lineCap="round";break;case"sq":case"square":e.lineCap="square";break;default:e.lineCap="butt"}const o=t.lineJoin||t.join;if(o)switch(o){case"round":e.lineJoin="round";break;case"bevel":e.lineJoin="bevel";break;default:e.lineJoin="miter"}if(t.miterLimit)e.miterLimit=t.miterLimit}drawBasicShape(t,e,r,o,s,i,n,a,l){const c=this.m_oContext;c.save();c.beginPath();switch(t){case"rect":case"rectangle":default:c.rect(e,r,o,s);break;case"ellipse":case"oval":c.ellipse(e+o/2,r+s/2,o/2,s/2,0,0,2*Math.PI);break;case"roundRect":this.drawRoundRectPath(c,e,r,o,s,.16667*Math.min(o,s));break;case"triangle":this.drawTrianglePath(c,e,r,o,s);break;case"diamond":this.drawDiamondPath(c,e,r,o,s);break;case"pentagon":this.drawPentagonPath(c,e,r,o,s);break;case"hexagon":this.drawHexagonPath(c,e,r,o,s);break;case"octagon":this.drawOctagonPath(c,e,r,o,s);break;case"star":case"star5":this.drawStarPath(c,e,r,o,s);break;case"rightArrow":this.drawRightArrowPath(c,e,r,o,s);break;case"leftArrow":this.drawLeftArrowPath(c,e,r,o,s);break;case"upArrow":this.drawUpArrowPath(c,e,r,o,s);break;case"downArrow":this.drawDownArrowPath(c,e,r,o,s)}if(i){c.fillStyle=this.colorToRgb(i);c.fill()}if(n){c.strokeStyle=this.colorToRgb(n);c.lineWidth=CoordinateTransform.mmToPixels(a||1);if(l)this.applyStrokeInfo(l);c.stroke()}c.restore()}drawCustomGeometry(t,e,r,o,s,i,n,a){try{if(!t||!t.pathLst||0===t.pathLst.length)return;this.m_oContext.save();this.m_oContext.translate(e,r);const l=t.coordSize?.width||1e3;const c=t.coordSize?.height||1e3;this.m_oContext.scale(o/l,s/c);t.pathLst.forEach((t,e)=>{this.drawGeometryPath(t,i,n,a)});this.m_oContext.restore()}catch(t){this.m_oContext.restore()}}drawGeometryPath(t,e,r,o){if(!t||!t.commands||0===t.commands.length)return;this.m_oContext.beginPath();t.commands.forEach(r=>{switch(r.type){case"moveTo":this.m_oContext.moveTo(r.x,r.y);break;case"lineTo":this.m_oContext.lineTo(r.x,r.y);break;case"curveTo":this.m_oContext.bezierCurveTo(r.x1,r.y1,r.x2,r.y2,r.x,r.y);break;case"close":if(e&&false!==t.fill&&"none"!==t.fill)this.m_oContext.closePath();break;case"arcTo":this.m_oContext.arcTo(r.x1,r.y1,r.x2,r.y2,r.radius);break;case"quadraticCurveTo":this.m_oContext.quadraticCurveTo(r.x1,r.y1,r.x,r.y)}});if(r&&false!==t.stroke){this.m_oContext.strokeStyle=this.colorToRgb(r);this.m_oContext.lineWidth=CoordinateTransform.mmToPixels(o||1);this.m_oContext.stroke()}if(e&&false!==t.fill&&"none"!==t.fill){this.m_oContext.fillStyle=this.colorToRgb(e);this.m_oContext.fill()}}drawShapePath(t,e,r,o,s){if(!t||!t.commands)return;this.m_oContext.beginPath();t.commands.forEach(t=>{switch(t.type){case"M":this.m_oContext.moveTo(t.x,t.y);break;case"L":this.m_oContext.lineTo(t.x,t.y);break;case"C":this.m_oContext.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"Q":this.m_oContext.quadraticCurveTo(t.x1,t.y1,t.x,t.y);break;case"A":this.drawArcCommand(t);break;case"Z":if(e&&false!==path.fill&&"none"!==path.fill)this.m_oContext.closePath()}});if(e){this.m_oContext.fillStyle=this.colorToRgb(e);this.m_oContext.fill()}if(r){this.m_oContext.strokeStyle=this.colorToRgb(r);this.m_oContext.lineWidth=o||1;if(s)this.applyStrokeInfo(s);this.m_oContext.stroke()}}applyStrokeInfoAlternative(t){if(!t)return;if(t.dashArray&&t.dashArray.length>0)this.m_oContext.setLineDash(t.dashArray);if(t.lineCap)this.m_oContext.lineCap=t.lineCap;if(t.lineJoin)this.m_oContext.lineJoin=t.lineJoin;if(t.miterLimit)this.m_oContext.miterLimit=t.miterLimit}drawArcCommand(t){const e=t.cx||t.x;const r=t.cy||t.y;const o=t.r||t.radius;const s=t.startAngle||0;const i=t.endAngle||2*Math.PI;const n=t.counterclockwise||false;this.m_oContext.arc(e,r,o,s,i,n)}drawRectangle(t,e,r,o,s,i,n,a){if(!this.m_oContext)return;this.m_oContext.save();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fillRect(t,e,r,o)}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;if(a)this.applyStrokeInfo(a);this.m_oContext.strokeRect(t,e,r,o)}this.m_oContext.restore()}drawEllipse(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=t+r/2;const l=e+o/2;const c=r/2;const h=o/2;this.m_oContext.ellipse(a,l,c,h,0,0,2*Math.PI);if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawRoundedRectangle(t,e,r,o,s,i,n,a){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const l=Math.min(r,o)/2;s=Math.min(s,l);this.m_oContext.moveTo(t+s,e);this.m_oContext.lineTo(t+r-s,e);this.m_oContext.quadraticCurveTo(t+r,e,t+r,e+s);this.m_oContext.lineTo(t+r,e+o-s);this.m_oContext.quadraticCurveTo(t+r,e+o,t+r-s,e+o);this.m_oContext.lineTo(t+s,e+o);this.m_oContext.quadraticCurveTo(t,e+o,t,e+o-s);this.m_oContext.lineTo(t,e+s);this.m_oContext.quadraticCurveTo(t,e,t+s,e);this.m_oContext.closePath();if(i){this.m_oContext.fillStyle=this.colorToRgb(i);this.m_oContext.fill()}if(n){this.m_oContext.strokeStyle=this.colorToRgb(n);this.m_oContext.lineWidth=a||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawTriangle(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();this.m_oContext.moveTo(t+r/2,e);this.m_oContext.lineTo(t+r,e+o);this.m_oContext.lineTo(t,e+o);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawDiamond(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=t+r/2;const l=e+o/2;this.m_oContext.moveTo(a,e);this.m_oContext.lineTo(t+r,l);this.m_oContext.lineTo(a,e+o);this.m_oContext.lineTo(t,l);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawRegularPolygon(t,e,r,o,s,i,n,a){if(!this.m_oContext||s<3)return;this.m_oContext.save();this.m_oContext.beginPath();const l=t+r/2;const c=e+o/2;const h=Math.min(r,o)/2;for(let t=0;t<s;t++){const e=2*t*Math.PI/s-Math.PI/2;const r=l+h*Math.cos(e);const o=c+h*Math.sin(e);if(0===t)this.m_oContext.moveTo(r,o);else this.m_oContext.lineTo(r,o)}this.m_oContext.closePath();if(i){this.m_oContext.fillStyle=this.colorToRgb(i);this.m_oContext.fill()}if(n){this.m_oContext.strokeStyle=this.colorToRgb(n);this.m_oContext.lineWidth=a||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawStar(t,e,r,o,s,i,n,a){if(!this.m_oContext||s<3)return;this.m_oContext.save();this.m_oContext.beginPath();const l=t+r/2;const c=e+o/2;const h=Math.min(r,o)/2;const u=.4*h;for(let t=0;t<2*s;t++){const e=t*Math.PI/s-Math.PI/2;const r=t%2===0?h:u;const o=l+r*Math.cos(e);const i=c+r*Math.sin(e);if(0===t)this.m_oContext.moveTo(o,i);else this.m_oContext.lineTo(o,i)}this.m_oContext.closePath();if(i){this.m_oContext.fillStyle=this.colorToRgb(i);this.m_oContext.fill()}if(n){this.m_oContext.strokeStyle=this.colorToRgb(n);this.m_oContext.lineWidth=a||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawRightArrow(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=.7*r;const l=.4*o;const c=.3*r;const h=.6*o;this.m_oContext.moveTo(t,e+(o-l)/2);this.m_oContext.lineTo(t+a,e+(o-l)/2);this.m_oContext.lineTo(t+a,e+(o-h)/2);this.m_oContext.lineTo(t+r,e+o/2);this.m_oContext.lineTo(t+a,e+(o+h)/2);this.m_oContext.lineTo(t+a,e+(o+l)/2);this.m_oContext.lineTo(t,e+(o+l)/2);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawLeftArrow(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=.7*r;const l=.4*o;const c=.3*r;const h=.6*o;this.m_oContext.moveTo(t,e+o/2);this.m_oContext.lineTo(t+c,e+(o-h)/2);this.m_oContext.lineTo(t+c,e+(o-l)/2);this.m_oContext.lineTo(t+r,e+(o-l)/2);this.m_oContext.lineTo(t+r,e+(o+l)/2);this.m_oContext.lineTo(t+c,e+(o+l)/2);this.m_oContext.lineTo(t+c,e+(o+h)/2);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawHeart(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=t+r/2;const l=e+.3*o;this.m_oContext.moveTo(a,l);this.m_oContext.bezierCurveTo(a-.3*r,e,t,e+.3*o,a,e+.8*o);this.m_oContext.bezierCurveTo(t+r,e+.3*o,a+.3*r,e,a,l);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawTeardrop(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=t+r/2;const l=e+.7*o;const c=.3*Math.min(r,o);this.m_oContext.arc(a,l,c,0,2*Math.PI);this.m_oContext.moveTo(a,l-c);this.m_oContext.quadraticCurveTo(a-.5*c,e+.2*o,a,e);this.m_oContext.quadraticCurveTo(a+.5*c,e+.2*o,a,l-c);if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawCylinder(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();const a=.15*o;const l=r/2;const c=a/2;const h=t+r/2;if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fillRect(t,e+c,r,o-a)}this.m_oContext.beginPath();this.m_oContext.ellipse(h,e+c,l,c,0,0,2*Math.PI);if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}this.m_oContext.beginPath();this.m_oContext.ellipse(h,e+o-c,l,c,0,0,2*Math.PI);if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.beginPath();this.m_oContext.moveTo(t,e+c);this.m_oContext.lineTo(t,e+o-c);this.m_oContext.moveTo(t+r,e+c);this.m_oContext.lineTo(t+r,e+o-c);this.m_oContext.stroke();this.m_oContext.beginPath();this.m_oContext.ellipse(h,e+c,l,c,0,0,2*Math.PI);this.m_oContext.stroke();this.m_oContext.beginPath();this.m_oContext.ellipse(h,e+o-c,l,c,0,0,2*Math.PI);this.m_oContext.stroke()}this.m_oContext.restore()}drawCube(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();const a=.3*Math.min(r,o);if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fillRect(t,e+a,r-a,o-a)}this.m_oContext.beginPath();this.m_oContext.moveTo(t,e+a);this.m_oContext.lineTo(t+a,e);this.m_oContext.lineTo(t+r,e);this.m_oContext.lineTo(t+r-a,e+a);this.m_oContext.closePath();if(s){const t=this.darkenColor(s,.8);this.m_oContext.fillStyle=this.colorToRgb(t);this.m_oContext.fill()}this.m_oContext.beginPath();this.m_oContext.moveTo(t+r-a,e+a);this.m_oContext.lineTo(t+r,e);this.m_oContext.lineTo(t+r,e+o-a);this.m_oContext.lineTo(t+r-a,e+o);this.m_oContext.closePath();if(s){const t=this.darkenColor(s,.6);this.m_oContext.fillStyle=this.colorToRgb(t);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.strokeRect(t,e+a,r-a,o-a);this.m_oContext.beginPath();this.m_oContext.moveTo(t,e+a);this.m_oContext.lineTo(t+a,e);this.m_oContext.lineTo(t+r,e);this.m_oContext.lineTo(t+r-a,e+a);this.m_oContext.closePath();this.m_oContext.stroke();this.m_oContext.beginPath();this.m_oContext.moveTo(t+r-a,e+a);this.m_oContext.lineTo(t+r,e);this.m_oContext.lineTo(t+r,e+o-a);this.m_oContext.lineTo(t+r-a,e+o);this.m_oContext.closePath();this.m_oContext.stroke();this.m_oContext.beginPath();this.m_oContext.moveTo(t,e+a);this.m_oContext.lineTo(t+a,e);this.m_oContext.moveTo(t+r-a,e+a);this.m_oContext.lineTo(t+r,e);this.m_oContext.moveTo(t+r-a,e+o);this.m_oContext.lineTo(t+r,e+o-a);this.m_oContext.stroke()}this.m_oContext.restore()}drawPlus(t,e,r,o,s,i,n){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();const a=.3*Math.min(r,o);const l=t+r/2;const c=e+o/2;this.m_oContext.moveTo(t,c-a/2);this.m_oContext.lineTo(t+r,c-a/2);this.m_oContext.lineTo(t+r,c+a/2);this.m_oContext.lineTo(t,c+a/2);this.m_oContext.closePath();this.m_oContext.moveTo(l-a/2,e);this.m_oContext.lineTo(l+a/2,e);this.m_oContext.lineTo(l+a/2,e+o);this.m_oContext.lineTo(l-a/2,e+o);this.m_oContext.closePath();if(s){this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fill()}if(i){this.m_oContext.strokeStyle=this.colorToRgb(i);this.m_oContext.lineWidth=n||1;this.m_oContext.stroke()}this.m_oContext.restore()}drawLine(t,e,r,o,s,i){if(!this.m_oContext)return;this.m_oContext.save();this.m_oContext.beginPath();this.m_oContext.moveTo(t,e);this.m_oContext.lineTo(r,o);const n=this.colorToRgb(s)||"rgba(0,0,0,1)";this.m_oContext.strokeStyle=n;const a=CoordinateTransform.mmToPixels(i||1);this.m_oContext.lineWidth=a;this.m_oContext.stroke();this.m_oContext.restore()}drawLineWithArrows(t,e,r,o,s,i=1,n=null){if(!this.m_oContext)return;const a=this.m_oContext;a.save();a.beginPath();a.moveTo(t,e);a.lineTo(r,o);const l=this.colorToRgb(s)||"rgba(0,0,0,1)";a.strokeStyle=l;const c=Math.max(CoordinateTransform.mmToPixels(i||1),1);a.lineWidth=c;if(n)this.applyStrokeInfo(n);a.stroke();const h=t=>{const e=(t||"").toString().toLowerCase();if("lg"===e||"large"===e)return 3;if("med"===e||"medium"===e)return 2;if("sm"===e||"small"===e)return 1;return 2};let u=n&&n.headEnd?{type:n.headEnd.type||n.headEnd.val||"none",lengthScale:h(n.headEnd.len),widthScale:h(n.headEnd.w)}:null;let f=n&&n.tailEnd?{type:n.tailEnd.type||n.tailEnd.val||"none",lengthScale:h(n.tailEnd.len),widthScale:h(n.tailEnd.w)}:null;if(u&&("none"===u.type||null===u.type||void 0===u.type))u=null;if(f&&("none"===f.type||null===f.type||void 0===f.type))f=null;if(u||f){const s=Math.atan2(o-e,r-t);const i=a.getTransform();const n=Math.sqrt(i.a*i.a+i.b*i.b);const c=3*a.lineWidth;const h=2.5*a.lineWidth;if(u){const r=u.lengthScale||1;const o=u.widthScale||1;this._drawArrowHead(a,t,e,s+Math.PI,c*r,h*o,l,a.lineWidth,u.type)}if(f){const t=f.lengthScale||1;const e=f.widthScale||1;this._drawArrowHead(a,r,o,s,c*t,h*e,l,a.lineWidth,f.type)}}a.restore()}_drawArrowHead(t,e,r,o,s,i,n,a,l="triangle"){t.save();t.translate(e,r);t.rotate(o);const c=i/2;const h=(l||"triangle").toString().toLowerCase();t.beginPath();switch(h){case"open":t.moveTo(0,0);t.lineTo(-s,-c);t.moveTo(0,0);t.lineTo(-s,c);break;case"stealth":t.moveTo(0,0);t.lineTo(-s,-.5*c);t.lineTo(.85*-s,0);t.lineTo(-s,.5*c);t.closePath();break;case"diamond":t.moveTo(0,0);t.lineTo(-s/2,-c);t.lineTo(-s,0);t.lineTo(-s/2,c);t.closePath();break;case"oval":t.ellipse(-s/2,0,s/2,c,0,0,2*Math.PI);break;default:t.moveTo(0,0);t.lineTo(-s,-c);t.lineTo(-s,c);t.closePath()}const u="string"===typeof n?n:this.colorToRgb(n)||"rgba(0,0,0,1)";if("open"===h){t.strokeStyle=u;t.lineWidth=a||1;t.stroke()}else{t.fillStyle=u;t.fill();t.strokeStyle=u;t.lineWidth=Math.max(.5,.3*(a||1));t.stroke()}t.restore()}darkenColor(t,e){if("string"===typeof t){const r=this.hexToRgb(t);return{r:Math.floor(r.r*e),g:Math.floor(r.g*e),b:Math.floor(r.b*e),a:r.a}}else if(void 0!==t.r)return{r:Math.floor(t.r*e),g:Math.floor(t.g*e),b:Math.floor(t.b*e),a:t.a};return t}colorToRgb(t){if("string"===typeof t)return t;else if(t&&void 0!==t.r){const e=void 0!==t.a?t.a/255:1;return`rgba(${t.r}, ${t.g}, ${t.b}, ${e})`}return null}createGradient(t,e,r,o,s){if(!this.m_oContext||!s||!s.stops||0===s.stops.length)return null;let i;if("linear"===s.type){const n=s.angle||0;const a=n*Math.PI/180;const l=t+r/2-Math.cos(a)*r/2;const c=e+o/2-Math.sin(a)*o/2;const h=t+r/2+Math.cos(a)*r/2;const u=e+o/2+Math.sin(a)*o/2;i=this.m_oContext.createLinearGradient(l,c,h,u)}else{const s=t+r/2;const n=e+o/2;const a=Math.max(r,o)/2;i=this.m_oContext.createRadialGradient(s,n,0,s,n,a)}for(const t of s.stops)i.addColorStop(t.position,this.colorToRgb(t.color));return i}fillRect(t,e,r,o,s){if(!this.m_oContext||!s)return;this.m_oContext.save();if(s&&"object"===typeof s&&"linear"===s.type&&s.stops){const i=this.createGradient(t,e,r,o,s);if(i)this.m_oContext.fillStyle=i;else this.m_oContext.fillStyle=this.colorToRgb(s.stops[0]?.color||{r:0,g:0,b:0})}else this.m_oContext.fillStyle=this.colorToRgb(s);this.m_oContext.fillRect(t,e,r,o);this.m_oContext.restore()}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16),a:255}:{r:0,g:0,b:0,a:255}}SaveGrState(){this.m_oContext.save();this.m_oTransformStack.push(this.m_oTransform.CreateDublicate())}RestoreGrState(){this.m_oContext.restore();if(this.m_oTransformStack.length>0)this.m_oTransform=this.m_oTransformStack.pop()}calculateCoordTransform(){this.m_oCoordTransform.Reset();this.m_oCoordTransform.sx=this.m_dWidth/this.m_dWidthMM;this.m_oCoordTransform.sy=this.m_dHeight/this.m_dHeightMM}calculateFullTransform(){this.m_oFullTransform=this.m_oCoordTransform.CreateDublicate();this.m_oFullTransform.Multiply(this.m_oTransform,1)}drawRoundRectPath(t,e,r,o,s,i){t.beginPath();t.moveTo(e+i,r);t.lineTo(e+o-i,r);t.quadraticCurveTo(e+o,r,e+o,r+i);t.lineTo(e+o,r+s-i);t.quadraticCurveTo(e+o,r+s,e+o-i,r+s);t.lineTo(e+i,r+s);t.quadraticCurveTo(e,r+s,e,r+s-i);t.lineTo(e,r+i);t.quadraticCurveTo(e,r,e+i,r)}drawTrianglePath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s);t.lineTo(e,r+s);t.closePath()}drawDiamondPath(t,e,r,o,s){t.moveTo(e+o/2,r);t.lineTo(e+o,r+s/2);t.lineTo(e+o/2,r+s);t.lineTo(e,r+s/2);t.closePath()}drawPentagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.moveTo(i,r);for(let e=1;e<5;e++){const r=2*e*Math.PI/5-Math.PI/2;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);t.lineTo(o,s)}t.closePath()}drawHexagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.moveTo(i+a,n);for(let e=1;e<6;e++){const r=e*Math.PI/3;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);t.lineTo(o,s)}t.closePath()}drawOctagonPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;t.moveTo(i+a,n);for(let e=1;e<8;e++){const r=e*Math.PI/4;const o=i+a*Math.cos(r);const s=n+a*Math.sin(r);t.lineTo(o,s)}t.closePath()}drawStarPath(t,e,r,o,s){const i=e+o/2;const n=r+s/2;const a=Math.min(o,s)/2;const l=.4*a;t.moveTo(i,r);for(let e=0;e<10;e++){const r=e*Math.PI/5-Math.PI/2;const o=e%2===0?a:l;const s=i+o*Math.cos(r);const c=n+o*Math.sin(r);t.lineTo(s,c)}t.closePath()}drawRightArrowPath(t,e,r,o,s){const i=.6*o;const n=s;const a=.6*s;const l=r+(s-a)/2;t.moveTo(e,l);t.lineTo(e+i,l);t.lineTo(e+i,r);t.lineTo(e+o,r+s/2);t.lineTo(e+i,r+s);t.lineTo(e+i,l+a);t.lineTo(e,l+a);t.closePath()}drawLeftArrowPath(t,e,r,o,s){const i=.4*o;const n=.6*s;const a=r+(s-n)/2;t.moveTo(e,r+s/2);t.lineTo(e+i,r);t.lineTo(e+i,a);t.lineTo(e+o,a);t.lineTo(e+o,a+n);t.lineTo(e+i,a+n);t.lineTo(e+i,r+s);t.closePath()}drawUpArrowPath(t,e,r,o,s){const i=.4*s;const n=.6*o;const a=e+(o-n)/2;t.moveTo(e+o/2,r);t.lineTo(e+o,r+i);t.lineTo(a+n,r+i);t.lineTo(a+n,r+s);t.lineTo(a,r+s);t.lineTo(a,r+i);t.lineTo(e,r+i);t.closePath()}drawDownArrowPath(t,e,r,o,s){const i=.4*s;const n=.6*o;const a=e+(o-n)/2;const l=r+s-i;t.moveTo(a,r);t.lineTo(a+n,r);t.lineTo(a+n,l);t.lineTo(e+o,l);t.lineTo(e+o/2,r+s);t.lineTo(e,l);t.lineTo(a,l);t.closePath()}}class w{constructor(){this.shapeCache=new Map;this.pathCache=new Map}processPresetShape(t,e,r){const o=`${t}_${e}_${r.width}_${r.height}`;if(this.shapeCache.has(o))return this.shapeCache.get(o);let s=null;switch(t){case 1:s=this.createRectangleShape(r);break;case 2:s=this.createRoundRectShape(r);break;case 3:s=this.createEllipseShape(r);break;case 4:s=this.createDiamondShape(r);break;case 5:s=this.createTriangleShape(r);break;case 6:s=this.createRightTriangleShape(r);break;case 7:s=this.createParallelogramShape(r);break;case 8:s=this.createTrapezoidShape(r);break;case 9:s=this.createHexagonShape(r);break;case 10:s=this.createOctagonShape(r);break;case 11:s=this.createPlusShape(r);break;case 12:s=this.createStar5Shape(r);break;case 13:s=this.createRightArrowShape(r);break;case 20:s=this.createLineShape(r);break;case 22:s=this.createCylinderShape(r);break;case 56:s=this.createPentagonShape(r);break;case 66:s=this.createLeftArrowShape(r);break;case 67:s=this.createDownArrowShape(r);break;case 68:s=this.createUpArrowShape(r);break;case 69:s=this.createLeftRightArrowShape(r);break;case 70:s=this.createUpDownArrowShape(r);break;case 74:s=this.createHeartShape(r);break;case 76:s=this.createQuadArrowShape(r);break;default:return null}if(s)this.shapeCache.set(o,s);return s}createRectangleShape(t){return{type:"preset",onlyOfficeType:1,path:{commands:[{type:"M",x:t.x,y:t.y},{type:"L",x:t.x+t.width,y:t.y},{type:"L",x:t.x+t.width,y:t.y+t.height},{type:"L",x:t.x,y:t.y+t.height},{type:"Z"}]}}}createEllipseShape(t){const e=t.x+t.width/2;const r=t.y+t.height/2;const o=t.width/2;const s=t.height/2;return{type:"preset",onlyOfficeType:3,path:{commands:[{type:"M",x:e+o,y:r},{type:"A",rx:o,ry:s,x:e-o,y:r,rotation:0,largeArc:0,sweep:1},{type:"A",rx:o,ry:s,x:e+o,y:r,rotation:0,largeArc:0,sweep:1},{type:"Z"}]}}}createDiamondShape(t){const e=t.x+t.width/2;const r=t.y+t.height/2;return{type:"preset",onlyOfficeType:4,path:{commands:[{type:"M",x:e,y:t.y},{type:"L",x:t.x+t.width,y:r},{type:"L",x:e,y:t.y+t.height},{type:"L",x:t.x,y:r},{type:"Z"}]}}}createTriangleShape(t){return{type:"preset",onlyOfficeType:5,path:{commands:[{type:"M",x:t.x+t.width/2,y:t.y},{type:"L",x:t.x+t.width,y:t.y+t.height},{type:"L",x:t.x,y:t.y+t.height},{type:"Z"}]}}}createRightArrowShape(t){const e=.7*t.width;const r=.4*t.height;const o=.3*t.width;const s=.6*t.height;return{type:"preset",onlyOfficeType:13,path:{commands:[{type:"M",x:t.x,y:t.y+(t.height-r)/2},{type:"L",x:t.x+e,y:t.y+(t.height-r)/2},{type:"L",x:t.x+e,y:t.y+(t.height-s)/2},{type:"L",x:t.x+t.width,y:t.y+t.height/2},{type:"L",x:t.x+e,y:t.y+(t.height+s)/2},{type:"L",x:t.x+e,y:t.y+(t.height+r)/2},{type:"L",x:t.x,y:t.y+(t.height+r)/2},{type:"Z"}]}}}createHeartShape(t){const e=t.x+t.width/2;const r=t.y+.3*t.height;return{type:"preset",onlyOfficeType:74,path:{commands:[{type:"M",x:e,y:r},{type:"C",x1:e-.3*t.width,y1:t.y,x2:t.x,y2:t.y+.3*t.height,x:e,y:t.y+.8*t.height},{type:"C",x1:t.x+t.width,y1:t.y+.3*t.height,x2:e+.3*t.width,y2:t.y,x:e,y:r},{type:"Z"}]}}}createLeftArrowShape(t){const e=.7*t.width;const r=.4*t.height;const o=.3*t.width;const s=.6*t.height;return{type:"preset",onlyOfficeType:66,path:{commands:[{type:"M",x:t.x,y:t.y+t.height/2},{type:"L",x:t.x+o,y:t.y+(t.height-s)/2},{type:"L",x:t.x+o,y:t.y+(t.height-r)/2},{type:"L",x:t.x+t.width,y:t.y+(t.height-r)/2},{type:"L",x:t.x+t.width,y:t.y+(t.height+r)/2},{type:"L",x:t.x+o,y:t.y+(t.height+r)/2},{type:"L",x:t.x+o,y:t.y+(t.height+s)/2},{type:"Z"}]}}}createPlusShape(t){const e=.3*Math.min(t.width,t.height);const r=t.x+t.width/2;const o=t.y+t.height/2;return{type:"preset",onlyOfficeType:11,path:{commands:[{type:"M",x:t.x,y:o-e/2},{type:"L",x:t.x+t.width,y:o-e/2},{type:"L",x:t.x+t.width,y:o+e/2},{type:"L",x:t.x,y:o+e/2},{type:"Z"},{type:"M",x:r-e/2,y:t.y},{type:"L",x:r+e/2,y:t.y},{type:"L",x:r+e/2,y:t.y+t.height},{type:"L",x:r-e/2,y:t.y+t.height},{type:"Z"}]}}}}class C{constructor(){this.sx=1;this.shy=0;this.shx=0;this.sy=1;this.tx=0;this.ty=0}Reset(){this.sx=1;this.shy=0;this.shx=0;this.sy=1;this.tx=0;this.ty=0}CreateDublicate(){const t=new C;t.sx=this.sx;t.shy=this.shy;t.shx=this.shx;t.sy=this.sy;t.tx=this.tx;t.ty=this.ty;return t}Multiply(t,e){if(1===e){const e=this.sx*t.sx+this.shy*t.shx;const r=this.sx*t.shy+this.shy*t.sy;const o=this.shx*t.sx+this.sy*t.shx;const s=this.shx*t.shy+this.sy*t.sy;const i=this.tx*t.sx+this.ty*t.shx+t.tx;const n=this.tx*t.shy+this.ty*t.sy+t.ty;this.sx=e;this.shy=r;this.shx=o;this.sy=s;this.tx=i;this.ty=n}else{const e=t.sx*this.sx+t.shy*this.shx;const r=t.sx*this.shy+t.shy*this.sy;const o=t.shx*this.sx+t.sy*this.shx;const s=t.shx*this.shy+t.sy*this.sy;const i=t.tx*this.sx+t.ty*this.shx+this.tx;const n=t.tx*this.shy+t.ty*this.sy+this.ty;this.sx=e;this.shy=r;this.shx=o;this.sy=s;this.tx=i;this.ty=n}}}class T{constructor(){this.Color={r:0,g:0,b:0,a:255};this.Alpha=255;this.Size=1;this.DashStyle=0;this.LineJoin=0;this.LineCap=0;this.MiterLimit=10}}class P{constructor(){this.Type=0;this.Color1={r:0,g:0,b:0,a:255};this.Color2={r:255,g:255,b:255,a:255};this.Alpha1=255;this.Alpha2=255;this.TexturePath="";this.TextureMode=0;this.TextureAlpha=255;this.LinearAngle=0;this.Rectable={x:0,y:0,w:0,h:0}}}class v{constructor(){this.Name="Arial";this.Size=12;this.Bold=false;this.Italic=false;this.Underline=false;this.Strikeout=false;this.Path="";this.FaceIndex=0;this.CharSpace=0}}if("object"!=="undefined"&&t.exports)t.exports={CGraphics,StandardShapeProcessor:w,StandardShapeTypes:x,OpenXmlShapeTypes:S,CMatrix:C,CPen:T,CBrush:P,CFont:v};const M={toRadians:function(t){return t*Math.PI/180},toDegrees:function(t){return 180*t/Math.PI},Sin:function(t){return Math.sin(t*Math.PI/108e5)},Cos:function(t){return Math.cos(t*Math.PI/108e5)},Tan:function(t){return Math.tan(t*Math.PI/108e5)},ATan2:function(t,e){return 108e5*Math.atan2(t,e)/Math.PI},CAt2:function(t,e,r){return t*Math.cos(Math.atan2(r,e))},SAt2:function(t,e,r){return t*Math.sin(Math.atan2(r,e))}};class A{constructor(){this.preset=null;this.pathLst=[];this.gdLst={};this.gdLstInfo=[];this.avLst={};this.adjLst={};this.ahXYLst=[];this.ahPolarLst=[];this.cnxLst=[];this.rect=null;this.width=21600;this.height=21600;this.isCalculated=false}setPreset(t){this.preset=t;this.isCalculated=false}addAdjustment(t,e,r,o){this.adjLst[t]={value:e,min:r||null,max:o||null};this.avLst[t]=true;this.isCalculated=false}addGuide(t,e,r,o,s){this.gdLstInfo.push({name:t,formula:e,x:r,y:o,z:s});this.isCalculated=false}calculateGuideValue(t,b,x,S,w){const C=this.getValue(x);const T=this.getValue(S);const P=this.getValue(w);let v=0;switch(b){case e:v=0!==P?C*T/P:0;break;case r:v=C+T-P;break;case o:v=0!==P?(C+T)/P:0;break;case s:v=C>0?T:P;break;case i:v=Math.abs(C);break;case n:v=M.ATan2(T,C);break;case a:v=M.CAt2(C,T,P);break;case l:v=C*M.Cos(T);break;case c:v=Math.max(C,T);break;case h:v=Math.min(C,T);break;case u:v=Math.sqrt(C*C+T*T+P*P);break;case f:if(T<C)v=C;else if(T>P)v=P;else v=T;break;case d:v=M.SAt2(C,T,P);break;case p:v=C*M.Sin(T);break;case g:v=Math.sqrt(Math.max(0,C));break;case m:v=C*M.Tan(T);break;case y:v=C;break;default:v=0}if(isNaN(v))v=0;this.gdLst[t]=v;return v}getValue(t){if("number"===typeof t)return t;if("string"===typeof t){const e=parseFloat(t);if(!isNaN(e))return e;switch(t){case"w":case"r":return this.width;case"h":case"b":return this.height;case"ss":return Math.min(this.width,this.height);case"ls":return Math.max(this.width,this.height);case"hc":case"wd2":return this.width/2;case"vc":case"hd2":return this.height/2;case"l":case"t":return 0;case"wd4":return this.width/4;case"hd4":return this.height/4;case"wd6":return this.width/6;case"hd6":return this.height/6;case"wd8":return this.width/8;case"hd8":return this.height/8;case"cd2":return 108e5;case"cd4":return 54e5;case"cd8":return 27e5;case"_3cd4":return 162e5;case"_3cd8":return 81e5;case"_5cd8":return 135e5;case"_7cd8":return 189e5}if(this.gdLst.hasOwnProperty(t))return this.gdLst[t];if(this.adjLst.hasOwnProperty(t))return this.adjLst[t].value}return 0}calculateGuides(){this.gdLst={};for(let t=0;t<this.gdLstInfo.length;t++){const e=this.gdLstInfo[t];this.calculateGuideValue(e.name,e.formula,e.x,e.y,e.z)}this.isCalculated=true}recalculate(t,e){this.width=t||21600;this.height=e||21600;this.calculateGuides()}addPath(t){this.pathLst.push(t)}getPathList(){if(!this.isCalculated)this.calculateGuides();return this.pathLst}}class E{constructor(){this.commands=[];this.fill="norm";this.stroke=true;this.w=void 0;this.h=void 0;this.extrusionOk=false}addCommand(t,...e){this.commands.push({type:t,args:e})}moveTo(t,e){this.addCommand("M",t,e)}lineTo(t,e){this.addCommand("L",t,e)}curveTo(t,e,r,o,s,i){this.addCommand("C",t,e,r,o,s,i)}quadTo(t,e,r,o){this.addCommand("Q",t,e,r,o)}arcTo(t,e,r,o,s,i,n){this.addCommand("A",t,e,r,o,s,i,n)}close(){this.addCommand("Z")}setFill(t){this.fill=t}setStroke(t){this.stroke=t}}class _{constructor(){this.shapeCache=new Map;this.presetDefinitions=new Map;this.initializePresetDefinitions()}initializePresetDefinitions(){this.presetDefinitions.set("rect",{guides:[],paths:[{commands:[{type:"M",args:["l","t"]},{type:"L",args:["r","t"]},{type:"L",args:["r","b"]},{type:"L",args:["l","b"]},{type:"Z",args:[]}],fill:"norm",stroke:true}],connections:[{ang:"cd4",x:"hc",y:"t"},{ang:"0",x:"r",y:"vc"},{ang:"_3cd4",x:"hc",y:"b"},{ang:"cd2",x:"l",y:"vc"}],textRect:{l:"l",t:"t",r:"r",b:"b"}});this.presetDefinitions.set("roundRect",{adjustments:[{name:"adj",formula:y,value:16667}],guides:[{name:"a",formula:f,x:"0",y:"adj",z:"50000"},{name:"x1",formula:e,x:"ss",y:"a",z:"100000"},{name:"y1",formula:e,x:"ss",y:"a",z:"100000"},{name:"x2",formula:r,x:"r",y:"0",z:"x1"},{name:"y2",formula:r,x:"b",y:"0",z:"y1"},{name:"il",formula:e,x:"x1",y:"29289",z:"100000"},{name:"ir",formula:r,x:"r",y:"0",z:"il"},{name:"it",formula:e,x:"y1",y:"29289",z:"100000"},{name:"ib",formula:r,x:"b",y:"0",z:"it"}],paths:[{commands:[{type:"M",args:["l","y1"]},{type:"Q",args:["l","t","x1","t"]},{type:"L",args:["x2","t"]},{type:"Q",args:["r","t","r","y1"]},{type:"L",args:["r","y2"]},{type:"Q",args:["r","b","x2","b"]},{type:"L",args:["x1","b"]},{type:"Q",args:["l","b","l","y2"]},{type:"Z",args:[]}],fill:"norm",stroke:true}],handles:[{type:"xy",gdRefX:"adj",minX:"0",maxX:"50000",x:"x1",y:"t"}],connections:[{ang:"cd4",x:"hc",y:"t"},{ang:"0",x:"r",y:"vc"},{ang:"_3cd4",x:"hc",y:"b"},{ang:"cd2",x:"l",y:"vc"}],textRect:{l:"il",t:"it",r:"ir",b:"ib"}});this.presetDefinitions.set("ellipse",{guides:[{name:"idx",formula:e,x:"wd2",y:"2700000",z:"21600000"},{name:"idy",formula:e,x:"hd2",y:"2700000",z:"21600000"},{name:"il",formula:r,x:"hc",y:"0",z:"idx"},{name:"ir",formula:r,x:"hc",y:"idx",z:"0"},{name:"it",formula:r,x:"vc",y:"0",z:"idy"},{name:"ib",formula:r,x:"vc",y:"idy",z:"0"}],paths:[{commands:[{type:"M",args:["l","vc"]},{type:"A",args:["wd2","hd2","0","1","1","r","vc"]},{type:"A",args:["wd2","hd2","0","1","1","l","vc"]},{type:"Z",args:[]}],fill:"norm",stroke:true}],connections:[{ang:"cd4",x:"hc",y:"t"},{ang:"0",x:"r",y:"vc"},{ang:"_3cd4",x:"hc",y:"b"},{ang:"cd2",x:"l",y:"vc"}],textRect:{l:"il",t:"it",r:"ir",b:"ib"}})}processPresetGeometry(t,e,r,o={}){const s=`${t}_${e}_${r}_${JSON.stringify(o)}`;if(this.shapeCache.has(s))return this.shapeCache.get(s);const i=this.presetDefinitions.get(t);if(!i)return this.createDefaultGeometry(e,r);const n=new A;n.setPreset(t);n.recalculate(e,r);if(i.adjustments)i.adjustments.forEach(t=>{const e=o[t.name]||t.value;n.addAdjustment(t.name,e,t.min,t.max)});if(i.guides)i.guides.forEach(t=>{n.addGuide(t.name,t.formula,t.x,t.y,t.z)});if(i.paths)i.paths.forEach(t=>{const e=new E;e.setFill(t.fill);e.setStroke(t.stroke);t.commands.forEach(t=>{const r=t.args.map(t=>"string"===typeof t?n.getValue(t):t);e.addCommand(t.type,...r)});n.addPath(e)});n.calculateGuides();this.shapeCache.set(s,n);return n}createDefaultGeometry(t,e){return this.processPresetGeometry("rect",t,e)}fillText(t,e,r,o={}){if(!this.m_oContext||!t)return;this.m_oContext.save();try{const s=o.fontSize||12;const i=this.m_oGraphicsAdapter&&this.m_oGraphicsAdapter.getTextScaleFactor?this.m_oGraphicsAdapter.getTextScaleFactor():1;const n=s*i;const a=o.fontFamily||"Arial";const l=o.fontWeight||(o.bold?"bold":"normal");const c=o.fontStyle||(o.italic?"italic":"normal");const h=`"${a}", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", Arial, sans-serif`;this.m_oContext.font=`${c} ${l} ${n}px ${h}`;if(o.color)if("object"===typeof o.color&&void 0!==o.color.r){const t=void 0!==o.color.a?o.color.a/255:1;const e=`rgba(${o.color.r}, ${o.color.g}, ${o.color.b}, ${t})`;this.m_oContext.fillStyle=e}else if("string"===typeof o.color)this.m_oContext.fillStyle=o.color;else this.m_oContext.fillStyle="#000000";else this.m_oContext.fillStyle="#000000";this.m_oContext.textBaseline=o.textBaseline||"alphabetic";this.m_oContext.textAlign=o.textAlign||"left";if(this.m_oFullTransform&&!this.m_oFullTransform.IsIdentity()){const t=this.m_oFullTransform;this.m_oContext.setTransform(t.sx,t.shy,t.shx,t.sy,t.tx,t.ty)}this.applyTextEffects(o.effects);this.m_oContext.fillText(t,e,r);this.resetTextEffects()}catch(t){}finally{this.m_oContext.restore()}}applyTextEffects(t){if(!t||!this.m_oContext)return;if(t.outerShadow)this.applyOuterShadow(t.outerShadow);if(t.glow)this.applyGlowEffect(t.glow);if(t.innerShadow)this.applyInnerShadow(t.innerShadow)}applyOuterShadow(t){if(!t||!this.m_oContext)return;const e=(t.blurRadius||0)/9525;const r=(t.distance||0)/9525;const o=(t.direction||0)/6e4;const s=o*Math.PI/180;const i=Math.cos(s)*r;const n=Math.sin(s)*r;this.m_oContext.shadowOffsetX=i;this.m_oContext.shadowOffsetY=n;this.m_oContext.shadowBlur=e;if(t.color){const e=this.convertColorToString(t.color);this.m_oContext.shadowColor=e}else this.m_oContext.shadowColor="rgba(0, 0, 0, 0.5)"}applyGlowEffect(t){if(!t||!this.m_oContext)return;const e=(t.radius||0)/9525;this.m_oContext.shadowOffsetX=0;this.m_oContext.shadowOffsetY=0;this.m_oContext.shadowBlur=e;if(t.color){const e=this.convertColorToString(t.color);this.m_oContext.shadowColor=e}else this.m_oContext.shadowColor="rgba(255, 255, 255, 0.8)"}applyInnerShadow(t){}resetTextEffects(){if(!this.m_oContext)return;this.m_oContext.shadowOffsetX=0;this.m_oContext.shadowOffsetY=0;this.m_oContext.shadowBlur=0;this.m_oContext.shadowColor="transparent"}convertColorToString(t){if(!t)return"black";if("srgb"===t.type){const e=t.value;const r=parseInt(e.substr(0,2),16);const o=parseInt(e.substr(2,2),16);const s=parseInt(e.substr(4,2),16);const i=t.alpha||1;return`rgba(${r}, ${o}, ${s}, ${i})`}else if("scheme"===t.type){const e={dk1:"#000000",lt1:"#FFFFFF",dk2:"#44546A",lt2:"#E7E6E6"};const r=e[t.value]||"#000000";const o=t.alpha||1;const s=parseInt(r.substr(1,2),16);const i=parseInt(r.substr(3,2),16);const n=parseInt(r.substr(5,2),16);return`rgba(${s}, ${i}, ${n}, ${o})`}return"black"}measureText(t,e={}){if(!this.m_oContext||!t)return{width:0,height:0};this.m_oContext.save();try{const r=e.fontSize||12;const o=this.m_oGraphicsAdapter&&this.m_oGraphicsAdapter.getTextScaleFactor?this.m_oGraphicsAdapter.getTextScaleFactor():1;const s=r*o;const i=e.fontFamily||"Arial";const n=e.fontWeight||(e.bold?"bold":"normal");const a=e.fontStyle||(e.italic?"italic":"normal");const l=`"${i}", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", Arial, sans-serif`;this.m_oContext.font=`${a} ${n} ${s}px ${l}`;const c=this.m_oContext.measureText(t);let h=s;if(void 0!==c.actualBoundingBoxAscent&&void 0!==c.actualBoundingBoxDescent)h=c.actualBoundingBoxAscent+c.actualBoundingBoxDescent;return{width:c.width,height:h}}catch(t){return{width:0,height:0}}finally{this.m_oContext.restore()}}}if("undefined"!==typeof window){window.CGraphics=CGraphics;window.StandardShapeProcessor=w}}(it);return it.exports}var ct=lt();var ht=s(ct);var ut={};var ft;function dt(){if(ft)return ut;ft=1;class FontEngine{constructor(){this.logger=new Logger("FontEngine");this.initializeFontSystem();this.availableFonts=new Set(["Arial","Calibri","Times New Roman","Courier New","Verdana","Georgia","Tahoma","Helvetica","Garamond","Impact","Segoe UI","Comic Sans MS","Trebuchet MS","Lucida Sans Unicode","Palatino Linotype","Book Antiqua","Bookman Old Style","Century Gothic"]);this.documentFonts=new Set;this.missingFonts=new Set;this.fontCache=new Map;this.fontManager=null}initializeFontSystem(){try{if("undefined"!==typeof window.AscFonts){this.fontManager=new window.AscFonts.CFontManagerEngine;this.initializeFonts()}else this.fontManager=new t}catch(e){this.fontManager=new t}}initializeFonts(){try{if("function"===typeof self.queryLocalFonts)this.loadSystemFonts();else this.loadFallbackFonts()}catch(t){this.loadFallbackFonts()}}async loadSystemFonts(){try{const t=await self.queryLocalFonts();t.forEach(t=>{this.availableFonts.add(t.family)})}catch(t){this.loadFallbackFonts()}}loadFallbackFonts(){const t=["Arial","Helvetica","Times New Roman","Times","Courier New","Courier","Verdana","Georgia","Palatino","Garamond","Bookman","Comic Sans MS","Trebuchet MS","Arial Black","Impact","Lucida Sans Unicode","Tahoma","Geneva","Lucida Grande","Segoe UI","Calibri","Cambria","Candara","Consolas","Constantia","Corbel","Franklin Gothic Medium","Gill Sans","Lucida Console","Lucida Sans Typewriter","MS Gothic","MS Mincho","MS PGothic","MS PMincho","MS Reference Sans Serif","MS Reference Specialty","MS Sans Serif","MS Serif","Myriad Pro","Optima","Perpetua","Rockwell","Rockwell Extra Bold","Segoe Print","Segoe Script","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold"];t.forEach(t=>{this.availableFonts.add(t)})}analyzeDocument(presentation){this.documentFonts.clear();if(presentation.defaultTextStyle)this.addFontFromStyle(presentation.defaultTextStyle);presentation.slides.forEach(slide=>{if(slide.commonSlideData&&slide.commonSlideData.shapeTree)slide.commonSlideData.shapeTree.forEach(t=>{this.analyzeShape(t)})});return Array.from(this.documentFonts)}addFontFromStyle(t){if(!t)return;if(t.font)this.documentFonts.add(t.font)}analyzeShape(t){if(!t)return;if(t.textBody&&t.textBody.paragraphs)t.textBody.paragraphs.forEach(t=>{if(t.runs)t.runs.forEach(t=>{if(t.properties&&t.properties.font)this.documentFonts.add(t.properties.font)})});if(t.shapeTree)t.shapeTree.forEach(t=>{this.analyzeShape(t)})}loadFonts(){this.missingFonts.clear();this.documentFonts.forEach(t=>{if(!this.availableFonts.has(t))this.missingFonts.add(t)})}getResults(){return{documentFonts:Array.from(this.documentFonts),availableFonts:Array.from(this.availableFonts),missingFonts:Array.from(this.missingFonts)}}getFontMetrics(t,e,r){const o=`${t}_${e}_${r}`;if(this.fontCache.has(o))return this.fontCache.get(o);const s={width:r.length*e*.6,height:1.2*e,ascent:.8*e,descent:.2*e,baseline:.8*e};this.fontCache.set(o,s);return s}isFontAvailable(t){return this.availableFonts.has(t)||this.documentFonts.has(t)}getFallbackFont(t){if(this.isFontAvailable(t))return t;return'Arial, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif'}renderText(t,e,r,o,s){const i=this.getFallbackFont(s.fontFamily||"Arial");const n=s.fontSize||12;const a=s.fontWeight||(s.bold?"bold":"normal");const l=s.fontStyle||(s.italic?"italic":"normal");t.font=`${l} ${a} ${n}px "${i}"`;let c="#000000";if(s.color)if("object"===typeof s.color&&void 0!==s.color.r){const t=void 0!==s.color.a?s.color.a/255:1;c=`rgba(${s.color.r}, ${s.color.g}, ${s.color.b}, ${t})`}else if("string"===typeof s.color)c=s.color;else c="#000000";else c="#000000";t.fillStyle=c;t.textBaseline="alphabetic";if(s.textAlign)t.textAlign=s.textAlign;if(1===e.length)t.fillText(e,r,o);else{let i=r;for(let r=0;r<e.length;r++){const n=e.charAt(r);t.fillText(n,i,o);const a=t.measureText(n);i+=a.width;if(s.letterSpacing)i+=s.letterSpacing}}}measureText(t,e,r){const o=this.getFallbackFont(r.fontFamily||"Arial");const s=r.fontSize||12;const i=r.fontWeight||(r.bold?"bold":"normal");const n=r.fontStyle||(r.italic?"italic":"normal");t.save();t.font=`${n} ${i} ${s}px "${o}"`;let a=0;let l=s;for(let o=0;o<e.length;o++){const s=e.charAt(o);const i=t.measureText(s);a+=i.width;if(r.letterSpacing)a+=r.letterSpacing;if(void 0!==i.actualBoundingBoxAscent&&void 0!==i.actualBoundingBoxDescent){const t=i.actualBoundingBoxAscent+i.actualBoundingBoxDescent;l=Math.max(l,t)}}t.restore();return{width:a,height:l}}}class t{constructor(){this.library=null;this.manager=null}openFont(t,e){return{SetFace:function(t,e){this.face=t;this.manager=e},IsSuccess:function(){return true}}}setHintsProps(t,e){this.hinting=t;this.subpixHinting=e}destroy(){this.library=null;this.manager=null}}if("undefined"!==typeof window){window.FontEngine=FontEngine;window.SimplifiedFontManager=t}return ut}var pt=dt();var gt=s(pt);var mt={};var yt;function bt(){if(yt)return mt;yt=1;class t{constructor(){this.type="";this.source="";this.mimeType="";this.duration=0;this.width=0;this.height=0;this.poster="";this.autoplay=false;this.loop=false;this.controls=true;this.muted=false;this.volume=1;this.startTime=0;this.endTime=0;this.relationship=null;this.embeddedData=null;this.thumbnail=null}}class e{constructor(){this.videoId="";this.startTime=0;this.endTime=0;this.autoplay=false;this.showControls=true;this.showInfo=false;this.loop=false;this.fullUrl="";this.embedUrl="";this.thumbnailUrl=""}}class r{constructor(t){this.context=t;this.logger=new Logger("MediaProcessor");this.supportedVideoTypes=["mp4","webm","ogg","avi","mov","wmv"];this.supportedAudioTypes=["mp3","wav","ogg","aac","m4a","wma"];this.supportedImageTypes=["jpg","jpeg","png","gif","bmp","svg","webp"]}parseMediaFromElement(t){try{if(this.isVideoElement(t))return this.parseVideoElement(t);else if(this.isAudioElement(t))return this.parseAudioElement(t);else if(this.isImageElement(t))return this.parseImageElement(t);else if(this.isYouTubeEmbed(t))return this.parseYouTubeEmbed(t);return null}catch(t){this.logger.logError(this.constructor.name,"Error parsing media element:",t);return null}}isVideoElement(t){const e=["video","p:video","a:video"];return e.some(e=>t.querySelector(e))||this.hasVideoMimeType(t)}isAudioElement(t){const e=["audio","p:audio","a:audio"];return e.some(e=>t.querySelector(e))||this.hasAudioMimeType(t)}isImageElement(t){const e=["pic","p:pic","image","img"];return e.some(e=>t.querySelector(e))||this.hasImageMimeType(t)}isYouTubeEmbed(t){const e=t.textContent||"";const r=t.innerHTML||"";return e.includes("youtube.com")||e.includes("youtu.be")||r.includes("youtube.com")||r.includes("youtu.be")}parseVideoElement(e){const r=new t;r.type="video";this.parseCommonMediaAttributes(e,r);const o=e.querySelector("video, p\\:video, a\\:video");if(o){r.poster=o.getAttribute("poster")||"";r.autoplay=o.hasAttribute("autoplay");r.loop=o.hasAttribute("loop");r.controls=!o.hasAttribute("controls")||"false"!==o.getAttribute("controls");r.muted=o.hasAttribute("muted")}this.extractMediaSource(e,r);return r}parseAudioElement(e){const r=new t;r.type="audio";this.parseCommonMediaAttributes(e,r);const o=e.querySelector("audio, p\\:audio, a\\:audio");if(o){r.autoplay=o.hasAttribute("autoplay");r.loop=o.hasAttribute("loop");r.controls=!o.hasAttribute("controls")||"false"!==o.getAttribute("controls");r.muted=o.hasAttribute("muted");const t=o.getAttribute("volume");if(t)r.volume=parseFloat(t)||1}this.extractMediaSource(e,r);return r}parseImageElement(e){const r=new t;r.type="image";this.parseCommonMediaAttributes(e,r);this.extractMediaSource(e,r);return r}parseYouTubeEmbed(r){const o=new t;o.type="youtube";const s=new e;const i=r.textContent||"";const n=r.innerHTML||"";const a=i+" "+n;const l=this.extractYouTubeVideoId(a);if(l){s.videoId=l;s.fullUrl=`https://www.youtube.com/watch?v=${l}`;s.embedUrl=`https://www.youtube.com/embed/${l}`;s.thumbnailUrl=`https://img.youtube.com/vi/${l}/maxresdefault.jpg`}const c=a.match(/[?&]t=(\d+)/);if(c)s.startTime=parseInt(c[1]);o.source=s.embedUrl;o.embeddedData=s;return o}parseCommonMediaAttributes(t,e){const r=t.getAttribute("width")||t.getAttribute("w");const o=t.getAttribute("height")||t.getAttribute("h");if(r)e.width=parseInt(r)||0;if(o)e.height=parseInt(o)||0;const s=t.getAttribute("duration");if(s)e.duration=parseFloat(s)||0;const i=t.getAttribute("r:id")||t.getAttribute("rid");if(i)e.relationship=i}extractMediaSource(t,e){const r=t.getAttribute("src");if(r){e.source=r;e.mimeType=this.getMimeTypeFromExtension(r);return}const o=t.querySelector("source");if(o){e.source=o.getAttribute("src")||"";e.mimeType=o.getAttribute("type")||this.getMimeTypeFromExtension(e.source);return}if(e.relationship&&this.context){const t=this.resolveRelationship(e.relationship);if(t){e.source=t;e.mimeType=this.getMimeTypeFromExtension(t);if("image/svg+xml"===this.getMimeTypeFromExtension(t))try{const r=this.getZipPackage();if(r&&r.getFileData)r.getFileData(t).then(t=>{if(t){const r=new TextDecoder("utf-8").decode(t);const o=btoa(r);e.embeddedData=`data:image/svg+xml;base64,${o}`}}).catch(e=>{this.logger.log("warn",this.constructor.name,`Failed to create SVG data URI for ${t}:`,e)})}catch(e){this.logger.log("warn",this.constructor.name,`Error creating SVG data URI for ${t}:`,e)}return}}const s=this.extractEmbeddedData(t);if(s){e.embeddedData=s;e.mimeType=this.getMimeTypeFromData(s)}}getZipPackage(){if(this.context&&this.context.zip)return this.context.zip;else if(this.context&&this.context.package)return this.context.package;else if(window.currentProcessor&&window.currentProcessor.package)return window.currentProcessor.package;else if(window.currentProcessor&&window.currentProcessor.zip)return window.currentProcessor.zip;return null}extractYouTubeVideoId(t){const e=[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/,/youtube\.com\/v\/([^&\n?#]+)/];for(const r of e){const e=t.match(r);if(e&&e[1])return e[1]}return null}getMimeTypeFromExtension(t){if(!t)return"";const e=t.split(".").pop().toLowerCase();const r={mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",avi:"video/x-msvideo",mov:"video/quicktime",wmv:"video/x-ms-wmv",mp3:"audio/mpeg",wav:"audio/wav",aac:"audio/aac",m4a:"audio/mp4",wma:"audio/x-ms-wma",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp"};return r[e]||""}resolveRelationship(t){try{if(!t||!this.context)return null;let e=null;if(this.context.zip)e=this.context.zip;else if(this.context.package)e=this.context.package;else if(window.currentProcessor&&window.currentProcessor.package)e=window.currentProcessor.package;if(!e||!e.relationships)return null;const r=Object.values(e.relationships);for(const e of r)if(e&&e[t]){const r=e[t];let o=r.target;if(o.startsWith("../"))o=o.replace("../","ppt/");else if(!o.startsWith("/"))o=`/ppt/${o}`;return o}this.logger.log("warn",this.constructor.name,`Could not resolve relationship ID: ${t}`);return null}catch(e){this.logger.logError(this.constructor.name,`Error resolving relationship ${t}:`,e);return null}}extractEmbeddedData(t){const e=["data","data-src","data-url","src","href"];for(const r of e){const e=t.getAttribute(r);if(e&&e.startsWith("data:"))return e}const r=t.textContent||"";const o=r.match(/data:[^;]+;base64,[A-Za-z0-9+/]+=*/g);if(o&&o.length>0)return o[0];return null}getMimeTypeFromData(t){if(!t||!t.startsWith("data:"))return"";const e=t.match(/^data:([^;]+)/);return e?e[1]:""}isSVGDataUri(t){if(!t||!t.startsWith("data:"))return false;const e=this.getMimeTypeFromData(t);return"image/svg+xml"===e}extractSVGFromDataUri(t){if(!this.isSVGDataUri(t))return null;try{const e=t.split(",")[1];if(!e)return null;const r=atob(e);return r}catch(t){return null}}hasVideoMimeType(t){const e=t.getAttribute("type")||"";return e.startsWith("video/")}hasAudioMimeType(t){const e=t.getAttribute("type")||"";return e.startsWith("audio/")}hasImageMimeType(t){const e=t.getAttribute("type")||"";return e.startsWith("image/")}createPlaceholder(e="media"){const r=new t;r.type=e;r.source="";r.width=320;r.height=240;r.controls=true;return r}}if("undefined"!==typeof window){window.MediaInfo=t;window.YouTubeEmbed=e;window.MediaProcessor=r}return mt}var xt=bt();var St=s(xt);var wt={};var Ct;function Tt(){if(Ct)return wt;Ct=1;class SVGRenderer{constructor(t){this.graphics=t;this.logger=new Logger("SVGRenderer");this.parser=new DOMParser}async renderSVG(t,e,r,o,s,i={}){try{let n=null;if("string"===typeof t){const i=t.trim();if(i.startsWith("<svg")){const t=this.parser.parseFromString(i,"image/svg+xml");n=t.documentElement}else if(i.startsWith("data:image/svg+xml")){const t=i.split(",")[1];const e=atob(t);const r=this.parser.parseFromString(e,"image/svg+xml");n=r.documentElement}else if(i.includes("<svg")){const t=this.parser.parseFromString(i,"image/svg+xml");n=t.documentElement}else{this.renderSVGPlaceholder(e,r,o,s,"External SVG");return}}else if(t instanceof Element)n=t;if(!n||"svg"!==n.tagName){this.renderSVGPlaceholder(e,r,o,s,"Invalid SVG");return}const a=this.getSVGViewBox(n);const l=this.getSVGDimensions(n,a);const c=o/l.width;const h=s/l.height;const u=false!==i.preserveAspectRatio?Math.min(c,h):Math.max(c,h);if(this.canUseImageMethod())await this.renderSVGViaImage(n,e,r,o,s,u,i);else this.renderSVGViaParsing(n,e,r,u,i)}catch(t){this.logger.logError(this.constructor.name,"Error rendering SVG:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Error")}}getSVGViewBox(t){const e=t.getAttribute("viewBox");if(e){const t=e.split(/\s+/).map(t=>parseFloat(t));if(4===t.length)return{x:t[0],y:t[1],width:t[2],height:t[3]}}return null}getSVGDimensions(t,e){let r=parseFloat(t.getAttribute("width"))||0;let o=parseFloat(t.getAttribute("height"))||0;if(!r&&!o&&e){r=e.width;o=e.height}if(!r)r=100;if(!o)o=100;return{width:r,height:o}}canUseImageMethod(){const t="undefined"!==typeof Image;const e=this.graphics._context||this.graphics.m_oContext;const r=e&&"function"===typeof e.drawImage;return t&&e&&r}enhanceSVGForRendering(t,e,r){try{const o=this.parser.parseFromString(t,"image/svg+xml");const s=o.documentElement;if(!s.hasAttribute("viewBox")){const t=s.getAttribute("width")||e;const o=s.getAttribute("height")||r;s.setAttribute("viewBox",`0 0 ${t} ${o}`)}s.setAttribute("width",e.toString());s.setAttribute("height",r.toString());if(!s.hasAttribute("xmlns"))s.setAttribute("xmlns","http://www.w3.org/2000/svg");return(new XMLSerializer).serializeToString(s)}catch(e){this.logger.log("warn",this.constructor.name,"Could not enhance SVG, using original:",e);return t}}async renderSVGViaImage(t,e,r,o,s,i,n){return new Promise((i,n)=>{try{const a=new XMLSerializer;const l=a.serializeToString(t);const c=this.enhanceSVGForRendering(l,o,s);const h="data:image/svg+xml;base64,"+btoa(c);const u=new Image;u.onload=()=>{try{if(this.graphics._context||this.graphics.m_oContext){const t=this.graphics._context||this.graphics.m_oContext;t.save();t.drawImage(u,e,r,o,s);t.restore()}else this.logger.logError(this.constructor.name,"No canvas context available for SVG drawing");i()}catch(t){this.logger.logError(this.constructor.name,"Error drawing SVG image:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Draw Error");n(t)}};u.onerror=t=>{this.logger.logError(this.constructor.name,"SVG image load error:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Load Error");n(t)};u.crossOrigin="anonymous";u.src=h;setTimeout(()=>{if(false===u.complete){this.logger.log("warn",this.constructor.name,"SVG loading timed out");this.renderSVGPlaceholder(e,r,o,s,"SVG Timeout");n(new Error("SVG loading timeout"))}},5e3)}catch(t){this.logger.logError(this.constructor.name,"Error in SVG Image rendering:",t);this.renderSVGPlaceholder(e,r,o,s,"SVG Render Error");n(t)}})}renderSVGViaParsing(t,e,r,o,s){try{if(!this.graphics._context)return;this.graphics._context.save();this.graphics._context.translate(e,r);this.graphics._context.scale(o,o);this.processSVGElements(t.children);this.graphics._context.restore()}catch(t){this.logger.logError(this.constructor.name,"Error in SVG parsing rendering:",t);this.renderSVGPlaceholder(e,r,100,100,"SVG Parse Error")}}processSVGElements(t){for(const e of t)this.processSVGElement(e)}processSVGElement(t){const e=t.tagName.toLowerCase();switch(e){case"rect":this.renderSVGRect(t);break;case"circle":this.renderSVGCircle(t);break;case"ellipse":this.renderSVGEllipse(t);break;case"line":this.renderSVGLine(t);break;case"polyline":case"polygon":this.renderSVGPolygon(t);break;case"path":this.renderSVGPath(t);break;case"text":this.renderSVGText(t);break;case"g":this.graphics._context.save();this.applySVGTransform(t);this.processSVGElements(t.children);this.graphics._context.restore()}}renderSVGRect(t){const e=parseFloat(t.getAttribute("x"))||0;const r=parseFloat(t.getAttribute("y"))||0;const o=parseFloat(t.getAttribute("width"))||0;const s=parseFloat(t.getAttribute("height"))||0;this.applySVGStyles(t);const i=this.graphics._context;i.fillRect(e,r,o,s);i.strokeRect(e,r,o,s)}renderSVGCircle(t){const e=parseFloat(t.getAttribute("cx"))||0;const r=parseFloat(t.getAttribute("cy"))||0;const o=parseFloat(t.getAttribute("r"))||0;this.applySVGStyles(t);const s=this.graphics._context;s.beginPath();s.arc(e,r,o,0,2*Math.PI);s.fill();s.stroke()}renderSVGLine(t){const e=parseFloat(t.getAttribute("x1"))||0;const r=parseFloat(t.getAttribute("y1"))||0;const o=parseFloat(t.getAttribute("x2"))||0;const s=parseFloat(t.getAttribute("y2"))||0;this.applySVGStyles(t);const i=this.graphics._context;i.beginPath();i.moveTo(e,r);i.lineTo(o,s);i.stroke()}renderSVGText(t){const e=parseFloat(t.getAttribute("x"))||0;const r=parseFloat(t.getAttribute("y"))||0;const o=t.textContent||"";this.applySVGStyles(t);const s=this.graphics._context;s.fillText(o,e,r)}applySVGStyles(t){const e=this.graphics._context;const r=t.getAttribute("fill");if(r&&"none"!==r)e.fillStyle=r;else e.fillStyle="transparent";const o=t.getAttribute("stroke");if(o&&"none"!==o)e.strokeStyle=o;else e.strokeStyle="transparent";const s=t.getAttribute("stroke-width");if(s)e.lineWidth=parseFloat(s);const i=t.getAttribute("opacity");if(i)e.globalAlpha=parseFloat(i)}applySVGTransform(t){const e=t.getAttribute("transform");if(e){const t=e.match(/translate\(([^)]+)\)/);if(t){const e=t[1].split(",").map(t=>parseFloat(t.trim()));if(e.length>=2)this.graphics._context.translate(e[0],e[1])}const r=e.match(/scale\(([^)]+)\)/);if(r){const t=r[1].split(",").map(t=>parseFloat(t.trim()));if(t.length>=1){const e=t[0];const r=t.length>1?t[1]:e;this.graphics._context.scale(e,r)}}const o=e.match(/rotate\(([^)]+)\)/);if(o){const t=parseFloat(o[1]);this.graphics._context.rotate(t*Math.PI/180)}}}renderSVGPlaceholder(t,e,r,o,s="SVG"){this.graphics.fillRect(t,e,r,o,{r:240,g:240,b:240});this.graphics.strokeRect(t,e,r,o,{r:200,g:200,b:200},1)}renderSVGEllipse(t){const e=parseFloat(t.getAttribute("cx"))||0;const r=parseFloat(t.getAttribute("cy"))||0;const o=parseFloat(t.getAttribute("rx"))||0;const s=parseFloat(t.getAttribute("ry"))||0;this.applySVGStyles(t);const i=this.graphics._context;i.save();i.translate(e,r);i.scale(o,s);i.beginPath();i.arc(0,0,1,0,2*Math.PI);i.restore();i.fill();i.stroke()}renderSVGPolygon(t){const e=t.getAttribute("points")||"";const r="polygon"===t.tagName.toLowerCase();if(!e.trim())return;this.applySVGStyles(t);const o=this.graphics._context;const s=e.trim().split(/[\s,]+/);if(s.length<4)return;o.beginPath();let i=parseFloat(s[0]);let n=parseFloat(s[1]);o.moveTo(i,n);for(let t=2;t<s.length;t+=2)if(t+1<s.length){i=parseFloat(s[t]);n=parseFloat(s[t+1]);o.lineTo(i,n)}if(r)o.closePath();o.fill();o.stroke()}renderSVGPath(t){const e=t.getAttribute("d")||"";if(!e.trim())return;this.applySVGStyles(t);try{const t=this.graphics._context;const r=this.parseSVGPathData(e);t.beginPath();this.executeSVGPathCommands(r,t);t.fill();t.stroke()}catch(e){this.logger.log("warn",this.constructor.name,"Error parsing SVG path:",e);const r=this.getElementBoundingBox(t);if(r){this.applySVGStyles(t);const e=this.graphics._context;e.fillRect(r.x,r.y,r.width,r.height);e.strokeRect(r.x,r.y,r.width,r.height)}}}parseSVGPathData(t){const e=[];const r=/([MmLlHhVvCcSsQqTtAaZz])((?:\s*[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?\s*,?\s*)*)/g;let o;while(null!==(o=r.exec(t))){const t=o[1];const r=o[2].trim();const s=r?r.split(/[\s,]+/).map(t=>parseFloat(t)).filter(t=>!isNaN(t)):[];e.push({command:t,params:s})}return e}executeSVGPathCommands(t,e){let r=0,o=0;let s=0,i=0;for(const{command:n,params:a}of t)switch(n.toLowerCase()){case"m":if(a.length>=2){if("M"===n){r=a[0];o=a[1]}else{r+=a[0];o+=a[1]}e.moveTo(r,o);for(let t=2;t<a.length;t+=2)if(t+1<a.length){if("M"===n){r=a[t];o=a[t+1]}else{r+=a[t];o+=a[t+1]}e.lineTo(r,o)}}break;case"l":for(let t=0;t<a.length;t+=2)if(t+1<a.length){if("L"===n){r=a[t];o=a[t+1]}else{r+=a[t];o+=a[t+1]}e.lineTo(r,o)}break;case"h":for(let t=0;t<a.length;t++){if("H"===n)r=a[t];else r+=a[t];e.lineTo(r,o)}break;case"v":for(let t=0;t<a.length;t++){if("V"===n)o=a[t];else o+=a[t];e.lineTo(r,o)}break;case"c":for(let t=0;t<a.length;t+=6)if(t+5<a.length){let l,c,h,u,f,d;if("C"===n){l=a[t];c=a[t+1];h=a[t+2];u=a[t+3];f=a[t+4];d=a[t+5]}else{l=r+a[t];c=o+a[t+1];h=r+a[t+2];u=o+a[t+3];f=r+a[t+4];d=o+a[t+5]}e.bezierCurveTo(l,c,h,u,f,d);s=h;i=u;r=f;o=d}break;case"q":for(let t=0;t<a.length;t+=4)if(t+3<a.length){let l,c,h,u;if("Q"===n){l=a[t];c=a[t+1];h=a[t+2];u=a[t+3]}else{l=r+a[t];c=o+a[t+1];h=r+a[t+2];u=o+a[t+3]}e.quadraticCurveTo(l,c,h,u);s=l;i=c;r=h;o=u}break;case"a":for(let t=0;t<a.length;t+=7)if(t+6<a.length){const s=a[t];const i=a[t+1];const l=a[t+2]*Math.PI/180;const c=a[t+3];const h=a[t+4];let u,f;if("A"===n){u=a[t+5];f=a[t+6]}else{u=r+a[t+5];f=o+a[t+6]}this.drawEllipticalArc(e,r,o,s,i,l,c,h,u,f);r=u;o=f}break;case"z":e.closePath()}}drawEllipticalArc(t,e,r,o,s,i,n,a,l,c){t.lineTo(l,c)}getElementBoundingBox(t){const e=parseFloat(t.getAttribute("x"))||0;const r=parseFloat(t.getAttribute("y"))||0;const o=parseFloat(t.getAttribute("width"))||10;const s=parseFloat(t.getAttribute("height"))||10;if(o>0&&s>0)return{x:e,y:r,width:o,height:s};return null}}if("undefined"!==typeof window)window.SVGRenderer=SVGRenderer;return wt}var Pt=Tt();var vt=s(Pt);var Mt={};var At;function Et(){if(At)return Mt;At=1;class t{constructor(){this.name="";this.colorScheme={};this.fontScheme={};this.formatScheme={};this.backgroundStyles=[];this.effects=[];this.themeElements={}}}class e{constructor(){this.dk1=null;this.lt1=null;this.dk2=null;this.lt2=null;this.accent1=null;this.accent2=null;this.accent3=null;this.accent4=null;this.accent5=null;this.accent6=null;this.hlink=null;this.folHlink=null}}class r{constructor(){this.majorFont={};this.minorFont={}}}class o{constructor(){this.id="";this.name="";this.preserve=false;this.cSld=null;this.clrMap=null;this.txStyles=null;this.sldLayoutLst=[];this.themeId="";this.hf=null;this.timing=null;this.transition=null}}class s{constructor(){this.id="";this.masterId="";this.name="";this.type="custom";this.preserve=false;this.showMasterSp=true;this.showMasterPhAnim=false;this.userDrawn=false;this.cSld=null;this.clrMapOvr=null;this.hf=null;this.timing=null;this.transition=null}}class i{constructor(t){this.context=t;this.logger=new Logger("ThemeProcessor");this.themes=new Map;this.masters=new Map;this.layouts=new Map}processTheme(e,r){try{const o=new DOMParser;const s=o.parseFromString(e,"text/xml");const i=s.querySelector("theme, a\\:theme");if(!i){this.logger.log("warn",this.constructor.name,"No theme element found in XML");return this.createDefaultTheme(r)}const theme=new t;theme.name=i.getAttribute("name")||`Theme${r}`;this.processThemeElements(i,theme);this.processColorScheme(i,theme);this.processFontScheme(i,theme);this.processFormatScheme(i,theme);this.themes.set(r,theme);return theme}catch(t){this.logger.logError(this.constructor.name,"Error processing theme:",t);return this.createDefaultTheme(r)}}processMasterSlide(t,e){try{const r=new DOMParser;const s=r.parseFromString(t,"text/xml");const i=s.querySelector("sldMaster, p\\:sldMaster");if(!i){this.logger.log("warn",this.constructor.name,"No slide master element found in XML");return this.createDefaultMaster(e)}const n=new o;n.id=e;n.name=i.getAttribute("name")||`Master${e}`;n.preserve="true"===i.getAttribute("preserve");this.processMasterElements(i,n);this.masters.set(e,n);return n}catch(t){this.logger.logError(this.constructor.name,"Error processing master slide:",t);return this.createDefaultMaster(e)}}processLayoutSlide(t,e,r){try{const o=new DOMParser;const i=o.parseFromString(t,"text/xml");const n=i.querySelector("sldLayout, p\\:sldLayout");if(!n){this.logger.log("warn",this.constructor.name,"No slide layout element found in XML");return this.createDefaultLayout(e,r)}const a=new s;a.id=e;a.masterId=r;a.name=n.getAttribute("name")||`Layout${e}`;a.type=n.getAttribute("type")||"custom";a.preserve="true"===n.getAttribute("preserve");a.showMasterSp="false"!==n.getAttribute("showMasterSp");a.showMasterPhAnim="true"===n.getAttribute("showMasterPhAnim");a.userDrawn="true"===n.getAttribute("userDrawn");this.processLayoutElements(n,a);this.layouts.set(e,a);const l=this.masters.get(r);if(l)l.sldLayoutLst.push(e);return a}catch(t){this.logger.logError(this.constructor.name,"Error processing layout slide:",t);return this.createDefaultLayout(e,r)}}processThemeElements(t,theme){const e=t.querySelector("themeElements, a\\:themeElements");if(e)theme.themeElements={element:e,parsed:false}}processColorScheme(t,theme){const r=t.querySelector("clrScheme, a\\:clrScheme");if(!r)return;const o=new e;const s={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink"};for(const[t,e]of Object.entries(s)){const s=r.querySelector(`${t}, a\\:${t}`);if(s)o[e]=this.parseColor(s)}theme.colorScheme=o}processFontScheme(t,theme){const e=t.querySelector("fontScheme, a\\:fontScheme");if(!e)return;const o=new r;const s=e.querySelector("majorFont, a\\:majorFont");if(s)o.majorFont=this.parseFontCollection(s);const i=e.querySelector("minorFont, a\\:minorFont");if(i)o.minorFont=this.parseFontCollection(i);theme.fontScheme=o}processFormatScheme(t,theme){const e=t.querySelector("fmtScheme, a\\:fmtScheme");if(e)theme.formatScheme={fillStyleLst:this.processFillStyles(e),lnStyleLst:this.processLineStyles(e),effectStyleLst:this.processEffectStyles(e),bgFillStyleLst:this.processBackgroundFillStyles(e)}}processMasterElements(t,e){const r=t.querySelector("cSld, p\\:cSld");if(r)e.cSld=this.parseCommonSlideData(r);const o=t.querySelector("clrMap, p\\:clrMap");if(o)e.clrMap=this.parseColorMap(o);const s=t.querySelector("txStyles, p\\:txStyles");if(s)e.txStyles=this.parseTextStyles(s);e.hf=this.parseHeaderFooter(t);e.timing=this.parseTiming(t);e.transition=this.parseTransition(t)}processLayoutElements(t,e){const r=t.querySelector("cSld, p\\:cSld");if(r)e.cSld=this.parseCommonSlideData(r);const o=t.querySelector("clrMapOvr, p\\:clrMapOvr");if(o)e.clrMapOvr=this.parseColorMapOverride(o);e.hf=this.parseHeaderFooter(t);e.timing=this.parseTiming(t);e.transition=this.parseTransition(t)}getTheme(t){return this.themes.get(t)||null}getMaster(t){return this.masters.get(t)||null}getLayout(t){return this.layouts.get(t)||null}resolveColor(t,e,r=null){const theme=this.getTheme(e);if(!theme||!theme.colorScheme)return null;const o=r&&r[t]?r[t]:t;return theme.colorScheme[o]||null}resolveFont(t,e,r="latin"){const theme=this.getTheme(e);if(!theme||!theme.fontScheme)return null;const o="major"===t?theme.fontScheme.majorFont:theme.fontScheme.minorFont;return o[r]||o.latin||null}parseColor(t){const e=t.querySelector("sysClr, a\\:sysClr");const r=t.querySelector("srgbClr, a\\:srgbClr");const o=t.querySelector("schemeClr, a\\:schemeClr");if(r){const t=r.getAttribute("val");if(t){const e=parseInt(t.substr(0,2),16);const r=parseInt(t.substr(2,2),16);const o=parseInt(t.substr(4,2),16);return{r:e,g:r,b:o}}}if(e){const t=e.getAttribute("val");const r={windowText:{r:0,g:0,b:0},window:{r:255,g:255,b:255}};return r[t]||{r:0,g:0,b:0}}return{r:0,g:0,b:0}}parseFontCollection(t){const e={};const r=t.querySelector("latin, a\\:latin");if(r)e.latin=r.getAttribute("typeface");const o=t.querySelector("cs, a\\:cs");if(o)e.cs=o.getAttribute("typeface");return e}parseCommonSlideData(t){return{name:t.getAttribute("name")||"",bg:this.parseBackground(t),spTree:this.parseShapeTree(t)}}parseColorMap(t){const e={};const r=t.attributes;for(let t=0;t<r.length;t++){const o=r[t];e[o.name]=o.value}return e}parseColorMapOverride(t){return{}}parseTextStyles(t){return{titleStyle:{},bodyStyle:{},otherStyle:{}}}parseShapeTree(t){return[]}parseBackground(t){return null}parseHeaderFooter(t){return null}parseTiming(t){return null}parseTransition(t){return null}processFillStyles(t){return[]}processLineStyles(t){return[]}processEffectStyles(t){return[]}processBackgroundFillStyles(t){return[]}createDefaultTheme(o){const theme=new t;theme.name=`Default Theme ${o}`;theme.colorScheme=new e;theme.fontScheme=new r;return theme}createDefaultMaster(t){const e=new o;e.id=t;e.name=`Default Master ${t}`;return e}createDefaultLayout(t,e){const r=new s;r.id=t;r.masterId=e;r.name=`Default Layout ${t}`;r.type="blank";return r}}if("undefined"!==typeof window){window.ThemeInfo=t;window.ColorScheme=e;window.FontScheme=r;window.MasterSlide=o;window.LayoutSlide=s;window.ThemeProcessor=i}return Mt}var _t=Et();var Ft=s(_t);const Rt="undefined"!==typeof globalThis&&globalThis.Logger?globalThis.Logger:class{constructor(){}log(){}info(){}warn(){}error(){}debug(){}trace(){}logError(){}};const kt="undefined"!==typeof globalThis&&globalThis.FontEngine?globalThis.FontEngine:class{constructor(){}};const It="undefined"!==typeof globalThis&&globalThis.CanvasGraphicsAdapter?globalThis.CanvasGraphicsAdapter:class{constructor(){}resetState(){}};const Lt="undefined"!==typeof globalThis&&globalThis.CDrawingDocument?globalThis.CDrawingDocument:class{constructor(){this.graphics=null;this.canvas=null;this.processor=null;this.logger=new Rt("CDrawingDocument")}init(t,e=null){this.canvas=t;this.processor=e;if(!this.graphics)this.graphics=new It;else if(this.graphics.resetState)this.graphics.resetState()}};const Dt="undefined"!==typeof globalThis&&globalThis.ZLib?globalThis.ZLib:class{constructor(){this.files={};this.isOpen=false}async open(t){this.isOpen=true;return true}async getFileText(t){return null}async getFile(t){return null}getPaths(){return[]}};const Bt="undefined"!==typeof globalThis&&globalThis.OpenXmlTypes||"undefined"!==typeof window&&window.OpenXmlTypes||{presentation:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"},slide:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"},slideLayout:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"},slideMaster:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"},theme:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"},image:{relationType:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"}};class Ot{constructor(t=0,e=0,r=0,o=0){this.x=t;this.y=e;this.w=r;this.h=o}isIntersectOther(t){return!(this.x>t.x+t.w||this.x+this.w<t.x||this.y>t.y+t.h||this.y+this.h<t.y)}}class PPTXSlideRenderer{constructor(){this.logger=new Rt("PPTXProcessor");this.zip=null;this.package=null;this.presentation=null;this.slides=[];this.slideMasters=[];this.slideLayouts=[];this.fontEngine=new kt;this.drawingDocument=null;this.initializeGraphicsEngine();this.currentSlideIndex=0;this.xmlParser=null;this.imageMap=new Map;this.mediaMap=new Map;this.imageCache=new Map;this.svgRelationshipMap=new Map;this.imageLoader=new ImageLoader;this.renderContext={enableOptimizations:true,enableBoundsChecking:true,enableViewportCulling:true,enableTextAntialiasing:true,enableShapeAntialiasing:true,quality:"high",dpi:96,pixelRatio:window.devicePixelRatio||1}}setupHighResolutionCanvas(t,e,r,o=null){const s=o||this.renderContext.pixelRatio||window.devicePixelRatio||1;t.style.width=e+"px";t.style.height=r+"px";t.width=e*s;t.height=r*s;const i=t.getContext("2d");i.scale(s,s);i.imageSmoothingEnabled=true;i.imageSmoothingQuality="high";return t}setRenderingDPI(t){this.renderContext.dpi=t;this.renderContext.pixelRatio=t/96}getRenderingDPI(){return this.renderContext.dpi}setPixelRatio(t){this.renderContext.pixelRatio=t;this.renderContext.dpi=96*t}initializeGraphicsEngine(){if("undefined"!==typeof CDrawingDocument)this.drawingDocument=new CDrawingDocument;else this.drawingDocument=new Lt;this.svgRenderer=null}getGraphicsEngine(){return this.drawingDocument}async processFile(t){try{this.updateProgress(1,"processing");await this.processZIP(t);this.updateProgress(1,"active",100);this.updateProgress(2,"processing");await this.processXMLToDOM();this.updateProgress(2,"active",100);this.updateProgress(3,"processing");this.fontEngine.analyzeDocument(this.presentation);this.fontEngine.loadFonts();this.updateProgress(3,"active",100);this.updateProgress(4,"processing");this.initializeRendering();this.updateProgress(4,"active",100);this.updateProgress(5,"processing");await this.preloadAllImages();this.updateProgress(5,"active",100);this.updateProgress(6,"active",100);return true}catch(t){throw t}}updateProgress(t,e,r=0){const o=document.getElementById(`progress${t}`);if(o)o.style.width=`${r}%`;const s=document.getElementById(`step${t}`);if(s){s.classList.remove("active","processing");if(e)s.classList.add(e)}}async processZIP(t){this.zip="undefined"!==typeof ZLib?new ZLib:new Dt;const e=await this.zip.open(t);if(!e)throw new Error("Failed to open ZIP archive");const r=this.zip.getPaths();const o=r.filter(t=>t.includes("slide")&&t.endsWith(".xml"));const s="undefined"!==typeof globalThis&&globalThis.OpenXmlPackage||"undefined"!==typeof window&&window.OpenXmlPackage||function(){class t{constructor(t,e,r){this.package=t;this.uri=e;this.contentType=r;this._content=null}async getDocumentContent(){if(null===this._content){const t=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await this.package.zip.getFileText(t)}return this._content}async getRelationships(){if(this.package.relationships[this.uri])return this.package.relationships[this.uri];const t=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels");const e=t.startsWith("/")?t.substring(1):t;const r=await this.package.zip.getFileText(e);if(r)return this.package.parseRelationships(r);return{}}}class e{constructor(t){this.zip=t;this.parts={};this.contentTypes={};this.relationships={}}async initialize(){const e=await this.zip.getFileText("[Content_Types].xml");if(e)this.parseContentTypes(e);const r=await this.zip.getFileText("_rels/.rels");if(r)this.relationships[""]=this.parseRelationships(r);const o=this.zip.getPaths();for(const t of o)if(t.startsWith("_rels/")&&t.endsWith(".rels")&&"_rels/.rels"!==t){const e=t.match(/^(.+)\/_rels\/(.+)\.rels$/);if(e){const r=e[1];const o=e[2];const s=`/${r}/${o}`;const i=await this.zip.getFileText(t);if(i)this.relationships[s]=this.parseRelationships(i)}}for(const e of o)if(!e.startsWith("_rels/")&&"[Content_Types].xml"!==e){const r=`/${e}`;const o=this.getContentType(r);this.parts[r]=new t(this,r,o)}}parseContentTypes(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");r.querySelectorAll("Default").forEach(t=>{const e=t.getAttribute("Extension");const r=t.getAttribute("ContentType");if(e)this.contentTypes[`ext:${e}`]=r});r.querySelectorAll("Override").forEach(t=>{const e=t.getAttribute("PartName");const r=t.getAttribute("ContentType");if(e)this.contentTypes[e]=r})}parseRelationships(t){const e=new DOMParser;const r=e.parseFromString(t,"text/xml");const o={};const s=r.getElementsByTagName("*");for(let t=0;t<s.length;t++){const e=s[t];if("Relationship"===e.localName){const t=e.getAttribute("Id");const r=e.getAttribute("Type");const s=e.getAttribute("Target");if(t)o[t]={type:r,target:s,targetMode:e.getAttribute("TargetMode")||"Internal"}}}return o}getContentType(t){if(this.contentTypes[t])return this.contentTypes[t];const e=t.split(".").pop();if(e&&this.contentTypes[`ext:${e}`])return this.contentTypes[`ext:${e}`];return"application/octet-stream"}getPartByRelationshipType(t){const e=this.relationships[""]||{};for(const r of Object.values(e))if(r.type===t){const t=r.target.startsWith("/")?r.target:`/${r.target}`;return this.parts[t]}return null}getPartByUri(t){return this.parts[t]||null}}return e}();this.package=new s(this.zip);await this.package.initialize();try{const t=this.package&&this.package.relationships?Object.keys(this.package.relationships):[]}catch(t){}}async processXMLToDOM(){try{const t="undefined"!==typeof globalThis&&globalThis.XmlParserContext?globalThis.XmlParserContext:"undefined"!==typeof window?window.XmlParserContext:null;this.xmlParser=t?new t:{zip:null};this.xmlParser.zip=this.zip;const e=this.xmlParser;let r=this.package.getPartByRelationshipType(Bt.presentation?Bt.presentation.relationType:void 0);if(!r){r=this.package.getPartByUri("/ppt/presentation.xml")||this.package.getPartByUri("ppt/presentation.xml");if(!r){const t=Object.keys(this.package.parts||{});const e=t.find(t=>/presentation\.xml$/i.test(t));if(e)r=this.package.getPartByUri(e)}if(!r&&this.zip&&"function"===typeof this.zip.getPaths)try{const t=this.zip.getPaths();let e=t.find(t=>/^(?:\/?|)ppt\/presentation\.xml$/i.test(t));if(!e)e=t.find(t=>/presentation\.xml$/i.test(t));if(e){const t=e.startsWith("/")?e:`/${e}`;const o=this;const s=class{constructor(t,e){this.package=t;this.uri=e;this._content=null}async getDocumentContent(){if(null===this._content){const t=this.uri.startsWith("/")?this.uri.substring(1):this.uri;this._content=await o.zip.getFileText(t)}return this._content}async getRelationships(){const t=this.uri.replace(/\/([^\/]+)$/,"/_rels/$1.rels");const e=t.startsWith("/")?t.substring(1):t;const r=await o.zip.getFileText(e);if(r)if(o.package&&"function"===typeof o.package.parseRelationships)return o.package.parseRelationships(r);return{}}};const i=new s(this.package,t);if(this.package&&this.package.parts)this.package.parts[t]=i;r=i}}catch(t){}if(!r)throw new Error("No presentation document found in PPTX file")}const o=await r.getDocumentContent();if(!o)throw new Error("Failed to extract presentation XML content");const s="undefined"!==typeof globalThis&&globalThis.StaxParser||"undefined"!==typeof window&&window.StaxParser||null;if(!s)throw new Error("StaxParser is not defined");const i=new s(o,r,e);const n=i.parse();if(!n)throw new Error("Failed to parse presentation XML document");this.presentation=this.createPresentationFromXML(n);if(!this.presentation)throw new Error("Failed to create presentation object from XML");await this.processThemes(e,r);await this.processSlideMasters(e,r);await this.processSlides(e);await this.processImages(e);this.buildSVGRelationshipMapping()}catch(t){throw t}}createPresentationFromXML(t){try{const e="undefined"!==typeof globalThis&&globalThis.CPresentation||"undefined"!==typeof window&&window.CPresentation||null;if(!e)throw new Error("CPresentation is not defined");const presentation=new e;const r=t.documentElement;if(r){const t=r.querySelector("sldSz, p\\:sldSz");if(t)presentation.slideSize={cx:parseInt(t.getAttribute("cx"))||9144e3,cy:parseInt(t.getAttribute("cy"))||6858e3};const e=r.querySelector("sldMasterIdLst, p\\:sldMasterIdLst");if(e){const t=[];const r=e.querySelectorAll("sldMasterId, p\\:sldMasterId");r.forEach(e=>{const r=e.getAttribute("r:id")||e.getAttribute("id");if(r)t.push(r)});presentation.masterIds=t}const o=r.querySelector("sldIdLst, p\\:sldIdLst");if(o){const t=[];const e=o.querySelectorAll("sldId, p\\:sldId");e.forEach(e=>{const r=e.getAttribute("r:id")||e.getAttribute("id");if(r)t.push(r)});presentation.slideIds=t}const s=r.querySelector("defaultTextStyle, p\\:defaultTextStyle");if(s)presentation.defaultTextStyle=this.parseTextStyleElement(s)}return presentation}catch(t){const e=new CPresentation;e.slideSize={cx:9144e3,cy:6858e3};return e}}async processImages(t){try{if("function"===typeof this.extractMediaMap)await this.extractMediaMap();else await this.extractImageMap()}catch(t){await this.extractImageMap()}await this.preloadAllImages();this.logImageProcessingResults()}logImageProcessingResults(){const t=[];for(const[e,r]of this.imageMap){const o=this.imageCache.has(e);t.push({relId:e,imagePath:r,cached:o})}const e=this.zip.getPaths();const r=e.filter(t=>t.startsWith("ppt/media/")&&this.isImageFile(t))}async extractMediaMap(){const t=[];const e=this.zip.getPaths();for(const r of e)if(r.startsWith("ppt/media/"))t.push(r);const parts=[];const r=this.package.getPartByRelationshipType(Bt.presentation.relationType);if(r)parts.push(r);if(this.slides&&this.slides.length>0){const t=Object.keys(this.package.parts);const e=Object.keys(this.package.relationships);for(const e of t)if(e.includes("/slides/slide")&&e.endsWith(".xml")){const t=this.package.getPartByUri(e);if(t)parts.push(t)}}if(this.slideMasters&&this.slideMasters.length>0){const t=Object.keys(this.package.parts);for(const e of t)if(e.includes("/slideMasters/slideMaster")&&e.endsWith(".xml")){const t=this.package.getPartByUri(e);if(t)parts.push(t)}}if(this.slideLayouts&&this.slideLayouts.length>0){const t=Object.keys(this.package.parts);for(const e of t)if(e.includes("/slideLayouts/slideLayout")&&e.endsWith(".xml")){const t=this.package.getPartByUri(e);if(t)parts.push(t)}}for(const t of parts)await this.extractPartMediaRelationships(t)}async extractImageMap(){const t=[];const e=this.zip.getPaths();for(const r of e)if(r.startsWith("ppt/media/")&&this.isImageFile(r))t.push(r);const parts=[this.package.getPartByRelationshipType(Bt.presentation.relationType),...this.slides.map((t,e)=>this.package.getPartByUri(`/ppt/slides/slide${e+1}.xml`)),...this.slideMasters.map((t,e)=>this.package.getPartByUri(`/ppt/slideMasters/slideMaster${e+1}.xml`)),...this.slideLayouts.map((t,e)=>this.package.getPartByUri(`/ppt/slideLayouts/slideLayout${e+1}.xml`))].filter(t=>null!==t);for(const t of parts)await this.extractPartImageRelationships(t)}async extractPartImageRelationships(t){try{const e=await t.getRelationships();for(const[t,r]of Object.entries(e))if(r.type===Bt.image.relationType){let e=r.target;if(e.startsWith("../"))e=e.replace("../","ppt/");else if(!e.startsWith("/"))e=`/ppt/${e}`;this.imageMap.set(t,e)}}catch(t){}}isImageFile(t){const e=[".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp",".tiff"];const r=t.toLowerCase();return e.some(t=>r.endsWith(t))}async preloadSlideImages(t){if(!this.slides[t]||!this.slides[t].commonSlideData)return;const slide=this.slides[t];const e=this.extractImageRelationshipsFromSlide(slide);const r=e.map(t=>this.loadImage(t));await Promise.allSettled(r)}async preloadAllImages(){const t=new Set;for(const slide of this.slides){const e=this.extractImageRelationshipsFromSlide(slide);e.forEach(e=>t.add(e));if(slide.backgroundFill&&slide.backgroundFill.fill&&"image"===slide.backgroundFill.fill.type&&slide.backgroundFill.fill.imageData?.relationshipId)t.add(slide.backgroundFill.fill.imageData.relationshipId)}for(const e of this.slideMasters)if("image"===e.cSld?.bg?.fill?.type&&e.cSld.bg.fill.imageData?.relationshipId)t.add(e.cSld.bg.fill.imageData.relationshipId);const e=Array.from(t);const r=5;for(let t=0;t<e.length;t+=r){const o=e.slice(t,t+r);const s=o.map(t=>this.loadImage(t));await Promise.allSettled(s);const i=Math.min(100,Math.round((t+r)/e.length*100))}}extractImageRelationshipsFromSlide(slide){const t=[];if(slide.commonSlideData&&slide.commonSlideData.shapeTree)for(const e of slide.commonSlideData.shapeTree){if("pic"===e.type&&e.imageRelId)t.push(e.imageRelId);if("grpSp"===e.type&&e.shapeTree)t.push(...this.extractImageRelationshipsFromShapeTree(e.shapeTree))}return t}extractImageRelationshipsFromShapeTree(t){const e=[];for(const r of t){if("pic"===r.type&&r.imageRelId)e.push(r.imageRelId);if("grpSp"===r.type&&r.shapeTree)e.push(...this.extractImageRelationshipsFromShapeTree(r.shapeTree))}return e}async preloadAllImages(){try{const t=new Set;for(let e=0;e<this.slides.length;e++){const r=this.extractImageRelationshipsFromSlide(this.slides[e]);r.forEach(e=>t.add(e))}const e=Array.from(t).map(t=>this.loadImage(t).catch(e=>{this.logger.log("warn",this.constructor.name,`Failed to preload image ${t}:`,e);return null}));const r=await Promise.allSettled(e);const o=r.filter(t=>"fulfilled"===t.status&&null!==t.value).length}catch(t){this.logger.logError(this.constructor.name,"Error during image preloading:",t)}}async loadImage(t){const e=this.svgRelationshipMap.get(t);if(e)t=e;if(this.imageCache.has(t))return this.imageCache.get(t);const r=this.imageMap.get(t);if(!r){this.logger.log("warn",this.constructor.name,`No image path found for relId: ${t}`);return null}if(r.startsWith("data:")){if(r.startsWith("data:image/svg+xml"))try{const e=r.split(",")[1];const o=atob(e);this.imageCache.set(t,{type:"svg",content:o,path:r,width:100,height:100});return this.imageCache.get(t)}catch(e){this.logger.logError(this.constructor.name,`Failed to decode SVG data URI for ${t}:`,e);return null}return null}try{const e=await this.zip.getFileData(r);if(!e)return null;if(this.isSVGFile(r)){const o=new TextDecoder("utf-8").decode(e);this.imageCache.set(t,{type:"svg",content:o,path:r,width:100,height:100});return this.imageCache.get(t)}const o=new Blob([e],{type:this.getMimeType(r)});const s=URL.createObjectURL(o);const image=await this.imageLoader.loadImageFromUrl(s);this.imageCache.set(t,{image,url:s,path:r,width:image.naturalWidth,height:image.naturalHeight});return this.imageCache.get(t)}catch(t){return null}}getMimeType(t){const e=t.toLowerCase().split(".").pop();const r={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",bmp:"image/bmp",svg:"image/svg+xml",webp:"image/webp",tiff:"image/tiff"};return r[e]||"image/png"}async processThemes(t,e){try{const t=await e.getRelationships();if(!t){const theme=new CTheme;this.presentation.theme=theme;return}const r=Object.values(t).find(t=>t.type&&t.type.includes("theme")&&t.target);if(!r){const theme=new CTheme;this.presentation.theme=theme;return}let o=r.target;if(o.startsWith("/"))o=o.substring(1);else if(o.startsWith("../"))o=o.replace("../","");if(!o.startsWith("ppt/"))o="ppt/"+o;const s=await this.zip.getFileText(o);if(!s){const theme=new CTheme;this.presentation.theme=theme;return}const i=new DOMParser;const n=i.parseFromString(s,"text/xml");if("parsererror"===n.documentElement.nodeName){const theme=new CTheme;this.presentation.theme=theme;return}const theme=this.parseThemeFromXML(n);if(theme)this.presentation.theme=theme;else{const t=new CTheme;this.presentation.theme=t}}catch(t){const theme=new CTheme;this.presentation.theme=theme}}parseThemeFromXML(t){try{const e=t.querySelector("a\\:theme, theme");if(!e)return null;const r=e.querySelector("a\\:themeElements a\\:clrScheme, themeElements clrScheme");if(!r)return null;const theme=new CTheme;theme.name=e.getAttribute("name")||"Default Theme";theme.colors={};theme.fonts={major:"Calibri",minor:"Calibri"};theme.colors=this.extractEnhancedThemeColors(r);if(theme.colors.accent6){const t=this.parseColorFromHex(theme.colors.accent6)}const o=e.querySelector("a\\:themeElements a\\:fontScheme, themeElements fontScheme");if(o){const t=o.querySelector("a\\:majorFont a\\:latin, majorFont latin");const e=o.querySelector("a\\:minorFont a\\:latin, minorFont latin");if(t)theme.fonts.major=t.getAttribute("typeface")||"Calibri";if(e)theme.fonts.minor=e.getAttribute("typeface")||"Calibri"}const s=e.querySelector("a\\:themeElements a\\:fmtScheme, themeElements fmtScheme");if(s)theme.formatScheme=this.parseEnhancedFormatScheme(s,theme.colors);else theme.formatScheme=this.createEnhancedDefaultFormatScheme(theme.colors);theme.metadata={extracted:true,source:"pptx_file",timestamp:(new Date).toISOString(),colorCount:Object.keys(theme.colors).length,fillStyleCount:theme.formatScheme.fillStyles?.length||0,backgroundFillCount:theme.formatScheme.backgroundFills?.length||0};window.extractedTheme=theme;return theme}catch(t){return null}}extractEnhancedThemeColors(t){const e={};try{const r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink","bg1","tx1","bg2","tx2"];for(const o of r){const r=t.querySelector(`a\\:${o}, ${o}`)||t.querySelector(`[name="${o}"]`);if(r){const t=this.extractColorFromThemeElement(r);if(t)e[o]=t}}const o=t.querySelectorAll("*");for(const t of o){const r=t.tagName.replace("a:","");if(!e[r]&&"clrScheme"!==r&&"themeElements"!==r){const o=this.extractColorFromThemeElement(t);if(o)e[r]=o}}if(e.dk1&&!e.tx1)e.tx1=e.dk1;if(e.lt1&&!e.bg1)e.bg1=e.lt1;if(e.dk2&&!e.tx2)e.tx2=e.dk2;if(e.lt2&&!e.bg2)e.bg2=e.lt2}catch(t){}return e}extractColorFromThemeElement(t){try{const e=t.querySelector("a\\:srgbClr, srgbClr");if(e){const t=e.getAttribute("val");if(t&&/^[0-9A-Fa-f]{6}$/.test(t))return`#${t.toUpperCase()}`}const r=t.querySelector("a\\:sysClr, sysClr");if(r){const t=r.getAttribute("lastClr");if(t&&/^[0-9A-Fa-f]{6}$/.test(t))return`#${t.toUpperCase()}`;const e=r.getAttribute("val");const o={windowText:"#000000",window:"#FFFFFF",btnFace:"#F0F0F0",btnText:"#000000"};if(e&&o[e])return o[e]}const o=t.querySelector("a\\:hslClr, hslClr");if(o){const t=parseInt(o.getAttribute("hue")||"0");const e=parseInt(o.getAttribute("sat")||"0")/1e5;const r=parseInt(o.getAttribute("lum")||"0")/1e5;return this.hslToHex(t/6e4,e,r)}const s=t.querySelector("a\\:prstClr, prstClr");if(s){const t=s.getAttribute("val");const e={black:"#000000",white:"#FFFFFF",red:"#FF0000",green:"#00FF00",blue:"#0000FF",yellow:"#FFFF00",magenta:"#FF00FF",cyan:"#00FFFF"};if(t&&e[t])return e[t]}}catch(t){}return null}hslToHex(t,e,r){const o=(t,e,r)=>{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};const s=r<.5?r*(1+e):r+e-r*e;const i=2*r-s;const n=Math.round(255*o(i,s,t+1/3));const a=Math.round(255*o(i,s,t));const l=Math.round(255*o(i,s,t-1/3));return`#${((1<<24)+(n<<16)+(a<<8)+l).toString(16).slice(1).toUpperCase()}`}parseFormatScheme(t){const e={fillStyles:[],backgroundFills:[],lineStyles:[]};try{const r=t.querySelector("a\\:fillStyleLst, fillStyleLst");if(r){const t=r.children;for(let r=0;r<t.length;r++){const o=t[r];const s=this.parseThemeFillStyle(o);if(s)e.fillStyles.push(s)}}const o=t.querySelector("a\\:bgFillStyleLst, bgFillStyleLst");if(o){const t=o.children;for(let r=0;r<t.length;r++){const o=t[r];const s=this.parseThemeFillStyle(o);if(s)e.backgroundFills.push(s)}}const s=t.querySelector("a\\:lnStyleLst, lnStyleLst");if(s){const t=s.children;for(const r of t){const t=this.parseThemeLineStyle(r);if(t)e.lineStyles.push(t)}}}catch(t){}if(0===e.fillStyles.length){const t=this.createDefaultFormatScheme();e.fillStyles=t.fillStyles}if(0===e.backgroundFills.length){const t=this.createDefaultFormatScheme();e.backgroundFills=t.backgroundFills}return e}parseThemeFillStyle(t){try{const e=t.tagName.replace("a:","").toLowerCase();switch(e){case"solidfill":const e=this.parseFill(t);if(e&&e.color&&"placeholder"===e.color.type){const r={type:"solid",color:e.color,rawElement:t.outerHTML};return r}if(e)return e;return{type:"solid",color:{r:128,g:128,b:128,a:255},rawElement:t.outerHTML};case"gradfill":const r=this.parseFill(t);if(r&&"gradient"===r.type)return{type:"gradient",...r,rawElement:t.outerHTML};const o=t.querySelectorAll("a\\:gs, gs");const s=[];for(let t=0;t<o.length;t++){const e=o[t];const r=parseFloat(e.getAttribute("pos")||"0")/1e5;const i=e.querySelector("a\\:schemeClr, schemeClr, a\\:srgbClr, srgbClr, a\\:hslClr, hslClr");let n={type:"placeholder",value:"phClr"};if(i){const t=i.tagName.replace("a:","").toLowerCase();if("schemeclr"===t){const t=i.getAttribute("val")||"phClr";const r=this.parseColorModifications(e);const o=this.parseColorModifications(i);const s=[...r,...o];n={type:"phClr"===t?"placeholder":"scheme",value:t,modifications:s}}else if("srgbclr"===t){const t=i.getAttribute("val");if(t)n=this.parseColorFromHex(`#${t}`)}}s.push({position:r,color:n})}if(0===s.length)s.push({position:0,color:{type:"placeholder",value:"phClr"}},{position:1,color:{type:"placeholder",value:"phClr"}});const i={type:"gradient",direction:"linear",angle:0,stops:s,rawElement:t.outerHTML};return i;case"blipfill":const n=this.parseFill(t);return n;case"pattfill":const a=this.parseFill(t);return a;case"nofill":return{type:"none"};default:return{type:"solid",color:{r:128,g:128,b:128,a:255},rawElement:t.outerHTML}}}catch(e){return{type:"solid",color:{r:128,g:128,b:128,a:255},rawElement:t.outerHTML}}}parseThemeLineStyle(t){try{return this.parseStroke(t)}catch(t){return null}}parseEnhancedFormatScheme(t,e){const r={fillStyles:[],backgroundFills:[],lineStyles:[]};try{const o=t.querySelector("a\\:fillStyleLst, fillStyleLst");if(o){const t=o.children;for(let o=0;o<t.length;o++){const s=t[o];const i=this.parseThemeAwareFillStyle(s,e,o);if(i){r.fillStyles.push(i);if(5===o);}else{const t=this.createFallbackFillStyle(o,e);r.fillStyles.push(t);if(5===o);}}}const s=t.querySelector("a\\:bgFillStyleLst, bgFillStyleLst");if(s){const t=s.children;for(let o=0;o<t.length;o++){const s=t[o];const i=this.parseThemeAwareFillStyle(s,e,o);if(i)r.backgroundFills.push(i);else{const t=this.createFallbackBackgroundFillStyle(o,e);r.backgroundFills.push(t)}}}}catch(t){}this.ensureMinimumFormatSchemeStyles(r,e);return r}parseThemeAwareFillStyle(t,e,r){try{const o=t.tagName.replace("a:","").toLowerCase();if("solidfill"===o)return this.parseThemeAwareSolidFill(t,e,r);else if("gradfill"===o)return this.parseThemeAwareGradientFill(t,e,r);else if("nofill"===o)return{type:"none",index:r};const s=this.parseThemeFillStyle(t);if(s){s.index=r;return s}return null}catch(t){return null}}parseThemeAwareSolidFill(t,e,r){const o={type:"solid",index:r,color:null};try{const s=t.querySelector("a\\:schemeClr, schemeClr");if(s){const t=s.getAttribute("val");if(t&&e[t]){o.color=this.parseColorFromHex(e[t]);const r=this.parseColorModifications(s);if(r.length>0)o.color=this.applyColorModifications(o.color,r);o.scheme=t;o.modifications=r;return o}}const i=t.querySelector("a\\:srgbClr, srgbClr");if(i){const t=i.getAttribute("val");if(t){o.color=this.parseColorFromHex(`#${t}`);return o}}o.color=this.getDefaultColorForIndex(r,e);o.isDefault=true}catch(t){o.color=this.getDefaultColorForIndex(r,e);o.isDefault=true}return o}parseThemeAwareGradientFill(t,e,r){const o={type:"gradient",index:r,gradient:{type:"linear",stops:[]}};try{const r=t.querySelectorAll("a\\:gs, gs");for(let t=0;t<r.length;t++){const s=r[t];const i=parseFloat(s.getAttribute("pos")||"0")/1e5;const n={position:i,color:null};const a=s.querySelector("a\\:schemeClr, schemeClr");if(a){const t=a.getAttribute("val");if(t&&e[t]){n.color=this.parseColorFromHex(e[t]);const r=this.parseColorModifications(a);if(r.length>0)n.color=this.applyColorModifications(n.color,r)}}if(!n.color){const t=s.querySelector("a\\:srgbClr, srgbClr");if(t){const e=t.getAttribute("val");if(e)n.color=this.parseColorFromHex(`#${e}`)}}if(!n.color)n.color=this.getDefaultColorForIndex(t,e);o.gradient.stops.push(n)}const s=t.querySelector("a\\:lin, lin");if(s){const t=parseInt(s.getAttribute("ang")||"0");o.gradient.angle=t/6e4}return o}catch(t){return{type:"solid",index:r,color:this.getDefaultColorForIndex(r,e),isDefault:true}}}getDefaultColorForIndex(t,e){const r=["accent1","accent2","accent3","accent4","accent5","accent6"];const o=r[t%r.length];if(e&&e[o]){const t=this.parseColorFromHex(e[o]);return t}return null}ensureMinimumFormatSchemeStyles(t,e){while(t.fillStyles.length<6){const r=t.fillStyles.length;const o=this.createFallbackFillStyle(r,e);t.fillStyles.push(o)}while(t.backgroundFills.length<3){const r=t.backgroundFills.length;const o=this.createFallbackBackgroundFillStyle(r,e);t.backgroundFills.push(o)}}createFallbackFillStyle(t,e){return{type:"solid",index:t,color:this.getDefaultColorForIndex(t,e),isDefault:true}}createFallbackBackgroundFillStyle(t,e){const r=[e?.bg1?this.parseColorFromHex(e.bg1):{r:255,g:255,b:255,a:255},e?.bg2?this.parseColorFromHex(e.bg2):{r:245,g:245,b:245,a:255},{r:220,g:220,b:220,a:255}];return{type:"solid",index:t,color:r[t%r.length],isDefault:true}}createEnhancedDefaultFormatScheme(t){const e={fillStyles:[],backgroundFills:[],lineStyles:[]};for(let r=0;r<6;r++)e.fillStyles.push(this.createFallbackFillStyle(r,t));for(let r=0;r<3;r++)e.backgroundFills.push(this.createFallbackBackgroundFillStyle(r,t));return e}createDefaultFormatScheme(){return{fillStyles:[],backgroundFills:[],lineStyles:[]}}async processSlideMasters(t,e){const r=this.presentation.masterIds||[];const o=await e.getRelationships();for(const e of r){const r=o[e];if(r&&r.target){let e=r.target;if(e.startsWith("/"))e=e.substring(1);else if(e.startsWith("../"))e=e.replace("../","");if(!e.startsWith("ppt/"))e="ppt/"+e;const o=this.package.getPartByUri("/"+e);if(o){const e=await o.getDocumentContent();if(e){const r=new StaxParser(e,o,t);const s=r.parse();if(s){const e=this.createSlideMasterFromXML(s,o);if(e){this.slideMasters.push(e);this.presentation.addSlideMaster(e);await this.processSlideLayouts(t,e,o)}}}}}}}async processSlideLayouts(t,e,r){const o=await r.getRelationships();for(const[r,s]of Object.entries(o))if(s.type===Bt.slideLayout.relationType){let o=s.target;if(o.startsWith("/"))o=o.substring(1);else if(o.startsWith("../"))o=o.replace("../","");if(!o.startsWith("ppt/"))o="ppt/"+o;const i=this.package.getPartByUri("/"+o);if(i){const n=await i.getDocumentContent();if(n){const a=new StaxParser(n,i,t);const l=a.parse();if(l){const t=this.createSlideLayoutFromXML(l,e.id,r,s.target,o);if(t){this.slideLayouts.push(t);e.addLayout(t)}}}}}}createSlideMasterFromXML(t,e){const r=t.documentElement;const o=e.uri||"master_"+this.slideMasters.length;const s=new CSlideMaster;s.id=o;s.name=r.getAttribute("name")||`Master ${this.slideMasters.length+1}`;s.layoutIds=[];const i=t.querySelector("sldLayoutIdLst, p\\:sldLayoutIdLst");if(i){const t=i.querySelectorAll("sldLayoutId, p\\:sldLayoutId");t.forEach(t=>{const e=t.getAttribute("r:id");if(e)s.layoutIds.push(e)})}const n=t.querySelector("cSld, p\\:cSld");if(n){s.cSld={name:n.getAttribute("name")||"",bg:this.parseBackground(n),spTree:this.processShapeTree(n.querySelector("spTree, p\\:spTree"))};s.commonSlideData=new CSld;s.commonSlideData.name=s.cSld.name;s.commonSlideData.backgroundFill=s.cSld.bg;s.commonSlideData.shapeTree=s.cSld.spTree}const a=t.querySelector("txStyles, p\\:txStyles");if(a)s.txStyles={titleStyle:this.parseTextStyleElement(a.querySelector("titleStyle, p\\:titleStyle")),bodyStyle:this.parseTextStyleElement(a.querySelector("bodyStyle, p\\:bodyStyle")),otherStyle:this.parseTextStyleElement(a.querySelector("otherStyle, p\\:otherStyle"))};const l=t.querySelector("clrMap, p\\:clrMap");if(l)s.clrMap=this.parseColorMapElement(l);this.xmlParser.registerSlideMaster(s.id,s);return s}createSlideLayoutFromXML(t,e,r=null,o=null,s=null){const i=t.documentElement;const n=r||`layout_${this.slideLayouts.length}`;const a=new CSlideLayout;a.id=n;a.relId=r;a.relTarget=o;a.layoutPath=s;a.uri=o;a.masterId=e;a.name=i.getAttribute("name")||`Layout ${this.slideLayouts.length+1}`;a.type=i.getAttribute("type")||"blank";a.matchingName=i.getAttribute("matchingName")||"";a.preserve="true"===i.getAttribute("preserve");a.showMasterSp="false"!==i.getAttribute("showMasterSp");a.showMasterPhAnim="true"===i.getAttribute("showMasterPhAnim");a.userDrawn="false"!==i.getAttribute("userDrawn");if("blank"===a.type)a.layoutType=this.inferLayoutTypeFromPlaceholders(i);else a.layoutType=a.type;const l=t.querySelector("cSld, p\\:cSld");if(l){const t=l.querySelector("spTree, p\\:spTree");const e=this.processShapeTree(t);a.cSld={name:l.getAttribute("name")||"",bg:this.parseBackground(l),spTree:e};a.commonSlideData=new CSld;a.commonSlideData.name=a.cSld.name;a.commonSlideData.backgroundFill=a.cSld.bg;a.commonSlideData.shapeTree=a.cSld.spTree}const c=t.querySelector("txStyles, p\\:txStyles");if(c)a.txStyles={titleStyle:this.parseTextStyleElement(c.querySelector("titleStyle, p\\:titleStyle")),bodyStyle:this.parseTextStyleElement(c.querySelector("bodyStyle, p\\:bodyStyle")),otherStyle:this.parseTextStyleElement(c.querySelector("otherStyle, p\\:otherStyle"))};const h=t.querySelector("clrMapOvr, p\\:clrMapOvr");if(h)a.clrMapOvr=this.parseColorMapOverride(h);this.xmlParser.registerSlideLayout(a.id,a,e);return a}async processSlides(t){const e=await this.package.getPartByRelationshipType(Bt.presentation.relationType).getRelationships();const r=[];for(const[t,o]of Object.entries(e))if(o.type===Bt.slide.relationType)r.push({id:t,target:o.target});if(0===r.length)return;let o=r;try{const t=this.presentation&&Array.isArray(this.presentation.slideIds)?this.presentation.slideIds:[];if(t&&t.length>0){const e=new Map(r.map(t=>[t.id,t]));const s=[];for(const r of t){const t=e.get(r);if(t){s.push(t);e.delete(r)}}if(e.size>0)for(const t of e.values())s.push(t);if(s.length>0)o=s}}catch(t){}for(let e=0;e<o.length;e++)try{const r=o[e];let s=r.target;if(s.startsWith("/"))s=s.substring(1);else if(s.startsWith("../"))s=s.replace("../","");if(!s.startsWith("ppt/"))s="ppt/"+s;const i="/"+s;const n=this.package.getPartByUri(i);if(!n)continue;await this.processSlidePart(n,t,e)}catch(t){}}createSlideFromXML(t){try{const slide=new CSlide;this.currentSlide=slide;const e=t.querySelector("cSld, p\\:cSld");if(e){slide.commonSlideData=new CSld;const t=e.querySelector("spTree, p\\:spTree");if(t){const e=this.processShapeTree(t);slide.commonSlideData.shapeTree=e}const r=e.querySelector("bg, p\\:bg");if(r)slide.backgroundFill=this.parseBackground(e)}const r=t.documentElement;if(r){slide.showMasterShapes="0"!==r.getAttribute("showMasterSp");const t=r.querySelector("name, p\\:name");if(t)slide.name=t.textContent||""}return slide}catch(t){const e=new CSlide;e.commonSlideData=new CSld;e.commonSlideData.shapeTree=[];return e}}async processSlidePart(t,e,r){const o=await t.getDocumentContent();if(!o)return;const s=new StaxParser(o,t,e);const i=s.parse();if(!i)return;const slide=this.createSlideFromXML(i);if(slide){await this.linkSlideToLayoutAndMaster(slide,t,e,r);this.slides.push(slide);this.presentation.addSlide(slide)}}async linkSlideToLayoutAndMaster(slide,t,e,r){try{const e=await t.getRelationships();for(const[t,r]of Object.entries(e))if(r.type===Bt.slideLayout.relationType){let e=this.slideLayouts.find(t=>{if(r.target&&t.relTarget){const e=r.target.split("/").pop();const o=t.relTarget.split("/").pop();if(e===o)return true}return false});if(!e)e=this.slideLayouts.find(t=>{if(t.uri===r.target)return true;return false});if(!e)e=this.slideLayouts.find(t=>{if(r.target&&t.relTarget){const e=t=>t.replace(/^\.\.\//,"").replace(/^\//,"");if(e(r.target)===e(t.relTarget))return true}return false});if(!e)e=this.slideLayouts.find(e=>{if(e.relId===t)return true;return false});if(e){slide.layout=e;slide.Layout=e;const t=this.slideMasters.find(t=>t.id===e.masterId);if(t){slide.master=t;slide.Master=t;e.master=t;e.Master=t}break}}if(!slide.layout&&this.slideLayouts.length>0){slide.layout=this.slideLayouts[0];slide.Layout=this.slideLayouts[0]}else if(!slide.layout);}catch(t){}}processShapeTree(t){const e=[];try{if(!t)return e;const r=t.children;for(let t=0;t<r.length;t++)try{const o=r[t];const s=this.processShapeElement(o);if(s)e.push(s)}catch(t){}}catch(t){}return e}processShapeElement(t){try{if(!t)return null;const e=t.localName||t.tagName?.toLowerCase();let r=null;switch(e){case"sp":case"p:sp":r=this.processRegularShape(t);break;case"pic":case"p:pic":r=this.processPictureShape(t);break;case"grpsp":case"grpSp":case"p:grpSp":case"p:grpsp":r=this.processGroupShape(t);break;case"cxnsp":case"cxnSp":case"p:cxnSp":case"p:cxnsp":r=this.processConnectorShape(t);break;case"graphicframe":case"graphicFrame":case"p:graphicFrame":case"p:graphicframe":r=this.processGraphicFrame(t);break;default:const o=["nvsppr","p:nvsppr","nvpicpr","p:nvpicpr","nvgrpsppr","p:nvgrpsppr","nvGrpSpPr","p:nvGrpSpPr","nvpr","p:nvpr","cnvpr","p:cnvpr","cnvsppr","p:cnvsppr","style","p:style","txstyles","p:txstyles","extlst","p:extlst","ext","p:ext","grpsppr","p:grpsppr","grpSpPr","p:grpSpPr","sppr","p:sppr","picpr","p:picpr","cxnsppr","p:cxnsppr"];if(o.includes(e)||o.includes(e.toLowerCase()))return null;r=this.processDefaultShape(t)}if(r){r.id=t.getAttribute("id")||Math.random().toString(36).substr(2,9);r.name=this.getShapeName(t)||`Shape_${r.id}`;if("Rectangle 3"===r.name||r.name?.includes("Rectangle 3")){const e=t.querySelectorAll("p\\:style, style");e.forEach((t,e)=>{const r=t.querySelector("a\\:fillRef, fillRef");if(r);})}const e=t.querySelector("spPr, p\\:spPr");if(e){const t=this.processShapeProperties(e);if(t.transform&&!r.properties?.transform){r.properties=r.properties||{};r.properties.transform=t.transform;if(!r.bounds||0===r.bounds.l&&0===r.bounds.t&&0===r.bounds.r&&0===r.bounds.b)r.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)}}if(t.fill&&!r.fill)r.fill=t.fill;if(t.stroke&&!r.stroke)r.stroke=t.stroke;if(t.geometry&&!r.geometry)r.geometry=t.geometry;if(!r.spPr)r.spPr=t;if(t.effectLst)r.effects=t.effectLst;if(r.style||r.preservedStyle);}const o=t.querySelector("txBody, p\\:txBody");if(o)r.textBody=this.processTextBody(o)}return r}catch(t){return{type:"unknown",id:Math.random().toString(36).substr(2,9),name:"Unknown Shape",bounds:{l:914400,t:914400,r:5486400,b:2743200}}}}processRegularShape(t){const e=new CShape;e.type="sp";e.name=this.getShapeName(t);const r=t.querySelector("nvSpPr, p\\:nvSpPr");const o=r?.querySelector("cNvPr, p\\:cNvPr");e.id=o?.getAttribute("id")||t.getAttribute("id")||null;if(o){const t=Array.from(o.attributes).map(t=>`${t.name}="${t.value}"`);const r=o.getAttribute("order")||o.getAttribute("z-order")||o.getAttribute("zOrder")||o.getAttribute("drawOrder");if(r)e.order=parseInt(r)}const s=t.getAttribute("order")||t.getAttribute("z-order")||t.getAttribute("zOrder")||t.getAttribute("drawOrder");if(s)e.order=parseInt(s);try{if(r){e.nvSpPr={cNvPr:null,nvPr:null};if(o){e.name=o.getAttribute("name")||e.name;e.nvSpPr.cNvPr={name:e.name,id:e.id}}const t=r.querySelector("nvPr, p\\:nvPr");if(t){const r=t.querySelector("ph, p\\:ph");if(r){e.placeholder=this.parsePlaceholder(r);e.isPlaceholder=true}e.nvSpPr.nvPr={placeholder:e.placeholder}}}e.type="sp";const s=t.querySelector("spPr, p\\:spPr");if(s){const t=this.processShapeProperties(s);e.properties=t;e.spPr=t;if(t.effectLst)e.effects=t.effectLst;if(t.transform)e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};else e.bounds={l:914400,t:914400,r:5486400,b:2743200};if(void 0!==t.fill)e.fill=t.fill;if(t.stroke)e.stroke=t.stroke;const r=s.querySelector("prstGeom, a\\:prstGeom");if(r){const t=r.getAttribute("prst")||"rect";e.geometry={type:"preset",preset:t}}const o=s.querySelector("custGeom, a\\:custGeom");if(o)e.geometry={type:"custom",pathList:this.parseCustomGeometry(o)}}else e.bounds={l:914400,t:914400,r:5486400,b:2743200};const i=t.querySelector("txBody, p\\:txBody");if(i){e.textBody=this.processTextBody(i);if(e.textBody&&e.textBody.paragraphs){let t=false;let r="";for(const o of e.textBody.paragraphs)for(const e of o.runs)if(e.text&&e.text.trim()){t=true;r+=e.text+" "}if(t);}}let n=false;const a=t.querySelector("style, p\\:style");if(a){e.style=this.parseShapeStyle(a);e.preservedStyle=e.style;n=true}if(!n&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){const t=window.currentSlideData.rawXMLShapes.find(t=>t.name===e.name||t.id===e.id);if(t&&t.style){e.style=t.style;e.preservedStyle=t.style;n=true}}if(!n){const r=this.extractStyleFromElement(t);if(r&&Object.keys(r).length>0){e.style=r;e.preservedStyle=r;n=true}}if(n){window.currentSlideData=window.currentSlideData||{};window.currentSlideData.rawXMLShapes=window.currentSlideData.rawXMLShapes||[];const t=window.currentSlideData.rawXMLShapes.findIndex(t=>t.name===e.name||t.id===e.id);if(-1===t)window.currentSlideData.rawXMLShapes.push({name:e.name,id:e.id,styleElement:a,style:e.style,hasStyle:true})}else{window.currentSlideData=window.currentSlideData||{};window.currentSlideData.rawXMLShapes=window.currentSlideData.rawXMLShapes||[];window.currentSlideData.rawXMLShapes.push({name:e.name,id:e.id,xmlElement:t,innerHTML:t.innerHTML.substring(0,500),hasStyle:false})}}catch(t){}this.applyPropertyInheritance(e);return e}processPictureShape(t){const e=new CShape;e.type="pic";let r=false;const o=t.querySelector("style, p\\:style");if(o){e.style=this.parseShapeStyle(o);e.preservedStyle=e.style;r=true}if(!r&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){const t=window.currentSlideData.rawXMLShapes.find(t=>t.name===e.name||t.id===e.id);if(t&&t.style){e.style=t.style;e.preservedStyle=t.style;r=true}}if(!r){const o=this.extractStyleFromElement(t);if(o&&Object.keys(o).length>0){e.style=o;e.preservedStyle=o;r=true}}if(!r);const s=t.querySelector("spPr, p\\:spPr");if(s){const t=this.processShapeProperties(s);e.properties=t;if(t.transform)e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};else e.bounds={l:914400,t:914400,r:5486400,b:2743200}}else e.bounds={l:914400,t:914400,r:5486400,b:2743200};const i=t.querySelector("blipFill, p\\:blipFill");if(i){const t=i.querySelector("blip, a\\:blip");if(t){const r=this.extractSVGRelationshipId(t);if(r){e.imageRelId=r;e.hasSVGAlternative=true}else{const r=t.getAttribute("r:embed");if(r)e.imageRelId=r}const o=t.querySelector("effects, a\\:effects");if(o)e.imageEffects=this.parseImageEffects(o)}const r=i.querySelector("stretch, a\\:stretch");const o=i.querySelector("tile, a\\:tile");if(r){e.imageFillMode="stretch";const t=r.querySelector("fillRect, a\\:fillRect");if(t)e.imageFillRect={l:parseInt(t.getAttribute("l"))||0,t:parseInt(t.getAttribute("t"))||0,r:parseInt(t.getAttribute("r"))||0,b:parseInt(t.getAttribute("b"))||0}}else if(o){e.imageFillMode="tile";e.imageTileProperties={tx:parseInt(o.getAttribute("tx"))||0,ty:parseInt(o.getAttribute("ty"))||0,sx:parseInt(o.getAttribute("sx"))||1e5,sy:parseInt(o.getAttribute("sy"))||1e5,flip:o.getAttribute("flip")||"none",algn:o.getAttribute("algn")||"tl"}}else e.imageFillMode="stretch"}e.name=this.getShapeName(t);this.applyPropertyInheritance(e);return e}parseImageEffects(t){const e={};const r=t.querySelector("alphaMod, a\\:alphaMod");if(r)e.alpha=parseInt(r.getAttribute("val"))/1e5;const o=t.querySelector("lum, a\\:lum");if(o){e.brightness=parseInt(o.getAttribute("bright"))||0;e.contrast=parseInt(o.getAttribute("contrast"))||0}const s=t.querySelector("clrMod, a\\:clrMod");if(s)e.colorMod=s.getAttribute("val");const i=t.querySelector("grayscl, a\\:grayscl");if(i)e.grayscale=true;return e}parseEffectList(t){const e={};const r=t.querySelector("outerShdw, a\\:outerShdw");if(r)e.outerShadow=this.parseOuterShadow(r);const o=t.querySelector("innerShdw, a\\:innerShdw");if(o)e.innerShadow=this.parseInnerShadow(o);const s=t.querySelector("glow, a\\:glow");if(s)e.glow=this.parseGlow(s);const i=t.querySelector("reflection, a\\:reflection");if(i)e.reflection=this.parseReflection(i);const n=t.querySelector("softEdge, a\\:softEdge");if(n)e.softEdge=this.parseSoftEdge(n);const a=t.querySelector("prstShdw, a\\:prstShdw");if(a)e.presetShadow=this.parsePresetShadow(a);return e}parseOuterShadow(t){const e={};e.blurRadius=parseInt(t.getAttribute("blurRad"))||0;e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;e.scaleX=parseInt(t.getAttribute("sx"))/1e5||1;e.scaleY=parseInt(t.getAttribute("sy"))/1e5||1;e.skewX=parseInt(t.getAttribute("kx"))||0;e.skewY=parseInt(t.getAttribute("ky"))||0;e.alignment=t.getAttribute("algn")||"bl";e.rotateWithShape="1"===t.getAttribute("rotWithShape");const r=t.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");if(r)e.color=this.parseColor(r);return e}parseInnerShadow(t){const e={};e.blurRadius=parseInt(t.getAttribute("blurRad"))||0;e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;const r=t.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");if(r)e.color=this.parseColor(r);return e}parseGlow(t){const e={};e.radius=parseInt(t.getAttribute("rad"))||0;const r=t.querySelector("srgbClr, a\\:srgbClr, schemeClr, a\\:schemeClr");if(r)e.color=this.parseColor(r);return e}parseReflection(t){const e={};e.blurRadius=parseInt(t.getAttribute("blurRad"))||0;e.startOpacity=parseInt(t.getAttribute("stA"))/1e5||1;e.endOpacity=parseInt(t.getAttribute("endA"))/1e5||0;e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;e.fadeDirection=parseInt(t.getAttribute("fadeDir"))||0;e.scaleX=parseInt(t.getAttribute("sx"))/1e5||1;e.scaleY=parseInt(t.getAttribute("sy"))/1e5||1;e.skewX=parseInt(t.getAttribute("kx"))||0;e.skewY=parseInt(t.getAttribute("ky"))||0;e.alignment=t.getAttribute("algn")||"bl";return e}parseSoftEdge(t){const e={};e.radius=parseInt(t.getAttribute("rad"))||0;return e}parsePresetShadow(t){const e={};e.preset=t.getAttribute("prst")||"shdw1";e.distance=parseInt(t.getAttribute("dist"))||0;e.direction=parseInt(t.getAttribute("dir"))||0;return e}parseColor(t){const e={};if(t.tagName.includes("srgbClr")){e.type="srgb";e.value=t.getAttribute("val")||"000000"}else if(t.tagName.includes("schemeClr")){e.type="scheme";e.value=t.getAttribute("val")||"dk1"}const r=t.querySelector("alpha, a\\:alpha");if(r)e.alpha=parseInt(r.getAttribute("val"))/1e5||1;else e.alpha=1;return e}processGroupShape(t){const e=new CShape;e.type="grpSp";e.name=this.getShapeName(t);e.id=t.getAttribute("id")||Math.random().toString(36).substr(2,9);e.shapeTree=[];e.groupCoordSystem={chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}};this.applyComprehensiveStyleExtraction(e,t,"group");const r=t.querySelector("grpSpPr, p\\:grpSpPr");if(r)this.processGroupProperties(r,e);const o=t.querySelector("spTree, p\\:spTree");if(o)e.shapeTree=this.processShapeTreeInGroup(o,e);else{const r=t.children;for(let t=0;t<r.length;t++){const o=r[t];const s=o.tagName.toLowerCase();if("sp"===s||"p:sp"===s||"pic"===s||"p:pic"===s||"grpsp"===s||"p:grpsp"===s||"cxnsp"===s||"p:cxnsp"===s)try{const t=this.processShapeElement(o);if(t){t.inGroup=true;t.parentGroup=e;this.transformChildShapeCoordinates(t,e);e.shapeTree.push(t)}}catch(t){}}}if(!e.bounds)this.calculateGroupBounds(e);this.applyPropertyInheritance(e);return e}processGroupProperties(t,e){const r=t.querySelector("xfrm, a\\:xfrm");if(r){const t=this.processGroupTransform(r);e.transform=t;e.groupCoordSystem=t.groupCoordSystem;if(t.groupOff&&t.groupExt)e.bounds={l:t.groupOff.x,t:t.groupOff.y,r:t.groupOff.x+t.groupExt.cx,b:t.groupOff.y+t.groupExt.cy}}const o=this.processShapeProperties(t);if(o.fill)e.fill=o.fill;if(o.stroke)e.stroke=o.stroke}processGroupTransform(t){const e={rotation:0,flipH:false,flipV:false,groupOff:{x:0,y:0},groupExt:{cx:0,cy:0},groupCoordSystem:{chOff:{x:0,y:0},chExt:{cx:0,cy:0},groupOff:{x:0,y:0},groupExt:{cx:0,cy:0}}};const r=t.getAttribute("rot");if(r)e.rotation=parseInt(r)/6e4;e.flipH="1"===t.getAttribute("flipH")||"true"===t.getAttribute("flipH");e.flipV="1"===t.getAttribute("flipV")||"true"===t.getAttribute("flipV");const o=t.querySelector("off, a\\:off");if(o){e.groupOff.x=parseInt(o.getAttribute("x"))||0;e.groupOff.y=parseInt(o.getAttribute("y"))||0}const s=t.querySelector("ext, a\\:ext");if(s){e.groupExt.cx=parseInt(s.getAttribute("cx"))||0;e.groupExt.cy=parseInt(s.getAttribute("cy"))||0}const i=t.querySelector("chOff, a\\:chOff");if(i){e.groupCoordSystem.chOff.x=parseInt(i.getAttribute("x"))||0;e.groupCoordSystem.chOff.y=parseInt(i.getAttribute("y"))||0}const n=t.querySelector("chExt, a\\:chExt");if(n){e.groupCoordSystem.chExt.cx=parseInt(n.getAttribute("cx"))||0;e.groupCoordSystem.chExt.cy=parseInt(n.getAttribute("cy"))||0}e.groupCoordSystem.groupOff={...e.groupOff};e.groupCoordSystem.groupExt={...e.groupExt};return e}processShapeTreeInGroup(t,e){const r=[];try{if(!t)return r;const o=t.children;for(let t=0;t<o.length;t++)try{const s=o[t];const i=this.processShapeElement(s);if(i){i.inGroup=true;i.parentGroup=e;this.transformChildShapeCoordinates(i,e);r.push(i)}}catch(t){}}catch(t){}return r}transformChildShapeCoordinates(t,e){if(!t.bounds||!e.groupCoordSystem)return;const r=e.groupCoordSystem;const o=t.bounds;let s=1,i=1;if(r.chExt.cx>0&&r.groupExt.cx>0)s=r.groupExt.cx/r.chExt.cx;if(r.chExt.cy>0&&r.groupExt.cy>0)i=r.groupExt.cy/r.chExt.cy;const n={l:r.groupOff.x+(o.l-r.chOff.x)*s,t:r.groupOff.y+(o.t-r.chOff.y)*i,r:r.groupOff.x+(o.r-r.chOff.x)*s,b:r.groupOff.y+(o.b-r.chOff.y)*i};t.originalBounds={...o};t.bounds=n;t.groupTransform={scaleX:s,scaleY:i,offsetX:r.groupOff.x-r.chOff.x*s,offsetY:r.groupOff.y-r.chOff.y*i}}calculateGroupBounds(t){if(!t.shapeTree||0===t.shapeTree.length){t.bounds={l:914400,t:914400,r:5486400,b:2743200};return}let e=1/0,r=1/0;let o=-1/0,s=-1/0;let i=false;for(const n of t.shapeTree)if(n.bounds){e=Math.min(e,n.bounds.l);r=Math.min(r,n.bounds.t);o=Math.max(o,n.bounds.r);s=Math.max(s,n.bounds.b);i=true}if(i)t.bounds={l:e,t:r,r:o,b:s};else t.bounds={l:914400,t:914400,r:5486400,b:2743200}}processConnectorShape(t){const e=new CShape;e.type="cxnSp";this.applyComprehensiveStyleExtraction(e,t,"connector");try{const e=t.getAttribute("id")||t.getAttribute("r:id");this.logger?.log("info",this.constructor.name,"[Connector Parse] start",{id:e})}catch(t){}const r=t.querySelector("spPr, p\\:spPr");if(r){const t=this.processShapeProperties(r);e.properties=t;if(t&&t.stroke){if(!e.properties.line)e.properties.line=t.stroke;if(!e.stroke)e.stroke=t.stroke}if(t&&t.transform)e.transform=Object.assign(e.transform||{},t.transform);try{const t=r.querySelector("a\\:ln, ln, p\\:ln");if(t){const r=this.parseStroke(t);e.properties=e.properties||{};e.properties.stroke=r;e.properties.line=r;e.stroke=r;e.spPr=e.spPr||{};e.spPr.ln=Object.assign({},r)}}catch(t){}if(t.geometry)e.geometry=t.geometry;if(t.transform){e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};try{this.logger?.log("info",this.constructor.name,"[Connector Parse] bounds from transform",{bounds:e.bounds,transform:t.transform})}catch(t){}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};try{this.logger?.log("warn",this.constructor.name,"[Connector Parse] no transform, using fallback bounds")}catch(t){}try{void 0}catch(t){}}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};try{this.logger?.log("warn",this.constructor.name,"[Connector Parse] no spPr found, using fallback bounds")}catch(t){}try{void 0}catch(t){}}this.applyPropertyInheritance(e);try{const t=this.getShapeStrokeColor(e);const r=this.getShapeLineWidth(e);const o=this.getShapeStrokeInfo(e)}catch(t){}return e}processGraphicFrame(t){const e=new CShape;e.type="graphicFrame";this.applyComprehensiveStyleExtraction(e,t,"graphic frame");const r=t.querySelector("spPr, p\\:spPr");if(r){const t=this.processShapeProperties(r);if(t.transform){const r=t.transform.x||0;const o=t.transform.y||0;const s=t.transform.cx||t.transform.width||0;const i=t.transform.cy||t.transform.height||0;e.bounds={l:r,t:o,r:r+s,b:o+i};e.x=r;e.y=o;e.w=s;e.h=i;if(!e.properties)e.properties={};e.properties.transform={x:r,y:o,width:s,height:i,cx:s,cy:i}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};e.x=914400;e.y=914400;e.w=4572e3;e.h=1828800}}else{const r=t.querySelector("xfrm, p\\:xfrm");if(r){const o=r.querySelector("off, p\\:off");const s=r.querySelector("ext, p\\:ext");if(o&&s){const r=parseInt(o.getAttribute("x"))||0;const i=parseInt(o.getAttribute("y"))||0;const n=parseInt(s.getAttribute("cx"))||914400;const a=parseInt(s.getAttribute("cy"))||914400;e.bounds={l:r,t:i,r:r+n,b:i+a};e.x=r;e.y=i;e.w=n;e.h=a;if(!e.properties)e.properties={};e.properties.transform={x:r,y:i,width:n,height:a,cx:n,cy:a};if(0===r&&0===i||n<=1e5&&a<=1e5){let o=t.parentElement;while(o&&o.tagName){const t=o.querySelector("xfrm, p\\:xfrm");if(t){const r=t.querySelector("off, p\\:off");const o=t.querySelector("ext, p\\:ext");if(r&&o){const t=parseInt(r.getAttribute("x"))||0;const s=parseInt(r.getAttribute("y"))||0;const i=parseInt(o.getAttribute("cx"))||0;const n=parseInt(o.getAttribute("cy"))||0;if(i>1e5&&n>1e5){e.bounds={l:t,t:s,r:t+i,b:s+n};e.x=t;e.y=s;e.w=i;e.h=n;if(!e.properties)e.properties={};e.properties.transform={x:t,y:s,width:i,height:n,cx:i,cy:n};break}}}o=o.parentElement}if(!e.bounds||e.x===r&&e.y===i);}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};e.x=914400;e.y=914400;e.w=4572e3;e.h=1828800}}else{e.bounds={l:914400,t:914400,r:5486400,b:2743200};e.x=914400;e.y=914400;e.w=4572e3;e.h=1828800}}let o=t.querySelector("graphic");if(!o)o=t.querySelector("p\\:graphic");if(!o)o=t.querySelector("a\\:graphic");if(!o)o=Array.from(t.children).find(t=>t.tagName.toLowerCase().includes("graphic"));if(o){let r=o.querySelector("graphicData");if(!r)r=o.querySelector("p\\:graphicData");if(!r)r=o.querySelector("a\\:graphicData");if(!r)r=Array.from(o.children).find(t=>t.tagName.toLowerCase().includes("graphicdata"));if(r){const o=r.getAttribute("uri");e.graphicData={uri:o};if("http://schemas.openxmlformats.org/drawingml/2006/table"===o){let t=r.querySelector("tbl");if(!t)t=r.querySelector("a\\:tbl");if(!t)t=Array.from(r.children).find(t=>t.tagName.toLowerCase().includes("tbl"));if(t)e.graphicData.tableXml=(new XMLSerializer).serializeToString(t)}else if("http://schemas.openxmlformats.org/drawingml/2006/chart"===o){e.graphicData.element=r;if(ChartProcessor)try{e.asyncChartProcessing=true;e.originalBounds={l:e.bounds.l,t:e.bounds.t,r:e.bounds.r,b:e.bounds.b};const r=e.originalBounds.r-e.originalBounds.l;const o=e.originalBounds.b-e.originalBounds.t;const s={event:"ORIGINAL_BOUNDS_STORAGE",shapeType:e.type,rawBounds:e.bounds,originalBounds:e.originalBounds,originalDimensions:{width:r,height:o,widthInches:(r/914400).toFixed(2),heightInches:(o/914400).toFixed(2)}};e._debugInfo=s;const i={...this.context,zip:this.zip||this.zipProcessor?.zip};const n=new ChartProcessor(i);n.parseChartFromGraphicFrame(t).then(t=>{if(t){e.chartData=t;e.asyncChartProcessing=false;if(this.graphics&&e.bounds)this.graphics.drawGraphicFrame(e,e.bounds);if("undefined"!==typeof window)window.dispatchEvent(new CustomEvent("chartRenderingComplete",{detail:{chartData:t}}))}}).catch(t=>{void 0;e.asyncChartProcessing=false})}catch(t){void 0}else void 0}}}return e}processDefaultShape(t){const e=new CShape;e.type="unknown";this.applyComprehensiveStyleExtraction(e,t,"default shape");const r=t.querySelector("spPr, p\\:spPr");if(r){const t=this.processShapeProperties(r);if(t.transform)e.bounds={l:t.transform.x||0,t:t.transform.y||0,r:(t.transform.x||0)+(t.transform.cx||t.transform.width||0),b:(t.transform.y||0)+(t.transform.cy||t.transform.height||0)};else e.bounds={l:914400,t:914400,r:5486400,b:2743200}}else e.bounds={l:914400,t:914400,r:5486400,b:2743200};this.applyPropertyInheritance(e);return e}getShapeName(t){const e=t.querySelector("nvSpPr, p\\:nvSpPr")||t.querySelector("nvPicPr, p\\:nvPicPr")||t.querySelector("nvGrpSpPr, p\\:nvGrpSpPr");if(e){const t=e.querySelector("cNvPr, p\\:cNvPr");if(t)return t.getAttribute("name")||""}return""}processShapeProperties(t){const e={};if(!t)return e;const r=Array.from(t.children);try{let r=t.querySelector("xfrm, p\\:xfrm, a\\:xfrm");if(!r)r=t.querySelector("xfrm");if(!r)for(const e of t.children)if("xfrm"===e.tagName||"a:xfrm"===e.tagName||"p:xfrm"===e.tagName){r=e;break}if(r){const t=Array.from(r.children);let o=r.querySelector("off, p\\:off, a\\:off");if(!o)o=r.querySelector("off");if(!o)for(const t of r.children)if("off"===t.tagName||"a:off"===t.tagName||"p:off"===t.tagName){o=t;break}let s=r.querySelector("ext, p\\:ext, a\\:ext");if(!s)s=r.querySelector("ext");if(!s)for(const t of r.children)if("ext"===t.tagName||"a:ext"===t.tagName||"p:ext"===t.tagName){s=t;break}if(o){const t=o.getAttribute("x");const e=o.getAttribute("y")}if(s){const t=s.getAttribute("cx");const e=s.getAttribute("cy")}if(o&&s){const t=parseInt(o.getAttribute("x"))||0;const r=parseInt(o.getAttribute("y"))||0;const i=parseInt(s.getAttribute("cx"))||100;const n=parseInt(s.getAttribute("cy"))||100;e.transform={x:t,y:r,cx:i,cy:n,width:i,height:n}}const i=r.getAttribute("rot");if(i){e.transform=e.transform||{};const t=parseInt(i)/6e4||0;e.transform.rot=t;e.transform.rotation=t;e.transform.rotEMU=parseInt(i)||0}const n=r.getAttribute("flipH");const a=r.getAttribute("flipV");if(null!==n||null!==a){e.transform=e.transform||{};if(null!==n)e.transform.flipH="1"===n||"true"===n;if(null!==a)e.transform.flipV="1"===a||"true"===a}}let o=t.querySelector("solidFill, p\\:solidFill, a\\:solidFill");if(!o)o=t.querySelector("gradFill, p\\:gradFill, a\\:gradFill");if(!o)o=t.querySelector("blipFill, p\\:blipFill, a\\:blipFill");if(!o)o=t.querySelector("pattFill, p\\:pattFill, a\\:pattFill");if(!o)o=t.querySelector("noFill, p\\:noFill, a\\:noFill");if(o){this._currentProcessingShape={name:this.getShapeName(t.closest("sp, p\\:sp"))||"Unknown"};e.fill=this.parseFill(o);this._currentProcessingShape=null;const r=this.getShapeName(t.closest("sp, p\\:sp"));if("Rectangle 3"===r||r?.includes("Rectangle 3"));}const s=t.querySelector("ln, p\\:ln, a\\:ln");if(s)e.stroke=this.parseStroke(s);const i=t.querySelector("prstGeom, p\\:prstGeom, a\\:prstGeom");if(i){const t=i.getAttribute("prst")||"rect";e.geometry={type:"preset",preset:t}}else{const e=Array.from(t.children)}const n=t.querySelector("custGeom, p\\:custGeom, a\\:custGeom");if(n)e.geometry={type:"custom",pathList:this.parseCustomGeometry(n)};const a=t.querySelector("effectLst, p\\:effectLst, a\\:effectLst");if(a)e.effectLst=this.parseEffectList(a)}catch(t){}return e}processTextBody(t){const e={paragraphs:[],bodyProperties:this.parseBodyProperties(t)};try{const r=t.querySelector("lstStyle, a\\:lstStyle");if(r)e.lstStyle=this.parseListStyle(r);const o=t.querySelectorAll("p, a\\:p");for(const t of o){const r={runs:[],properties:this.parseParagraphProperties(t)};const o=t.querySelectorAll("r, a\\:r");for(const t of o){const e=t.querySelector("t, a\\:t");const o=e?e.textContent:"";const s={text:o||"",properties:this.parseRunProperties(t)};if(o&&o.trim());r.runs.push(s)}if(0===r.runs.length)r.runs.push({text:"",properties:{}});e.paragraphs.push(r)}const s=e.paragraphs.reduce((t,e)=>t+e.runs.length,0);const i=e.paragraphs.reduce((t,e)=>t+e.runs.filter(t=>t.text&&t.text.trim()).length,0);const n=e.paragraphs.map(t=>t.runs.map(t=>t.text||"").join("")).join(" ").trim()}catch(t){}return e}parseListStyle(t){const e={};try{for(let r=1;r<=9;r++){const o=t.querySelector(`lvl${r}pPr, a\\:lvl${r}pPr`);if(o){const t={align:o.getAttribute("algn")||"left",marL:parseInt(o.getAttribute("marL"))||0,indent:parseInt(o.getAttribute("indent"))||0};const s=o.querySelector("defRPr, a\\:defRPr");if(s){const e=parseInt(s.getAttribute("sz"))||1800;t.fontSize=e/100;t.bold="1"===s.getAttribute("b");t.italic="1"===s.getAttribute("i");const r=s.getAttribute("cap");if(r)t.cap=r;const o=s.querySelector("latin, a\\:latin");if(o)t.fontFamily=o.getAttribute("typeface")||"Arial";const i=s.querySelector("solidFill, a\\:solidFill");if(i)t.color=this.parseColor(i)}e[`lvl${r}pPr`]=t}}}catch(t){}return e}parseBodyProperties(t){const e={wrap:true,verticalAlign:"top",anchorX:"center",anchorY:"middle"};try{const r=t.querySelector("bodyPr, a\\:bodyPr");if(r){if("none"===r.getAttribute("wrap"))e.wrap=false;const t=r.getAttribute("anchor");if(t)e.verticalAlign=t;e.anchorX=r.getAttribute("anchorX")||"center";e.anchorY=r.getAttribute("anchorY")||"middle";e.leftMargin=parseInt(r.getAttribute("lIns"))||45720;e.rightMargin=parseInt(r.getAttribute("rIns"))||45720;e.topMargin=parseInt(r.getAttribute("tIns"))||22860;e.bottomMargin=parseInt(r.getAttribute("bIns"))||22860}}catch(t){}return e}parseParagraphProperties(t){const e={align:"left",lineHeight:100,spacing:{before:0,after:0},bullet:null};try{const r=t.querySelector("pPr, a\\:pPr");if(r){const t=r.getAttribute("lvl");if(null!==t&&void 0!==t)e.level=parseInt(t)||0;else e.level=0;const o=r.getAttribute("algn");if(o)e.align=o;const s=r.querySelector("lnSpc, a\\:lnSpc");if(s){const t=s.querySelector("spcPct, a\\:spcPct");const r=s.querySelector("spcPts, a\\:spcPts");if(t)e.lineHeight=parseInt(t.getAttribute("val"))/1e3;else if(r){const t=parseInt(r.getAttribute("val"));e.lineHeightPoints=t/100}}const i=r.querySelector("spcBef, a\\:spcBef");if(i){const t=i.querySelector("spcPts, a\\:spcPts");if(t)e.spacing.before=127*parseInt(t.getAttribute("val"))}const n=r.querySelector("spcAft, a\\:spcAft");if(n){const t=n.querySelector("spcPts, a\\:spcPts");if(t)e.spacing.after=127*parseInt(t.getAttribute("val"))}const a=r.getAttribute("marL");const l=r.getAttribute("indent");if(null!==a||null!==l)e.indent={left:a?parseInt(a):0,hanging:l?parseInt(l):0};this.parseBulletProperties(r,e);const c=r.querySelector("defRPr, a\\:defRPr");if(c){const t=parseInt(c.getAttribute("sz"))||1800;e.fontSize=t/100;e.bold="1"===c.getAttribute("b");e.italic="1"===c.getAttribute("i");const r=c.querySelector("latin, a\\:latin");if(r)e.fontFamily=r.getAttribute("typeface")||"Arial";const o=c.querySelector("solidFill, a\\:solidFill");if(o)e.color=this.parseColor(o)}}}catch(t){}return e}parseBulletProperties(t,e){try{const r=t.querySelector("buChar, a\\:buChar");if(r){const t=r.getAttribute("char");if(t){e.bullet={type:"character",char:t};return}}const o=t.querySelector("buNum, a\\:buNum");if(o){const t=o.getAttribute("startAt")||"1";e.bullet={type:"number",startAt:parseInt(t)};return}const s=t.querySelector("buAutoNum, a\\:buAutoNum");if(s){const t=s.getAttribute("type")||"arabicPeriod";const r=s.getAttribute("startAt")||"1";e.bullet={type:"autoNumber",subType:t,startAt:parseInt(r)};return}const i=t.querySelector("buNone, a\\:buNone");if(i){e.bullet={type:"none"};return}}catch(t){}}parseRunProperties(t){const e={};try{const r=t.querySelector("rPr, a\\:rPr");if(r){let t=null;if(r.hasAttribute("sz"))t=parseInt(r.getAttribute("sz"));else{const e=r.querySelector("sz, a\\:sz");if(e)t=parseInt(e.getAttribute("val"))}if(t&&t>0)e.fontSize=t/100;const o=r.querySelector("latin, a\\:latin");if(o)e.fontFamily=o.getAttribute("typeface")||"Arial";else e.fontFamily=null;if(r.hasAttribute("b")){const t=r.getAttribute("b");e.bold="0"!==t&&"false"!==t}if(r.hasAttribute("i")){const t=r.getAttribute("i");e.italic="0"!==t&&"false"!==t}if(r.hasAttribute("u"))e.underline="none"!==r.getAttribute("u");if(r.hasAttribute("strike"))e.strike="noStrike"!==r.getAttribute("strike");if(r.hasAttribute("baseline")){const t=parseInt(r.getAttribute("baseline"))||0;if(t>0)e.verticalAlign="superscript";else if(t<0)e.verticalAlign="subscript"}if(r.hasAttribute("cap"))e.cap=r.getAttribute("cap");if(r.hasAttribute("spc"))e.letterSpacing=parseInt(r.getAttribute("spc"))/100;const s=r.querySelector("solidFill, a\\:solidFill");if(s)e.color=this.parseColor(s);const i=r.querySelector("highlight, a\\:highlight");if(i)e.highlight=this.parseColor(i)}}catch(t){}return e}parseFill(t){if(!t)return null;const e=this._currentProcessingShape;const r=e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3"));if(r);let o=t.querySelector("solidFill, a\\:solidFill");if(!o&&("a:solidFill"===t.tagName||"solidFill"===t.tagName))o=t;if(r)if(o);if(o){if(r);let t=null;try{t=this.parseColor(o);if(r);}catch(t){if(r);return null}const e={type:"solid",color:t};if(r);return e}const s=t.querySelector("gradFill, a\\:gradFill");if(s){const t=this.parseGradient(s);return{type:"gradient",gradient:t}}const i=t.querySelector("pattFill, a\\:pattFill");if(i)return{type:"pattern",pattern:this.parsePattern(i)};const n=t.querySelector("blipFill, a\\:blipFill");if(n){const t=this.parseBlipFill(n);return{type:"image",imageData:t}}const a=t.querySelector("noFill, a\\:noFill");if(a||"a:noFill"===t.tagName||"noFill"===t.tagName||"noFill"===t.localName)return{type:"none"};return null}parseBlipFill(t){const e=t.querySelector("blip, a\\:blip");if(!e)return null;const r={};const o=e.getAttribute("r:embed");if(o)r.relationshipId=o;const s=t.querySelector("effects, a\\:effects");if(s)r.effects=this.parseImageEffects(s);const i=t.querySelector("stretch, a\\:stretch");const n=t.querySelector("tile, a\\:tile");if(i){r.fillMode="stretch";const t=i.querySelector("fillRect, a\\:fillRect");if(t)r.fillRect={l:parseInt(t.getAttribute("l"))||0,t:parseInt(t.getAttribute("t"))||0,r:parseInt(t.getAttribute("r"))||0,b:parseInt(t.getAttribute("b"))||0}}else if(n){r.fillMode="tile";r.tileProperties={tx:parseInt(n.getAttribute("tx"))||0,ty:parseInt(n.getAttribute("ty"))||0,sx:parseInt(n.getAttribute("sx"))||1e5,sy:parseInt(n.getAttribute("sy"))||1e5,flip:n.getAttribute("flip")||"none",algn:n.getAttribute("algn")||"tl"}}else r.fillMode="stretch";const a=t.querySelector("srcRect, a\\:srcRect");if(a)r.sourceRect={l:parseInt(a.getAttribute("l"))||0,t:parseInt(a.getAttribute("t"))||0,r:parseInt(a.getAttribute("r"))||0,b:parseInt(a.getAttribute("b"))||0};return r}parseColor(t){if(!t)return{r:0,g:0,b:0,a:255};const e=t.querySelector("srgbClr, a\\:srgbClr");if(e){const t=e.getAttribute("val");if(t){let r={r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:255};r=this.applyColorModificationsToRgb(e,r);return r}}const r=t.querySelector("schemeClr, a\\:schemeClr");if(r){const t=r.getAttribute("val");const e=this._currentProcessingShape;const o=e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3"));if(o)if(this.presentation?.theme?.colors);if("phClr"===t)return{type:"placeholder",scheme:"phClr",modifications:this.parseColorModifications(r),r:128,g:128,b:128,a:255};let s=null;if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){const e=this.presentation.theme.colors[t];if(e){s=this.parseColorFromHex(e);if(o);}else if(o);}else if(o);if(!s){if(o);const e={};s=e[t]||null;if(o);}s=this.applyColorModificationsToRgb(r,s);if(o);return s}return{r:0,g:0,b:0,a:255}}parseColorModifications(t){const e=[];const r=t.querySelectorAll("*");for(const t of r){const r=t.tagName.replace("a:","").toLowerCase();const o=t.getAttribute("val");if(o)e.push({type:r,value:parseInt(o)})}return e}applyColorModificationsToRgb(t,e){if(!t)return e;const r={...e};const o=t.querySelector("tint, a\\:tint");if(o){const t=parseInt(o.getAttribute("val"))/1e5;r.r=Math.round(r.r+(255-r.r)*t);r.g=Math.round(r.g+(255-r.g)*t);r.b=Math.round(r.b+(255-r.b)*t)}const s=t.querySelector("shade, a\\:shade");if(s){const t=parseInt(s.getAttribute("val"))/1e5;r.r=Math.round(r.r*(1-t));r.g=Math.round(r.g*(1-t));r.b=Math.round(r.b*(1-t))}const i=t.querySelector("lumMod, a\\:lumMod");if(i){const t=parseInt(i.getAttribute("val"))/1e5;r.r=Math.round(r.r*t);r.g=Math.round(r.g*t);r.b=Math.round(r.b*t)}const n=t.querySelector("lumOff, a\\:lumOff");if(n){const t=parseInt(n.getAttribute("val"))/1e5*255;r.r=Math.round(Math.min(255,r.r+t));r.g=Math.round(Math.min(255,r.g+t));r.b=Math.round(Math.min(255,r.b+t))}const a=t.querySelector("alpha, a\\:alpha");if(a){const t=parseInt(a.getAttribute("val"))/1e5;r.a=Math.round(255*t)}r.r=Math.max(0,Math.min(255,r.r));r.g=Math.max(0,Math.min(255,r.g));r.b=Math.max(0,Math.min(255,r.b));r.a=Math.max(0,Math.min(255,r.a));return r}parseGradient(t){const e={stops:[],type:"linear"};const r=t.querySelector("gsLst, a\\:gsLst");if(r){const t=r.querySelectorAll("gs, a\\:gs");t.forEach(t=>{const r=parseInt(t.getAttribute("pos"))||0;const o=this.parseColor(t);e.stops.push({position:r/1e5,color:o})})}const o=t.querySelector("lin, a\\:lin");if(o){e.angle=parseInt(o.getAttribute("ang"))||0;e.scaled="true"===o.getAttribute("scaled")}const s=t.querySelector("rad, a\\:rad");if(s)e.type="radial";return e}parsePattern(t){return{preset:t.getAttribute("prst"),foregroundColor:this.parseColor(t.querySelector("fgClr, a\\:fgClr")),backgroundColor:this.parseColor(t.querySelector("bgClr, a\\:bgClr"))}}parseStroke(t){try{const e={};const r=t.getAttribute("w");if(r)e.width=parseInt(r)||12700;else e.width=12700;let o=t.querySelector("solidFill, a\\:solidFill");if(o)e.color=this.parseColor(o);else{o=t.querySelector("gradFill, a\\:gradFill");if(o){e.gradient=this.parseGradient(o);e.color=e.gradient}}const s=t.getAttribute("cap");if(s)e.cap=s;else e.cap="flat";const i=t.getAttribute("join");if(i)e.join=i;else e.join="round";const n=t.getAttribute("cmpd");if(n)e.compound=n;else e.compound="sng";const a=t.querySelector("prstDash, a\\:prstDash");if(a){e.dashStyle=a.getAttribute("val")||"solid";e.dashArray=this.getDashArray(e.dashStyle)}else{e.dashStyle="solid";e.dashArray=[]}const l=t.querySelector("custDash, a\\:custDash");if(l){e.dashArray=this.parseCustomDash(l);e.dashStyle="custom"}const c=t.getAttribute("algn");if(c)e.alignment=c;else e.alignment="ctr";const h=t.querySelector("headEnd, a\\:headEnd");if(h)e.headEnd={type:h.getAttribute("type")||h.getAttribute("val")||"none",w:h.getAttribute("w")||h.getAttribute("width")||"med",len:h.getAttribute("len")||h.getAttribute("length")||"med"};const u=t.querySelector("tailEnd, a\\:tailEnd");if(u)e.tailEnd={type:u.getAttribute("type")||u.getAttribute("val")||"none",w:u.getAttribute("w")||u.getAttribute("width")||"med",len:u.getAttribute("len")||u.getAttribute("length")||"med"};return e}catch(t){return{color:{r:0,g:0,b:0,a:255},width:12700,cap:"flat",join:"round",compound:"sng",dashStyle:"solid",dashArray:[],alignment:"ctr"}}}getDashArray(t){const e={solid:[],dot:[1,1],dash:[3,1],dashDot:[3,1,1,1],dashDotDot:[3,1,1,1,1,1],lgDash:[8,3],lgDashDot:[8,3,1,3],lgDashDotDot:[8,3,1,3,1,3],sysDash:[2,2],sysDot:[1,2],sysDashDot:[2,2,1,2],sysDashDotDot:[2,2,1,2,1,2]};return e[t]||[]}parseCustomDash(t){const e=[];try{const r=t.querySelectorAll("ds, a\\:ds");for(const t of r){const r=parseInt(t.getAttribute("d"))||1e5;const o=parseInt(t.getAttribute("sp"))||1e5;e.push(r/1e5,o/1e5)}}catch(t){}return e}parseCustomGeometry(t){const e=[];try{const r=t.querySelector("pathLst, a\\:pathLst");if(r){const t=r.querySelectorAll("path, a\\:path");for(const r of t){const t={w:parseInt(r.getAttribute("w"))||100,h:parseInt(r.getAttribute("h"))||100,commands:[]};const o=r.querySelectorAll("moveTo, lineTo, cubicBezTo, close, a\\:moveTo, a\\:lineTo, a\\:cubicBezTo, a\\:close");for(const e of o){const r=this.parsePathCommand(e);if(r)t.commands.push(r)}e.push(t)}}}catch(t){}return e}parsePathCommand(t){const e=t.tagName.toLowerCase().replace(/^a:/,"");switch(e){case"moveto":const e=t.querySelector("pt, a\\:pt");if(e)return{type:"moveTo",x:parseInt(e.getAttribute("x"))||0,y:parseInt(e.getAttribute("y"))||0};break;case"lineto":const r=t.querySelector("pt, a\\:pt");if(r)return{type:"lineTo",x:parseInt(r.getAttribute("x"))||0,y:parseInt(r.getAttribute("y"))||0};break;case"cubicbezto":const o=t.querySelectorAll("pt, a\\:pt");if(o.length>=3)return{type:"cubicBezTo",x1:parseInt(o[0].getAttribute("x"))||0,y1:parseInt(o[0].getAttribute("y"))||0,x2:parseInt(o[1].getAttribute("x"))||0,y2:parseInt(o[1].getAttribute("y"))||0,x3:parseInt(o[2].getAttribute("x"))||0,y3:parseInt(o[2].getAttribute("y"))||0};break;case"close":return{type:"close"}}return null}parseShapeStyle(t){const e={};try{const r=t.querySelector("fillRef, a\\:fillRef");if(r)e.fillRef={idx:parseInt(r.getAttribute("idx"))||0,color:this.parseColor(r)};const o=t.querySelector("lnRef, a\\:lnRef");if(o)e.lnRef={idx:parseInt(o.getAttribute("idx"))||0,color:this.parseColor(o)};const s=t.querySelector("effectRef, a\\:effectRef");if(s)e.effectRef={idx:parseInt(s.getAttribute("idx"))||0};const i=t.querySelector("fontRef, a\\:fontRef");if(i)e.fontRef={idx:i.getAttribute("idx")||"minor"}}catch(t){}return e}extractStyleFromElement(t){const e={};try{const r=t.querySelector("style, p\\:style, a\\:style");if(r)return this.parseShapeStyle(r);const o=t.querySelector("spPr, p\\:spPr");if(o){const t=this.extractStyleAttributesFromSpPr(o);if(t&&Object.keys(t).length>0)Object.assign(e,t)}const s=this.extractStyleAttributesFromElement(t);if(s&&Object.keys(s).length>0)Object.assign(e,s);const i=t.querySelector("nvSpPr, p\\:nvSpPr");if(i){const t=this.extractStyleAttributesFromNvSpPr(i);if(t&&Object.keys(t).length>0)Object.assign(e,t)}}catch(t){}return e}extractStyleAttributesFromSpPr(t){const e={};try{const r=t.getAttribute("style")||t.getAttribute("styleRef");if(r){const t=this.parseStyleReference(r);if(t)Object.assign(e,t)}const o=t.querySelector("schemeClr, a\\:schemeClr");if(o){const t=o.getAttribute("val");if(t)e.schemeColor=t}}catch(t){}return e}extractStyleAttributesFromElement(t){const e={};try{const r=["style","styleRef","themeRef","colorRef"];r.forEach(r=>{const o=t.getAttribute(r);if(o)e[r]=o})}catch(t){}return e}extractStyleAttributesFromNvSpPr(t){const e={};try{const r=t.querySelector("ph, p\\:ph");if(r){const t=r.getAttribute("type");const o=r.getAttribute("idx");if(t){const r={title:{fillRef:{idx:1}},body:{fillRef:{idx:2}},ctrTitle:{fillRef:{idx:1}},subTitle:{fillRef:{idx:2}},obj:{fillRef:{idx:3}}};if(r[t])Object.assign(e,r[t])}}}catch(t){}return e}parseStyleReference(t){try{if(t.includes("fillRef")){const e=t.match(/fillRef:(\d+)/);if(e)return{fillRef:{idx:parseInt(e[1])||0}}}}catch(t){}return null}applyComprehensiveStyleExtraction(t,e,r="shape"){let o=false;const s=e.querySelector("style, p\\:style");if(s){t.style=this.parseShapeStyle(s);t.preservedStyle=t.style;o=true}if(!o&&window.currentSlideData&&window.currentSlideData.rawXMLShapes){const e=window.currentSlideData.rawXMLShapes.find(e=>e.name===t.name||e.id===t.id);if(e&&e.style){t.style=e.style;t.preservedStyle=e.style;o=true}}if(!o){const r=this.extractStyleFromElement(e);if(r&&Object.keys(r).length>0){t.style=r;t.preservedStyle=r;o=true}}return o}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(e)return{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)};return{r:0,g:0,b:0}}initializeRendering(){try{const t=document.createElement("canvas");t.width=800;t.height=600;const e=this.getGraphicsEngine();if(!e)this.initializeGraphicsEngine();if(this.drawingDocument){this.drawingDocument.init(t,this);const e="undefined"!==typeof globalThis&&globalThis.SVGRenderer||"undefined"!==typeof window&&window.SVGRenderer||null;if(e&&this.drawingDocument.graphics)this.svgRenderer=new e(this.drawingDocument.graphics);else throw new Error("SVGRenderer is not defined")}else throw new Error("standard graphics engine not available")}catch(t){throw new Error("Failed to initialize rendering system: "+t.message)}}async renderSlide(t,e){const r=performance.now();try{if(!t)throw new Error("Canvas is required for rendering");if(e<0||e>=this.slides.length)throw new Error(`Invalid slide index: ${e}`);const slide=this.slides[e];if(!slide)throw new Error(`Slide at index ${e} is null`);this.currentSlide=slide;const o=this.getGraphicsEngine();if(!o)this.initializeGraphicsEngine();const s=this.getSlideDimensions();const i=this.calculateCanvasRect(t,s);if(!this.drawingDocument)throw new Error("standard graphics engine not available");this.drawingDocument.init(t,this);const n=this.drawingDocument.graphics;if(this.renderContext.enableOptimizations){const e=parseFloat(t.style.width)||t.width/(window.devicePixelRatio||1);const r=parseFloat(t.style.height)||t.height/(window.devicePixelRatio||1);n.updatedRect=new Ot(0,0,e,r)}n.clear();await this.preloadSlideImages(e);this.logSlideImageStatus(slide,e);await this.drawingDocument.drawSlide(slide,e);this.currentSlideIndex=e;const a=performance.now()-r}catch(e){if(t){const r=t.getContext("2d");r.fillStyle="#ffebee";r.fillRect(0,0,t.width,t.height);r.fillStyle="#f44336";r.font="16px Arial";r.textAlign="center";r.fillText("Rendering Error",t.width/2,t.height/2);r.fillText(e.message,t.width/2,t.height/2+25)}}}async renderMaster(t,e){try{if(!t)throw new Error("Canvas is required for rendering");if(e<0||e>=this.slideMasters.length)throw new Error(`Invalid master index: ${e}`);const r=this.slideMasters[e];if(!r)throw new Error(`Master at index ${e} is null`);const o={name:r.name||`Master ${e+1}`,type:"master",commonSlideData:r.commonSlideData||r.cSld,backgroundFill:r.cSld?.bg,showMasterShapes:false,layout:null,master:null};this.currentSlide=o;const s=this.getSlideDimensions();const i=this.calculateCanvasRect(t,s);if(!this.drawingDocument)this.initializeRendering();this.drawingDocument.init(t,this);const n=this.drawingDocument.graphics;n.clear();await this.drawingDocument.drawSlide(o,e)}catch(e){if(t){const r=t.getContext("2d");r.fillStyle="#f0f8ff";r.fillRect(0,0,t.width,t.height);r.fillStyle="#e74c3c";r.font="16px Arial";r.textAlign="center";r.fillText("Master Rendering Error",t.width/2,t.height/2);r.fillText(e.message,t.width/2,t.height/2+25)}}}async renderLayout(t,e){try{if(!t)throw new Error("Canvas is required for rendering");if(e<0||e>=this.slideLayouts.length)throw new Error(`Invalid layout index: ${e}`);const r=this.slideLayouts[e];if(!r)throw new Error(`Layout at index ${e} is null`);const o=this.slideMasters.find(t=>t.id===r.masterId);const s={name:r.name||`Layout ${e+1}`,type:"layout",commonSlideData:r.commonSlideData||r.cSld,backgroundFill:r.cSld?.bg||o?.cSld?.bg,showMasterShapes:false!==r.showMasterSp,layout:r,master:o};this.currentSlide=s;const i=this.getSlideDimensions();const n=this.calculateCanvasRect(t,i);if(!this.drawingDocument)this.initializeRendering();this.drawingDocument.init(t,this);const a=this.drawingDocument.graphics;a.clear();await this.drawingDocument.drawSlide(s,e)}catch(e){if(t){const r=t.getContext("2d");r.fillStyle="#fff5f5";r.fillRect(0,0,t.width,t.height);r.fillStyle="#e74c3c";r.font="16px Arial";r.textAlign="center";r.fillText("Layout Rendering Error",t.width/2,t.height/2);r.fillText(e.message,t.width/2,t.height/2+25)}}}drawRegularShapeGeometry(t,e,r,o,s,i,n,a,l,c=null){let h=this.getShapePreset(e);if(!h&&e.geometry)h=e.geometry.preset;if(!h&&e.properties&&e.properties.geometry)h=e.properties.geometry.preset;if(c)n=c;else if(n&&"object"===typeof n&&"linear"===n.type);let u=null;let f=null;if(n)if("linear"===n.type&&n.stops)u=n;else if("string"===typeof n){const t=this.hexToRgb(n);u=t}else if(void 0!==n.r)u=n;if(a)if("string"===typeof a){const t=this.hexToRgb(a);f=t}else if(void 0!==a.r)f=a;const d=this.getShapeStrokeInfo(e);if(h)t.drawPresetGeometry(h,r,o,s,i,u,f,l,d);else t.drawRectangle(r,o,s,i,u,f,l,d)}getSlideCount(){return this.slides.length}getCurrentSlideIndex(){return this.currentSlideIndex}getSlideInfo(t){const slide=this.slides[t];if(!slide)return null;return{index:t,name:slide.getName(),shapeCount:slide.getShapeTree().length}}getSlideDimensions(){return this.presentation?.slideSize||{cx:9144e3,cy:6858e3}}getSlideDimensionsForCanvas(t,e){const r=this.getSlideDimensions();const o=t/r.cx;const s=e/r.cy;const i=Math.min(o,s);return{width:r.cx*i,height:r.cy*i,scale:i,offsetX:(t-r.cx*i)/2,offsetY:(e-r.cy*i)/2}}async generateSlideThumbnail(t,e=320,r=240){try{if(!this.getGraphicsEngine())this.initializeGraphicsEngine();if(!this.slides[t])return this.createFallbackThumbnail(t,e,r);const slide=this.slides[t];const o=this.getSlideDimensions();const s=o.cx/o.cy;const i=o.cx/914400*96;const n=o.cy/914400*96;const a=e/i;const l=r/n;const c=Math.min(a,l);let h=i*c;let u=n*c;h=Math.max(h,100);u=Math.max(u,75);const f=document.createElement("canvas");this.setupHighResolutionCanvas(f,h,u);if(this.drawingDocument){this.drawingDocument.init(f,this);try{await this.drawingDocument.drawSlide(slide,t);return f}catch(e){return this.createFallbackThumbnail(t,h,u)}}else return this.createFallbackThumbnail(t,h,u)}catch(o){return this.createFallbackThumbnail(t,e,r)}}createFallbackThumbnail(t,e,r){const o=document.createElement("canvas");this.setupHighResolutionCanvas(o,e,r);const s=o.getContext("2d");s.fillStyle="#f0f0f0";s.fillRect(0,0,e,r);s.fillStyle="#666";s.font="16px Arial";s.textAlign="center";s.fillText(`Slide ${t+1}`,e/2,r/2);try{const t=this.getSlideDimensions();const o=t.cx/t.cy;s.font="12px Arial";s.fillText(`${o.toFixed(2)}:1`,e/2,r/2+20)}catch(t){}return o}inferLayoutTypeFromPlaceholders(t){const e=t.querySelector("cSld, p\\:cSld");if(!e)return"blank";const r=e.querySelector("spTree, p\\:spTree");if(!r)return"blank";const o=[];const s=r.children;for(let t=0;t<s.length;t++){const e=s[t];const r=this.extractPlaceholderInfo(e);if(r)o.push(r.type)}if(o.includes("title")&&o.includes("body"))return"titleAndContent";else if(o.includes("title"))return"titleOnly";else if(o.includes("body"))return"contentOnly";else if(0===o.length)return"blank";return"custom"}extractPlaceholderInfo(t){const e=t.querySelector("nvSpPr, p\\:nvSpPr")||t.querySelector("nvPicPr, p\\:nvPicPr")||t.querySelector("nvGrpSpPr, p\\:nvGrpSpPr");if(!e)return null;const r=e.querySelector("nvPr, p\\:nvPr");if(!r)return null;const o=r.querySelector("ph, p\\:ph");if(!o)return null;return{type:o.getAttribute("type")||"obj",idx:o.getAttribute("idx"),orient:o.getAttribute("orient"),sz:o.getAttribute("sz")}}parsePlaceholder(t){const e=t.getAttribute("idx");const r=null===e||void 0===e?void 0:isNaN(parseInt(e,10))?void 0:parseInt(e,10);const o={type:t.getAttribute("type")||"obj",orient:t.getAttribute("orient")||"horz",sz:t.getAttribute("sz")||"full",idx:r};const s=t.querySelector("extLst, p\\:extLst");if(s){const t=s.querySelector("ext, p\\:ext");if(t){const e=t.querySelector("phTxt, p\\:phTxt");if(e)o.text=e.textContent}}return o}parseBackground(t){const e=t.querySelector("bg, p\\:bg");if(!e)return null;const r=e.querySelector("bgPr, p\\:bgPr");if(r){const t=this.parseFill(r);return{type:"bgPr",fill:t}}const o=e.querySelector("bgRef, p\\:bgRef");if(o)return{type:"bgRef",idx:o.getAttribute("idx")};return null}parseTextStyleElement(t){if(!t)return null;return{element:t,parsed:false}}parseColorMapElement(t){if(!t)return null;const e={};const r=t.attributes;for(let t=0;t<r.length;t++){const o=r[t];e[o.name]=o.value}return e}parseColorMapOverride(t){if(!t)return null;const e=t.querySelector("masterClrMapping, p\\:masterClrMapping");if(e)return this.parseColorMapElement(e);const r=t.querySelector("overrideClrMapping, p\\:overrideClrMapping");if(r)return this.parseColorMapElement(r);return null}calculateCanvasRect(t,e){const r=e.cx/914400*96;const o=e.cy/914400*96;let s,i;if(t.style.width&&t.style.height){s=parseFloat(t.style.width);i=parseFloat(t.style.height)}else{s=t.width/(window.devicePixelRatio||1);i=t.height/(window.devicePixelRatio||1)}const n=s/r;const a=i/o;let l=Math.min(n,a);const c=r*l;const h=o*l;const u=(s-c)/2;const f=(i-h)/2;let d=Math.round(c);let p=Math.round(h);let g=Math.round(u);let m=Math.round(f);if(Math.abs(d-s)<=1&&Math.abs(p-i)<=1){d=Math.round(s);p=Math.round(i);g=0;m=0}const y=d/r;const b=p/o;l=Math.min(y,b);return{widthPx:Math.round(s),heightPx:Math.round(i),slideWidthPx:r,slideHeightPx:o,scale:l,offsetX:g,offsetY:m,scaledWidth:d,scaledHeight:p,widthMM:e.cx/914400*25.4,heightMM:e.cy/914400*25.4}}calculateShapeBounds(t,e){if(!t||!t.bounds)return{x:0,y:0,w:100,h:100};const r=this.getSlideDimensions();const o=r.cx;const s=r.cy;const i=e.slideWidthPx;const n=e.slideHeightPx;const a={x:(t.bounds.l||0)/o*i,y:(t.bounds.t||0)/s*n,w:((t.bounds.r||0)-(t.bounds.l||0))/o*i,h:((t.bounds.b||0)-(t.bounds.t||0))/s*n};const l=e.offsetX+a.x*e.scale;const c=e.offsetY+a.y*e.scale;const h=a.w*e.scale;const u=a.h*e.scale;const f=this.getShapeRotation(t);if(f&&0!==f)return this.calculateRotatedBounds({x:l,y:c,w:h,h:u},f);return{x:l,y:c,w:h,h:u}}getShapeBounds(t,e){if(!t||!t.bounds)return{x:0,y:0,w:100,h:100};const r=this.getSlideDimensions();const o=r.cx;const s=r.cy;const i=e.slideWidthPx;const n=e.slideHeightPx;const a={x:(t.bounds.l||0)/o*i,y:(t.bounds.t||0)/s*n,w:((t.bounds.r||0)-(t.bounds.l||0))/o*i,h:((t.bounds.b||0)-(t.bounds.t||0))/s*n};const l=e.offsetX+a.x*e.scale;const c=e.offsetY+a.y*e.scale;const h=a.w*e.scale;const u=a.h*e.scale;return{x:l,y:c,w:h,h:u}}calculateShapeTransform(t,e){if(!t||!t.properties||!t.properties.transform)return null;const r=t.properties.transform;const o=new CMatrix;const s=this.getSlideDimensions();const i=s.cx;const n=s.cy;const a=e.slideWidthPx;const l=e.slideHeightPx;if(void 0!==r.x&&void 0!==r.y){const t=r.x/i*a;const s=r.y/n*l;o.tx=e.offsetX+t*e.scale;o.ty=e.offsetY+s*e.scale}if(void 0!==r.rot){const t=r.rot*Math.PI/180;const s=Math.cos(t);const i=Math.sin(t);o.sx=s*e.scale;o.sy=s*e.scale;o.shx=-i*e.scale;o.shy=i*e.scale}else{o.sx=e.scale;o.sy=e.scale}return o}drawSlideBackground(t,slide,e){if(slide.backgroundFill)this.renderBackgroundFill(t,slide.backgroundFill,e)}renderBackgroundFill(t,e,r){if(!e||!e.fill)return;const o=e.fill;switch(o.type){case"solid":this.renderSolidBackground(t,o,r);break;case"gradient":this.renderGradientBackground(t,o,r);break;case"image":this.renderImageBackground(t,o,r);break;case"pattern":this.renderPatternBackground(t,o,r)}}renderSolidBackground(t,e,r){if(e.color){const o=this.rgbToHex(e.color);t.fillRect(0,0,r.widthPx,r.heightPx,o)}}renderGradientBackground(t,e,r){if(!e.gradient||!e.gradient.stops||0===e.gradient.stops.length){const o=e.gradient?.stops?.[0]?.color||{r:255,g:255,b:255,a:255};t.fillRect(0,0,r.widthPx,r.heightPx,this.rgbToHex(o));return}const o=t.context;const{widthPx:s,heightPx:i}=r;let n;if("radial"===e.gradient.type){const t=s/2;const e=i/2;const r=Math.max(s,i)/2;n=o.createRadialGradient(t,e,0,t,e,r)}else{const t=(e.gradient.angle||0)*Math.PI/180/6e4;const r=Math.sqrt(s*s+i*i);const a=s/2-Math.cos(t)*r/2;const l=i/2-Math.sin(t)*r/2;const c=s/2+Math.cos(t)*r/2;const h=i/2+Math.sin(t)*r/2;n=o.createLinearGradient(a,l,c,h)}e.gradient.stops.forEach(t=>{const e=this.rgbToHex(t.color);n.addColorStop(t.position,e)});o.fillStyle=n;o.fillRect(0,0,s,i)}renderImageBackground(t,e,r){if(!e.imageData||!e.imageData.relationshipId){t.fillRect(0,0,r.widthPx,r.heightPx,"#f0f0f0");return}const o=e.imageData.relationshipId;const s=this.imageCache.get(o);if(s&&s.image)this.drawBackgroundImage(t,s.image,e.imageData,r);else{t.fillRect(0,0,r.widthPx,r.heightPx,"#f8f9fa");const e=t.context;e.fillStyle="#6c757d";e.font="14px Arial";e.textAlign="center";e.fillText("Loading background...",r.widthPx/2,r.heightPx/2);this.loadImageAsync(o)}}drawBackgroundImage(t,image,e,r){const o=t.context;const{widthMM:s,heightMM:i}=r;o.save();try{if("tile"===e.fillMode)this.drawTiledBackgroundImage(o,image,e.tileProperties,s,i);else{let r=0,o=0,n=s,a=i;if(e.fillRect){const t=e.fillRect;r=s*t.l/1e5;o=i*t.t/1e5;n=s*(1e5-t.l-t.r)/1e5;a=i*(1e5-t.t-t.b)/1e5}if(e.sourceRect){const s=e.sourceRect;const i=image.naturalWidth*s.l/1e5;const l=image.naturalHeight*s.t/1e5;const c=image.naturalWidth*(1e5-s.l-s.r)/1e5;const h=image.naturalHeight*(1e5-s.t-s.b)/1e5;t.drawImageHighRes(image,i,l,c,h,r,o,n,a)}else t.drawImageHighRes(image,r,o,n,a)}if(e.effects)this.applyImageEffects(t,e.effects)}catch(t){o.fillStyle="#f0f0f0";o.fillRect(0,0,s,i)}finally{o.restore()}}drawTiledBackgroundImage(t,image,e,r,o){if(!e)return;const s=e.sx/1e5;const i=e.sy/1e5;const n=e.tx/914400*25.4;const a=e.ty/914400*25.4;const l=image.naturalWidth*s;const c=image.naturalHeight*i;const h=document.createElement("canvas");h.width=l;h.height=c;const u=h.getContext("2d");u.imageSmoothingEnabled=true;u.imageSmoothingQuality="high";u.drawImage(image,0,0,l,c);const f=t.createPattern(h,"repeat");t.save();t.translate(n,a);t.fillStyle=f;t.fillRect(-n,-a,r,o);t.restore()}renderPatternBackground(t,e,r){const o=e.pattern?.foregroundColor||{r:128,g:128,b:128,a:255};const s=this.rgbToHex(o);t.fillRect(0,0,r.widthMM,r.heightMM,s)}getShapeFillColor(t){this._currentProcessingShape=t;const e=t&&("Rectangle 3"===t.name||t.name?.includes("Rectangle 3"));if(t.fill){if("solid"===t.fill.type&&t.fill.color){const r=this.processShapeColor(t.fill.color);if(e);this._currentProcessingShape=null;return r}if("gradient"===t.fill.type&&t.fill.gradient){this._currentProcessingShape=null;return this.processGradientFill(t.fill.gradient)}if("none"===t.fill.type){this._currentProcessingShape=null;return null}}if(t.properties&&t.properties.fill){if("solid"===t.properties.fill.type&&t.properties.fill.color){const r=this.processShapeColor(t.properties.fill.color);if(e);this._currentProcessingShape=null;return r}if("gradient"===t.properties.fill.type&&t.properties.fill.gradient)return this.processGradientFill(t.properties.fill.gradient);if("none"===t.properties.fill.type)return null}if("sp"===t.type&&t.placeholder&&t.placeholder.type){t.placeholder.type;this._currentProcessingShape=null;return null}const r=t.preservedStyle||t.style;if(r&&r.fillRef){this._currentProcessingShape=t;const e=this.resolveStyleFillColor(r.fillRef);if(e){this._currentProcessingShape=null;return e}}if("pic"===t.type){this._currentProcessingShape=null;return null}let o;if(t.name&&t.name.includes("Rectangle")){const e=t.name.match(/\d+/);const r=e?parseInt(e[0]):1;o=null}else o=null;this._currentProcessingShape=null;return o}_normalizeColorDescriptor(t){if(!t)return null;if("object"===typeof t&&void 0!==t.r)return t;if("string"===typeof t)return t;if("object"===typeof t&&t.type&&t.value){if("scheme"===t.type)return{scheme:t.value,alpha:t.alpha};if("srgb"===t.type)return`#${t.value}`}return t}resolveStyleStrokeColor(t){try{if(!t)return null;const e=this._normalizeColorDescriptor(t.color||t);const r=this.processShapeColor(e);return r}catch(t){return null}}getShapeStrokeColor(t){try{if(t?.properties?.stroke?.color){const e=this._normalizeColorDescriptor(t.properties.stroke.color);const r=this.processShapeColor(e);return r}if(t?.stroke?.color){const e=this._normalizeColorDescriptor(t.stroke.color);const r=this.processShapeColor(e);return r}const e=t?.preservedStyle||t?.style;if(e?.lnRef){const t=this.resolveStyleStrokeColor(e.lnRef);if(t)return t}}catch(t){}const e={r:80,g:80,b:80,a:255};return e}getShapeLineWidth(t){try{let e=null;if(void 0!==t?.properties?.stroke?.width)e=parseInt(t.properties.stroke.width)||12700;else if(void 0!==t?.stroke?.width)e=parseInt(t.stroke.width)||12700;else e=12700;const r=e/914400*25.4;const o=2*25.4/96;const s=Math.max(r,o);return s}catch(t){return.75}}resolveInheritedFillColor(t){try{const slide=this.slides[this.getCurrentSlideIndex()];if(!slide)return null;if(!t.placeholder||!t.placeholder.type)return null;const e=t.placeholder.type;const r=t.placeholder.idx||0;if(slide.layout&&slide.layout.cSld&&slide.layout.cSld.spTree)for(const t of slide.layout.cSld.spTree)if(this.isMatchingPlaceholder(t,e,r)){const e=this.extractShapeFillColor(t);if(e)return e}if(slide.layout&&slide.layout.master&&slide.layout.master.cSld&&slide.layout.master.cSld.spTree)for(const t of slide.layout.master.cSld.spTree)if(this.isMatchingPlaceholder(t,e,r)){const e=this.extractShapeFillColor(t);if(e)return e}const o=this.getThemeColorForPlaceholder(e);if(o)return o;return null}catch(t){return null}}isMatchingPlaceholder(t,e,r){if(!t.placeholder)return false;if(t.placeholder.type===e){if(void 0!==r&&void 0!==t.placeholder.idx)return t.placeholder.idx===r;return true}if("title"===e&&"ctrTitle"===t.placeholder.type||"ctrTitle"===e&&"title"===t.placeholder.type)return true;return false}inheritShapeStyles(t,e){try{if(e.spPr){if(!t.spPr)t.spPr={};if(e.spPr.solidFill&&!t.spPr.solidFill)t.spPr.solidFill=e.spPr.solidFill;if(e.spPr.gradFill&&!t.spPr.gradFill)t.spPr.gradFill=e.spPr.gradFill;if(e.spPr.pattFill&&!t.spPr.pattFill)t.spPr.pattFill=e.spPr.pattFill;if(e.spPr.blipFill&&!t.spPr.blipFill)t.spPr.blipFill=e.spPr.blipFill;if(e.spPr.noFill&&!t.spPr.noFill)t.spPr.noFill=e.spPr.noFill;if(e.spPr.ln&&!t.spPr.ln)t.spPr.ln=e.spPr.ln;if(e.spPr.effectLst&&!t.spPr.effectLst)t.spPr.effectLst=e.spPr.effectLst;if(e.spPr.geometry&&!t.spPr.geometry&&!this.isTextPlaceholder(t))t.spPr.geometry=e.spPr.geometry;if(e.spPr.xfrm&&!t.spPr.xfrm)t.spPr.xfrm=e.spPr.xfrm}if(e.style){if(!t.style)t.style={};if(e.style.fillRef&&!t.style.fillRef)t.style.fillRef=e.style.fillRef;if(e.style.lnRef&&!t.style.lnRef)t.style.lnRef=e.style.lnRef;if(e.style.effectRef&&!t.style.effectRef)t.style.effectRef=e.style.effectRef;if(e.style.fontRef&&!t.style.fontRef)t.style.fontRef=e.style.fontRef}if(this.isTextPlaceholder(t)||t.textBody)this.inheritTextProperties(t,e);if(e.effects&&!t.effects)t.effects=e.effects;if(e.fill&&(!t.fill||null===t.fill))t.fill=e.fill;if(e.properties&&e.properties.fill){if(!t.properties)t.properties={};if(!t.properties.fill||null===t.properties.fill)t.properties.fill=e.properties.fill}if(e.properties&&e.properties.transform){if(!t.properties)t.properties={};if(!t.properties.transform)t.properties.transform=JSON.parse(JSON.stringify(e.properties.transform))}if((!t.properties||!t.properties.transform)&&t.spPr&&t.spPr.xfrm){const e=t.spPr.xfrm;const r=void 0!==e.x?e.x:void 0!==(e.off&&e.off.x)?e.off.x:0;const o=void 0!==e.y?e.y:void 0!==(e.off&&e.off.y)?e.off.y:0;const s=void 0!==e.width?e.width:void 0!==e.cx?e.cx:void 0!==(e.ext&&e.ext.cx)?e.ext.cx:void 0;const i=void 0!==e.height?e.height:void 0!==e.cy?e.cy:void 0!==(e.ext&&e.ext.cy)?e.ext.cy:void 0;if(void 0!==s&&void 0!==i){if(!t.properties)t.properties={};t.properties.transform={x:r,y:o,width:s,height:i}}}}catch(t){}}inheritTextProperties(t,e){try{if(e.textBody){if(!t.textBody)t.textBody={paragraphs:[]};const r=e.textBody.bodyProperties||e.textBody.bodyPr;if(!t.textBody.bodyProperties){if(r)t.textBody.bodyProperties=JSON.parse(JSON.stringify(r))}else if(r){const e=t.textBody.bodyProperties;if(!e.anchor&&!e.verticalAlign||"top"===e.verticalAlign||"t"===e.verticalAlign)if(r.anchor)e.anchor=r.anchor;else if(r.verticalAlign)e.verticalAlign=r.verticalAlign;if(void 0===e.leftMargin&&void 0!==r.leftMargin)e.leftMargin=r.leftMargin;if(void 0===e.rightMargin&&void 0!==r.rightMargin)e.rightMargin=r.rightMargin;if(void 0===e.topMargin&&void 0!==r.topMargin)e.topMargin=r.topMargin;if(void 0===e.bottomMargin&&void 0!==r.bottomMargin)e.bottomMargin=r.bottomMargin}if(e.textBody.lstStyle&&!t.textBody.lstStyle)t.textBody.lstStyle=e.textBody.lstStyle}if(e.txBody&&!t.txBody)t.txBody=e.txBody}catch(t){}}isTextPlaceholder(t){const e=t?.placeholder?.type||t.nvSpPr&&t.nvSpPr.nvPr&&t.nvSpPr.nvPr.ph&&t.nvSpPr.nvPr.ph.type;if(e)return["title","body","ctrTitle","subTitle","dt","ftr","hdr","sldNum"].includes(e);return false}applyPropertyInheritance(t,e=null){try{const r=e||this.currentSlide;if(!r)return;if(r.layout&&r.layout.cSld&&r.layout.cSld.spTree){const e=this.findMatchingShapeInTemplate(t,r.layout.cSld.spTree);if(e)this.inheritShapeStyles(t,e)}if(r.layout&&r.layout.master&&r.layout.master.cSld&&r.layout.master.cSld.spTree){const e=this.findMatchingShapeInTemplate(t,r.layout.master.cSld.spTree);if(e)this.inheritShapeStyles(t,e)}}catch(t){}}findMatchingShapeInTemplate(t,e){if(!e||!Array.isArray(e))return null;if(t.placeholder)for(const r of e)if(this.isMatchingPlaceholder(r,t.placeholder.type,t.placeholder.idx))return r;if(t.name)for(const r of e)if(r.name===t.name)return r;if(t.name&&t.name.includes("Text Placeholder")&&t.textBody)for(const t of e)if(t.name&&t.name.includes("Text Placeholder")&&t.textBody)return t;if(t.bounds&&!t.placeholder)for(const r of e)if(this.isShapeAtSimilarPosition(t,r))return r;return null}isShapeAtSimilarPosition(t,e){if(!t.bounds||!e.bounds)return false;const r=91440;const o=Math.abs(t.bounds.l-e.bounds.l)<=r;const s=Math.abs(t.bounds.t-e.bounds.t)<=r;return o&&s}extractShapeGeometry(t){if(t.spPr&&t.spPr.geometry)return t.spPr.geometry;if(t.geometry)return t.geometry;if(t.properties&&t.properties.geometry)return t.properties.geometry;return null}extractShapeFillColor(t){if(t.fill&&t.fill.color)return this.processShapeColor(t.fill.color);if(t.properties&&t.properties.fill&&t.properties.fill.color)return this.processShapeColor(t.properties.fill.color);if(t.style&&t.style.fillRef)return this.resolveStyleFillColor(t.style.fillRef);return null}getThemeColorForPlaceholder(t){const theme=this.presentation?.theme;if(!theme||!theme.colors)return null;switch(t){case"title":case"ctrTitle":case"body":case"obj":default:return null;case"subTitle":return{r:245,g:245,b:245,a:255}}}processShapeColor(t){if(!t)return null;if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b)return t;if("string"===typeof t&&t.startsWith("#"))return this.hexToRgb(t);if(t.scheme){const e=this.resolveThemeColor(t.scheme);if(e)return this.applyColorModifications(e,t)}return t}processGradientFill(t){if(!t||!t.stops||0===t.stops.length)return null;const e={type:t.type||"linear",angle:t.angle||0,stops:t.stops.map(t=>({position:t.position,color:this.processShapeColor(t.color)}))};return e}resolveThemeColor(t){if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){const e=this.presentation.theme.colors[t];if(e){const t=this.parseColorFromHex(e);if(t)return t}}const e={};const r=e[t]||null;return r}resolvePlaceholderColor(t,e=null){if(!t||"placeholder"!==t.type)return t;let r=e;if(!r)if(this.presentation&&this.presentation.theme&&this.presentation.theme.colors){const t=this.presentation.theme.colors.accent1;if(t)r=this.parseColorFromHex(t)}if(!r)return null;if(t.modifications&&t.modifications.length>0)r=this.applyColorModifications(r,t.modifications);return r}rgbToHsl(t,e,r){t/=255;e/=255;r/=255;const o=Math.max(t,e,r);const s=Math.min(t,e,r);let i,n,a=(o+s)/2;if(o===s)i=n=0;else{const l=o-s;n=a>.5?l/(2-o-s):l/(o+s);switch(o){case t:i=(e-r)/l+(e<r?6:0);break;case e:i=(r-t)/l+2;break;case r:i=(t-e)/l+4}i/=6}return{h:360*i,s:n,l:a}}hslToRgb(t,e,r){t/=360;const o=(t,e,r)=>{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};let s,i,n;if(0===e)s=i=n=r;else{const a=r<.5?r*(1+e):r+e-r*e;const l=2*r-a;s=o(l,a,t+1/3);i=o(l,a,t);n=o(l,a,t-1/3)}return{r:Math.round(255*s),g:Math.round(255*i),b:Math.round(255*n)}}parseColorFromHex(t){if(!t||"string"!==typeof t)return null;const e=t.replace("#","");if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:255};return null}applyColorModifications(t,e){if(!t||!e||0===e.length)return t;const r={...t};const o=this.rgbToHsl(r.r,r.g,r.b);let{h:s,s:i,l:n}=o;for(const t of e){const e=t.value;switch(t.type){case"tint":const t=e/1e5;n+=(1-n)*t;break;case"shade":const o=e/1e5;n*=1-o;break;case"lummod":case"lumMod":const a=e/1e5;n*=a;break;case"lumoff":case"lumOff":const l=e/1e5;n=Math.min(1,Math.max(0,n+l));break;case"satmod":case"satMod":const c=e/1e5;i*=c;break;case"satoff":case"satOff":const h=e/1e5;i=Math.min(1,Math.max(0,i+h));break;case"hue":s=e/6e4%360;break;case"hueoff":case"hueOff":const u=e/6e4;s=(s+u)%360;break;case"huemod":case"hueMod":const f=e/1e5;s=s*f%360;break;case"alpha":r.a=Math.round(e/1e5*255);break;case"alphamod":case"alphaMod":const d=e/1e5;r.a=Math.round(r.a*d);break;case"alphaoff":case"alphaOff":const p=e/1e5;r.a=Math.min(255,Math.max(0,Math.round(r.a+255*p)))}}const a=this.hslToRgb(s,i,n);r.r=a.r;r.g=a.g;r.b=a.b;r.r=Math.min(255,Math.max(0,Math.round(r.r)));r.g=Math.min(255,Math.max(0,Math.round(r.g)));r.b=Math.min(255,Math.max(0,Math.round(r.b)));r.a=Math.min(255,Math.max(0,Math.round(r.a||255)));return r}rgbToHsl(t,e,r){t/=255;e/=255;r/=255;const o=Math.max(t,e,r);const s=Math.min(t,e,r);let i,n,a=(o+s)/2;if(o===s)i=n=0;else{const l=o-s;n=a>.5?l/(2-o-s):l/(o+s);switch(o){case t:i=(e-r)/l+(e<r?6:0);break;case e:i=(r-t)/l+2;break;case r:i=(t-e)/l+4}i/=6}return{h:i,s:n,l:a}}hslToRgb(t,e,r){let o,s,i;if(0===e)o=s=i=r;else{const n=(t,e,r)=>{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};const a=r<.5?r*(1+e):r+e-r*e;const l=2*r-a;o=n(l,a,t+1/3);s=n(l,a,t);i=n(l,a,t-1/3)}return{r:Math.round(255*o),g:Math.round(255*s),b:Math.round(255*i)}}parseColorFromHex(t){if(!t||"string"!==typeof t)return null;const e=t.replace("#","");if(6===e.length)return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:255};return null}applyColorModifications(t,e){const r={...t};if(void 0!==e.tint){const t=e.tint/1e5;r.r=Math.round(r.r+(255-r.r)*t);r.g=Math.round(r.g+(255-r.g)*t);r.b=Math.round(r.b+(255-r.b)*t)}if(void 0!==e.shade){const t=e.shade/1e5;r.r=Math.round(r.r*(1-t));r.g=Math.round(r.g*(1-t));r.b=Math.round(r.b*(1-t))}if(void 0!==e.sat){const t=e.sat/1e5;const o=.299*r.r+.587*r.g+.114*r.b;r.r=Math.round(o+(r.r-o)*t);r.g=Math.round(o+(r.g-o)*t);r.b=Math.round(o+(r.b-o)*t)}if(void 0!==e.alpha)r.a=Math.round(255*(e.alpha/1e5));r.r=Math.max(0,Math.min(255,r.r));r.g=Math.max(0,Math.min(255,r.g));r.b=Math.max(0,Math.min(255,r.b));r.a=Math.max(0,Math.min(255,r.a));return r}getAllShapesFromTree(t){const e=[];const r=t=>{if(!t)return;if(Array.isArray(t))t.forEach(r);else if("object"===typeof t){if(t.nvSpPr||t.nvPicPr||t.nvGrpSpPr)e.push(t);Object.values(t).forEach(t=>{if(t&&"object"===typeof t)r(t)})}};r(t);return e}resolveStyleFillColor(t){try{if(!t)return null;const e=this._currentProcessingShape;const r=e&&("Rectangle 3"===e.name||e.name?.includes("Rectangle 3"));if(r);const o=t.idx||0;if(r);if(t.color){const e=this.processShapeColor(t.color);const o=e&&void 0!==e.r?`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||255})`:JSON.stringify(e);if(r);return e}const theme=this.presentation?.theme;if(r)if(theme)if(theme.colors&&theme.colors.accent6){const t=this.parseColorFromHex(theme.colors.accent6)}if(theme&&theme.formatScheme){if(r)if(theme.formatScheme.fillStyles)theme.formatScheme.fillStyles.forEach((t,e)=>{});if(o<1e3){const e=o-1;if(e>=0&&theme.formatScheme.fillStyles&&e<theme.formatScheme.fillStyles.length){const r=theme.formatScheme.fillStyles[e];if(r.color&&"solid"===r.type)return r.color;else if(r.gradient&&"gradient"===r.type)return this.processGradientFill(r.gradient);const o=this.processFillStyleToColor(r,t.color);if(o)return o}}else if(o>=1001){const e=o-1001;if(e>=0&&theme.formatScheme.backgroundFills&&e<theme.formatScheme.backgroundFills.length){const r=theme.formatScheme.backgroundFills[e];if(r.color&&"solid"===r.type)return r.color;const o=this.processFillStyleToColor(r,t.color);if(o)return o}}}return null}catch(t){return null}}processFillStyleToColor(t,e=null){if(!t)return null;try{if("solid"===t.type&&t.color){if("placeholder"===t.color.type&&"phClr"===t.color.scheme){const r=this._currentProcessingShape;if(r&&!r.placeholder)return null;const o=e?this.processShapeColor(e):null;const s=this.resolvePlaceholderColor(t.color,o);return s}if(e)return this.processShapeColor(e);return this.processShapeColor(t.color)}if("gradient"===t.type){let r=null;if(t.stops&&t.stops.length>0)r=t.stops[0].color;else if(t.gradient&&t.gradient.colors&&t.gradient.colors.length>0)r=t.gradient.colors[0];if(r){if("placeholder"===r.type&&"phClr"===r.value){const t=this._currentProcessingShape;if(t&&!t.placeholder)return null;const o=e?this.processShapeColor(e):null;let s=this.resolvePlaceholderColor(r,o);if(r.modifications&&r.modifications.length>0)s=this.applyColorModifications(s,r.modifications);return s}if("scheme"===r.type){const t=this.getThemeColor(r.value);if(t){let e=t;if(r.modifications&&r.modifications.length>0)e=this.applyColorModifications(e,r.modifications);return e}}if(e)return this.processShapeColor(e);return this.processShapeColor(r)}}if("pattern"===t.type&&t.fgColor){if(e)return this.processShapeColor(e);return this.processShapeColor(t.fgColor)}if("blip"===t.type||"image"===t.type)return null;if("none"===t.type||"noFill"===t.type)return null}catch(t){}return null}isImageLoading(t){return!this.imageCache.has(t)&&this.imageMap.has(t)}triggerSlideRerender(){if("undefined"!==typeof window)window.dispatchEvent(new Event("slideImageLoaded",{detail:{slideIndex:this.currentSlideIndex}}))}logSlideImageStatus(slide,t){if(slide.backgroundFill&&slide.backgroundFill.fill){const t=slide.backgroundFill.fill;if("image"===t.type&&t.imageData){const e=t.imageData.relationshipId;const r=this.imageCache.has(e)}}let e=0;if(slide.commonSlideData&&slide.commonSlideData.shapeTree)for(const t of slide.commonSlideData.shapeTree)if("pic"===t.type&&t.imageRelId){const r=this.imageCache.has(t.imageRelId);e++}}async drawGroupShapeGeometry(t,e,r,o,s,i,n,a,l,c){t.SaveGrState();try{if(e.transform){if(e.transform.rotation&&0!==e.transform.rotation){const n=r+s/2;const a=o+i/2;t.transform(Math.cos(e.transform.rotation*Math.PI/180),Math.sin(e.transform.rotation*Math.PI/180),-Math.sin(e.transform.rotation*Math.PI/180),Math.cos(e.transform.rotation*Math.PI/180),n-n*Math.cos(e.transform.rotation*Math.PI/180)+a*Math.sin(e.transform.rotation*Math.PI/180),a-n*Math.sin(e.transform.rotation*Math.PI/180)-a*Math.cos(e.transform.rotation*Math.PI/180))}if(e.transform.flipH||e.transform.flipV){const n=e.transform.flipH?-1:1;const a=e.transform.flipV?-1:1;const l=r+s/2;const c=o+i/2;t.transform(n,0,0,a,l-l*n,c-c*a)}}if(n)if("object"===typeof n&&"linear"===n.type)t.fillRect(r,o,s,i,n);else{let e=null;if("string"===typeof n)e=this.hexToRgb(n);else if(void 0!==n.r)e=n;if(e)t.drawRectangle(r,o,s,i,e,null,0)}if(a&&l>0){let e=null;if("string"===typeof a)e=this.hexToRgb(a);else if(void 0!==a.r)e=a;if(e)t.drawRectangle(r,o,s,i,null,e,l)}if(e.shapeTree&&e.shapeTree.length>0){const r=this.sortShapesByRenderOrder(e.shapeTree);for(let e=0;e<r.length;e++){const o=r[e];try{await this.renderShape(t,o,c)}catch(t){}}}}catch(t){}finally{t.RestoreGrState()}}drawConnectorShapeGeometry(t,e,r,o,s,i,n,a){t.drawLine(r,o+i/2,r+s,o+i/2,n,a)}drawGraphicFrameGeometry(t,e,r,o,s,i,n,a,l){t.drawRectangle(r,o,s,i,null,"#a0a0a0",1)}drawDefaultShapeGeometry(t,e,r,o,s,i,n,a,l){t.drawRectangle(r,o,s,i,n,"#ff0000",l)}rgbToHex(t){if(!t)return null;const e=t=>{const e=Math.max(0,Math.min(255,Math.round(t))).toString(16);return 1===e.length?"0"+e:e};return`#${e(t.r||t.R||0)}${e(t.g||t.G||0)}${e(t.b||t.B||0)}`}createRotationMatrix(t,e,r){const o=t*Math.PI/180;const s=Math.cos(o);const i=Math.sin(o);return{a:s,b:i,c:-i,d:s,e:e-e*s+r*i,f:r-e*i-r*s}}applyRotationTransform(t,e,r,o,s,i){const n=this.getShapeRotation(e);if(!n||0===n)return false;const a=r+s/2;const l=o+i/2;const c=this.createRotationMatrix(n,a,l);const h={sx:c.a,sy:c.d,shx:c.c,shy:c.b,tx:c.e,ty:c.f,createDuplicate(){return{sx:this.sx,sy:this.sy,shx:this.shx,shy:this.shy,tx:this.tx,ty:this.ty,createDuplicate:this.createDuplicate}}};if(t.transform3)t.transform3(h);else if(t.transform)t.transform(c.a,c.b,c.c,c.d,c.e,c.f);return true}getShapeRotation(t){if(void 0!==t.properties?.transform?.rot)return t.properties.transform.rot;if(void 0!==t.transform?.rotation)return t.transform.rotation;if(void 0!==t.spPr?.transform?.rot)return t.spPr.transform.rot;return 0}calculateRotatedBounds(t,e){if(!e||0===e)return t;const{x:r,y:o,w:s,h:i}=t;const n=r+s/2;const a=o+i/2;const l=[{x:r,y:o},{x:r+s,y:o},{x:r+s,y:o+i},{x:r,y:o+i}];const c=e*Math.PI/180;const h=Math.cos(c);const u=Math.sin(c);const f=l.map(t=>{const e=t.x-n;const r=t.y-a;return{x:n+e*h-r*u,y:a+e*u+r*h}});const d=Math.min(...f.map(t=>t.x));const p=Math.min(...f.map(t=>t.y));const g=Math.max(...f.map(t=>t.x));const m=Math.max(...f.map(t=>t.y));return{x:d,y:p,w:g-d,h:m-p}}getDefaultTextColor(t){if(this.presentation?.theme?.colors)if("title"===t.placeholder?.type||"ctrTitle"===t.placeholder?.type){const t=this.resolveThemeColor("dk2");if(t)return t;const e=this.resolveThemeColor("dk1");if(e)return e;return this.presentation.theme.colors.tx1||{r:0,g:0,b:0,a:255}}else return this.presentation.theme.colors.tx1||this.presentation.theme.colors.tx2||{r:0,g:0,b:0,a:255};return{r:0,g:0,b:0,a:255}}async extractPartMediaRelationships(t){try{const e=await t.getRelationships();for(const[t,r]of Object.entries(e))if(r.type===Bt.image.relationType||r.type.includes("video")||r.type.includes("audio")){let e=r.target;if(e.startsWith("../"))e=e.replace("../","ppt/");else if(!e.startsWith("/"))e=`/ppt/${e}`;this.mediaMap.set(t,{path:e,type:r.type});if(this.isImageFile(e)){const r=this.imageMap.get(t);if(!r||this.isSVGFile(e)&&!this.isSVGFile(r)){this.imageMap.set(t,e);if(this.isSVGFile(e));}else if(!this.isSVGFile(e)&&this.isSVGFile(r));else this.imageMap.set(t,e)}}}catch(t){}}isMediaFile(t){const e=[".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp",".tiff",".mp4",".mov",".avi",".mp3",".wav",".ogg"];const r=t.toLowerCase();return e.some(t=>r.endsWith(t))}isSVGFile(t){return t&&t.toLowerCase().endsWith(".svg")}extractSVGRelationshipId(t){try{const e=t.querySelector('extLst, a\\:extLst, [*|localName="extLst"]');if(!e)return null;const r=e.querySelectorAll('ext, a\\:ext, [*|localName="ext"]');for(const t of r){const e=t.getAttribute("uri");if("{96DAC541-7B7A-43D3-8B79-37D633B846F1}"===e){const e=t.querySelector('svgBlip, asvg\\:svgBlip, [*|localName="svgBlip"]');if(e){const t=e.getAttribute("r:embed")||e.getAttribute("r:id");if(t)return t}}}return null}catch(t){void 0;return null}}buildSVGRelationshipMapping(){const t=new Map;const e=new Map;for(const[r,o]of this.imageMap.entries()){const s=o.split("/").pop();const i=s.replace(/\.[^.]+$/,"");if(this.isSVGFile(o))e.set(i,r);else if(o.toLowerCase().endsWith(".png"))t.set(i,r)}for(const[r,o]of t.entries()){let t=e.get(r);if(!t){const o=r.match(/^(image-\d+-)(\d+)$/);if(o){const r=o[1];const s=parseInt(o[2]);const i=r+(s+1);t=e.get(i);if(t);}}if(t)this.svgRelationshipMap.set(o,t)}}async loadAndDrawImage(t,e,r,o,s,i,n){try{if(this.isSVGFile(r.path)&&this.svgRenderer){await this.loadAndDrawSVGImage(t,e,r,o,s,i,n);return}else if(this.isSVGFile(r.path))this.logger.log("warn",this.constructor.name,`SVG detected but no SVG renderer available: ${r.path}`);let a=this.imageCache.get(e.imageRelId);if(!a){const t=await this.zip.getFileData(r.path);if(!t)throw new Error("Image file not found in ZIP");const o=this.getMimeType(r.path);const s=new Blob([t],{type:o});const i=URL.createObjectURL(s);const image=new Image;image.crossOrigin="anonymous";await new Promise((t,r)=>{image.onload=()=>{a={image,width:image.naturalWidth,height:image.naturalHeight,url:i};this.imageCache.set(e.imageRelId,a);t()};image.onerror=()=>{r(new Error("Failed to load image"))};image.src=i})}this.drawActualImage(t,e,a,o,s,i,n)}catch(r){this.drawImagePlaceholder(t,e,o,s,i,n)}}async loadAndDrawSVGImage(t,e,r,o,s,i,n){try{let t=this.imageCache.get(e.imageRelId);if(!t){const o=await this.zip.getFileData(r.path);if(!o)throw new Error("SVG file not found in ZIP");const s=new TextDecoder("utf-8").decode(o);t={content:s,type:"svg",path:r.path,width:100,height:100};this.imageCache.set(e.imageRelId,t)}const a={x:o,y:s,w:i,h:n};await this.svgRenderer.renderSVG(t.content,a.x,a.y,a.w,a.h,{preserveAspectRatio:true})}catch(a){this.logger.logError(this.constructor.name,`Failed to load/render SVG: ${r.path}`,a);try{const a=await this.zip.getFileData(r.path);if(a){const r=new Blob([a],{type:"image/svg+xml"});const l=URL.createObjectURL(r);const image=new Image;image.crossOrigin="anonymous";await new Promise((r,a)=>{image.onload=()=>{const a={image,width:image.naturalWidth,height:image.naturalHeight,url:l};this.drawActualImage(t,e,a,o,s,i,n);r()};image.onerror=a;image.src=l})}}catch(r){this.logger.log("warn",this.constructor.name,"SVG fallback also failed, showing placeholder");this.drawImagePlaceholder(t,e,o,s,i,n)}}}drawFilePlaceholder(t,e,r,o,s,i,n){const a=t.getContext();a.save();a.fillStyle="#e9ecef";a.fillRect(o,s,i,n);a.strokeStyle="#adb5bd";a.lineWidth=1;a.strokeRect(o,s,i,n);let l="❓";if(r.includes("video"))l="🎬";else if(r.includes("audio"))l="🎵";a.fillStyle="#495057";a.font=`${.5*Math.min(i,n)}px Arial`;a.textAlign="center";a.textBaseline="middle";a.fillText(l,o+i/2,s+n/2);a.restore()}async renderShape(t,e,r){try{if(!e)return;const o=this.getShapeBounds(e,r);if(!o)return;if(o.w<=0||o.h<=0)return;const{x:s,y:i,w:n,h:a}=o;if(e.groupTransform){t.SaveGrState();const o=this.createTransformMatrix(e,r);t.transform3(o)}if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri);switch(e.type){case"sp":this.renderRegularShape(t,e,s,i,n,a);break;case"pic":await this.renderPictureShape(t,e,s,i,n,a);break;case"grpSp":this.renderGroupShape(t,e);break;case"cxnSp":this.renderConnectorShape(t,e,s,i,n,a);break;case"graphicFrame":await this.renderGraphicFrame(t,e,s,i,n,a);break;default:this.renderDefaultShape(t,e,s,i,n,a)}if(e.groupTransform)t.RestoreGrState()}catch(t){}}renderRegularShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);if(0!==n)t.SaveGrState();const a=this.applyRotationTransform(t,e,r,o,s,i);const l=this.getShapeFillColor(e);const c=this.getShapeStrokeColor(e);const h=this.getShapeLineWidth(e);const u=this.getShapeGradientFill(e);const f=this.getShapeStrokeInfo(e);const d=this.getShapePresetGeometry(e);const p=this.extractShapeAdjustments(e);let g=l;if(u)g=u;let m=null;let y=null;if(g)if("string"===typeof g){const t=this.hexToRgb(g);m=t}else if(void 0!==g.r)m=g;if(c)if("string"===typeof c){const t=this.hexToRgb(c);y=t}else if(void 0!==c.r)y=c;const b=false;let x="none";if(d){t.drawPresetGeometry(d,r,o,s,i,m,y,h,f,p);x="preset-geometry"}else{t.drawRectangle(r,o,s,i,m,y,h||2,f);x="fallback-rectangle"}if(0!==n)t.RestoreGrState()}extractShapeAdjustments(t){const e={};try{if(t.geometry){if(t.geometry.avLst)for(const[r,o]of Object.entries(t.geometry.avLst))if("object"===typeof o&&void 0!==o.val)e[r]=o.val;else if("number"===typeof o)e[r]=o;if(t.geometry.adjLst)for(const[r,o]of Object.entries(t.geometry.adjLst))if("object"===typeof o&&void 0!==o.val)e[r]=o.val;else if("number"===typeof o)e[r]=o;if(t.geometry.preset&&t.geometry.adjustments)for(const[r,o]of Object.entries(t.geometry.adjustments))e[r]=o}if(t.spPr&&t.spPr.geometry){const r=t.spPr.geometry;if(r.avLst)for(const t of r.avLst)if(t.name&&void 0!==t.fmla){const r=this.parseAdjustmentValue(t.fmla);if(null!==r)e[t.name]=r}}if(t.adjustments)Object.assign(e,t.adjustments);if(t.commonSlideData&&t.commonSlideData.adjustments)Object.assign(e,t.commonSlideData.adjustments)}catch(t){}return e}parseAdjustmentValue(t){if("number"===typeof t)return t;if("string"===typeof t){const e=parseFloat(t);if(!isNaN(e))return e;const r=t.match(/val\s+(-?\d+)/);if(r)return parseInt(r[1],10);const o=t.match(/(-?\d+)%/);if(o)return 1e3*parseInt(o[1],10)}return null}getShapeStrokeInfo(t){const e={};const r=t.properties?.line||t.properties?.stroke;if(r){if(r.dashArray&&r.dashArray.length>0)e.dashArray=r.dashArray;if(r.lineCap||r.cap)e.lineCap=r.lineCap||r.cap;if(r.lineJoin||r.join)e.lineJoin=r.lineJoin||r.join;if(r.miterLimit)e.miterLimit=r.miterLimit;if(r.headEnd){const t=r.headEnd;e.headEnd={type:t.type||t.val||"none",w:t.w||t.width,len:t.len||t.length}}if(r.tailEnd){const t=r.tailEnd;e.tailEnd={type:t.type||t.val||"none",w:t.w||t.width,len:t.len||t.length}}}if(t.spPr&&t.spPr.ln){const r=t.spPr.ln;if(r.prstDash)e.dashArray=this.convertstandardDashPattern(r.prstDash);if(r.cap)e.lineCap=this.convertstandardLineCap(r.cap);if(r.join)e.lineJoin=this.convertstandardLineJoin(r.join);const o=this._mapArrowSize.bind(this);const s=t=>{if(!t)return"none";const e=t.toString();return e};if(r.headEnd)e.headEnd={type:s(r.headEnd.type),w:r.headEnd.w,len:r.headEnd.len};if(r.tailEnd)e.tailEnd={type:s(r.tailEnd.type),w:r.tailEnd.w,len:r.tailEnd.len}}return Object.keys(e).length>0?e:null}_mapArrowSize(t){switch((t||"").toString()){case"sm":case"small":default:return 1;case"med":case"medium":return 1.5;case"lg":case"large":return 2}}convertstandardDashPattern(t){const e={solid:[],dot:[2,2],dash:[8,4],dashDot:[8,4,2,4],dashDotDot:[8,4,2,4,2,4],lgDash:[16,8],lgDashDot:[16,8,4,8],lgDashDotDot:[16,8,4,8,4,8],sysDash:[6,3],sysDashDot:[6,3,2,3],sysDashDotDot:[6,3,2,3,2,3],sysDot:[1,1]};return e[t]||[]}convertstandardLineCap(t){const e={rnd:"round",sq:"square",flat:"butt"};return e[t]||"round"}convertstandardLineJoin(t){const e={round:"round",bevel:"bevel",miter:"miter"};return e[t]||"round"}async renderPictureShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapePresetGeometry(e);if(l&&"rect"!==l){const n=this.getShapeStrokeColor(e);const a=this.getShapeLineWidth(e);const c=this.getShapeStrokeInfo(e);t.drawPresetGeometry(l,r,o,s,i,null,n,a,c)}const c=this.getShapeFillColor(e);const h=this.getShapeStrokeColor(e);const u=this.getShapeLineWidth(e);try{await this.drawPictureShapeGeometry(t,e,r,o,s,i,c,h,u)}catch(n){this.drawImagePlaceholder(t,e,r,o,s,i)}if(a)t.RestoreGrState()}renderConnectorShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapeStrokeColor(e);const c=this.getShapeLineWidth(e);const h=this.getShapeStrokeInfo(e);const u=this.getConnectorType(e);try{this.logger?.log("info",this.constructor.name,"[Connector Render] start",{connectorType:u,bounds:{x:r,y:o,w:s,h:i},strokeColor:l,lineWidth:c,strokeInfo:h})}catch(t){}switch(u){case"straight":if("function"===typeof t.drawLineWithArrows)t.drawLineWithArrows(r,o,r+s,o+i,l,c,h);else t.drawLine(r,o,r+s,o+i,l,c);break;case"elbow":this.drawElbowConnector(t,r,o,s,i,l,c,h);break;case"curved":this.drawCurvedConnector(t,r,o,s,i,l,c,h);break;default:t.drawLine(r,o,r+s,o+i,l,c)}if(a)t.RestoreGrState();try{this.logger?.log("info",this.constructor.name,"[Connector Render] done")}catch(t){}}getConnectorType(t){if(t.properties&&t.properties.connector)return t.properties.connector.type||"straight";if(t.spPr&&t.spPr.connector)return t.spPr.connector.type||"straight";const e=this.getShapePresetGeometry(t);if(e&&e.includes("Connector"))if(e.includes("bent"))return"elbow";else if(e.includes("curved"))return"curved";return"straight"}drawElbowConnector(t,e,r,o,s,i,n,a){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.beginPath();const l=e+.5*o;const c=r+.5*s;t.m_oContext.moveTo(e,r);t.m_oContext.lineTo(l,r);t.m_oContext.lineTo(l,c);t.m_oContext.lineTo(e+o,c);t.m_oContext.lineTo(e+o,r+s);if(i){t.m_oContext.strokeStyle=t.colorToRgb(i);t.m_oContext.lineWidth=n||1;if(a)t.applyStrokeInfo(a);t.m_oContext.stroke()}t.m_oContext.restore()}drawCurvedConnector(t,e,r,o,s,i,n,a){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.beginPath();t.m_oContext.moveTo(e,r);t.m_oContext.bezierCurveTo(e+.3*o,r,e+.7*o,r+s,e+o,r+s);if(i){t.m_oContext.strokeStyle=t.colorToRgb(i);t.m_oContext.lineWidth=n||1;if(a)t.applyStrokeInfo(a);t.m_oContext.stroke()}t.m_oContext.restore()}async renderGraphicFrame(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapeStrokeColor(e);const c=this.getShapeLineWidth(e)||1;const h=this.getShapeStrokeInfo(e);t.drawRectangle(r,o,s,i,null,l,c,h);if(e.graphicData)switch(e.graphicData.uri){case"http://schemas.openxmlformats.org/drawingml/2006/table":this.renderTableFrame(t,e,r,o,s,i);break;case"http://schemas.openxmlformats.org/drawingml/2006/chart":await this.renderChartFrame(t,e,r,o,s,i);break;case"http://schemas.openxmlformats.org/drawingml/2006/diagram":this.renderDiagramFrame(t,e,r,o,s,i);break;default:this.renderGenericFrame(t,e,r,o,s,i)}else this.renderGenericFrame(t,e,r,o,s,i);if(a)t.RestoreGrState()}renderTableFrame(t,e,r,o,s,i){const n=this.getTableInstance(e);if(!n){this.drawTablePlaceholder(t,r,o,s,i);return}t.SaveGrState();try{this.drawTableBackgroundAndOuterBorder(t,n,r,o,s,i);this.drawCellsBackground(t,n,r,o,s,i);this.drawCellsContent(t,n,r,o,s,i);this.drawCellsBorders(t,n,r,o,s,i)}catch(e){this.drawTablePlaceholder(t,r,o,s,i)}finally{t.RestoreGrState()}}getTableInstance(t){if(t.table&&t.table instanceof CTable)return t.table;if(t.graphicData&&t.graphicData.tableXml)try{const e=this.parseTableFromXML(t.graphicData.tableXml);if(e){t.table=e;return e}}catch(t){void 0;void 0}return null}drawTableBackgroundAndOuterBorder(t,e,r,o,s,i){const n=e.getTableProperties();const a=e.getTableBorders();const l=e.getTableShading();if(l&&l.fill){const e=this.resolveTableBackgroundColor(l);t.b_color1(e.r,e.g,e.b,e.a||255);t.TableRect(r,o,s,i)}if(a)this.drawTableOuterBorder(t,a,r,o,s,i)}drawCellsBackground(t,e,r,o,s,i){const n=e.getRowCount();const a=e.getColumnCount();const l=this.calculateCellWidths(e,s);const c=this.calculateCellHeights(e,i);let h=o;for(let o=0;o<n;o++){let s=r;const i=c[o];for(let r=0;r<a;r++){const i=e.getCell(o,r);if(!i)continue;const n=l[r];const a=i.getGridSpan()||1;const u=i.getRowSpan()||1;const f=this.calculateMergedCellWidth(l,r,a);const d=this.calculateMergedCellHeight(c,o,u);if(this.isStartingCellOfMerge(i,o,r))this.drawCellBackground(t,i,s,h,f,d);s+=n}h+=i}}drawCellsContent(t,e,r,o,s,i){const n=e.getRowCount();const a=e.getColumnCount();const l=this.calculateCellWidths(e,s);const c=this.calculateCellHeights(e,i);let h=o;for(let o=0;o<n;o++){let s=r;const i=c[o];for(let r=0;r<a;r++){const i=e.getCell(o,r);if(!i)continue;const n=l[r];if(this.isStartingCellOfMerge(i,o,r)){const e=i.getGridSpan()||1;const n=i.getRowSpan()||1;const a=this.calculateMergedCellWidth(l,r,e);const u=this.calculateMergedCellHeight(c,o,n);this.drawCellContent(t,i,s,h,a,u)}s+=n}h+=i}}drawCellsBorders(t,e,r,o,s,i){const n=e.getRowCount();const a=e.getColumnCount();const l=this.calculateCellWidths(e,s);const c=this.calculateCellHeights(e,i);const h=o;for(let s=0;s<n;s++)for(let i=a-1;i>=0;i--){const n=e.getCell(s,i);if(!n)continue;const a=l[i];const h=c[s];const u=r+this.calculateCellXOffset(l,i);const f=o+this.calculateCellYOffset(c,s);this.drawCellBorders(t,n,u,f,a,h,s,i,e)}}drawTablePlaceholder(t,e,r,o,s){const i=o/3;const n=s/3;for(let o=0;o<3;o++)for(let s=0;s<3;s++){const a=e+s*i;const l=r+o*n;t.drawRectangle(a,l,i,n,null,{r:128,g:128,b:128,a:255},1)}this.drawCenteredText(t,"Table",e,r,o,s)}drawTableOuterBorder(t,e,r,o,s,i){const n=["top","right","bottom","left"];n.forEach(n=>{const a=e[n];if(a&&"none"!==a.style){const e=this.resolveBorderColor(a);const l=a.width||1;t.p_color(e.r,e.g,e.b,e.a||255);t.p_width(l);switch(n){case"top":t.drawHorLine(r,o,r+s,o,l);break;case"right":t.drawVerLine(r+s,o,o+i,l);break;case"bottom":t.drawHorLine(r,o+i,r+s,o+i,l);break;case"left":t.drawVerLine(r,o,o+i,l)}}})}drawCellBackground(t,e,r,o,s,i){const n=e.getCellShading();if(n&&n.fill){const e=this.resolveCellBackgroundColor(n);t.b_color1(e.r,e.g,e.b,e.a||255);t.TableRect(r,o,s,i)}}drawCellContent(t,e,r,o,s,i){const n=e.getTextBody();if(!n||!n.paragraphs)return;const a=5;const l=r+a;const c=o+a;const h=s-2*a;const u=i-2*a;this.renderCellTextContent(t,n,l,c,h,u)}drawCellBorders(t,e,r,o,s,i,n,a,l){const c=e.getCellBorders();if(!c)return;const h=["top","right","bottom","left"];h.forEach(e=>{const h=c[e];if(!h||"none"===h.style)return;if(this.shouldDrawBorder(e,n,a,l)){const n=this.resolveBorderColor(h);const a=h.width||1;t.p_color(n.r,n.g,n.b,n.a||255);t.p_width(a);switch(e){case"top":t.drawHorLine(r,o,r+s,o,a);break;case"right":t.drawVerLine(r+s,o,o+i,a);break;case"bottom":t.drawHorLine(r,o+i,r+s,o+i,a);break;case"left":t.drawVerLine(r,o,o+i,a)}}})}shouldDrawBorder(t,e,r,o){const s=o.getRowCount();const i=o.getColumnCount();switch(t){case"top":return 0===e;case"right":return r===i-1;case"bottom":return e===s-1;case"left":return 0===r;default:return true}}calculateCellWidths(t,e){const r=t.getTableGrid();if(!r||0===r.length){const r=t.getColumnCount();return new Array(r).fill(e/r)}const o=r.reduce((t,e)=>t+(e.width||0),0);return r.map(t=>{const r=t.width||0;return r/o*e})}calculateCellHeights(t,e){const r=t.getRowCount();const o=[];for(let s=0;s<r;s++){const i=t.getRow(s);if(i&&i.height)o.push(i.height);else o.push(e/r)}return o}isStartingCellOfMerge(t,e,r){return!t.isMergedContinue}calculateMergedCellWidth(t,e,r){let o=0;for(let s=0;s<r;s++)if(e+s<t.length)o+=t[e+s];return o}calculateMergedCellHeight(t,e,r){let o=0;for(let s=0;s<r;s++)if(e+s<t.length)o+=t[e+s];return o}calculateCellXOffset(t,e){let r=0;for(let o=0;o<e;o++)r+=t[o];return r}calculateCellYOffset(t,e){let r=0;for(let o=0;o<e;o++)r+=t[o];return r}resolveTableBackgroundColor(t){return{r:255,g:255,b:255,a:255}}resolveCellBackgroundColor(t){return{r:255,g:255,b:255,a:255}}resolveBorderColor(t){return{r:0,g:0,b:0,a:255}}renderCellTextContent(t,e,r,o,s,i){if(!e.paragraphs||0===e.paragraphs.length)return;let n=o;const a=16;e.paragraphs.forEach(e=>{if(!e.runs||0===e.runs.length){n+=a;return}const o=e.runs.map(t=>t.text||"").join("");if(!o.trim()){n+=a;return}const s=e.properties||{};const i=s.fontSize||12;const l=s.fontFamily||"Arial";const c=s.bold||false;const h=s.italic||false;t.font(l,i,c?"bold":"normal",h?"italic":"normal");const u=this.resolveTextColor(e);t.b_color1(u.r,u.g,u.b,u.a||255);t.FillText(r,n,o);n+=a})}resolveTextColor(t){return{r:0,g:0,b:0,a:255}}parseTableFromXML(t){if(!t)return null;try{const e=new DOMParser;const r=e.parseFromString(t,"text/xml");if("parsererror"===r.documentElement.nodeName){void 0;return null}const o=new CTable;this.parseTableProperties(r,o);this.parseTableGrid(r,o);this.parseTableRows(r,o);this.processTableMerges(o);const s=this.validateTableStructure(o);if(!s)return null;return o}catch(t){void 0;void 0;return null}}parseTableProperties(t,e){let r=t.querySelector("tblPr");if(!r)r=t.querySelector("a\\:tblPr");if(r){const t={};let o=r.querySelector("tblStyle");if(!o)o=r.querySelector("a\\:tblStyle");if(o)t.style=o.getAttribute("val");let s=r.querySelector("tblBorders");if(!s)s=r.querySelector("a\\:tblBorders");if(s)t.borders=this.parseTableBorders(s);let i=r.querySelector("tblShading");if(!i)i=r.querySelector("a\\:tblShading");if(i)t.shading=this.parseTableShading(i);let n=r.querySelector("tblLayout");if(!n)n=r.querySelector("a\\:tblLayout");if(n)t.layout=n.getAttribute("type")||"autofit";let a=r.querySelector("tblW");if(!a)a=r.querySelector("a\\:tblW");if(a){const e=a.getAttribute("w");const r=a.getAttribute("type")||a.getAttribute("wtype")||"auto";if(e)t.preferredWidth={value:parseInt(e)||0,type:r.toLowerCase()};else t.preferredWidth={value:0,type:r.toLowerCase()}}e.setTableProperties(t)}}parseTableGrid(t,e){let r=t.querySelector("tblGrid");if(!r)r=t.querySelector("a\\:tblGrid");if(r){let t=r.querySelectorAll("gridCol");if(0===t.length)t=r.querySelectorAll("a\\:gridCol");const o=[];t.forEach(t=>{const e=t.getAttribute("w");const r={width:e?parseInt(e):914400,type:t.getAttribute("type")||"auto"};o.push(r)});e.setTableGrid(o)}}parseTableRows(t,e){let r=t.querySelectorAll("tr");if(0===r.length)r=t.querySelectorAll("a\\:tr");r.forEach((t,r)=>{const o=new CTableRow;this.parseRowProperties(t,o);this.parseRowCells(t,o,r);e.addRow(o)})}parseRowProperties(t,e){let r=t.querySelector("trPr");if(!r)r=t.querySelector("a\\:trPr");if(r){let t=r.querySelector("trHeight");if(!t)t=r.querySelector("a\\:trHeight");if(t){const r=parseInt(t.getAttribute("val"),10);if(!Number.isNaN(r))e.height=r;e.heightRule=t.getAttribute("hRule")||"auto"}let o=r.querySelector("tblHeader");if(!o)o=r.querySelector("a\\:tblHeader");if(o)e.isHeader=true}if((!e.height||e.height<=0)&&t){const r=t.getAttribute("h");if(null!==r){const t=parseInt(r,10);if(!Number.isNaN(t)&&t>0){e.height=t;if(!e.heightRule)e.heightRule="auto"}}}}parseRowCells(t,e,r){let o=t.querySelectorAll("tc");if(0===o.length)o=t.querySelectorAll("a\\:tc");o.forEach((t,o)=>{const s=new CTableCell;this.parseCellProperties(t,s,r,o);this.parseCellContent(t,s);e.addCell(s)})}parseCellProperties(t,e,r,o){let s=t.querySelector("tcPr");if(!s)s=t.querySelector("a\\:tcPr");if(s){let t=s.querySelector("gridSpan");if(!t)t=s.querySelector("a\\:gridSpan");if(t)e.gridSpan=parseInt(t.getAttribute("val"))||1;let r=s.querySelector("rowSpan");if(!r)r=s.querySelector("a\\:rowSpan");if(r)e.rowSpan=parseInt(r.getAttribute("val"))||1;let o=s.querySelector("vMerge");if(!o)o=s.querySelector("a\\:vMerge");if(o){const t=o.getAttribute("val");e.vMerge="restart"===t?"start":"continue"}let i=s.querySelector("tcBorders");if(!i)i=s.querySelector("a\\:tcBorders");if(i)e.borders=this.parseCellBorders(i);let n=s.querySelector("tcShading");if(!n)n=s.querySelector("a\\:tcShading");if(n)e.shading=this.parseCellShading(n);let a=s.querySelector("tcMar");if(!a)a=s.querySelector("a\\:tcMar");if(a)e.margins=this.parseCellMargins(a)}}parseCellContent(t,e){const r=this.parseTextBodyFromElement(t);if(r)e.setTextBody(r)}processTableMerges(t){const e=t.getRows();for(let r=0;r<e.length;r++){const o=e[r];const s=o.getCells();for(let e=0;e<s.length;e++){const o=s[e];if(o.gridSpan>1)this.processHorizontalMerge(t,r,e,o.gridSpan);if(o.rowSpan>1)this.processVerticalMerge(t,r,e,o.rowSpan)}}}processHorizontalMerge(t,e,r,o){for(let s=1;s<o;s++){const o=t.getCell(e,r+s);if(o){o.isMergedContinue=true;o.mergeParent={row:e,col:r}}}}processVerticalMerge(t,e,r,o){for(let s=1;s<o;s++){const o=t.getCell(e+s,r);if(o){o.isMergedContinue=true;o.mergeParent={row:e,col:r}}}}validateTableStructure(t){const e=t.getRows();if(0===e.length)return false;const r=t.getTableGrid().length;if(0===r)return false;for(const t of e){const e=t.getCells();if(e.length!==r)void 0}return true}parseTableBorders(t){const e={};const r=["top","left","bottom","right","insideH","insideV"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=this.parseBorderProperties(o)});return e}parseCellBorders(t){return this.parseTableBorders(t)}parseBorderProperties(t){return{style:t.getAttribute("val")||"single",size:parseInt(t.getAttribute("sz"))||4,color:this.parseColor(t),space:parseInt(t.getAttribute("space"))||0}}parseTableShading(t){return this.parseCellShading(t)}parseCellShading(t){const e=t.getAttribute("fill");const r=t.getAttribute("color");return{fill:e,color:r?this.parseColorFromHex(r):null}}parseCellMargins(t){const e={};const r=["top","left","bottom","right"];r.forEach(r=>{let o=t.querySelector(r);if(!o)o=t.querySelector(`a\\:${r}`);if(o)e[r]=parseInt(o.getAttribute("w"))||0});return e}async renderChartFrame(t,e,r,o,s,i){try{let n=e.chartData;if(!n&&e.graphicData&&window.ChartProcessor){const a=new ChartProcessor(this.context);if(e.graphicData.element)n=a.parseEmbeddedChartData(e.graphicData.element);else if(e.graphicData.chartRef){const n={slideIndex:this.currentSlideIndex,slideName:this.currentSlide?.name||`slide${this.currentSlideIndex+1}`,slide:this.currentSlide};a.loadChartFromRelationship(e.graphicData.chartRef,n).then(async n=>{if(n){e.chartData=n;await this.renderChartFrame(t,e,r,o,s,i)}}).catch(t=>{void 0})}else n=a.createPlaceholderChart();if(n)e.chartData=n}if(n&&ChartRenderer){const e=new ChartRenderer(t);await e.renderChart(n,r,o,s,i);return}this.renderEnhancedChartPlaceholder(t,e,r,o,s,i)}catch(n){void 0;this.renderSimpleChartPlaceholder(t,e,r,o,s,i)}}renderEnhancedChartPlaceholder(t,e,r,o,s,i){try{t.fillRect(r,o,s,i,{r:248,g:249,b:250});t.strokeRect(r,o,s,i,{r:200,g:200,b:200},1);const e=r+40;const n=o+30;const a=s-80;const l=i-60;const c=[4500,5200,4800,6100,5900];const h=["Q1 2023","Q2 2023","Q3 2023","Q4 2023","Q1 2024"];const u=7e3;const f=0;const d=n+l-20;t.drawLine(e,n,e,d,{r:68,g:68,b:68},1);for(let r=0;r<=7;r++){const o=1e3*r;const s=d-o/u*(l-40);if(r>0)t.drawLine(e,s,e+a,s,{r:200,g:200,b:200},1)}t.drawLine(e,d,e+a,d,{r:68,g:68,b:68},1);const p=a/(c.length-1);const g={r:91,g:155,b:213};for(let r=0;r<c.length;r++){const o=e+r*p;const s=(c[r]-f)/(u-f);const i=d-s*(l-40);if(r<c.length-1){const s=e+(r+1)*p;const n=(c[r+1]-f)/(u-f);const a=d-n*(l-40);t.drawLine(o,i,s,a,g,2)}t.fillCircle(o,i,4,g)}const m=d+40;const y=e+a/2;t.drawLine(y-30,m,y-10,m,g,2);t.fillCircle(y-20,m,3,g)}catch(n){void 0;this.renderSimpleChartPlaceholder(t,e,r,o,s,i)}}renderSimpleChartPlaceholder(t,e,r,o,s,i){const n=s/5;const a=.8*i;const l=o+i-20;for(let e=0;e<4;e++){const o=r+20+e*n;const s=a*(.3+.7*Math.random());const i=l-s;t.drawRectangle(o,i,.8*n,s,{r:100,g:150,b:200,a:255},null,0)}}drawValueLabel(t,e,r,o){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.fillStyle="rgba(80, 80, 80, 1)";t.m_oContext.font="10px Calibri";t.m_oContext.textAlign="center";t.m_oContext.textBaseline="bottom";t.m_oContext.fillText(e,r,o);t.m_oContext.restore()}drawCategoryLabel(t,e,r,o){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.fillStyle="rgba(68, 68, 68, 1)";t.m_oContext.font="10px Calibri";t.m_oContext.textAlign="center";t.m_oContext.textBaseline="top";t.m_oContext.fillText(e,r,o);t.m_oContext.restore()}drawChartTitle(t,e,r,o){if(!t.m_oContext)return;t.m_oContext.save();t.m_oContext.fillStyle="rgba(0, 0, 0, 1)";t.m_oContext.font="bold 14px Calibri";t.m_oContext.textAlign="center";t.m_oContext.textBaseline="middle";t.m_oContext.fillText(e,r,o);t.m_oContext.restore()}renderDiagramFrame(t,e,r,o,s,i){const n=r+s/2;const a=o+i/2;const l=Math.min(s,i)/4;const c=[{x:n,y:a-l},{x:n+l,y:a},{x:n,y:a+l},{x:n-l,y:a}];for(let e=0;e<c.length;e++){const r=(e+1)%c.length;t.drawLine(c[e].x,c[e].y,c[r].x,c[r].y,{r:128,g:128,b:128,a:255},2)}c.forEach(e=>{t.drawEllipse(e.x-15,e.y-15,30,30,{r:200,g:200,b:200,a:255},{r:128,g:128,b:128,a:255},2)})}renderGenericFrame(t,e,r,o,s,i){t.drawRectangle(r,o,s,i,null,"#a0a0a0",1)}drawCenteredText(t,e,r,o,s,i){return}renderDefaultShape(t,e,r,o,s,i){const n=this.getShapeRotation(e);const a=n&&0!==n;if(a){t.SaveGrState();this.applyRotationTransform(t,e,r,o,s,i)}const l=this.getShapeFillColor(e);const c=this.getShapeStrokeColor(e);const h=this.getShapeLineWidth(e)||1;const u=this.getShapeStrokeInfo(e);t.drawRectangle(r,o,s,i,l,c,h,u);this.drawCenteredText(t,e.type||"Shape",r,o,s,i);if(a)t.RestoreGrState()}processShapeColor(t){if(!t)return null;let e;if("string"===typeof t)if(t.startsWith("#"))e=this.hexToRgb(t);else return null;else if("object"===typeof t&&void 0!==t.r)e=t;else return null;const r=`rgba(${e.r}, ${e.g}, ${e.b}, ${e.a||255})`;const o={...e};if(void 0!==t.tint){const e=t.tint/1e5;o.r=Math.round(o.r+(255-o.r)*e);o.g=Math.round(o.g+(255-o.g)*e);o.b=Math.round(o.b+(255-o.b)*e)}if(void 0!==t.shade){const e=1-t.shade/1e5;o.r=Math.round(o.r*e);o.g=Math.round(o.g*e);o.b=Math.round(o.b*e)}if(void 0!==t.satMod){const e=this.rgbToHsl(o.r,o.g,o.b);e.s*=t.satMod/1e5;const r=this.hslToRgb(e.h,e.s,e.l);o.r=r.r;o.g=r.g;o.b=r.b}const s=`rgba(${o.r}, ${o.g}, ${o.b}, ${o.a||255})`;return o}rgbToHsl(t,e,r){t/=255;e/=255;r/=255;const o=Math.max(t,e,r);const s=Math.min(t,e,r);let i,n,a=(o+s)/2;if(o===s)i=n=0;else{const l=o-s;n=a>.5?l/(2-o-s):l/(o+s);switch(o){case t:i=(e-r)/l+(e<r?6:0);break;case e:i=(r-t)/l+2;break;case r:i=(t-e)/l+4}i/=6}return{h:i,s:n,l:a}}hslToRgb(t,e,r){let o,s,i;if(0===e)o=s=i=r;else{const n=(t,e,r)=>{if(r<0)r+=1;if(r>1)r-=1;if(r<1/6)return t+6*(e-t)*r;if(r<1/2)return e;if(r<2/3)return t+(e-t)*(2/3-r)*6;return t};const a=r<.5?r*(1+e):r+e-r*e;const l=2*r-a;o=n(l,a,t+1/3);s=n(l,a,t);i=n(l,a,t-1/3)}return{r:Math.round(255*o),g:Math.round(255*s),b:Math.round(255*i)}}sortShapesByRenderOrder(t){if(!t||0===t.length)return[];const e=[...t];e.sort((e,r)=>{const o=e.order||e.zOrder||e.index||0;const s=r.order||r.zOrder||r.index||0;if(o!==s)return o-s;const i=t.indexOf(e);const n=t.indexOf(r);return i-n});return e}}class ImageLoader{constructor(){this.loadingImages=new Set;this.logger=new Logger("ImageLoader")}async loadImageFromUrl(t){return new Promise((e,r)=>{const o=new Image;o.onload=()=>{e(o)};o.onerror=t=>{r(new Error(`Failed to load image: ${t.message||"Unknown error"}`))};if(t.startsWith("blob:"))o.crossOrigin="anonymous";o.src=t})}async loadImageFromData(t,e="image/png"){try{const r=new Blob([t],{type:e});const o=URL.createObjectURL(r);const image=await this.loadImageFromUrl(o);return image}catch(t){throw t}}async preloadImages(t){const e=t.map(t=>this.loadImageFromUrl(t).catch(t=>null));const r=await Promise.allSettled(e);return r.map(t=>"fulfilled"===t.status?t.value:null)}async getImageDimensions(t){return new Promise((e,r)=>{const o=new Image;o.onload=()=>{e({width:o.naturalWidth,height:o.naturalHeight,aspectRatio:o.naturalWidth/o.naturalHeight})};o.onerror=()=>{r(new Error("Failed to load image for dimension check"))};o.src=t})}createThumbnail(image,t=150,e=150){const r=document.createElement("canvas");const o=r.getContext("2d");const s=image.naturalWidth/image.naturalHeight;let i,n;if(s>1){i=Math.min(t,image.naturalWidth);n=i/s}else{n=Math.min(e,image.naturalHeight);i=n*s}r.width=i;r.height=n;o.imageSmoothingEnabled=true;o.imageSmoothingQuality="high";o.drawImage(image,0,0,i,n);return r}getTableData(t){for(let e=0;e<this.slides.length;e++){const slide=this.slides[e];if(slide&&slide.shapes)for(const e of slide.shapes)if(e.id===t||e.name===t)if(e.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===e.graphicData.uri)return this.extractTableStructure(e)}return null}getAllTableData(){const t=[];for(let e=0;e<this.slides.length;e++){const slide=this.slides[e];if(slide&&slide.shapes)for(const r of slide.shapes)if(r.graphicData&&"http://schemas.openxmlformats.org/drawingml/2006/table"===r.graphicData.uri){const o=this.extractTableStructure(r);if(o){o.slideIndex=e;o.shapeId=r.id;o.shapeName=r.name;t.push(o)}}}return t}extractTableStructure(t){if(!t.graphicData||!t.graphicData.tableXml)return null;try{const e=this.parseTableFromXML(t.graphicData.tableXml);if(!e)return null;const r={id:t.id,name:t.name,type:"table",properties:this.extractTableProperties(e),structure:this.extractTableStructureData(e),content:this.extractTableContent(e),styling:this.extractTableStyling(e),position:t.bounds||t.properties?.transform,metadata:{rowCount:e.getRowCount(),columnCount:e.getColumnCount(),hasMergedCells:this.hasMergedCells(e),tableStyle:e.getTableProperties()?.style||"TableGrid"}};return r}catch(t){return null}}extractTableProperties(t){const e=t.getTableProperties()||{};return{style:e.style||"TableGrid",layout:e.layout||"autofit",width:e.width||"auto",alignment:e.alignment||"left",borders:e.borders||{},shading:e.shading||{},spacing:{before:e.spacing?.before||0,after:e.spacing?.after||0,line:e.spacing?.line||240}}}extractTableStructureData(t){const e=t.getRows();const r=t.getTableGrid();return{grid:r.map((t,e)=>({index:e,width:t.width,type:t.type||"auto"})),rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false,cells:t.getCells().map((t,e)=>({index:e,gridSpan:t.gridSpan||1,rowSpan:t.rowSpan||1,vMerge:t.vMerge||null,isMergedContinue:t.isMergedContinue||false,mergeParent:t.mergeParent||null}))}))}}extractTableContent(t){const e=t.getRows();return{cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,text:this.extractCellText(t),textBody:this.extractCellTextBody(t),content:this.extractCellContent(t)})))}}extractTableStyling(t){const e=t.getRows();return{table:{borders:t.getTableProperties()?.borders||{},shading:t.getTableProperties()?.shading||{},style:t.getTableProperties()?.style||"TableGrid"},rows:e.map((t,e)=>({index:e,height:t.height,heightRule:t.heightRule||"auto",isHeader:t.isHeader||false})),cells:e.map((t,e)=>t.getCells().map((t,r)=>({rowIndex:e,cellIndex:r,borders:t.borders||{},shading:t.shading||{},margins:t.margins||{},verticalAlignment:t.verticalAlignment||"top",textDirection:t.textDirection||"lr"})))}}hasMergedCells(t){const e=t.getRows();for(const t of e)for(const e of t.getCells())if(e.gridSpan>1||e.rowSpan>1||e.isMergedContinue)return true;return false}extractCellTextBody(t){const e=t.getTextBody();if(!e||!e.paragraphs)return null;return{paragraphs:e.paragraphs.map(t=>({properties:t.properties||{},runs:t.runs?.map(t=>({text:t.text||"",properties:t.properties||{}}))||[]}))}}extractCellContent(t){const e={type:"text",data:null};const r=t.getTextBody();if(r&&r.paragraphs){e.type="text";e.data=this.extractCellTextBody(t)}return e}extractCellText(t){if(!t.textBody||!t.textBody.paragraphs)return"";return t.textBody.paragraphs.map(t=>{if(!t.runs)return"";return t.runs.map(t=>t.text||"").join("")}).join("\n")}cleanup(){this.loadingImages.clear()}}if("undefined"!==typeof globalThis){globalThis.PPTXSlideRenderer=PPTXSlideRenderer;globalThis.ImageLoader=ImageLoader}if("undefined"!==typeof window){if(!window.PPTXSlideRenderer)window.PPTXSlideRenderer=PPTXSlideRenderer;if(!window.ImageLoader)window.ImageLoader=ImageLoader}class PPTXProcessor{constructor(t={}){const e=this._getValidator();const r=this._validateConstructorOptions(t);this.errorBoundary=new(this._getErrorBoundary())({context:"PPTXProcessor",enableLogging:false!==r.enableLogging,errorHandler:r.errorHandler});this.processor=null;this.presentation=null;this.isInitialized=false;this.config={maxFileSize:r.maxFileSize||100*1024*1024,timeout:r.timeout||8e4,enableValidation:false!==r.enableValidation,strictMode:true===r.strictMode,retryOptions:{maxAttempts:r.maxRetryAttempts||3,baseDelay:r.retryDelay||1e3},...r};this.performanceMarks=new Map;this.memoryUsage={peak:0,current:0};this.processingState="idle";this.lastError=null;this.currentSlideIndex=0;this._initializeMonitoring()}async initialize(){if(this.isInitialized)return;return this.errorBoundary.wrap(async()=>{this._markPerformance("initialize_start");try{this._validateEnvironment();await this._initializeWithRetry();this.isInitialized=true;this.processingState="idle";this._markPerformance("initialize_end");if(window.logger)window.logger.info("PPTXProcessor","Processor initialized successfully")}catch(t){this.processingState="error";this.lastError=t;throw this._enhanceError(t,"initialization")}},{context:"initialize"})()}async _ensureInitialized(){if(!this.isInitialized)await this.initialize();if(!this.processor)throw this._createError("Failed to initialize PPTX processor",{name:"ProcessingError",code:"INITIALIZATION_FAILED",recoverable:true})}async processFile(t,e={}){const r=this._validateFileInput(t,e);if(!r.valid)throw this._createValidationError("Invalid file input",r.errors);return this.errorBoundary.wrap(async()=>{this._markPerformance("processFile_start");this.processingState="processing";try{await this._ensureInitialized();this._updateMemoryUsage();const e=await this._processWithTimeout(()=>this.processor.processFile(t),this.config.timeout);this.presentation=this.processor.presentation;this.processingState="completed";this._markPerformance("processFile_end");if(this.config.enableValidation)this._validateProcessingResult(this.presentation);if(window.logger){const t=this._getPerformanceTiming("processFile_start","processFile_end");window.logger.info("PPTXProcessor",`File processed successfully in ${t}ms`)}return this.presentation}catch(e){this.processingState="error";this.lastError=e;throw this._enhanceError(e,"file_processing",{arrayBufferSize:t.byteLength})}},{context:"processFile"})()}async loadFromArrayBuffer(t){return this.processFile(t)}async renderSlide(t,e,r={}){const o=this._validateRenderInput(t,e,r);if(!o.valid)throw this._createValidationError("Invalid render input",o.errors);return this.errorBoundary.wrap(async()=>{this._markPerformance("renderSlide_start");try{await this._ensureInitialized();const o=this.getSlidesCount();if(e<0||e>=o)throw this._createError(`Slide index ${e} out of bounds (0-${o-1})`,{name:"ValidationError",code:"INVALID_SLIDE_INDEX"});this._updateMemoryUsage();const s=await this._processWithTimeout(()=>this.processor.renderSlide(t,e),r.timeout||this.config.timeout);this.currentSlideIndex=e;this._markPerformance("renderSlide_end");if(window.logger){const t=this._getPerformanceTiming("renderSlide_start","renderSlide_end");window.logger.trace("PPTXProcessor",`Slide ${e} rendered in ${t}ms`)}return s}catch(r){throw this._enhanceError(r,"slide_rendering",{slideIndex:e,canvasSize:`${t.width}x${t.height}`})}},{context:"renderSlide"})()}getSlidesCount(){if(!this.processor||!this.processor.slides)return 0;return this.processor.slides.length}getCurrentSlideIndex(){return void 0!==this.currentSlideIndex?this.currentSlideIndex:0}getCurrentSlide(t=null){if(!this.processor||!this.processor.slides)return null;const e=null!==t?t:this.getCurrentSlideIndex();return this.processor.slides[e]||null}getSlideDimensions(){if(!this.processor)return{cx:9144e3,cy:6858e3};if("function"===typeof this.processor.getSlideDimensions)return this.processor.getSlideDimensions();if(this.processor.presentation&&this.processor.presentation.slideSize)return this.processor.presentation.slideSize;return{cx:9144e3,cy:6858e3}}clearCaches(){this._ensureInitialized();if(this.processor){if(this.processor.imageCache){for(const[t,e]of this.processor.imageCache)if(e.url&&e.url.startsWith("blob:"))URL.revokeObjectURL(e.url);this.processor.imageCache.clear()}if(this.processor.imageMap)this.processor.imageMap.clear();if(this.processor.mediaMap)this.processor.mediaMap.clear();if(this.processor.clearCaches&&"function"===typeof this.processor.clearCaches)this.processor.clearCaches();if(this.processor.drawingDocument&&this.processor.drawingDocument.graphics)this.processor.drawingDocument.graphics.resetState();if(this.processor.presentation)this.processor.presentation=null}this.presentation=null}getPresentation(){if(!this.presentation&&this.config.strictMode)throw this._createError("No presentation loaded",{name:"ProcessingError",code:"NO_PRESENTATION_LOADED"});return this.presentation}getProcessingStats(){return{state:this.processingState,isInitialized:this.isInitialized,slidesCount:this.getSlidesCount(),memoryUsage:{...this.memoryUsage},lastError:this.lastError?{name:this.lastError.name,message:this.lastError.message,timestamp:this.lastError.timestamp}:null,performanceMarks:Array.from(this.performanceMarks.entries())}}_getValidator(){return"undefined"!==typeof window&&window.DataValidator?window.DataValidator:class{validate(){return{valid:true,errors:[]}}}}_getErrorBoundary(){return"undefined"!==typeof window&&window.ErrorBoundary?window.ErrorBoundary:class{constructor(){}wrap(t){return t}}}_validateConstructorOptions(t){const e=this._getValidator();const r={type:"object",properties:{maxFileSize:{type:"number",minimum:1024,maximum:500*1024*1024},timeout:{type:"number",minimum:1e3,maximum:3e5},enableLogging:{type:"boolean"},enableValidation:{type:"boolean"},strictMode:{type:"boolean"},maxRetryAttempts:{type:"number",minimum:0,maximum:10},retryDelay:{type:"number",minimum:100,maximum:1e4}}};try{const o=new e({throwOnError:false}).validate(t,r);if(!o.valid&&window.logger)window.logger.warn("PPTXProcessor","Invalid constructor options:",o.errors)}catch(t){}return t}_validateEnvironment(){const t=["Logger","PPTXSlideRenderer"];const e=t.filter(t=>"undefined"===typeof globalThis[t]);if(e.length>0)throw this._createError(`Missing required dependencies: ${e.join(", ")}`,{name:"ProcessingError",code:"MISSING_DEPENDENCIES",details:{missingDependencies:e}})}async _initializeWithRetry(){const{maxAttempts:t,baseDelay:e}=this.config.retryOptions;const r="undefined"!==typeof window&&window.ErrorRecovery?window.ErrorRecovery:{retry:async(t,e)=>{let r;for(let o=0;o<e.maxAttempts;o++)try{return await t(o+1)}catch(t){r=t;if(o<e.maxAttempts-1)await new Promise(t=>setTimeout(t,e.baseDelay))}throw r}};return r.retry(async t=>{if(window.logger)window.logger.trace("PPTXProcessor",`Initialization attempt ${t}`);this.processor=new globalThis.PPTXSlideRenderer;if(!this.processor||"function"!==typeof this.processor.processFile)throw new Error("PPTXSlideRenderer instance is invalid");return this.processor},{maxAttempts:t,baseDelay:e})}_validateFileInput(t,e){const r=[];if(!(t instanceof ArrayBuffer))r.push("Input must be an ArrayBuffer");else{if(0===t.byteLength)r.push("ArrayBuffer cannot be empty");if(t.byteLength>this.config.maxFileSize)r.push(`File size ${t.byteLength} exceeds maximum ${this.config.maxFileSize}`);const e=new Uint8Array(t,0,Math.min(4,t.byteLength));if(e.length>=2&&(80!==e[0]||75!==e[1]))r.push("File does not appear to be a valid ZIP/PPTX file")}if(e&&"object"!==typeof e)r.push("Options must be an object");return{valid:0===r.length,errors:r}}_validateRenderInput(t,e,r){const o=[];if(!t)o.push("Canvas is required");else if(!(t instanceof HTMLCanvasElement))o.push("Canvas must be an HTMLCanvasElement");else if(t.width<=0||t.height<=0)o.push("Canvas must have positive dimensions");if("number"!==typeof e||!Number.isInteger(e))o.push("Slide index must be an integer");if(r&&"object"!==typeof r)o.push("Options must be an object");return{valid:0===o.length,errors:o}}_validateProcessingResult(presentation){if(!presentation)throw this._createError("Processing completed but no presentation was created",{name:"ProcessingError",code:"NO_PRESENTATION_RESULT"});if(this.config.strictMode)if(!this.processor.slides||0===this.processor.slides.length)window.logger?.warn("PPTXProcessor","No slides found in presentation")}async _processWithTimeout(t,e){return new Promise((r,o)=>{const s=setTimeout(()=>{o(this._createError(`Operation timed out after ${e}ms`,{name:"TimeoutError",code:"OPERATION_TIMEOUT"}))},e);Promise.resolve(t()).then(t=>{clearTimeout(s);r(t)}).catch(t=>{clearTimeout(s);o(t)})})}_initializeMonitoring(){if("undefined"!==typeof performance&&performance.mark)this.performanceEnabled=true;if("undefined"!==typeof performance&&performance.memory)this.memoryMonitoringEnabled=true}_markPerformance(t){if(this.performanceEnabled)try{performance.mark(t);this.performanceMarks.set(t,performance.now())}catch(t){}else this.performanceMarks.set(t,Date.now())}_getPerformanceTiming(t,e){const r=this.performanceMarks.get(t);const o=this.performanceMarks.get(e);if(r&&o)return Math.round(o-r);return 0}_updateMemoryUsage(){if(this.memoryMonitoringEnabled&&performance.memory)try{const t=performance.memory.usedJSHeapSize;this.memoryUsage.current=t;this.memoryUsage.peak=Math.max(this.memoryUsage.peak,t)}catch(t){}}_createError(t,e={}){const r="undefined"!==typeof window&&window.ErrorHandlerFactory?window.ErrorHandlerFactory:{createFromError:t=>new Error(t.message||t)};const o=new Error(t);o.name=e.name||"ProcessingError";o.code=e.code||null;o.context="PPTXProcessor";o.timestamp=(new Date).toISOString();o.recoverable=false!==e.recoverable;if(e.details)o.details=e.details;return o}_createValidationError(t,e){const r=this._createError(t,{name:"ValidationError",code:"INPUT_VALIDATION_FAILED"});r.validationErrors=e;return r}_enhanceError(t,e,r={}){if(t.enhanced)return t;const o=t instanceof Error?t:new Error(String(t));o.operation=e;o.processorContext=r;o.timestamp=(new Date).toISOString();o.memoryUsage={...this.memoryUsage};o.enhanced=true;return o}}!function t(){const e="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:null;if(!e)return;const r=(t={})=>{try{return new PPTXProcessor(t)}catch(t){try{(e.logger||window?.logger)?.error?.("PPTXProcessor","Failed to create processor:",t)}catch(t){}throw t}};if(!e.createPPTXProcessor)e.createPPTXProcessor=r;if(!e.PPTXProcessor)e.PPTXProcessor=PPTXProcessor}();let qt="1.1.0";try{if("undefined"!==typeof process&&process.env&&process.env.npm_package_version)qt=process.env.npm_package_version}catch(t){}const zt=(t,e)=>{if(t)return t;if("undefined"!==typeof globalThis&&globalThis[e])return globalThis[e];if("undefined"!==typeof window&&window[e])return window[e];throw new Error(`${e} is required but was not found. Install and import "${"Chart"===e?"chart.js":"jszip"}" in your application.`)};const Chart=zt(e,"Chart");const JSZip=zt(r,"JSZip");if("undefined"!==typeof globalThis){if(!globalThis.Logger){class t{constructor(){}log(){}info(){}warn(){}error(){}debug(){}trace(){}logError(){}markTiming(){}measureTiming(){}}globalThis.Logger=t}if(!globalThis.PPTXSlideRenderer&&"undefined"!==typeof window&&window.PPTXSlideRenderer)globalThis.PPTXSlideRenderer=window.PPTXSlideRenderer;if("undefined"!==typeof window)if(!window.PPTXSlideRenderer&&globalThis.PPTXSlideRenderer)window.PPTXSlideRenderer=globalThis.PPTXSlideRenderer;if(!globalThis.FontEngine&&"undefined"!==typeof window&&window.FontEngine)globalThis.FontEngine=window.FontEngine;if(!globalThis.SimplifiedFontManager&&"undefined"!==typeof window&&window.SimplifiedFontManager)globalThis.SimplifiedFontManager=window.SimplifiedFontManager;if(!globalThis.ZLib&&"undefined"!==typeof window&&window.ZLib)globalThis.ZLib=window.ZLib;if(!globalThis.OpenXmlPackage&&"undefined"!==typeof window&&window.OpenXmlPackage)globalThis.OpenXmlPackage=window.OpenXmlPackage;if(!globalThis.OpenXmlPart&&"undefined"!==typeof window&&window.OpenXmlPart)globalThis.OpenXmlPart=window.OpenXmlPart;if(!globalThis.OpenXmlTypes&&"undefined"!==typeof window&&window.OpenXmlTypes)globalThis.OpenXmlTypes=window.OpenXmlTypes;if(!globalThis.SVGRenderer&&"undefined"!==typeof window&&window.SVGRenderer)globalThis.SVGRenderer=window.SVGRenderer;if(!globalThis.XmlParserContext&&"undefined"!==typeof window&&window.XmlParserContext)globalThis.XmlParserContext=window.XmlParserContext;if(!globalThis.StaxParser&&"undefined"!==typeof window&&window.StaxParser)globalThis.StaxParser=window.StaxParser;if(!globalThis.CPresentation&&"undefined"!==typeof window&&window.CPresentation)globalThis.CPresentation=window.CPresentation;if(!globalThis.CSlide&&"undefined"!==typeof window&&window.CSlide)globalThis.CSlide=window.CSlide;if(!globalThis.CSld&&"undefined"!==typeof window&&window.CSld)globalThis.CSld=window.CSld;if(!globalThis.CShape&&"undefined"!==typeof window&&window.CShape)globalThis.CShape=window.CShape;if(!globalThis.CGroupShape&&"undefined"!==typeof window&&window.CGroupShape)globalThis.CGroupShape=window.CGroupShape;if(!globalThis.CSlideMaster&&"undefined"!==typeof window&&window.CSlideMaster)globalThis.CSlideMaster=window.CSlideMaster;if(!globalThis.CSlideLayout&&"undefined"!==typeof window&&window.CSlideLayout)globalThis.CSlideLayout=window.CSlideLayout;if(!globalThis.CTheme&&"undefined"!==typeof window&&window.CTheme)globalThis.CTheme=window.CTheme;if(!globalThis.CTable&&"undefined"!==typeof window&&window.CTable)globalThis.CTable=window.CTable;if(!globalThis.JSZip&&"undefined"!==typeof JSZip)globalThis.JSZip=JSZip;if(!globalThis.PPTXProcessor&&"function"===typeof PPTXProcessor)globalThis.PPTXProcessor=PPTXProcessor;if(!globalThis.createPPTXProcessor&&"function"===typeof PPTXProcessor)globalThis.createPPTXProcessor=(t={})=>new PPTXProcessor(t)}if("undefined"!==typeof globalThis){if("undefined"!==typeof window){window.CGraphics=window.CGraphics||globalThis.CGraphics||void 0;if(!window.Chart&&"undefined"!==typeof Chart)window.Chart=Chart;if(!window.PPTXSlideRenderer&&"undefined"!==typeof globalThis.PPTXSlideRenderer)window.PPTXSlideRenderer=globalThis.PPTXSlideRenderer;if(!window.PPTXProcessor&&"undefined"!==typeof globalThis.PPTXProcessor)window.PPTXProcessor=globalThis.PPTXProcessor;if(!window.createPPTXProcessor&&"undefined"!==typeof globalThis.createPPTXProcessor)window.createPPTXProcessor=globalThis.createPPTXProcessor}if(!globalThis.CGraphics&&"undefined"!==typeof window&&window.CGraphics)globalThis.CGraphics=window.CGraphics}class $t{constructor(t={}){const e=t||{};this.options={canvas:e.canvas??null,debug:e.debug??false,enableThumbnails:e.enableThumbnails??true,slideSizeMode:e.slideSizeMode??"fit",backgroundColor:e.backgroundColor??"#ffffff",autoRenderFirstSlide:e.autoRenderFirstSlide??true,logger:e.logger??("undefined"!==typeof window?window.console:console),autoExposeGlobals:e.autoExposeGlobals??true,autoChartRerenderDelayMs:e.autoChartRerenderDelayMs??200};Object.assign(this.options,e);this.processor=null;this.presentation=null;this.currentSlideIndex=0;this.slideCount=0;this.isLoaded=false;this.eventListeners={};this._initPromise=null;this._scheduledPostLoadRerender=false}async _initializeProcessor(){if(this._initPromise)return this._initPromise;this._initPromise=(async()=>{const t="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:null;const e=()=>{const e=t?t.PPTXProcessor||null:null;const r=t?t.createPPTXProcessor||null:null;return{ctor:e,factory:r}};try{let t=0;let r=e();while(!r.ctor&&!r.factory&&t<100){await new Promise(t=>setTimeout(t,20));t+=1;r=e()}if(r.ctor&&"function"===typeof r.ctor)this.processor=new r.ctor;else if(r.factory&&"function"===typeof r.factory)this.processor=r.factory();else this.processor=null;if(!this.processor)throw new Error("PPTXProcessor is not available. Ensure processors are loaded.");if("function"===typeof this.processor.initialize)await this.processor.initialize();this.emit("processorReady");return this.processor}catch(t){this.emit("initError",t);throw t}})();return this._initPromise}async loadFile(t,e={}){if(this.isLoaded&&this.processor){try{if("function"===typeof this.processor.destroy)this.processor.destroy();else if("function"===typeof this.processor.reset)this.processor.reset()}catch(t){}this.processor=null;this._initPromise=null}await this._initializeProcessor();try{this.emit("loadStart");let r;if("undefined"!==typeof File&&t instanceof File)r=await t.arrayBuffer();else if(t instanceof ArrayBuffer)r=t;else if(t instanceof Uint8Array)r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);else throw new Error("Input must be File, ArrayBuffer, or Uint8Array");await this.processor.processFile(r,e);this.presentation=this.processor.presentation;this.slideCount=this.processor.getSlidesCount();this.currentSlideIndex=0;this.isLoaded=true;this._scheduledPostLoadRerender=false;if(this.options.autoExposeGlobals)try{this._exposeGlobalsForCharts()}catch(t){}this.emit("loadComplete",{slideCount:this.slideCount,presentation:this.presentation});return this}catch(t){this.emit("loadError",t);throw t}}async loadFromUrl(t){this.emit("loadStart");try{const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch PPTX: ${e.status} ${e.statusText}`);const r=await e.arrayBuffer();return this.loadFile(r)}catch(t){this.emit("loadError",t);throw t}}async render(t,e={}){if(!this.isLoaded)throw new Error("No PPTX loaded. Call loadFile() first.");const r=t||this.options.canvas;if(!r)throw new Error("Canvas element required. Provide canvas parameter or set in constructor.");const o=void 0!==e.slideIndex?e.slideIndex:this.currentSlideIndex;if(o<0||o>=this.slideCount)throw new Error(`Invalid slide index: ${o}.`);try{this.emit("renderStart",o);await this.processor.renderSlide(r,o,e);this.currentSlideIndex=o;this.emit("renderComplete",o);this.emit("slideChanged",o);if(this.options.autoChartRerenderDelayMs>0&&!this._scheduledPostLoadRerender){this._scheduledPostLoadRerender=true;const t=this.options.autoChartRerenderDelayMs;setTimeout(()=>{try{this.render(r,{...e,slideIndex:o})}catch(t){}},t)}return this}catch(t){this.emit("renderError",t);throw t}}async renderSlide(t,e=null,r={}){return this.render(e,{...r,slideIndex:t})}async nextSlide(t=null){if(this.currentSlideIndex<this.slideCount-1)await this.render(t,{slideIndex:this.currentSlideIndex+1});return this}async previousSlide(t=null){if(this.currentSlideIndex>0)await this.render(t,{slideIndex:this.currentSlideIndex-1});return this}async goToSlide(t,e=null){return this.render(e,{slideIndex:t})}getSlideCount(){return this.slideCount}getCurrentSlideIndex(){return this.currentSlideIndex}setCanvas(t){this.options.canvas=t;return this}on(t,e){if(!this.eventListeners[t])this.eventListeners[t]=[];this.eventListeners[t].push(e)}off(t,e){if(!this.eventListeners[t])return;const r=this.eventListeners[t].indexOf(e);if(r>-1)this.eventListeners[t].splice(r,1)}emit(t,...e){if(this.eventListeners[t])this.eventListeners[t].forEach(t=>{try{t(...e)}catch(t){}})}destroy(){this.processor=null;this.eventListeners={};this.isLoaded=false;this.currentSlideIndex=0;this.slideCount=0}_exposeGlobalsForCharts(){try{const t=this.processor;if(!t)return;const e=t.zip||t.processor?.zip||t.zipProcessor?.zip||null;const r=t.package||t.processor?.package||t.zipProcessor?.package||null;const o=()=>{const t="function"===typeof this.getCurrentSlideIndex?this.getCurrentSlideIndex():this.currentSlideIndex||0;const e=this.options.canvas;if(e)this.render(e,{slideIndex:t}).catch(()=>{})};const s={processor:t,zip:e,package:r,reRenderShape:o};if("undefined"!==typeof window){window.currentProcessor=s;if(e)window.currentZipData=e;if(window.PPTXSlideRenderer&&e)try{window.PPTXSlideRenderer.currentZip=s.zip}catch(t){}try{if(window.currentProcessor&&window.currentProcessor.processor){if(!window.currentProcessor.processor.zip&&e)window.currentProcessor.processor.zip=e;if(!window.currentProcessor.processor.package&&r)window.currentProcessor.processor.package=r;if(!window.currentProcessor.processor.zipProcessor)window.currentProcessor.processor.zipProcessor={};if(e&&!window.currentProcessor.processor.zipProcessor.zip)window.currentProcessor.processor.zipProcessor.zip=e;if(r&&!window.currentProcessor.processor.zipProcessor.package)window.currentProcessor.processor.zipProcessor.package=r}}catch(t){}}}catch(t){}}}function Nt({canvas:t,fileInput:e,prevBtn:r,nextBtn:o,statusEl:s,options:i={}}={}){if(!t)throw new Error("canvas is required");const n=new $t({canvas:t,...i});const a=()=>{try{const t=n.getSlideCount();const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;if(r)r.disabled=!(e>0);if(o)o.disabled=!(e<t-1);if(s)s.textContent=t?`Slide ${e+1} / ${t}`:""}catch(t){}};n.on("renderComplete",()=>a());n.on("loadComplete",()=>{try{if(n&&n.processor&&false!==i.autoExposeGlobals){const e=n.processor;const r={processor:e,zip:e.zip,package:e.package,reRenderShape:()=>{const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})}};if("undefined"!==typeof window){window.currentProcessor=r;if(e.zip)window.currentZipData=e.zip;if(window.PPTXSlideRenderer&&r.zip)try{window.PPTXSlideRenderer.currentZip=r.zip}catch(t){}}}}catch(t){}a()});if(e)e.addEventListener("change",async()=>{const r=e.files&&e.files[0];if(!r)return;if(s)s.textContent="Loading...";try{await n.loadFile(r);try{if(n&&n.processor&&false!==i.autoExposeGlobals){const e=n.processor;const r=e.zip||e.processor?.zip||e.zipProcessor?.zip||null;const o=e.package||e.processor?.package||e.zipProcessor?.package||null;if("undefined"!==typeof window){window.currentProcessor={processor:e,zip:r,package:o,reRenderShape:()=>{const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})}};if(r)window.currentZipData=r;try{if(window.currentProcessor&&window.currentProcessor.processor){if(!window.currentProcessor.processor.zip&&r)window.currentProcessor.processor.zip=r;if(!window.currentProcessor.processor.package&&o)window.currentProcessor.processor.package=o;if(!window.currentProcessor.processor.zipProcessor)window.currentProcessor.processor.zipProcessor={};if(r&&!window.currentProcessor.processor.zipProcessor.zip)window.currentProcessor.processor.zipProcessor.zip=r;if(o&&!window.currentProcessor.processor.zipProcessor.package)window.currentProcessor.processor.zipProcessor.package=o}}catch(t){}}}}catch(t){}await n.render(t,{slideIndex:0});const e="number"===typeof i.autoChartRerenderDelayMs?i.autoChartRerenderDelayMs:200;if(e>0)setTimeout(()=>{const e="function"===typeof n.getCurrentSlideIndex?n.getCurrentSlideIndex():0;n.render(t,{slideIndex:e}).catch(()=>{})},e)}catch(t){if(s)s.textContent="Error: "+(t?.message||"Failed to load")}});if(r)r.addEventListener("click",async()=>{await n.previousSlide(t)});if(o)o.addEventListener("click",async()=>{await n.nextSlide(t)});return n}const Gt={PPTXViewer:$t,version:qt,mountSimpleViewer:Nt};const Ht=t=>{try{if("undefined"!==typeof globalThis&&globalThis[t]&&!Gt[t])Gt[t]=globalThis[t]}catch(t){}};["CGraphics","FontEngine","SimplifiedFontManager","ZLib","OpenXmlPackage","OpenXmlPart","OpenXmlTypes","SVGRenderer","XmlParserContext","StaxParser","CPresentation","CSlide","CSld","CShape","CGroupShape","CSlideMaster","CSlideLayout","CTheme","CTable","PPTXProcessor","PPTXSlideRenderer","Chart","JSZip"].forEach(Ht);if("undefined"!==typeof globalThis){globalThis.PptxViewJS=Gt;if(!globalThis.PPTXProcessor&&"undefined"!==typeof PPTXProcessor)globalThis.PPTXProcessor=PPTXProcessor;if(!globalThis.createPPTXProcessor&&"undefined"!==typeof PPTXProcessor)globalThis.createPPTXProcessor=(t={})=>new PPTXProcessor(t)}if(!globalThis.PPTXSlideRenderer&&"function"===typeof PPTXSlideRenderer)globalThis.PPTXSlideRenderer=PPTXSlideRenderer;t.PPTXViewer=$t;t.default=Gt;Object.defineProperty(t,"__esModule",{value:true})});!function(){try{var t="undefined"!==typeof window&&(window.CDrawingDocument||window.CDrawingDocumentClass);if(t&&!t.prototype.colorToRgb)t.prototype.colorToRgb=function(t){try{if(this.graphics&&"function"===typeof this.graphics.colorToRgb)return this.graphics.colorToRgb(t)}catch(t){}if("string"===typeof t)return t;if(t&&"object"===typeof t){var e=void 0!==t.r?t.r:void 0!==t.R?t.R:0;var r=void 0!==t.g?t.g:void 0!==t.G?t.G:0;var o=void 0!==t.b?t.b:void 0!==t.B?t.B:0;var s=void 0!==t.a?t.a:void 0!==t.A?t.A:255;return 255!==s?"rgba("+e+", "+r+", "+o+", "+s/255+")":"rgb("+e+", "+r+", "+o+")"}return"rgb(0, 0, 0)"}}catch(t){}}();
|