From 545ed66e74dd82212e46700ef78d5e39e6bec249 Mon Sep 17 00:00:00 2001 From: orinsid <73414076+orinsid@users.noreply.github.com> Date: Tue, 10 Nov 2026 10:36:04 +0800 Subject: [PATCH] page-usage-board: a usage dashboard page (#844) Adds @magpie-community/page-usage-board: a usage dashboard page with its own zero-dependency local service (quota cards with expiry tiers, TTFT, 7x24 heatmap, optional remote attribution). Reviewed at 8ca2562: the author's 80137b0 plus a maintainer merge of main (registry entry re-appended after upstream's newer packages). Since the 6b2625d review: [::1] in MAGPIE_ADDR stays IPv6 loopback (only 0.0.0.0/[::] map to 127.0.0.1), the config-dir test compares real paths so it passes on macOS, and the registry-block test tolerates CRLF. Run on mote at 8ca2562: packages/page-usage-board `bun test` 36 pass, `node --test test/*.test.mjs` 36 pass; `bun scripts/check.mjs` all ok. Not tried this round: the page in a live magpie window. --- README.md | 1 + packages/page-usage-board/.env.example | 61 + packages/page-usage-board/LICENSE | 21 + .../page-usage-board/LICENSES/Apache-2.0.txt | 202 +++ packages/page-usage-board/NOTICE | 24 + packages/page-usage-board/README.md | 193 +++ .../page-usage-board/build/echarts-entry.mjs | 24 + .../docs/community-submission.md | 82 + .../page-usage-board/docs/data-semantics.md | 66 + packages/page-usage-board/index.mjs | 57 + packages/page-usage-board/package-lock.json | 533 ++++++ packages/page-usage-board/package.json | 82 + packages/page-usage-board/page/boot.js | 114 ++ packages/page-usage-board/page/icon.svg | 12 + packages/page-usage-board/page/index.html | 48 + .../scripts/build-echarts.mjs | 40 + packages/page-usage-board/scripts/prepack.mjs | 104 ++ packages/page-usage-board/server.mjs | 899 ++++++++++ .../page-usage-board/static/echarts.min.js | 49 + packages/page-usage-board/static/index.html | 1443 +++++++++++++++++ .../page-usage-board/test/aggregate.test.mjs | 39 + .../page-usage-board/test/server.test.mjs | 630 +++++++ registry.json | 4 +- 23 files changed, 4727 insertions(+), 1 deletion(-) create mode 100644 packages/page-usage-board/.env.example create mode 100644 packages/page-usage-board/LICENSE create mode 100644 packages/page-usage-board/LICENSES/Apache-2.0.txt create mode 100644 packages/page-usage-board/NOTICE create mode 100644 packages/page-usage-board/README.md create mode 100644 packages/page-usage-board/build/echarts-entry.mjs create mode 100644 packages/page-usage-board/docs/community-submission.md create mode 100644 packages/page-usage-board/docs/data-semantics.md create mode 100644 packages/page-usage-board/index.mjs create mode 100644 packages/page-usage-board/package-lock.json create mode 100644 packages/page-usage-board/package.json create mode 100644 packages/page-usage-board/page/boot.js create mode 100644 packages/page-usage-board/page/icon.svg create mode 100644 packages/page-usage-board/page/index.html create mode 100644 packages/page-usage-board/scripts/build-echarts.mjs create mode 100644 packages/page-usage-board/scripts/prepack.mjs create mode 100644 packages/page-usage-board/server.mjs create mode 100644 packages/page-usage-board/static/echarts.min.js create mode 100644 packages/page-usage-board/static/index.html create mode 100644 packages/page-usage-board/test/aggregate.test.mjs create mode 100644 packages/page-usage-board/test/server.test.mjs diff --git a/README.md b/README.md index 25fb97a..12389df 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ These add a page to magpie's window, in the app and in `magpie web`, under Plugi | [nowledge-mem](packages/nowledge-mem) | Connection settings, recall and capture switches, a real connection test, and the scope of what is sent | None | | [agent-office](packages/agent-office) | What are my agents doing: a real WebGL 3D office with six scenes, an isometric/2D office, grouped workbench, Today usage and recent conversations | no `magpie.read`; its host part reads local session files of Claude Code, Codex, Copilot CLI, Kimi Code, dsh, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build, including prompts, replies and tool commands (`text:false` keeps statuses and tool names only) | | [page-usage-tree](packages/page-usage-tree) | Account usage: usage as provider -> account -> model, each level expandable, with per-account calls, errors and cost; adds the account layer Usage glance's `usage:summary` does not contain | none (its local service calls Magpie's local usage API) | +| [page-usage-board](packages/page-usage-board) | Full usage board: quota cards with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail | none (the page reads nothing through the bridge; its local service reads your usage.jsonl, magpie's usage/quota API, and — for optional remote attribution — your magpie config's provider key to query the configured remote magpie) | | [fingerprint](packages/fingerprint) | Numeric response fingerprints to investigate suspected model substitution across providers, with shared challenges, candidate rankings, local evidence and JSON export | none (its local service calls magpie’s gateway; sampling uses provider quota) | | [chat](packages/chat) | Chat with magpie's models, your MCP servers, instructions and skills, by Magic_zero ([Magiczerowxy](https://github.com/Magiczerowxy)). Has a host part: a local service the page goes to | none (its service calls magpie's gateway) | | [window-warmup](packages/window-warmup) | Window warmup: send one fixed short message ("hi", max_tokens 16) to a provider, account and model you pick, right after its quota window resets, daily at set times or every few hours, so the next subscription window opens early, by [YangHonghang](https://github.com/YangHonghang). Has a host part: a local service on 127.0.0.1 the page goes to | none; its service calls magpie's gateway and reads magpie's providers.json (keys only as sha256 fingerprints, plus key names and account models) and model cache. Each send uses the chosen account's quota | diff --git a/packages/page-usage-board/.env.example b/packages/page-usage-board/.env.example new file mode 100644 index 0000000..a8c1464 --- /dev/null +++ b/packages/page-usage-board/.env.example @@ -0,0 +1,61 @@ +# Copy to .env and edit as needed; run the board with `npm start` (or `node server.mjs`). +# Every variable is optional — commented-out lines show the built-in defaults. + +# Listen port. Default 3455; 0 = let the OS pick. When the port is held the service +# retries for ~8s, then reuses a live instance of the same build, or fails with a clear +# error when a different build / a foreign process holds it. It never scans upward. +#PORT=3455 + +# Bind address. Keep the loopback default: the board page answers loopback binds and +# loopback Host names only — a non-loopback bind never serves the page (403). +#HOST=127.0.0.1 + +# Token for scripts that call the API (send it as the "x-dash-key" request header). +# Optional: when unset, every start generates a random token — not persisted, not logged, +# not in any URL. Set it EMPTY explicitly (PAGE_KEY=) to serve the API without a token. +# Never commit a real key: .env is git-ignored. +#PAGE_KEY= + +# Extra Host names the API may be reached by behind a reverse proxy (comma-separated). +# The board page stays loopback-only regardless. +#ALLOWED_HOSTS= + +# magpie's local gateway API and its bearer key (live quotas / KPIs). +# Resolution order: manifest options.gateway → GATEWAY → MAGPIE_GATEWAY → +# MAGPIE_ADDR (set by magpie's plugin host) → the 3425 default. +#GATEWAY=http://127.0.0.1:3425 +#MAGPIE_KEY= + +# magpie's config directory — explicit override only (magpie itself has no such +# env; the service follows the host's cwd, then XDG_CONFIG_HOME/magpie, then +# ~/.config/magpie, so portable installs need nothing here). +# usage.jsonl, plugin-providers.json and providers.json live there. +#MAGPIE_CONFIG_DIR= + +# magpie's usage log — the only data source (no prompts or message bodies are read). +#USAGE_JSONL= + +# Brand logos: the only source is magpie's own plugin-providers.json (data-URI icons, +# no downloads, no directory scanning). Default: the file next to usage.jsonl. +#MAGPIE_PROVIDERS_FILE= + +# ---- Remote attribution: OPT-IN, OFF by default ------------------------------- +# ATTRIBUTION=local (default) keeps all attribution on this machine's usage.jsonl. +# ATTRIBUTION=remote makes the service read this machine's magpie providers.json (or +# REMOTE_BASE/REMOTE_KEY below) and send that provider's key to the remote magpie's +# /v1/magpie/usage/requests — the key leaves this machine only toward that remote +# magpie. The equivalent manifest option is options.attribution: "remote". +#ATTRIBUTION=local + +# Remote provider credentials (read only when ATTRIBUTION=remote). Default source: the +# preset remote-magpie / magpie-direct / magpie-cf provider in MAGPIE_PROVIDERS. +#MAGPIE_PROVIDERS=~/.config/magpie/providers.json +#REMOTE_BASE= +#REMOTE_KEY= + +# Caller names kept for the remote charts. No default: empty means no filtering. +#REMOTE_CALLERS= + +# Provider aliases counted as "remote" in the 24-hour split. Default: magpie's own three +# route names; override via manifest options.remoteProviders. +#REMOTE_PROVIDERS=magpie-direct,magpie-cf,remote-magpie diff --git a/packages/page-usage-board/LICENSE b/packages/page-usage-board/LICENSE new file mode 100644 index 0000000..3e630d7 --- /dev/null +++ b/packages/page-usage-board/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 magpie-usage-board contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/page-usage-board/LICENSES/Apache-2.0.txt b/packages/page-usage-board/LICENSES/Apache-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/packages/page-usage-board/LICENSES/Apache-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/page-usage-board/NOTICE b/packages/page-usage-board/NOTICE new file mode 100644 index 0000000..14f63e1 --- /dev/null +++ b/packages/page-usage-board/NOTICE @@ -0,0 +1,24 @@ +magpie usage board +Copyright 2026 magpie-usage-board contributors + +This product includes third-party software and assets: + +* Apache ECharts (static/echarts.min.js) + Copyright 2018-2026 Apache Software Foundation. + Licensed under the Apache License, Version 2.0 (the "License"); you may + not use this file except in compliance with the License. The full license + text ships with this distribution at LICENSES/Apache-2.0.txt and is also + available at https://www.apache.org/licenses/LICENSE-2.0 + Provenance: custom build from the npm `echarts@5.5.1` package via + `build/echarts-entry.mjs` (see that file for the included components). + The bundle is byte-for-byte reproducible with `npm run build:echarts` + (scripts/build-echarts.mjs). + +* Brand logos + Provider logos are not bundled with this package: at service startup the + server reads magpie's own `plugin-providers.json` (the registry magpie + maintains next to its usage.jsonl) and keeps only the data-URI icons it + already contains. No network downloads and no plugin-directory scanning + are involved. Product and company names and logos are trademarks or + registered trademarks of their respective owners, used solely to identify + the corresponding providers; they do not imply endorsement. diff --git a/packages/page-usage-board/README.md b/packages/page-usage-board/README.md new file mode 100644 index 0000000..944abff --- /dev/null +++ b/packages/page-usage-board/README.md @@ -0,0 +1,193 @@ +# magpie usage board + +A usage dashboard page inside [magpie](https://usemagpie.ai)'s window, served by the plugin's +own zero-dependency local service. + +**Most of this board repeats magpie's own Usage page** — the allowance cards, the +per-provider and per-model totals and the request list are all there already. Install this +page for the five things Usage does not show: + +1. **Remote attribution by caller key** — traffic routed through a remote magpie, split by + which caller key caused it (opt-in; see *Remote attribution*). +2. **TTFT p50/p90 per provider** — latency quality next to the volume. +3. **A 7×24 heatmap** — when the calls actually happen, by weekday and hour. +4. **Direct-vs-remote split of the last 24 hours** — how much went out through a remote + magpie versus straight out of this machine. +5. **Expiry tiers on the quota cards** — how soon each allowance lapses, not just how much + is left. + +Everything else is convenience around those: daily and per-provider charts, 24-hour +cache-hit and token curves, per-account detail for the remote side. + +Where [`@magpie-community/page-usage`](https://github.com/magpie-community/plugins/tree/main/packages/usage) +is a bridge-only glance at magpie's summary totals, this page is the full board. Where +[`page-usage-tree`](https://github.com/magpie-community/plugins/tree/main/packages/page-usage-tree) +drills provider → account → model, this one puts quotas, costs and quality on one screen. + +## What it answers + +1. **Which providers were used** — local direct traffic plus traffic that landed on a remote + magpie (opt-in), merged under real provider names (daily chart, provider pies). +2. **How much** — calls, tokens, daily trend; the quota wall shows what is left and when it + lapses. +3. **How good** — TTFT P50/P90, per-account detail and error counts for the remote side. + +The two accounting views (KPI ledger vs. provider charts) and the exit-alias rules are +documented in [`docs/data-semantics.md`](docs/data-semantics.md). + +## How it works + +Two layers, the same shape the community uses for host-part pages: + +1. `index.mjs` is an OpenCode v1 plugin loaded by magpie's Bun host. When magpie calls its + `server()` entry it starts `server.mjs`, a zero-dependency Node 22+/Bun HTTP service on + `127.0.0.1:3455`. +2. `page/index.html` + `page/boot.js` is the hosted page. It asks the bridge for + `magpie.service` first: when `magpie web` runs on another machine it proxies the local + service under magpie's own origin, so **magpie's own key/auth is the outer gate** and the + page never leaves that origin. A desktop window has no service, so it falls back to + `http://127.0.0.1:3455/` — the port it read from `magpie.options.get()`, the same value + the service was started with. An 8-second `` is the fallback if the boot + script is blocked. + +The 8-second `` is deliberate: an earlier all-script page could be declared dead +by the host after 10 seconds when the bridge handshake raced; the meta fallback still +navigates if `boot.js` never runs, and the window is wide enough for slow bridge handshakes +that `boot.js` resolves first. + +### Why a local service (and its token) + +magpie's bridge exposes a small set of reads — the bridge-only `usage` page uses just +`usage:summary`. This board needs quotas, per-provider/per-day totals, a 7×24 heatmap, +recent requests, TTFT and account detail; those are not in that summary. Like +[`page-usage-tree`](https://github.com/magpie-community/plugins/tree/main/packages/page-usage-tree), +it therefore runs a small local service that reads `usage.jsonl`. + +That service is a separate origin on `127.0.0.1`, outside magpie's auth. The gate is the same +model the community [`page-usage-tree`](https://github.com/magpie-community/plugins/tree/main/packages/page-usage-tree) +uses: the board page is served only on a loopback bind **and** a loopback `Host` — any +non-loopback bind answers 403 for the page — and the service injects its token into the +served HTML (`window.__KEY__`), so nobody types it. `/api/*` (except the two anonymous +liveness routes below) checks the same token from the `x-dash-key` request header. There is +no `?key=` query authentication and no token cookie: a key must never reach a URL, where +proxy and browser-history logs would record it. + +The token comes from the `PAGE_KEY` environment variable when you set one (for scripts that +call the API); otherwise every start generates a fresh random token that is never written to +disk and never appears in a log line or URL. When `magpie web` is remote, the page goes +through `magpie.service` and stays under magpie's origin, so magpie's key remains the outer +gate. + +## Install + +Requires Node 22+. Inside magpie (once the package is merged into the community registry): + +```sh +magpie plugin add @magpie-community/page-usage-board +``` + +Standalone, from a checkout or the npm package: + +```sh +npm start # or: node server.mjs +# [magpie-usage] listening on http://127.0.0.1:3455/ +``` + +The board is local-only: the page answers loopback binds and loopback `Host` names, and a +non-loopback bind never serves it (403) — there is no remote-visitor auth channel. Scripts +that want the API set `PAGE_KEY` and send it as the `x-dash-key` request header. The service +reads `~/.config/magpie/usage.jsonl`. + +## Configuration + +| Variable | Default | Meaning | +|---|---|---| +| `PORT` | `3455` | Listen port; `0` = let the OS pick. When the port is held, the service retries for ~8s, then reuses a live instance of the **same build** (recognised anonymously via the build id on `/api/ping`) or fails with a clear error when a different build or a foreign process holds it. It never scans upward. | +| `HOST` | `127.0.0.1` | Bind address. Keep loopback: the board page answers loopback binds and loopback `Host` names only, and other local users of this machine can reach a loopback-bound board. | +| `PAGE_KEY` | generated | Optional token for scripts that call the API (sent as the `x-dash-key` header). When unset, every start generates a random token — not persisted, not logged, not in any URL. Set it **empty explicitly** (`PAGE_KEY=`) to serve the API without a token. | +| `ALLOWED_HOSTS` | empty | Comma-separated extra `Host` names the **API** may be reached by (e.g. behind a reverse proxy). The page stays loopback-only regardless. | +| `GATEWAY` | `http://127.0.0.1:3425` | magpie's local gateway API. Resolved in this order: manifest `options.gateway` → `GATEWAY` → `MAGPIE_GATEWAY` → **`MAGPIE_ADDR`** (set by magpie's plugin host; a `0.0.0.0:`/`[::]:` prefix is normalised to loopback) → the `3425` default. | +| `MAGPIE_KEY` | empty | Bearer key for the gateway, when the gateway requires one. | +| `USAGE_JSONL` | `~/.config/magpie/usage.jsonl` | magpie's usage log. | +| `MAGPIE_CONFIG_DIR` | `~/.config/magpie` | Explicit override for magpie's config directory (magpie itself has no such env — this is for tests and unusual layouts). The service resolves the dir the way magpie does: the **host's cwd** when it carries magpie markers (`usage.jsonl` / `plugins.json` / `providers.json` — the plugin host starts the service with the data dir as cwd, which covers portable installs) → `XDG_CONFIG_HOME/magpie` → `~/.config/magpie`. `usage.jsonl`, `plugin-providers.json` and `providers.json` default to files inside it. | +| `MAGPIE_PROVIDERS_FILE` | `/plugin-providers.json` | Where brand logos are read from (magpie's own provider registry — see *Brand logos*). | +| `ATTRIBUTION` | `local` | Remote attribution is **opt-in**: the default `local` keeps attribution on this machine's log; `ATTRIBUTION=remote` (or manifest `options.attribution: "remote"`) makes the service query the configured remote magpie — the provider key is sent to that remote magpie. | +| `MAGPIE_PROVIDERS` | `~/.config/magpie/providers.json` | Where the remote URL and key are read from (used only with `ATTRIBUTION=remote`). | +| `REMOTE_BASE` / `REMOTE_KEY` | empty | Explicit remote override (both required) instead of `providers.json`. | +| `REMOTE_CALLERS` | empty | Caller names kept for the remote charts. **No default** — empty means no caller filtering. | +| `REMOTE_PROVIDERS` | `magpie-direct,magpie-cf,remote-magpie` | Provider aliases counted as "remote" in the 24-hour split. The default is exactly magpie's own three route names; override via manifest `options.remoteProviders`. | + +## Manifest options + +The magpie manifest (`magpie.options` in package.json) carries the same knobs. Options take +precedence over environment variables, and the built-in default applies when neither is set: + +| Option | Default | Meaning | +|---|---|---| +| `port` | `3455` | Service port. `magpie.page.service.option: "port"` tells magpie to inject the user's chosen port into `server(input, options)`; `index.mjs` forwards it to `startServer`. | +| `attribution` | `"local"` | Keep `"local"` to hold attribution on this machine (the default — remote is never enabled implicitly). `"remote"` is the explicit opt-in that queries the configured remote magpie and sends the provider key to it. | +| `remoteCallers` | `""` | Caller filter for the remote charts; empty means no filtering. | +| `remoteProviders` | `"magpie-direct,magpie-cf,remote-magpie"` | Provider aliases counted as "remote" in the 24-hour split. | + +## Languages + +The interface ships in Chinese and English. `?lang=zh` or `?lang=en` forces one; otherwise +the page follows `navigator.language` automatically. + +## Brand logos + +The quota wall shows provider brand icons. Their only source is magpie's own +`plugin-providers.json` — the registry magpie maintains next to `usage.jsonl` +(`MAGPIE_PROVIDERS_FILE` overrides the path). At startup the service reads that file once, +keeps only `data:image/...` URIs (each capped at 2 MB, at most 4 MB injected in total) and +injects them into the served HTML. There is no plugin-directory scanning, no download, no +disk cache and no `/logos` route: `https://` icons are deliberately not fetched, so the +board never contacts a third-party CDN on your behalf — providers without a data-URI icon +fall back to a colored first-letter block. + +## Data and privacy + +- Reads this machine's `usage.jsonl` and magpie's local gateway API. The board itself sends + no telemetry; its Content-Security-Policy allows no third-party host at all. +- **Remote attribution is opt-in and off by default.** Only `ATTRIBUTION=remote` (or manifest + `options.attribution: "remote"`) enables it: the service then makes read-only requests to + the configured remote magpie's own `/v1/magpie/usage/requests`, using the provider key + already configured in this machine's `providers.json` — that key is sent to that remote + magpie and nowhere else. Rows are filtered by `REMOTE_CALLERS` (no default filter) and + aggregated locally; no prompts or message bodies are involved. There is no second service + and no separate page key. +- The page and its assets are served from `127.0.0.1`. The trust boundary is the local + machine: other local users can reach a loopback-bound board, and remote attribution reads + every caller's rows on the shared remote magpie (filtered for display, disclosed in the + Pages table). +- The anonymous surface is exactly two routes: `GET /api/ping` (an identity fingerprint + + build id, used to recognise a live instance of the same build) and `GET /api/health` + (liveness). Every other `/api/*` route requires the token via the `x-dash-key` header, + every route checks `Host` to block DNS rebinding, and the board page itself is never + served on a non-loopback bind or a public `Host` name. +- No prompts or message bodies are read — the service aggregates model, provider, tokens, + cost, timing and error counts. + +## Develop + +These commands run from a git checkout — the npm package (`npm pack`) ships the runtime, +docs and notices; `test/` stays in the checkout. + +```sh +node --test # auth/host/page gate, caller filtering, package metadata +npm run build:echarts # rebuild static/echarts.min.js byte-for-byte (verify: git diff --exit-code static/echarts.min.js) +``` + +- `static/index.html` is the page source; at request time the service injects + `window.__DATA__`, `window.QLOGOS` (brand logos) and, on a loopback bind, `window.__KEY__` + into the served HTML. +- `npm test` / `npm pack` run the same checks; `prepack` refuses to package a stray + `remote.js` or a literal page key. +- Remote attribution defaults to off and must be opted into (see *Configuration*). + +## License + +MIT. `static/echarts.min.js` is a custom Apache-2.0 build of Apache ECharts, reproducible +byte-for-byte with `npm run build:echarts` (see `NOTICE`). Provider logos are collected at +runtime from magpie's `plugin-providers.json` and are the trademarks of their owners, used +only to identify providers (see `NOTICE`). diff --git a/packages/page-usage-board/build/echarts-entry.mjs b/packages/page-usage-board/build/echarts-entry.mjs new file mode 100644 index 0000000..0d2ddf1 --- /dev/null +++ b/packages/page-usage-board/build/echarts-entry.mjs @@ -0,0 +1,24 @@ +// 定制构建入口:只包含看板用到的图表与组件(见第四轮瘦身分析)。 +// 重建命令:npx esbuild build/echarts-entry.mjs --bundle --minify --global-name=echarts +// --outfile=static/echarts.min.js +// 页面通过全局 echarts.init(...) 使用;新增图表类型时在此补 import 并重建。 +import * as echarts from 'echarts/core'; +import { BarChart, LineChart, PieChart, HeatmapChart } from 'echarts/charts'; +import { + TooltipComponent, LegendComponent, GridComponent, DataZoomComponent, + DataZoomInsideComponent, DataZoomSliderComponent, VisualMapComponent, + AxisPointerComponent, +} from 'echarts/components'; +import { CanvasRenderer } from 'echarts/renderers'; + +echarts.use([ + BarChart, LineChart, PieChart, HeatmapChart, + TooltipComponent, LegendComponent, GridComponent, DataZoomComponent, + DataZoomInsideComponent, DataZoomSliderComponent, VisualMapComponent, + AxisPointerComponent, CanvasRenderer, +]); + +// 页面通过全局 echarts.init(...) 使用;--global-name 的 iife 会把 default export +// 嵌套进 .default,这里直接赋值保证 window.echarts 就是完整命名空间 +if (typeof window !== 'undefined') window.echarts = echarts; +export default echarts; diff --git a/packages/page-usage-board/docs/community-submission.md b/packages/page-usage-board/docs/community-submission.md new file mode 100644 index 0000000..a16eda9 --- /dev/null +++ b/packages/page-usage-board/docs/community-submission.md @@ -0,0 +1,82 @@ +# Community submission + +The community publishes packages by merging a pull request into +[`magpie-community/plugins`](https://github.com/magpie-community/plugins). Submitting is just +that PR — no dashboard form, and no manual `npm publish`: merging to the registry's main +branch bumps the version and **trusted publishing puts the package on npm automatically**, +so `package.json`'s `version` must be release-ready when the PR lands. One PR adds three +things: + +1. `packages/page-usage-board/` — this package (all files from `npm pack`, plus `LICENSE`, + `README.md`, `docs/` and the development files — see the layout trap below). +2. One entry in `registry.json`. +3. One row in the README's **Pages** table. + +## registry.json entry + +```json +{ + "package": "@magpie-community/page-usage-board", + "name": "Usage Board", + "kind": "page", + "community": true, + "summary": { + "en": "A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.", + "zh": "额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。" + } +} +``` + +The `summary` above must stay **verbatim-identical** to `magpie.summary` in package.json — +copy it into the PR description together with the difference declaration (the registry +requires all three texts to match). + +## README Pages row + +```md +| [page-usage-board](packages/page-usage-board) | Full usage board: quota cards with expiry tiers, daily and per-provider charts, 24-hour cache-hit and token curves, optional remote attribution and account detail | none (the page reads nothing through the bridge; its local service reads your usage.jsonl, magpie's usage/quota API, and — for optional remote attribution — your magpie config's provider key to query the configured remote magpie) | +``` + +## The packaging layout + +`npm pack` ships what the `files` field in package.json lists — the runtime (`index.mjs`, +`server.mjs`, `page/`, `static/`), the vendored echarts bundle (`build/echarts-entry.mjs` + +`static/echarts.min.js`), `docs/`, `scripts/` (`prepack.mjs`, `build-echarts.mjs`) and +`NOTICE`. The `prepack` hook asserts that the echarts entry and its build script exist and +are covered by `files`, and validates every relative link in README.md and `docs/*.md`. + +Correct layout for `packages/page-usage-board/`: the `npm pack` output, plus `LICENSE`, +`.env.example` and `test/` (development files the README references — they do not need to +be in `files`). + +Check before opening the PR: + +- `docs/` and `.env.example` are in the staged tree. +- Every relative link in README.md and `docs/*.md` resolves inside + `packages/page-usage-board/` — click through them in the GitHub PR preview. + +## Checks before opening the PR + +- `npm test` passes (auth, `Host`, page gate, traversal, lead-page, package metadata). +- `npm pack --dry-run` contains no `remote.js`, no page key, and includes `LICENSE`. +- The host part guards every route with a token **and checks `Host`** (community requirement + for pages that navigate to a local service). The board page itself is served only on a + loopback bind with a loopback `Host` name — the token is injected into the served HTML + rather than typed, and a non-loopback bind or a proxied public `Host` never receives the + page. Deliberate anonymous routes, filed here for review: `GET /api/ping` (returns + `{service,ok,build,version}` — an identity fingerprint + build id, used to recognise a + live instance of the same build) and `GET /api/health` (returns `{ok,jsonl}` — liveness). + Both carry no key and no usage data; every other `/api/*` route requires the token via + the `x-dash-key` header (no `?key=` query auth, no cookie channel), and `/static/*` holds + only the chart library and page assets (no data). +- Remote attribution defaults to **off** (`magpie.options.attribution: "local"`); the user + must explicitly opt in (`ATTRIBUTION=remote` or `options.attribution: "remote"`), which + sends the configured provider key to the remote magpie and nowhere else. +- The hosted page uses `window.magpie.service` when present, so a remote `magpie web` + deployment keeps the frame under magpie's own origin and key. +- The lead page has no inline scripts (its only sources are magpie's `_magpie/bridge.js` + and the plugin's `boot.js`) and fetches nothing; the board itself only calls its own + service on `127.0.0.1`. Its Content-Security-Policy allows no third-party host, and brand + logos come from magpie's `plugin-providers.json` as data URIs — the page never contacts a + third-party CDN. +- `magpie.permissions` is `[]`: the page reads nothing through the bridge. \ No newline at end of file diff --git a/packages/page-usage-board/docs/data-semantics.md b/packages/page-usage-board/docs/data-semantics.md new file mode 100644 index 0000000..480d88a --- /dev/null +++ b/packages/page-usage-board/docs/data-semantics.md @@ -0,0 +1,66 @@ +# Data semantics + +Read this before changing the page or the aggregations. Two different totals are shown on +purpose; they answer different questions and must not be silently reconciled. + +## The four exit aliases are two routes + +magpie renamed its outbound providers over time: + +| Route | Names in `usage.jsonl` | Remote `caller` | +|---|---|---| +| direct | `magpie-direct`, `remote-magpie` | `cloud` | +| Cloudflare | `magpie-cf`, `magpie-2` | `Magpie` | + +The page keeps all four in one `REMOTE_ENTRY` set. Never hand-write a single name. + +## Charts use real providers + +- Local, non-exit providers are taken from the detail log as-is. +- Remote attribution adds per-provider totals under the same provider names. +- When attribution is available, the exit aliases do **not** enter the charts; their traffic + is already attributed. +- When attribution is unavailable, the four exit aliases collapse into one series labelled + "remote (unattributed)", so nothing disappears silently. +- The daily chart stacks providers; the provider pie merges aliases. + +## Where the remote side comes from + +The local service reads the remote magpie's own `/v1/magpie/usage/requests` (provider key +already in `providers.json`) and keeps rows whose `callerKeyName` is in `REMOTE_CALLERS` +(default `cloud`, `Magpie`). The caller breakdown still lists every caller on that instance +(e.g. `hermes`), but provider/account/day/hourly numbers are this machine's only. The 24-hour +remote curve is caller-filtered too; older builds that read the remote log without that filter +over-counted other callers. + +The standalone `/usage2` service is retired: it was only a way to run that filter on the +remote log when the magpie API could not give per-caller rows. + +## KPI cards use the local gateway ledger + +Cost on the KPI cards is magpie's own pricing (subscription quota converted to money), not +money actually spent. It is intentionally different from the chart totals, which follow real +providers. Label both clearly; do not "fix" one to match the other. + +## Quota cards deduplicate by subscription + +The same subscription can be read through two routes (direct / proxy) and two instances +(local / remote). The quota wall groups by (normalized subscription + account) and shows one +card per group; the `· Magpie direct/proxy` suffix is stripped from the name. Different +accounts (different phone numbers or keys) are different quotas and stay as separate cards. + +## Remote cards have three states + +- No remote data source (remote attribution is opt-in and defaults to local): hide the TTFT and account cards. +- Source configured but the fetch fails (45 s client timeout, 10 s per remote page server-side): show a red error card explaining it. +- Success: show the data. + +A dead source must never make the card vanish without a trace — silence looks like "zero +usage" and is the one failure mode that misleads. + +## What is read + +`usage.jsonl` lines are aggregated into daily × provider totals, a 7×24 heatmap, 24-hour +token/cache curves, recent requests and per-account attribution. Probe lines +(`kind: "model_list"`, `source: "probe"`) are filtered out. Prompts, messages and tool output +are never read or displayed. \ No newline at end of file diff --git a/packages/page-usage-board/index.mjs b/packages/page-usage-board/index.mjs new file mode 100644 index 0000000..6b2c813 --- /dev/null +++ b/packages/page-usage-board/index.mjs @@ -0,0 +1,57 @@ +// magpie 窗口里的「用量看板」页面。 +// +// 两层结构(同 Magiczerowxy/magpie-chat、magpie-community/page-usage-tree 的做法): +// 1. 本文件作为 OpenCode v1 插件被 magpie 的 Bun 宿主加载。模块导入必须零副作用 +// (社区 scripts_check.mjs 会直接 import 做静态检查,导入即监听会占端口、写配置); +// 服务只在 magpie 调用 server(input, options) 时启动,且 await 到真正监听后才返回。 +// 2. page/index.html + page/boot.js 是 magpie 托管的「带路页」:优先跳 +// window.magpie.service(magpie web 在自己域名下的转发路径,页面留在 magpie +// origin、由 magpie 自己的 key 保护),桌面回退 http://127.0.0.1:3455/。 +// 服务端把口令注入返回的看板(window.__KEY__),只有 API 路由校验它。 +// +// 服务已在本机跑着(另一个插件实例 / 手动 node)时端口占用,server.mjs 会静默复用。 +import { fileURLToPath, pathToFileURL } from "node:url"; +import path from "node:path"; + +const here = path.dirname(fileURLToPath(import.meta.url)); +let starting = null; + +const plugin = { + id: "magpie-usage-board", + server: async (_input, options) => { + if (!starting) { + // manifest options(page.service.option = "port" 时 options.port 由 magpie 注入) + // → startServer() 内部再回退到环境变量/默认值。port 的 0/非法值归成 undefined: + // 服务回落到默认口,页面从同一 options 读到的也走同一回落,两边永远一致。 + const n = Number(options?.port); + const port = Number.isInteger(n) && n > 0 && n < 65536 ? n : undefined; + starting = import(pathToFileURL(path.join(here, "server.mjs")).href) + .then((m) => m.startServer({ + port, + attribution: options?.attribution, + remoteCallers: options?.remoteCallers, + remoteProviders: options?.remoteProviders, + gateway: options?.gateway, + })) + .then((port) => ({ ok: true, port })) + .catch((err) => { + starting = null; // 允许 magpie 下次调用重试 + console.error("[magpie-usage-board] server not started:", err?.message || err); + throw err; + }); + } + await starting; + // 返回 { ok, port }:magpie 只要 await 成功即可,多出的字段便于测试与排障 + return await starting; + }, +}; + +export default plugin; + +// 手动启动入口:node index.mjs(与 server.mjs 直跑等价,走同一生命周期契约) +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + plugin.server().catch((e) => { + console.error(`[magpie-usage-board] not started: ${e?.message || e}`); + process.exit(1); + }); +} diff --git a/packages/page-usage-board/package-lock.json b/packages/page-usage-board/package-lock.json new file mode 100644 index 0000000..0ab57e4 --- /dev/null +++ b/packages/page-usage-board/package-lock.json @@ -0,0 +1,533 @@ +{ + "name": "@magpie-community/page-usage-board", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@magpie-community/page-usage-board", + "version": "0.1.0", + "license": "MIT", + "devDependencies": { + "echarts": "5.5.1", + "esbuild": "0.28.2" + }, + "engines": { + "magpie": ">=0.1.1340", + "node": ">=22" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/echarts": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.5.1.tgz", + "integrity": "sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "2.3.0", + "zrender": "5.6.0" + } + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", + "dev": true, + "license": "0BSD" + }, + "node_modules/zrender": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.0.tgz", + "integrity": "sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tslib": "2.3.0" + } + } + } +} diff --git a/packages/page-usage-board/package.json b/packages/page-usage-board/package.json new file mode 100644 index 0000000..2ad8c28 --- /dev/null +++ b/packages/page-usage-board/package.json @@ -0,0 +1,82 @@ +{ + "name": "@magpie-community/page-usage-board", + "version": "0.1.0", + "description": "在 magpie 窗口里查看用量:额度到期卡片墙 + 每日/模型/provider 用量图表 + 可选远端归因,由插件自带的本机服务供数。A usage dashboard page in magpie's window: quota cards with expiry tiers, daily and per-provider charts, optional remote attribution, served by the plugin's own local service.", + "type": "module", + "main": "./index.mjs", + "files": [ + "index.mjs", + "server.mjs", + "page", + "static", + "build", + "LICENSE", + "README.md", + "scripts", + "NOTICE", + "docs", + "LICENSES" + ], + "scripts": { + "start": "node server.mjs", + "test": "node --test", + "build:echarts": "node scripts/build-echarts.mjs", + "prepack": "node scripts/prepack.mjs" + }, + "engines": { + "node": ">=22", + "magpie": ">=0.1.1340" + }, + "keywords": [ + "magpie", + "magpie-page", + "magpie-plugin", + "usage", + "dashboard", + "quota", + "charts", + "token" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/magpie-community/plugins.git", + "directory": "packages/page-usage-board" + }, + "homepage": "https://github.com/magpie-community/plugins/tree/main/packages/page-usage-board", + "bugs": { + "url": "https://github.com/magpie-community/plugins/issues" + }, + "magpie": { + "name": "Usage Board", + "summary": { + "en": "A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.", + "zh": "额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。" + }, + "page": { + "title": "Usage Board", + "titles": { + "en": "Usage Board", + "zh": "用量看板" + }, + "file": "page/index.html", + "icon": "page/icon.svg", + "service": { + "port": 3455, + "option": "port" + } + }, + "permissions": [], + "options": { + "port": 3455, + "attribution": "local", + "remoteCallers": "", + "remoteProviders": "magpie-direct,magpie-cf,remote-magpie" + }, + "icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8IS0tIFVzYWdlIGJvYXJkOiBkYXJrIHJvdW5kZWQgcGxhdGUsIGJsdWUgdXNhZ2UgbGluZSwgb25lIGFtYmVyIGJhciAtLT4KICA8cmVjdCB4PSI0IiB5PSI0IiB3aWR0aD0iOTIiIGhlaWdodD0iOTIiIHJ4PSIyMCIgZmlsbD0iIzFlMjQzMCIvPgogIDwhLS0gYW1iZXIgYmFyIChxdW90YSB0b2RheSkgLS0+CiAgPHJlY3QgeD0iMjQiIHk9IjU2IiB3aWR0aD0iMTAiIGhlaWdodD0iMjQiIHJ4PSIzIiBmaWxsPSIjZjVhNjIzIi8+CiAgPCEtLSBibHVlIHVzYWdlIGxpbmUgb3ZlciB0aGUgbGFzdCBob3VycyAtLT4KICA8cG9seWxpbmUgcG9pbnRzPSIyMiw2NiAzNiw1MiA1MCw1OCA2NCwzOCA3OCwzMCIKICAgIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzRjOWZmZSIgc3Ryb2tlLXdpZHRoPSI3IgogICAgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CiAgPCEtLSBlbmRwb2ludCBkb3QgLS0+CiAgPGNpcmNsZSBjeD0iNzgiIGN5PSIzMCIgcj0iNS41IiBmaWxsPSIjNGM5ZmZlIi8+Cjwvc3ZnPgo=" + }, + "devDependencies": { + "echarts": "5.5.1", + "esbuild": "0.28.2" + } +} diff --git a/packages/page-usage-board/page/boot.js b/packages/page-usage-board/page/boot.js new file mode 100644 index 0000000..0fcaa46 --- /dev/null +++ b/packages/page-usage-board/page/boot.js @@ -0,0 +1,114 @@ +// Navigate magpie's frame to the board service. +// +// Prefer window.magpie.service: magpie web proxies the service on its own address, so the +// page stays under magpie's origin and magpie's own key/auth is the gate. A desktop window +// has no service; fall back to loopback on the port from the manifest options — the same +// value the service itself was started with, so they can never disagree. +// +// Do not probe the service: the page's CSP is connect-src 'none', so fetch/XHR is refused. +// The progress bar here is therefore driven by two real signals only — the bridge handshake +// (window.magpie.ready) and elapsed time. The meta refresh in index.html (8 s) is the last +// fallback if this script never runs. +(async () => { + const DEFAULT_PORT = 3455; + const words = { + en: { + title: "Usage Board", + bridging: "Connecting to the host bridge…", + slow: "Bridge is slow — opening the local board…", + err: (m) => `Bridge did not respond: ${m} — opening the local board…`, + nobridge: "No host bridge detected — opening the local board…", + ready: "Board located, navigating…", + readyLocal: "Ready — opening the local board…", + }, + zh: { + title: "用量看板", + bridging: "正在连接宿主桥接…", + slow: "桥接响应慢,即将直接打开本机看板…", + err: (m) => `桥接未响应:${m} —— 将直接打开本机看板…`, + nobridge: "未检测到宿主桥接,直接打开本机看板…", + ready: "已定位看板服务,正在跳转…", + readyLocal: "已就绪,正在打开本机看板…", + }, + }; + let lang = String(navigator.language || "en").toLowerCase().startsWith("zh") ? "zh" : "en"; + let port = DEFAULT_PORT; + let theme = ""; // magpie 自己的深浅色;空 = 看板回落 prefers-color-scheme + const bar = document.getElementById("bar"); + const msg = document.getElementById("msg"); + const say = (t, bad) => { + if (!msg) return; + msg.textContent = t; + msg.classList.toggle("bad", !!bad); + }; + const setBar = (pct, bad) => { + if (!bar) return; + bar.style.width = pct + "%"; + if (bar.parentElement) bar.parentElement.classList.toggle("bad", !!bad); + }; + setBar(18); + // 桥接慢时进度条缓慢爬行,6 秒后预告回退(meta refresh 8 秒兜底) + const creep = setInterval(() => setBar(Math.min(38, (parseFloat(bar?.style.width) || 18) + 2.5)), 350); + let service = ""; + let bridgeErr = ""; + const hasBridge = !!window.magpie; + try { + const current = await window.magpie?.ready; + if (current) { + if (typeof current.lang === "string" && current.lang) { + lang = current.lang.toLowerCase().startsWith("zh") ? "zh" : "en"; + } + if (typeof current.dark === "boolean") theme = current.dark ? "dark" : "light"; + } + } catch (e) { + bridgeErr = (e && e.message) || "bridge handshake failed"; + } + try { + const options = await window.magpie?.options?.get?.(); + const n = Number(options?.port); + if (Number.isInteger(n) && n > 0 && n < 65536) port = n; + } catch { + // Use the declared default. + } + try { + const s = window.magpie?.service; + if (typeof s === "string" && /^https?:\/\//.test(s)) service = s; + } catch { + // Desktop windows navigate directly to loopback. + } + clearInterval(creep); + const w = words[lang]; + document.title = w.title; + const head = document.querySelector(".box b"); + if (head) head.textContent = w.title; + if (bridgeErr) { + // 桥接报错:如实展示原因,仍回退打开本机看板 + setBar(30, true); + say(w.err(bridgeErr), true); + } else if (!hasBridge) { + setBar(72); + say(w.nobridge); + } else { + setBar(72); + say(service ? w.ready : w.readyLocal); + } + let target = service || `http://127.0.0.1:${port}/`; + // lang/theme 都通过 URL 带给看板(走 service 代理路径时同样要带——用 URL 拼接避免丢已有参数) + try { + const u = new URL(target, location.href); + u.searchParams.set("lang", lang); + if (theme) u.searchParams.set("theme", theme); + target = u.href; + } catch { + target += (target.includes("?") ? "&" : "?") + "lang=" + lang + (theme ? "&theme=" + theme : ""); + } + const go = document.getElementById("go"); + if (go) go.setAttribute("content", "0;url=" + target); + setTimeout(() => { + try { + location.replace(target); + } catch { + // The meta refresh above still navigates. + } + }, 350); // 让用户看清最终状态再跳 +})(); diff --git a/packages/page-usage-board/page/icon.svg b/packages/page-usage-board/page/icon.svg new file mode 100644 index 0000000..b7e2f0d --- /dev/null +++ b/packages/page-usage-board/page/icon.svg @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/packages/page-usage-board/page/index.html b/packages/page-usage-board/page/index.html new file mode 100644 index 0000000..d700d55 --- /dev/null +++ b/packages/page-usage-board/page/index.html @@ -0,0 +1,48 @@ + + + + + +用量看板 + + + + + +
+ 用量看板 +
+ 正在打开看板… +
+ + + + \ No newline at end of file diff --git a/packages/page-usage-board/scripts/build-echarts.mjs b/packages/page-usage-board/scripts/build-echarts.mjs new file mode 100644 index 0000000..ec8f6bb --- /dev/null +++ b/packages/page-usage-board/scripts/build-echarts.mjs @@ -0,0 +1,40 @@ +// Reproducible build of the vendored ECharts bundle (custom build: bar/line/pie/heatmap only). +// +// npm run build:echarts # rebuild static/echarts.min.js from build/echarts-entry.mjs +// +// The output must stay byte-identical, so this script IS the build definition. +// Verify locally after any change: +// node scripts/build-echarts.mjs && git diff --exit-code static/echarts.min.js +// Pins: echarts@5.5.1, esbuild per devDependencies (exact) and package-lock.json. +// +// - no --global-name: the entry assigns window.echarts directly (with --global-name the +// iife gets wrapped in "var echarts=…" and the default export nests under .default); +// - the provenance banner below is prepended, so it is part of the reproducible output. +import { createHash } from 'node:crypto'; +import { readFileSync, statSync, writeFileSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { build } from 'esbuild'; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const outfile = path.join(root, 'static', 'echarts.min.js'); + +const BANNER = + '/* Apache ECharts v5.5.1 custom build (bar/line/pie/heatmap + tooltip/legend/grid/dataZoom/visualMap/axisPointer). ' + + 'Copyright 2018-2026 Apache Software Foundation, Apache-2.0. See NOTICE. */\n'; + +const result = await build({ + entryPoints: [path.join(root, 'build', 'echarts-entry.mjs')], + bundle: true, + minify: true, + outfile, + write: false, + logLevel: 'warning', +}); + +const js = result.outputFiles[0].text; +writeFileSync(outfile, BANNER + js); + +const sha = createHash('sha256').update(readFileSync(outfile)).digest('hex'); +const kb = Math.round(statSync(outfile).size / 1024); +console.log(`static/echarts.min.js rebuilt: ${kb} KiB sha256=${sha.slice(0, 16)}…`); diff --git a/packages/page-usage-board/scripts/prepack.mjs b/packages/page-usage-board/scripts/prepack.mjs new file mode 100644 index 0000000..8fe70f4 --- /dev/null +++ b/packages/page-usage-board/scripts/prepack.mjs @@ -0,0 +1,104 @@ +// npm pack / publish 前的守卫:公开包里不能出现口令或本机部署物料。 +// 这些文件不进 git(见 .gitignore);在错误的目录(如运行时副本)里执行 npm pack +// 就会把 key 带上船。同时做布局守卫(community-submission.md 的 layout trap): +// README/docs 承诺的文件(docs/、vendored echarts 构建产物)必须真实存在, +// 文档相对链接必须可达——否则合并后全 404。 +import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const problems = []; + +const forbidden = [ + 'static/remote.js', + 'server.log', + 'usage-page-key', +]; +for (const f of forbidden) { + if (existsSync(path.join(root, f))) problems.push(`${f} must not be in the package`); +} + +// 口令可能是任意随机串(含 base64url),不限 32-hex:字符集放宽到 base64url 字母表 +const secret = /[?&]key=[A-Za-z0-9_-]{16,}|"key"\s*:\s*"[A-Za-z0-9_-]{16,}"|PAGE_KEY\s*[:=]\s*['"]?[A-Za-z0-9_-]{16,}/i; +for (const f of ['page/index.html', 'static/index.html', 'server.mjs', 'index.mjs']) { + const full = path.join(root, f); + if (!existsSync(full)) continue; + const text = readFileSync(full, 'utf8'); + if (secret.test(text)) problems.push(`${f} contains what looks like a page key`); +} + +const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')); +for (const f of pkg.files) { + if (!existsSync(path.join(root, f))) problems.push(`files entry is missing: ${f}`); +} +if (!pkg.files.includes('LICENSE')) problems.push('files must include LICENSE'); +for (const f of ['build/echarts-entry.mjs', 'scripts/build-echarts.mjs']) { + if (!existsSync(path.join(root, f))) problems.push(`${f} must exist (vendored echarts build must be reproducible)`); + const dir = f.split('/')[0]; + if (!pkg.files.includes(dir)) problems.push(`files must include ${dir} (${f} must ship)`); +} + +// 布局守卫:README 与 docs 承诺的文件必须随仓库走。 +// 仅在 git checkout 里强制(tarball 解包环境没有这些开发文件,属正常) +const inCheckout = existsSync(path.join(root, '.git')); +if (inCheckout) { + for (const f of ['docs', '.env.example', 'README.md', 'LICENSE', 'NOTICE', 'LICENSES']) { + if (!existsSync(path.join(root, f))) problems.push(`repo tree must contain ${f} (docs/README references 404 otherwise)`); + } + for (const f of ['docs', 'scripts', 'build', 'NOTICE', 'LICENSES']) { + if (!pkg.files.includes(f)) problems.push(`files must include ${f} (docs/NOTICE references 404 on npm otherwise)`); + } +} +// README 与 docs 里的 .md 相对链接必须指向存在的文件 +function walk(dir) { + let out = []; + let entries; + try { entries = readdirSync(dir, { withFileTypes: true }); } catch { return out; } + for (const e of entries) { + if (e.name.startsWith('.') || e.name === 'node_modules') continue; + const full = path.join(dir, e.name); + if (statSync(full).isDirectory()) out = out.concat(walk(full)); + else out.push(full); + } + return out; +} +for (const doc of ['README.md', ...walk('docs').filter((f) => f.endsWith('.md'))]) { + const text = readFileSync(path.join(root, doc), 'utf8'); + for (const m of text.matchAll(/\]\(([^)#]+?\.md)\)/g)) { + const target = path.resolve(path.dirname(path.join(root, doc)), m[1]); + if (!existsSync(target)) problems.push(`${doc} links to missing file: ${m[1]}`); + } +} +// 全量扫描 files 条目覆盖到的文本文件:口令模式不允许出现在任何被打包的位置 +const pkgFiles = []; +for (const entry of pkg.files) { + const full = path.join(root, entry); + if (!existsSync(full)) continue; + if (statSync(full).isFile()) pkgFiles.push(full); + else pkgFiles.push(...walk(full)); +} +for (const full of pkgFiles) { + let text; + try { text = readFileSync(full, 'utf8'); } catch { continue; } + const rel = path.relative(root, full); + if (secret.test(text)) problems.push(`${rel} contains what looks like a page key`); + // remote.js 任何形态都不允许(打包产物里按任意路径出现也算) + if (path.basename(full).toLowerCase() === 'remote.js') problems.push(`${rel} must not be in the package`); +} +// 非十六进制的长随机口令(允许 base64url 形式):PAGE_KEY=xxx 16 位以上非空白也要拦 +const passphr = /PAGE_KEY\s*[:=]\s*['"]?[A-Za-z0-9_/+-]{16,}/; +for (const f of ['.env.example']) { + const full = path.join(root, f); + if (!existsSync(full)) continue; + const text = readFileSync(full, 'utf8'); + const hit = [...text.matchAll(/PAGE_KEY\s*[:=]\s*['"]?([^\s'"]{16,})/g)].filter((m) => !/^\$\{/.test(m[1]) && m[1] !== 'must-be-set'); + if (hit.length) problems.push(`${f} contains a literal PAGE_KEY value (${hit.length} occurrence(s))`); + if (passphr.test(text)) problems.push(`${f} contains what looks like a page passphrase`); +} + +if (problems.length) { + console.error('✗ cannot pack:\n ' + problems.join('\n ')); + process.exit(1); +} +console.log('✓ package is publishable'); diff --git a/packages/page-usage-board/server.mjs b/packages/page-usage-board/server.mjs new file mode 100644 index 0000000..7aa2975 --- /dev/null +++ b/packages/page-usage-board/server.mjs @@ -0,0 +1,899 @@ +#!/usr/bin/env node +// magpie 用量看板 — 零依赖,Node 22+/Bun 均可运行 +// 环境变量:HOST(默认回环)、PORT(默认 3455,0=系统挑;被同构建占用则复用,异种占用则报错)、 +// GATEWAY(上游网关)、MAGPIE_KEY(网关 key,本地不需要)、USAGE_JSONL、 +// PAGE_KEY(脚本调 API 用的口令,不设则每次启动生成随机 token;页面 HTML 由服务端注入, +// 浏览器里永远不需要手输)、ALLOWED_HOSTS(反代域名白名单,逗号分隔)、 +// ATTRIBUTION(local|remote,默认 local:远端归因会把 provider key 发给远端 magpie,必须显式开启)、 +// REMOTE_CALLERS/REMOTE_PROVIDERS/MAGPIE_PROVIDERS/MAGPIE_PROVIDERS_FILE +import { createServer } from 'node:http'; +import { createHash, randomBytes, timingSafeEqual } from 'node:crypto'; +import { readFile } from 'node:fs/promises'; +import { createReadStream, existsSync, readFileSync, statSync } from 'node:fs'; +import { brotliCompressSync, gzipSync } from 'node:zlib'; +import path from 'node:path'; +import os from 'node:os'; +import { fileURLToPath } from 'node:url'; + +const ROOT = path.dirname(fileURLToPath(import.meta.url)); +const HOST = process.env.HOST || '127.0.0.1'; +// 日志里对外展示的 host:监听 0.0.0.0/:: 这类地址时展示成 127.0.0.1,IPv6 补方括号 +const URL_HOST = HOST === '0.0.0.0' || HOST === '::' ? '127.0.0.1' : (HOST.includes(':') ? `[${HOST}]` : HOST); +// 回环绑定:看板页面只对回环开放(口令注入返回的 HTML,本机用户即所有者——与社区 +// page-usage-tree 同一模型)。注意:'::' 与 0.0.0.0 同为通配监听(dual-stack),绝不能算回环。 +const LOOPBACK_BIND = HOST === '127.0.0.1' || HOST === 'localhost' || HOST === '::1'; +// magpie 的配置目录:与 usage.jsonl、plugin-providers.json、providers.json 的所在。 +// 顺序照 magpie 自己的 appdir.Config():宿主数据目录(便携安装)→ XDG → ~/.config/magpie。 +// 便携/宿主场景靠 cwd 探测:magpie 的插件宿主以 settings.Dir() 为 cwd 启动服务 +// (internal/plugin/host.go 的 bunCommand),desktop 用户无法为宿主设环境变量, +// 所以任何 MAGPIE_CONFIG_DIR 之类的 env 都救不了便携安装——cwd 是唯一可靠信号。 +// MAGPIE_CONFIG_DIR 仍保留为显式覆盖(测试/特殊布局用;magpie 本身没有这个变量)。 +function magpieConfigDir() { + if (process.env.MAGPIE_CONFIG_DIR) return process.env.MAGPIE_CONFIG_DIR; + try { + const cwd = process.cwd(); + if (cwd !== ROOT && (existsSync(path.join(cwd, 'usage.jsonl')) || existsSync(path.join(cwd, 'plugins.json')) || existsSync(path.join(cwd, 'providers.json')))) return cwd; + } catch {} + const xdg = process.env.XDG_CONFIG_HOME; + if (xdg && path.isAbsolute(xdg)) return path.join(xdg, 'magpie'); + return path.join(os.homedir(), '.config', 'magpie'); +} +const CONFIG_DIR = magpieConfigDir(); +// 网关解析链(与 page-usage-tree 一致):manifest options.gateway → GATEWAY → +// MAGPIE_GATEWAY → MAGPIE_ADDR(magpie 宿主总会设置,端口可被用户改过,不能写死)→ 3425。 +// MAGPIE_ADDR 是 host:port。只有**未指定地址**(0.0.0.0 / [::])才换成回环——那是 +// 「绑所有网卡」的意思,等价于本机;而 [::1] 是明确的 IPv6 回环,监听在 [::1] 的网关 +// 通常**没有**在 127.0.0.1 上监听,改写会把请求打到空处(与 magpie 自己的 hostAddr +// 语义一致:它也只处理 unspecified 地址)。 +function gatewayCandidates(optionsGateway) { + const out = []; + const push = (v) => { + const text = String(v || '').trim().replace(/\/+$/, ''); + if (text && /^https?:\/\//i.test(text) && !out.includes(text)) out.push(text); + }; + push(optionsGateway); + push(process.env.GATEWAY); + push(process.env.MAGPIE_GATEWAY); + const addr = process.env.MAGPIE_ADDR; + if (addr) { + // $1=地址 $2=冒号:换掉地址、保住端口分隔 + const text = String(addr).trim().replace(/^(0\.0\.0\.0|\[::\])(:|$)/, '127.0.0.1$2'); + // host:port 或 [v6]:port;URL 里的 IPv6 字面量必须带方括号 + if (/^(\[[0-9a-f:.]+\]|[\w.-]+):\d+$/.test(text)) push('http://' + text); + } + push('http://127.0.0.1:3425'); + return out; +} +// 实际生效的网关在 main() 里定稿(listen 前);upstream() 按请求时值取用 +let GATEWAY = 'http://127.0.0.1:3425'; +const KEY = process.env.MAGPIE_KEY || ''; +const USAGE_JSONL = process.env.USAGE_JSONL || path.join(CONFIG_DIR, 'usage.jsonl'); +// 页面访问口令:未设 PAGE_KEY → 每次启动生成随机 token(页面 HTML 服务端注入,URL/日志/磁盘 +// 都不落);显式设置 → 脚本调 API 用(x-dash-key 头;?key= 已废除,key 不进 URL)。 +let PAGE_KEY = ''; +const PORT_BASE = 3455; +// manifest options(index.mjs 传入)→ 环境变量 → 内置默认,三级回退;startServer() 时定稿 +const CFG = { port: null, attribution: null, remoteCallers: null, remoteProviders: null, gateway: null }; +// 远端归因(opt-in):开启后会把本机 magpie 配好的 remote provider key 发给远端 magpie +// 换逐条请求记录——必须用户显式选择,绝不默认。 +let ATTRIBUTION_MODE = 'local'; +// 本机直连/远端的口径:usage.jsonl 里这些 provider 线路前缀的流量记为「走远端」(其余为直连)。 +// 默认只含 magpie 自己的线路名(非个人配置);个人化口径用 REMOTE_PROVIDERS 覆盖。 +let REMOTE_PROVIDERS = ['magpie-direct', 'magpie-cf', 'remote-magpie']; +let REMOTE_CALLERS = []; +// Host 校验:默认只认识回环名。反代或非回环部署时用 ALLOWED_HOSTS=域名1,域名2 显式放行。 +const ALLOWED_HOSTS = (process.env.ALLOWED_HOSTS || '').split(',').map((x) => x.trim().toLowerCase()).filter(Boolean); +const STATIC_DIR = path.join(ROOT, 'static'); +// 品牌 logo:读 magpie 自己维护的 plugin-providers.json(插件注册 provider 时上报的 id→icon, +// data URI 为主)。零扫描、零下载、零落盘——https 图标不抓取(避免启动时向第三方 CDN 发请求), +// 页面对没有图标的品牌用首字色块兜底。 +const PROVIDERS_FILE = process.env.MAGPIE_PROVIDERS_FILE || ''; +const MAGPIE_PROVIDERS = process.env.MAGPIE_PROVIDERS || path.join(CONFIG_DIR, 'providers.json'); + +const MIME = { + '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', + '.css': 'text/css; charset=utf-8', '.svg': 'image/svg+xml', '.png': 'image/png', + '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.ico': 'image/x-icon', + '.txt': 'text/plain; charset=utf-8', +}; + +const json = (res, code, obj) => { + res.writeHead(code, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store' }); + res.end(JSON.stringify(obj)); +}; + +async function upstream(p) { + // 瞬时网关挂起重试一次(上限 12s×2):失败已可见化(note/红条),这里只为削掉偶发抖动 + let last; + for (let i = 0; i < 2; i++) { + try { + const r = await fetch(GATEWAY + p, { + headers: KEY ? { Authorization: `Bearer ${KEY}` } : {}, + signal: AbortSignal.timeout(12000), + }); + const body = await r.text(); + try { return { code: r.status, json: JSON.parse(body) }; } + catch { return { code: r.status, json: { error: body.slice(0, 200) } }; } + } catch (e) { last = e; } + await new Promise((r2) => setTimeout(r2, 500 * (i + 1))); + } + return { code: 0, json: { error: String(last && last.message || last).slice(0, 200) } }; +} + +// usage.jsonl 聚合:按天×provider、7×24 热力、最近请求(60s 缓存)。 +// 流式逐行读取:日志曾到 23MB,整读+全量解析把 RSS 放大 ~9 倍——现在峰值只保留聚合结果 +async function* linesOf(path) { + const stream = createReadStream(path, { encoding: 'utf8' }); + let buf = ''; + for await (const chunk of stream) { + buf += chunk; + let i; + while ((i = buf.indexOf('\n')) >= 0) { + const line = buf.slice(0, i); + buf = buf.slice(i + 1); + if (line) yield line; + } + } + if (buf) yield buf; +} +// echarts.min.js 的预压缩缓存(按 mtime 失效):br ~172KB / gzip ~190KB,避免每次导航白拉 612KB +let echartsEnc = null; +function echartsEncoded(full) { + const mtime = statSync(full).mtimeMs; + if (!echartsEnc || echartsEnc.mtime !== mtime) { + const raw = readFileSync(full); + echartsEnc = { mtime, br: brotliCompressSync(raw), gz: gzipSync(raw, { level: 8 }) }; + } + return echartsEnc; +} +let detailCache = null; +async function readDetail(days) { + const cacheKey = days + ':' + Math.floor(Date.now() / 60000); + if (detailCache && detailCache.key === cacheKey) return detailCache.data; + const since = days > 0 ? Date.now() - days * 86400e3 : 0; + const daily = new Map(); + const heat = new Array(7 * 24).fill(0); + let recent = []; + try { + for await (const line of linesOf(USAGE_JSONL)) { + if (!line) continue; + let r; try { r = JSON.parse(line); } catch { continue; } + // magpie 自家探活行(kind:"model_list", source:"probe")不是真实调用,过滤(2026-11-04,实测占 9.5%) + if (r.kind === 'model_list' || r.source === 'probe') continue; + const ts = r.t ? Date.parse(r.t) : NaN; + if (!Number.isFinite(ts) || ts < since) continue; + const day = typeof r.t === 'string' ? r.t.slice(0, 10) : ''; + if (!day) continue; // 脏行(t 非字符串)跳过本行,绝不静默清空整张图 + const prov = r.provider || 'unknown'; + let dp = daily.get(day); if (!dp) { dp = new Map(); daily.set(day, dp); } + let a = dp.get(prov); + if (!a) { a = { calls: 0, errors: 0, inp: 0, out: 0, cache: 0, reasoning: 0, ttft: 0, timed: 0 }; dp.set(prov, a); } + a.calls++; if (r.status !== 200) a.errors++; + a.inp += r.in || 0; a.out += r.out || 0; a.cache += r.cache_read || 0; a.reasoning += r.reasoning || 0; + if (r.ttft_ms > 0) { a.ttft += r.ttft_ms; a.timed++; } + if (ts >= Date.now() - 7 * 86400e3) heat[new Date(ts).getDay() * 24 + new Date(ts).getHours()]++; + if (r.status != null) { + recent.push({ + t: r.t, agent: r.agent, provider: prov, model: r.served || r.model, + in: r.in || 0, out: r.out || 0, ttft: r.ttft_ms || null, ms: r.ms || null, + status: r.status, tries: r.tries || 1, + }); + // recent 有界:日志按时间追加,最后 40 条即最新;超限排序截断防止长日志撑爆 + if (recent.length > 80) { recent.sort((x, y) => (x.t < y.t ? 1 : -1)); recent.length = 40; } + } + } + } catch (e) { + // 读不到(ENOENT)= 全新安装的空态;其他读失败(权限/损坏)必须可见,不能伪装成零用量 + if (e && e.code === 'ENOENT') return { daily: [], heat, recent: [] }; + console.error('[magpie-usage] usage.jsonl read failed:', (e && e.message) || e); + return { daily: [], heat, recent: [], error: 'usage log read failed (' + ((e && e.code) || (e && e.message) || '?') + ')' }; + } + recent.sort((x, y) => (x.t < y.t ? 1 : -1)); + recent = recent.slice(0, 40); + const data = { + daily: [...daily.entries()].sort().map(([day, ps]) => ({ + day, providers: [...ps.entries()].map(([provider, a]) => ({ provider, ...a })), + })), + heat, recent, + }; + detailCache = { key: cacheKey, data }; + return data; +} + +// 远端归因:只有远端网关的 usage.jsonl 记着 providerAccount / callerKeyName, +// 本地那一侧一条 magpie-direct 看不出真实花在谁身上。这里按调用方把账算出来。 +let attrCache = { key: '', data: null }; +const pct = (arr, p) => { + if (!arr.length) return null; + const s = [...arr].sort((a, b) => a - b); + const i = Math.min(s.length - 1, Math.max(0, Math.round((p / 100) * (s.length - 1)))); + return s[i]; +}; +// 近 24h 按小时聚合;d=直连(本机自己的 provider),r=走远端(REMOTE_PROVIDERS) +let h24Cache = { key: '', data: null }; +async function readHourly24() { + const key = 'h24:' + Math.floor(Date.now() / 300000); + if (h24Cache.data && h24Cache.key === key) return h24Cache.data; + const since = Date.now() - 24 * 3600e3; + const hours = new Map(); + try { + for await (const line of linesOf(USAGE_JSONL)) { + if (!line) continue; + let r; try { r = JSON.parse(line); } catch { continue; } + // magpie 自家探活行(kind:"model_list", source:"probe")不是真实调用,过滤(2026-11-04,实测占 9.5%) + if (r.kind === 'model_list' || r.source === 'probe') continue; + const ts = r.t ? Date.parse(r.t) : NaN; + if (!Number.isFinite(ts) || ts < since) continue; + const t = new Date(ts); + const hk = String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0') + + ' ' + String(t.getHours()).padStart(2, '0') + ':00'; + let h = hours.get(hk); + if (!h) { h = { d: { calls: 0, input: 0, output: 0, cache_read: 0 }, r: { calls: 0, input: 0, output: 0, cache_read: 0 } }; hours.set(hk, h); } + const side = REMOTE_PROVIDERS.includes(r.provider || '') ? 'r' : 'd'; + const b = h[side]; + b.calls++; b.input += r.in || 0; b.output += r.out || 0; b.cache_read += r.cache_read || 0; + } + } catch (e) { + if (e && e.code === 'ENOENT') return { hours: [] }; // 全新安装:空态 + console.error('[magpie-usage] usage.jsonl read failed (hourly):', (e && e.message) || e); + return { hours: [], error: 'usage log read failed (' + ((e && e.code) || (e && e.message) || '?') + ')' }; + } + const data = { hours: [...hours.entries()].sort().map(([hour, v]) => ({ hour, ...v })) }; + h24Cache = { key, data }; + return data; +} + +// 百分位采样:每 provider 最多 512 个样本(确定性跨步替换),长日志不会把样本数组撑爆 +async function aggregateAttribution(rows, { period, days, callers, source }) { + const sampN = new Map(); + const pushSample = (map, key, v, cap = 512) => { + let s = map.get(key); if (!s) { s = []; map.set(key, s); } + if (s.length < cap) { s.push(v); return; } + const c = (sampN.get(key) || 0) + 1; sampN.set(key, c); + s[c % cap] = v; + }; + const since = days > 0 ? Date.now() - days * 86400e3 : 0; + const prov = new Map(), acct = new Map(), byDay = new Map(), byCaller = new Map(), hourly = new Map(); + const ttftSamples = new Map(), msSamples = new Map(); + const totals = { calls: 0, errors: 0, input: 0, output: 0, cache_read: 0, ttft_ms: 0, timed: 0 }; + for await (const r of rows) { + if (!r) continue; + // magpie 自家探活行(kind:"model_list", source:"probe")不是真实调用,过滤 + if (r.kind === 'model_list' || r.source === 'probe') continue; + // 远端 API 的 t 带 9 位小数秒,Date.parse 只认毫秒,先截断 + const ts = Date.parse(String(r.t || '').replace(/(\.\d{3})\d+/, '$1')); + if (!Number.isFinite(ts) || ts < since) continue; + // 按调用方拆分:这一项不受 caller 过滤影响,前端要拿它画「本机 / remote / hermes」占比 + const cn = r.callerKeyName || '(无)'; + let cb = byCaller.get(cn); + if (!cb) { cb = { name: cn, calls: 0, input: 0, output: 0 }; byCaller.set(cn, cb); } + cb.calls++; cb.input += r.in || 0; cb.output += r.out || 0; + if (callers.length && !callers.includes(r.callerKeyName || '')) continue; + if (ts >= Date.now() - 24 * 3600e3) { + const t = new Date(ts); + const hk = String(t.getMonth() + 1).padStart(2, '0') + '-' + String(t.getDate()).padStart(2, '0') + + ' ' + String(t.getHours()).padStart(2, '0') + ':00'; + let hv = hourly.get(hk); + if (!hv) { hv = { calls: 0, input: 0, output: 0, cache_read: 0 }; hourly.set(hk, hv); } + hv.calls++; hv.input += r.in || 0; hv.output += r.out || 0; hv.cache_read += r.cache_read || 0; + } + const pn = r.provider || 'unknown'; + const inTok = r.in || 0, outTok = r.out || 0, cache = r.cache_read || 0; + const err = r.status !== 200 ? 1 : 0; + totals.calls++; totals.errors += err; + totals.input += inTok; totals.output += outTok; totals.cache_read += cache; + if (r.ttft_ms > 0) { totals.ttft_ms += r.ttft_ms; totals.timed++; } + let a = prov.get(pn); + if (!a) { a = { provider: pn, calls: 0, errors: 0, input: 0, output: 0, cache_read: 0 }; prov.set(pn, a); } + a.calls++; a.errors += err; a.input += inTok; a.output += outTok; a.cache_read += cache; + if (r.ttft_ms > 0) pushSample(ttftSamples, pn, r.ttft_ms); + if (r.ms > 0) pushSample(msSamples, pn, r.ms); + const an = r.providerAccount || ''; + if (an) { + const k = pn + '\u0000' + an; + let b = acct.get(k); + if (!b) { b = { provider: pn, account: an, calls: 0, errors: 0, input: 0, output: 0 }; acct.set(k, b); } + b.calls++; b.errors += err; b.input += inTok; b.output += outTok; + } + const day = String(r.t || '').slice(0, 10); + if (day) { + let d = byDay.get(day); + if (!d) { d = new Map(); byDay.set(day, d); } + let c = d.get(pn); + if (!c) { c = { calls: 0, input: 0, output: 0, cache_read: 0 }; d.set(pn, c); } + c.calls++; c.input += inTok; c.output += outTok; c.cache_read += cache; + } + } + const providers = [...prov.values()].sort((x, y) => y.calls - x.calls).map((p) => { + const ts = ttftSamples.get(p.provider) || []; + const ms = msSamples.get(p.provider) || []; + return { + ...p, + ttft_p50: pct(ts, 50), ttft_p90: pct(ts, 90), + ttft_avg: ts.length ? ts.reduce((s, v) => s + v, 0) / ts.length : null, + ms_p50: pct(ms, 50), ms_p90: pct(ms, 90), timed: ts.length, + }; + }); + return { + source, + callers, + period, + since: since ? new Date(since).toISOString() : null, + totals, + providers, + accounts: [...acct.values()].sort((x, y) => y.calls - x.calls).slice(0, 30), + callerBreakdown: [...byCaller.values()].sort((x, y) => y.calls - x.calls), + days: [...byDay.entries()].sort().map(([day, m]) => ({ day, providers: Object.fromEntries(m) })), + // 远端归因的小时行按 {hour, r:{...}} 输出——页面 drawHourly 按 x.r 读取远端侧 + // (扁平结构会被当成空对象,全远端出口的部署 24h 图会全 0) + hourly: [...hourly.entries()].sort().map(([hour, v]) => ({ hour, r: v })), + }; +} + +async function readAttribution(period, days, callers) { + // 归因数据变化很慢,5 分钟够用(看板自身也是 5 分钟自动刷新) + const bucket = Math.floor(Date.now() / (5 * 60000)); + const cacheKey = 'local:' + period + ':' + callers.join(',') + ':' + bucket; + if (attrCache.data && attrCache.key === cacheKey) return attrCache.data; + async function* localRows() { + for await (const line of linesOf(USAGE_JSONL)) { + let r; try { r = JSON.parse(line); } catch { continue; } + yield r; + } + } + let data; + try { data = await aggregateAttribution(localRows(), { period, days, callers, source: 'local' }); } + catch { return null; } + attrCache = { key: cacheKey, data }; + return data; +} + +// 远端 magpie 的逐条请求记录:/v1/magpie/usage/requests 每行都带 callerKeyId/Name、 +// provider/providerAccount、时间、TTFT。summary 端点不支持按 caller 过滤,但 rows 可以。 +// 用本机 magpie 已经配好的 remote provider(providers.json)的 URL+key,不引入第二把 key。 +const REMOTE_PAGE = 500, REMOTE_MAX = 40000, REMOTE_CONC = 4; + +function remoteSources() { + if (ATTRIBUTION_MODE !== 'remote') return []; + const callers = REMOTE_CALLERS; + const out = []; + const push = (base, key) => { + const b = String(base || '').replace(/\/+$/, '').replace(/\/v1$/, ''); + let u; try { u = new URL(b); } catch { return; } + // Bearer key 只走 https;明文 http 仅限本机回环(本地测试用) + if (u.protocol !== 'https:' && !['127.0.0.1', 'localhost', '::1'].includes(u.hostname)) return; + if (key && !out.some((x) => x.base === b && x.key === key)) out.push({ base: b, key, callers }); + }; + if (process.env.REMOTE_BASE && process.env.REMOTE_KEY) { + // 显式 override 独占:设置 REMOTE_BASE/KEY 时不再读 providers.json(文档承诺的语义) + push(process.env.REMOTE_BASE, process.env.REMOTE_KEY); + return out; + } + try { + const j = JSON.parse(readFileSync(MAGPIE_PROVIDERS, 'utf8')); + for (const p of j.providers || []) { + if (!p || !p.key || !/^https?:\/\//.test(String(p.chat || p.responses || ''))) continue; + if (p.preset !== 'remote-magpie' && p.id !== 'magpie-direct' && p.id !== 'magpie-cf') continue; + push(p.chat || p.responses, p.key); + } + } catch {} + return out; +} + +let lastGoodRemote = null; +function orderedSources() { + const list = remoteSources(); + if (lastGoodRemote) { + const i = list.findIndex((x) => x.base === lastGoodRemote.base && x.key === lastGoodRemote.key); + if (i > 0) list.unshift(list.splice(i, 1)[0]); + } + return list; +} + +async function remotePage(src, period, offset) { + const u = src.base + '/v1/magpie/usage/requests?period=' + encodeURIComponent(period) + + '&limit=' + REMOTE_PAGE + '&offset=' + offset; + let last; + for (let i = 0; i < 2; i++) { + try { + const r = await fetch(u, { headers: { Authorization: 'Bearer ' + src.key }, signal: AbortSignal.timeout(10000) }); + if (r.ok) return r.json(); + last = new Error('remote usage/requests ' + r.status); + if (r.status < 500) break; + } catch (e) { last = e; } + await new Promise((r) => setTimeout(r, 600 * (i + 1))); + } + throw last || new Error('remote usage/requests failed'); +} + +async function fetchRemoteRows(src, period, first) { + const rows = [...((first && first.rows) || [])]; + const total = Number(first.total) || rows.length; + let offset = rows.length; + const t0 = Date.now(); + while (offset < total && rows.length < REMOTE_MAX) { + // 远端分页总时限:provider key 是真实凭据,拉取不能无上限(前端 45s 会先行放弃) + if (Date.now() - t0 > 40000) break; + const offsets = []; + for (let i = 0; i < REMOTE_CONC; i++) { + const o = offset + i * REMOTE_PAGE; + if (o >= total || rows.length + offsets.length * REMOTE_PAGE >= REMOTE_MAX) break; + offsets.push(o); + } + if (!offsets.length) break; + const pages = await Promise.all(offsets.map((o) => remotePage(src, period, o))); + for (const page of pages) rows.push(...(page.rows || [])); + offset = offsets[offsets.length - 1] + REMOTE_PAGE; + } + return rows; +} + +async function readRemoteAttribution(period, days, callers, sources) { + const bucket = Math.floor(Date.now() / (5 * 60000)); + const suffix = ':' + period + ':' + callers.join(',') + ':' + bucket; + if (attrCache.data && attrCache.key.startsWith('remote:') && attrCache.key.endsWith(suffix)) return attrCache.data; + // 上次成功的源优先;首次或失败时并发要首页,谁先回用谁,剩下的页只走这个源。 + let picked = null; + if (lastGoodRemote && sources.some((s) => s.base === lastGoodRemote.base && s.key === lastGoodRemote.key)) { + try { picked = { src: lastGoodRemote, page: await remotePage(lastGoodRemote, period, 0) }; } + catch { lastGoodRemote = null; } + } + if (!picked) { + try { + picked = await Promise.any(sources.map(async (src) => ({ src, page: await remotePage(src, period, 0) }))); + } catch (e) { + const why = (e && e.errors ? e.errors.map((x) => x && x.message).filter(Boolean).join('; ') : String(e && e.message || e)); + throw new Error(why || 'all remote sources failed'); + } + } + lastGoodRemote = picked.src; + const rows = await fetchRemoteRows(picked.src, period, picked.page); + const data = await aggregateAttribution(rows, { period, days, callers, source: 'remote' }); + attrCache = { key: 'remote:' + picked.src.base + suffix, data }; + return data; +} +function sameKey(given) { + // 先比字节长度:JS 字符串长度 ≠ 字节长(非 ASCII 自定义 key 曾让 timingSafeEqual 抛错→鉴权全 500) + if (typeof given !== 'string' || Buffer.byteLength(given) !== Buffer.byteLength(PAGE_KEY)) return false; + return timingSafeEqual(Buffer.from(given), Buffer.from(PAGE_KEY)); +} + +function authed(req) { + if (!PAGE_KEY) return true; + // 口令只走 x-dash-key 头:?key= 已废除(key 一旦进 URL 就会落进代理/历史记录), + // 浏览器端由服务端注入 HTML 的脚本带着头调 API,脚本调用方显式设 PAGE_KEY。 + return sameKey(String(req.headers['x-dash-key'] || '')); +} + +// 防 DNS rebinding:只接受本机回环名 / 本机网卡地址 / ALLOWED_HOSTS 里的名字。 +// 回环名不看端口(Docker 端口映射、ssh 隧道的外部端口与监听口必然不同,而 +// rebinding 的威胁在域名不在端口);非回环名的端口必须是本进程监听口, +// 除非名字进了 ALLOWED_HOSTS(反代常把 Host 写成 domain:443)。 +function hostAllowed(req) { + const raw = String(req.headers.host || '').toLowerCase(); + if (!raw) return false; + const m = raw.match(/^(\[[^\]]+\]|[^:]+)(?::(\d+))?$/); + if (!m) return false; + const name = m[1]; + const port = Number(m[2] || 0); + const bound = server.address()?.port || 0; + // 显式白名单优先(反代常把 Host 写成 domain:443,端口与本机监听口不同) + if (ALLOWED_HOSTS.includes(name) || ALLOWED_HOSTS.includes(raw)) return true; + if (name === '127.0.0.1' || name === 'localhost' || name === '[::1]') return true; + if (port && bound && port !== bound) return false; + if (HOST !== '127.0.0.1' && HOST !== 'localhost' && HOST !== '::1') { + if (name === HOST.toLowerCase()) return true; + for (const list of Object.values(os.networkInterfaces())) { + for (const a of list || []) if (a.address.toLowerCase() === name) return true; + } + } + return false; +} + +function secHeaders(res) { + res.setHeader('X-Content-Type-Options', 'nosniff'); + res.setHeader('Referrer-Policy', 'no-referrer'); +} + +// 页面 HTML 的跨源读取:沙盒 frame 是 opaque origin(null),顶层导航没有 Origin; +// 其它网站发来的 Origin 一律拒绝,避免它们 fetch 到注入口令的页面。 +// 本机 origin 只认「本进程实际监听口」——任意 localhost 端口不放行。 +function originOk(req, boundPort) { + const o = req.headers.origin; + if (!o || o === 'null') return true; + return loopbackOrigin(o, boundPort); +} + +function loopbackOrigin(o, boundPort) { + if (!boundPort) return false; + return o === `http://127.0.0.1:${boundPort}` + || o === `http://localhost:${boundPort}` + || o === `http://[::1]:${boundPort}`; +} + +// 沙盒 frame(插件页面导航过来,opaque origin)跨源 fetch:允许 Origin: null, +// key 走 x-dash-key 头(opaque origin 无 cookie)。其它 origin 一律不给 ACAO—— +// 页面是这份服务的唯一客户端,本机其它端口的页面也不例外。 +function cors(req, res) { + const o = req.headers.origin; + const allow = (v) => { + res.setHeader('Access-Control-Allow-Origin', v); + res.setHeader('Vary', 'Origin'); + return true; + }; + if (o === undefined || o === 'null') return allow('null'); + if (loopbackOrigin(o, server.address()?.port || 0)) return allow(o); + return false; +} + +// 请求处理主体(原 handler 体):任何未捕获异常都由下方 createServer 的 .catch +// 兜底成 500,进程必须存活、继续服务下一个请求。 +async function handleRequest(req, res, url) { + const p = url.pathname; + secHeaders(res); + if (!hostAllowed(req)) { + res.writeHead(403, { 'Content-Type': 'text/plain; charset=utf-8' }); + return res.end('invalid host'); + } + console.log(`[req] ${req.method} ${p} origin=${req.headers.origin || '-'} xdk=${req.headers['x-dash-key'] ? 'yes' : 'no'}`); + + if (p.startsWith('/api/')) { + // 免鉴权实例指纹:同款服务复用判定用;只报身份,不泄露网关/口令 + if (p === '/api/ping') return json(res, 200, { service: 'magpie-usage-board', ok: true, build: BUILD_ID, version: VERSION }); + if (req.method === 'OPTIONS') { + if (!cors(req, res)) { res.writeHead(403); return res.end(); } + res.writeHead(204, { + 'Access-Control-Allow-Methods': 'GET, OPTIONS', + 'Access-Control-Allow-Headers': 'x-dash-key', + 'Access-Control-Max-Age': '86400', + }); + return res.end(); + } + if (!cors(req, res)) { res.writeHead(403); return res.end('cross-origin reads not allowed'); } + // health 免鉴权:探活与实例识别都依赖匿名访问(响应里无口令、无用量数据) + if (p === '/api/health') return json(res, 200, { ok: true, jsonl: existsSync(USAGE_JSONL) }); + if (!authed(req)) return json(res, 401, { error: 'unauthorized: send the x-dash-key header' }); + try { + if (p === '/api/quotas') { + const [r, lim] = await Promise.all([ + upstream('/v1/magpie/quotas'), + upstream('/v1/magpie/limit?format=json').catch(() => null), + ]); + const out = { ...r.json }; + // magpie 0.1.2981+ 的 /v1/magpie/limit:报告本 caller key 当前被什么 holds(limited/key) + if (lim && lim.code === 200 && lim.json && typeof lim.json === 'object') out.limit = lim.json; + // code 0 = 网关无响应(upstream 内部已重试):writeHead(0) 会 RangeError 并吞掉真实原因 + const status = r.code >= 400 && r.code <= 599 ? r.code : r.code === 200 ? 200 : 502; + return json(res, status, out); + } + if (p === '/api/overview') { + const period = ['7d', '30d', 'all'].includes(url.searchParams.get('period')) ? url.searchParams.get('period') : '30d'; + const days = period === '7d' ? 7 : period === '30d' ? 30 : 0; + // 网关挂起/失败不拖垮本地数据:usage/limit 失败 → null + note,本地日志聚合照常返回 + const [u, lim] = await Promise.all([ + upstream('/v1/magpie/usage?period=' + period).catch(() => ({ code: 0, json: null })), + upstream('/v1/magpie/limit?format=json').catch(() => null), + ]); + const detail = await readDetail(days); + const notes = [u.code === 200 ? undefined : 'usage API ' + (u.code || 'no response'), detail && detail.error].filter(Boolean); + return json(res, 200, { period, usage: u.code === 200 ? u.json : null, detail, + limit: (lim && lim.code === 200 && lim.json) || undefined, + note: notes.length ? notes.join(';') : undefined }); + } + // /api/icon/ 已退役(2026-11-04):前端 logo 全走 QLOGOS manifest,仅 README 提及历史 + if (p === '/api/hourly') { + const data = await readHourly24(); + return json(res, 200, data); + } + if (p === '/api/attribution') { + const period = ['7d', '30d', 'all'].includes(url.searchParams.get('period')) ? url.searchParams.get('period') : '30d'; + const days = period === '7d' ? 7 : period === '30d' ? 30 : 0; + // 本机 magpie 配了 remote provider 时,归因直接问远端 magpie 的 usage/requests, + // 用已有的 provider key,按 caller 过滤;否则退回本机 usage.jsonl(VPS standalone)。 + const sources = orderedSources(); + if (sources.length) { + try { + const data = await readRemoteAttribution(period, days, sources[0].callers, sources); + return json(res, 200, data); + } catch (e) { + return json(res, 502, { error: 'remote attribution: ' + String(e && e.message || e) }); + } + } + const callers = (url.searchParams.get('caller') || '').split(',').map((x) => x.trim()).filter(Boolean); + const data = await readAttribution(period, days, callers); + if (!data) return json(res, 503, { error: 'usage.jsonl not readable' }); + return json(res, 200, data); + } + return json(res, 404, { error: 'not found' }); + } catch (e) { + return json(res, 502, { error: String(e && e.message || e) }); + } + } + + let file = p === '/' ? '/index.html' : p; + if (file.startsWith('/static/')) file = file.slice('/static'.length); + // 静态资源全部来自包内 static/;品牌 logo 不再有独立路由(data URI 注入 window.QLOGOS) + const base = STATIC_DIR; + const full = path.resolve(base, '.' + file); + const rel = path.relative(base, full); + let isFile = false; + try { isFile = !rel.startsWith('..') && !path.isAbsolute(rel) && statSync(full).isFile(); } catch {} + if (!isFile) { res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' }); return res.end('not found'); } + // 页面本身不要求口令(与社区 page-usage-tree 一致):回环绑定直接返回看板, + // 由服务端把口令注入 HTML;公网绑定仍要求口令,避免把数据和口令交给匿名访问者。 + // 这只拦跨源 fetch(Origin 非空且不是本机),顶层导航不带 Origin,不受影响。 + // 看板页面是这份服务的唯一客户端:回环绑定时一律注入口令返回(本机用户即所有者, + // 顶层/沙盒 frame 导航都不带 Origin;与社区 page-usage-tree 同一模型,桌面宿主 + // 不需要任何环境变量)。非回环绑定不开放页面——?key= 已废除,远程访问者没有 + // 认证通道;脚本调用走 x-dash-key 头。 + if (file === '/index.html') { + if (!originOk(req, server.address()?.port || 0)) { + res.writeHead(403, { 'Content-Type': 'text/plain; charset=utf-8' }); + return res.end('cross-origin page read not allowed'); + } + if (!LOOPBACK_BIND) { + res.writeHead(403, { 'Content-Type': 'text/plain; charset=utf-8' }); + return res.end('the board page is loopback-only; APIs accept the x-dash-key header'); + } + // 页面还要求 Host 是回环名:反代把公共域名(ALLOWED_HOSTS 放行的 Host)转发进来时, + // 页面不随之开放——公网访问者只能拿 403;API 走 x-dash-key 头仍可用(P1 回归)。 + const hostName = (String(req.headers.host || '').toLowerCase().match(/^(\[[^\]]+\]|[^:]+)/) || [])[1] || ''; + if (!['127.0.0.1', 'localhost', '[::1]'].includes(hostName)) { + res.writeHead(403, { 'Content-Type': 'text/plain; charset=utf-8' }); + return res.end('the board page answers loopback hosts only'); + } + } + + // 首页:服务端把数据直接内联进 HTML(window.__DATA__),页面加载即有数据, + // 不发任何 fetch——沙盒 frame(opaque origin)里跨源 fetch 会被浏览器/ + // 中间层拦成 "Failed to fetch",这是实测结论;同帧内联是唯一稳路。 + if (file === '/index.html') { + let html = await readFile(full, 'utf8'); + let data = null, note = ''; + try { + const period = ['7d', '30d', 'all'].includes(url.searchParams.get('period')) ? url.searchParams.get('period') : '30d'; + const days = period === '7d' ? 7 : period === '30d' ? 30 : 0; + const [u, detail, q] = await Promise.all([ + upstream('/v1/magpie/usage?period=' + period), + readDetail(days), + upstream('/v1/magpie/quotas'), + ]); + data = { period, usage: u.json, quotas: q.json?.data || [], detail }; + if (u.code !== 200) note = 'usage API ' + u.code; + } catch (e) { note = String(e && e.message || e); } + const trap = '`; + // 页面需要的口令只出现在这份 HTML 里;API 路由仍校验它,URL/书签里不出现 + const keyInject = PAGE_KEY ? `` : ''; + html = html.replace('', () => '' + keyInject + trap + inject); + const boundPort = server.address()?.port || 0; + res.writeHead(200, { + 'Content-Type': 'text/html; charset=utf-8', + 'Cache-Control': 'no-store', + // 页面脚本全是同源文件 + 少量内联(数据注入);数据获取全部同源 /api/*。 + // connect-src 除 'self' 外显式列出本机回环地址——WebKit 的沙盒 frame(opaque + // origin)会把 'self' 解析成 opaque,同源 fetch 被拦,显式地址实测可行。 + // frame-ancestors:看板本来就是被 magpie 的框架嵌入的(桌面/webview/web 的宿主 + // origin 不固定,收不了紧)——显式写 * 表明「被宿主嵌入是设计意图」,而不是遗漏。 + 'Content-Security-Policy': `default-src 'self' data:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:${boundPort} http://localhost:${boundPort}; object-src 'none'; base-uri 'none'; frame-ancestors *`, + }); + return res.end(html); + } + + const heads = { 'Content-Type': MIME[path.extname(full).toLowerCase()] || 'application/octet-stream', 'Cache-Control': 'no-store' }; + // echarts.min.js:URL 带 ?v= 构建戳(内容变更即换 URL)→ 长缓存;按 Accept-Encoding 供 + // 启动时预压缩的 br/gzip 版本(612KB → br ~172KB),避免每次导航白拉全量 + if (file === '/echarts.min.js') { + heads['Cache-Control'] = 'public, max-age=31536000, immutable'; + const enc = echartsEncoded(full); + const ae = String(req.headers['accept-encoding'] || ''); + if (/\bbr\b/.test(ae)) { heads['Content-Encoding'] = 'br'; heads['Content-Length'] = String(enc.br.length); heads['Vary'] = 'Accept-Encoding'; res.writeHead(200, heads); return res.end(enc.br); } + if (/\bgzip\b/.test(ae)) { heads['Content-Encoding'] = 'gzip'; heads['Content-Length'] = String(enc.gz.length); heads['Vary'] = 'Accept-Encoding'; res.writeHead(200, heads); return res.end(enc.gz); } + } + if (file.endsWith('.svg')) heads['Content-Security-Policy'] = 'sandbox'; // SVG 可内嵌脚本:被直接打开时整页隔离 + res.writeHead(200, heads); + res.end(await readFile(full)); +} + +const server = createServer((req, res) => { + // 畸形请求目标(如 GET // HTTP/1.1)会让 new URL 抛 Invalid URL:单独 try/catch + // 拦下直接 400,不进入 Host 校验/鉴权/任何业务逻辑(P0 修复:原实现无容错, + // 任意外部请求即可打死进程)。 + let url; + try { + url = new URL(req.url, 'http://x'); + } catch { + res.writeHead(400, { 'Content-Type': 'text/plain; charset=utf-8' }); + return res.end('bad request'); + } + handleRequest(req, res, url).catch((e) => { + // 最外层兜底:任何未捕获异常 → 500,固定文案(不带堆栈与内部错误细节),进程继续服务 + console.log(`[magpie-usage] handler error: ${e && e.message || e}`); + if (!res.headersSent) { + res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' }); + res.end('internal server error'); + } else { try { res.end(); } catch {} } + }); +}); + +// 最后防线:unhandledRejection 只记日志、不退出进程(Node/Bun 默认会终止进程), +// 兜住请求处理之外(定时器、fire-and-forget fetch 等)的意外拒绝。 +process.on('unhandledRejection', (e) => { + console.log(`[magpie-usage] unhandled rejection: ${e && e.message || e}`); +}); + +// ---- 启动 ---- +// 构建指纹:版本号 + 运行时文件哈希。端口被占时用 /api/ping 互认——只有「同一份代码」 +// 的实例才允许复用(旧版本/别的构建一律报错,绝不把看板交给一个未知进程)。 +const VERSION = (() => { + try { const v = JSON.parse(readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version; return typeof v === 'string' ? v : '0'; } catch { return '0'; } +})(); +const BUILD_FILES = ['server.mjs', 'index.mjs', 'package.json', 'static/index.html', 'static/echarts.min.js', 'page/index.html', 'page/boot.js']; +const BUILD_ID = (() => { + try { + const h = createHash('sha256'); + for (const f of BUILD_FILES) { h.update(f); h.update('\0'); h.update(readFileSync(path.join(ROOT, f))); } + return h.digest('hex').slice(0, 16); + } catch { return 'ver:' + VERSION; } +})(); + +// 占用端口的是不是本构建的实例:/api/ping 匿名报身份(无口令、无数据),同构建才复用。 +async function probe(hp) { + try { + const j = await (await fetch(`http://${hp}/api/ping`, { signal: AbortSignal.timeout(1200) })).json(); + if (j && j.service === 'magpie-usage-board') return { build: String(j.build || ''), version: String(j.version || '') }; + } catch {} + return null; +} + +// 品牌 logo:读 magpie 自己维护的 plugin-providers.json(插件注册 provider 时上报的 +// id→icon,data URI 为主)。只取 data URI(≤2MB);https 图标一律不抓取——那会让本机 +// 服务在启动时向第三方 CDN 发起用户不可见的请求。页面 brandIcon() 的别名/去后缀兜底链 +// 在前端保持不变,未命中品牌走首字色块。 +let providerLogos = {}; +function loadProviderLogos() { + const f = PROVIDERS_FILE || path.join(CONFIG_DIR, 'plugin-providers.json'); + try { + const j = JSON.parse(readFileSync(f, 'utf8')); + const out = {}; + let total = 0; + for (const p of Object.values(j)) { + const id = p && typeof p.id === 'string' ? p.id.toLowerCase() : ''; + const icon = p && typeof p.icon === 'string' ? p.icon : ''; + if (!id || !icon.startsWith('data:image/')) continue; + const comma = icon.indexOf(','); + if (comma <= 0 || icon.length - comma > 2 * 1024 * 1024) continue; // 解码前 2MB 上限 + if (out[id] === undefined) { out[id] = icon; total += icon.length; } + if (total > 4 * 1024 * 1024) break; // 注入 HTML 的总体积上限 + } + providerLogos = out; + console.log(`[magpie-usage] logos: ${Object.keys(out).length} brands from ${f}`); + } catch (e) { + console.log(`[magpie-usage] logos: plugin-providers.json not readable (${(e && e.code) || (e && e.message) || e}) — badges only`); + } +} + +function main(resolve, reject) { + // 口令定稿(listen 前):显式 PAGE_KEY 环境变量优先(空串=API 开放;页面门禁只看回环 + // 绑定,不受它影响);未设 → 每次启动生成随机 token——页面 HTML 由服务端注入,URL、 + // 日志、磁盘都不落。复用同构建实例时无需互通口令:页面由持有端口的实例自己服务。 + const envKey = process.env.PAGE_KEY; + if (envKey !== undefined) PAGE_KEY = envKey; + else PAGE_KEY = randomBytes(24).toString('base64url'); + + // 配置定稿:manifest options(index.mjs 传入)→ 环境变量 → 内置默认 + const optStr = (o, env, dft) => { const v = o === undefined || o === null || o === '' ? env : o; return v === undefined || v === null || v === '' ? dft : String(v); }; + const attr = optStr(CFG.attribution, process.env.ATTRIBUTION, 'local').toLowerCase(); + // 远端归因 opt-in:只有显式 remote(auto 为兼容别名)才启用——它会拿本机配好的 + // remote provider key 去查远端 magpie 的请求明细。 + ATTRIBUTION_MODE = attr === 'remote' || attr === 'auto' ? 'remote' : 'local'; + REMOTE_CALLERS = optStr(CFG.remoteCallers, process.env.REMOTE_CALLERS, '').split(',').map((x) => x.trim()).filter(Boolean); + REMOTE_PROVIDERS = optStr(CFG.remoteProviders, process.env.REMOTE_PROVIDERS, 'magpie-direct,magpie-cf,remote-magpie').split(',').map((x) => x.trim()).filter(Boolean); + // 网关按链路解析(options → GATEWAY → MAGPIE_GATEWAY → MAGPIE_ADDR → 3425):宿主把 + // MAGPIE_ADDR 指到哪,看板就问哪——端口改过/便携安装时写死 3425 会全盘落空。 + GATEWAY = gatewayCandidates(CFG.gateway)[0]; + + loadProviderLogos(); + + let startPort = null; + const rawPort = CFG.port ?? process.env.PORT; + if (rawPort !== undefined && rawPort !== null && rawPort !== '') { + const n = Number(rawPort); + if (!Number.isInteger(n) || n < 0 || n > 65535) { + const err = new Error(`invalid PORT=${rawPort} — must be an integer 0-65535`); + console.error(`[magpie-usage] ${err.message}`); + reject(err); + return; + } + startPort = n; + } + + // 端口语义(与社区 page-usage-tree 一致):目标口 = 显式 PORT / manifest options.port, + // 否则 PORT_BASE。空闲 → 绑定;被占 → 短重试(宿主重启时上一代濒死,通常一秒内释放); + // 仍被占 → /api/ping 指纹互认:同一份代码(BUILD_ID 一致)→ 二次确认活着后复用; + // 异构建或异种进程 → 明确报错。绝不向上扫描——带路页从 manifest options 读到的端口 + // 必须与绑定口一致,扫上去页面也连不上。 + const target = startPort === null ? PORT_BASE : startPort; + const deadline = Date.now() + 8000; + const attempt = async () => { + const bound = await bindOnce(target); + if (bound) return; + const st = await probe(`${URL_HOST}:${target}`); + if (st && st.build === BUILD_ID) { + // 濒死实例也能应答单次探测:1.5s 后仍活着才复用;死了就继续等端口释放 + const confirm = await new Promise((r2) => setTimeout(() => probe(`${URL_HOST}:${target}`).then(r2, () => r2(null)), 1500)); + if (confirm && confirm.build === BUILD_ID) { + console.log(`[magpie-usage] port ${target} in use by the same build (${BUILD_ID}) — reusing it`); + resolve(target); + return; + } + } + if (Date.now() < deadline) { setTimeout(attempt, 150); return; } + reject(new Error(st + ? `port ${target} is held by another build of this board (build ${st.build || 'unknown'}) — free it or set PORT` + : `port ${target} is in use and not by this board — free it or set PORT`)); + }; + attempt(); + + function bindOnce(p) { + return new Promise((res) => { + const onListen = () => { cleanup(); finish2(server.address().port); res(true); }; + const onErr = (e) => { + cleanup(); + if (e.code !== 'EADDRINUSE' && e.code !== 'EACCES') { + console.log(`[magpie-usage] not started: ${e.code || e.message}`); + reject(new Error(`not started: ${e.code || e.message}`)); + res(true); // 已 reject,外层不必重试 + return; + } + res(false); + }; + const cleanup = () => { server.off('listening', onListen); server.off('error', onErr); }; + server.once('listening', onListen); + server.once('error', onErr); + server.listen(p, HOST); + }); + } + // open 日志:URL 永不带口令(?key= 已废除)——回环绑定页面免口令,非回环绑定 + // 页面不开放、API 用 x-dash-key 头。 + function openUrl(port) { + const base = `http://${URL_HOST}:${port}/`; + if (!LOOPBACK_BIND) return `${base}(页面仅本机可开;API 请求带 x-dash-key 头)`; + return base; + } + function finish2(port) { + console.log(`[magpie-usage] listening on http://${URL_HOST}:${port}/ gateway=${GATEWAY} jsonl=${USAGE_JSONL}(${existsSync(USAGE_JSONL) ? 'ok' : 'missing'}) attribution=${ATTRIBUTION_MODE} build=${BUILD_ID}`); + console.log(`[magpie-usage] open ${openUrl(port)}`); + server.on('error', (e) => console.log(`[magpie-usage] server error: ${e.message}`)); // 绑定后的常驻兜底 + resolve(port); + } +} +let bootPromise = null; +// 返回 Promise:resolve 于首次成功监听(或确认复用同构建实例),reject 于终态启动失败。 +// index.mjs 的 server() 会 await 它——magpie 在 server() 返回后立刻探测服务端口, +// 「发射后不管」会让那次探测吃 connection refused(社区生命周期契约)。 +function startServer(options = {}) { + if (bootPromise) return bootPromise; + // manifest options 三级回退的第一级;startServer() 已启动过则忽略(bootPromise 复用)。 + // port 0 = 由系统挑随机口(测试与嵌入场景);index.mjs 会把 options.port 的 0/非法值 + // 归成 undefined 落到默认口,页面从同一 options 读到的值与服务保持一致。 + CFG.port = options && Number.isFinite(Number(options.port)) ? Number(options.port) : null; + CFG.attribution = options ? options.attribution : null; + CFG.remoteCallers = options ? options.remoteCallers : null; + CFG.remoteProviders = options ? options.remoteProviders : null; + CFG.gateway = options ? options.gateway : null; + bootPromise = new Promise((resolve, reject) => { + try { + main(resolve, reject); + } catch (e) { reject(e); } + }); + bootPromise.catch(() => { bootPromise = null; }); // 失败不缓存:下一次 server() 调用重试 + return bootPromise; +} + +export { startServer, aggregateAttribution }; + +if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + startServer().catch((e) => { console.error(`[magpie-usage] not started: ${e.message}`); process.exit(1); }); +} diff --git a/packages/page-usage-board/static/echarts.min.js b/packages/page-usage-board/static/echarts.min.js new file mode 100644 index 0000000..451abee --- /dev/null +++ b/packages/page-usage-board/static/echarts.min.js @@ -0,0 +1,49 @@ +/* Apache ECharts v5.5.1 custom build (bar/line/pie/heatmap + tooltip/legend/grid/dataZoom/visualMap/axisPointer). Copyright 2018-2026 Apache Software Foundation, Apache-2.0. See NOTICE. */ +(()=>{var TT=Object.defineProperty;var ze=(r,t)=>{for(var e in t)TT(r,e,{get:t[e],enumerable:!0})};var Bf={};ze(Bf,{Axis:()=>Uf,ChartView:()=>Ut,ComponentModel:()=>pt,ComponentView:()=>Lt,List:()=>lo,Model:()=>_t,PRIORITY:()=>wv,SeriesModel:()=>qt,color:()=>Uo,connect:()=>CL,dataTool:()=>RL,dependencies:()=>lL,disConnect:()=>DL,disconnect:()=>mS,dispose:()=>AL,env:()=>j,extendChartView:()=>KI,extendComponentModel:()=>ZI,extendComponentView:()=>XI,extendSeriesModel:()=>qI,format:()=>sd,getCoordinateSystemDimensions:()=>LL,getInstanceByDom:()=>Cv,getInstanceById:()=>EL,getMap:()=>PL,graphic:()=>od,helper:()=>$v,init:()=>ML,innerDrawElementOnCanvas:()=>no,matrix:()=>Qr,number:()=>ad,parseGeoJSON:()=>kf,parseGeoJson:()=>kf,registerAction:()=>Br,registerCoordinateSystem:()=>Lv,registerLayout:()=>Iv,registerLoading:()=>xf,registerLocale:()=>Au,registerMap:()=>Rv,registerPostInit:()=>Av,registerPostUpdate:()=>Ev,registerPreprocessor:()=>yf,registerProcessor:()=>_f,registerTheme:()=>Dv,registerTransform:()=>Ov,registerUpdateLifecycle:()=>Hs,registerVisual:()=>ci,setCanvasCreator:()=>IL,setPlatformAPI:()=>gl,throttle:()=>ja,time:()=>nd,use:()=>Bt,util:()=>ld,vector:()=>vr,version:()=>sL,zrUtil:()=>q,zrender:()=>Kl});var yh=function(r,t){return yh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(e[a]=i[a])},yh(r,t)};function I(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");yh(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Kl={};ze(Kl,{dispose:()=>aC,disposeAll:()=>nC,getElementSSRData:()=>sC,getInstance:()=>oC,init:()=>ql,registerPainter:()=>vc,registerSSRDataGetter:()=>dc,version:()=>lC});var MT=(function(){function r(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return r})(),CT=(function(){function r(){this.browser=new MT,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<"u"}return r})(),ji=new CT;typeof wx=="object"&&typeof wx.getSystemInfoSync=="function"?(ji.wxa=!0,ji.touchEventsSupported=!0):typeof document>"u"&&typeof self<"u"?ji.worker=!0:typeof navigator>"u"||navigator.userAgent.indexOf("Node.js")===0?(ji.node=!0,ji.svgSupported=!0):DT(navigator.userAgent,ji);function DT(r,t){var e=t.browser,i=r.match(/Firefox\/([\d.]+)/),a=r.match(/MSIE\s([\d.]+)/)||r.match(/Trident\/.+?rv:(([\d.]+))/),n=r.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(r);i&&(e.firefox=!0,e.version=i[1]),a&&(e.ie=!0,e.version=a[1]),n&&(e.edge=!0,e.version=n[1],e.newEdge=+n[1].split(".")[0]>18),o&&(e.weChat=!0),t.svgSupported=typeof SVGRect<"u",t.touchEventsSupported="ontouchstart"in window&&!e.ie&&!e.edge,t.pointerEventsSupported="onpointerdown"in window&&(e.edge||e.ie&&+e.version>=11),t.domSupported=typeof document<"u";var s=document.documentElement.style;t.transform3dSupported=(e.ie&&"transition"in s||e.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||e.ie&&+e.version>=9}var j=ji;var q={};ze(q,{HashMap:()=>Rm,RADIAN_TO_DEGREE:()=>xl,assert:()=>Ft,bind:()=>H,clone:()=>Y,concatArray:()=>wh,createCanvas:()=>VT,createHashMap:()=>W,createObject:()=>Xr,curry:()=>ct,defaults:()=>K,disableUserSelect:()=>Do,each:()=>b,eqNaN:()=>Ji,extend:()=>N,filter:()=>Mt,find:()=>BT,guid:()=>wo,hasOwn:()=>Ze,indexOf:()=>it,inherits:()=>To,isArray:()=>O,isArrayLike:()=>Ot,isBuiltInObject:()=>_h,isDom:()=>Qi,isFunction:()=>G,isGradientObject:()=>Zr,isImagePatternObject:()=>bh,isNumber:()=>nt,isObject:()=>F,isPrimitive:()=>cn,isRegExp:()=>HT,isString:()=>U,isStringSafe:()=>vn,isTypedArray:()=>Et,keys:()=>lt,logError:()=>$i,map:()=>k,merge:()=>tt,mergeAll:()=>UT,mixin:()=>Jt,noop:()=>Dt,normalizeCssArray:()=>Co,reduce:()=>fe,retrieve:()=>Dr,retrieve2:()=>et,retrieve3:()=>Ar,setAsPrimitive:()=>ta,slice:()=>Mo,trim:()=>te});var ml=12,AT="sans-serif",pr=ml+"px "+AT,ET=20,LT=100,IT="007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";function PT(r){var t={};if(typeof JSON>"u")return t;for(var e=0;e=0)s=o*e.length;else for(var l=0;lSl,applyTransform:()=>Nt,clone:()=>Th,copy:()=>YT,create:()=>qr,dist:()=>dn,distSquare:()=>mi,distance:()=>Eo,distanceSquare:()=>Om,div:()=>QT,dot:()=>$T,len:()=>Ch,lenSquare:()=>Dh,length:()=>qT,lengthSquare:()=>KT,lerp:()=>Lo,max:()=>qe,min:()=>Xe,mul:()=>jT,negate:()=>JT,normalize:()=>Ah,scale:()=>Ao,scaleAndAdd:()=>XT,set:()=>ZT,sub:()=>Mh});function qr(r,t){return r==null&&(r=0),t==null&&(t=0),[r,t]}function YT(r,t){return r[0]=t[0],r[1]=t[1],r}function Th(r){return[r[0],r[1]]}function ZT(r,t,e){return r[0]=t,r[1]=e,r}function Sl(r,t,e){return r[0]=t[0]+e[0],r[1]=t[1]+e[1],r}function XT(r,t,e,i){return r[0]=t[0]+e[0]*i,r[1]=t[1]+e[1]*i,r}function Mh(r,t,e){return r[0]=t[0]-e[0],r[1]=t[1]-e[1],r}function Ch(r){return Math.sqrt(Dh(r))}var qT=Ch;function Dh(r){return r[0]*r[0]+r[1]*r[1]}var KT=Dh;function jT(r,t,e){return r[0]=t[0]*e[0],r[1]=t[1]*e[1],r}function QT(r,t,e){return r[0]=t[0]/e[0],r[1]=t[1]/e[1],r}function $T(r,t){return r[0]*t[0]+r[1]*t[1]}function Ao(r,t,e){return r[0]=t[0]*e,r[1]=t[1]*e,r}function Ah(r,t){var e=Ch(t);return e===0?(r[0]=0,r[1]=0):(r[0]=t[0]/e,r[1]=t[1]/e),r}function Eo(r,t){return Math.sqrt((r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1]))}var dn=Eo;function Om(r,t){return(r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1])}var mi=Om;function JT(r,t){return r[0]=-t[0],r[1]=-t[1],r}function Lo(r,t,e,i){return r[0]=t[0]+i*(e[0]-t[0]),r[1]=t[1]+i*(e[1]-t[1]),r}function Nt(r,t,e){var i=t[0],a=t[1];return r[0]=e[0]*i+e[2]*a+e[4],r[1]=e[1]*i+e[3]*a+e[5],r}function Xe(r,t,e){return r[0]=Math.min(t[0],e[0]),r[1]=Math.min(t[1],e[1]),r}function qe(r,t,e){return r[0]=Math.max(t[0],e[0]),r[1]=Math.max(t[1],e[1]),r}var mn=(function(){function r(t,e){this.target=t,this.topTarget=e&&e.topTarget}return r})(),tM=(function(){function r(t){this.handler=t,t.on("mousedown",this._dragStart,this),t.on("mousemove",this._drag,this),t.on("mouseup",this._dragEnd,this)}return r.prototype._dragStart=function(t){for(var e=t.target;e&&!e.draggable;)e=e.parent||e.__hostTarget;e&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this.handler.dispatchToElement(new mn(e,t),"dragstart",t.event))},r.prototype._drag=function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,a=t.offsetY,n=i-this._x,o=a-this._y;this._x=i,this._y=a,e.drift(n,o,t),this.handler.dispatchToElement(new mn(e,t),"drag",t.event);var s=this.handler.findHover(i,a,e).target,l=this._dropTarget;this._dropTarget=s,e!==s&&(l&&s!==l&&this.handler.dispatchToElement(new mn(l,t),"dragleave",t.event),s&&s!==l&&this.handler.dispatchToElement(new mn(s,t),"dragenter",t.event))}},r.prototype._dragEnd=function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this.handler.dispatchToElement(new mn(e,t),"dragend",t.event),this._dropTarget&&this.handler.dispatchToElement(new mn(this._dropTarget,t),"drop",t.event),this._draggingTarget=null,this._dropTarget=null},r})(),Nm=tM;var eM=(function(){function r(t){t&&(this._$eventProcessor=t)}return r.prototype.on=function(t,e,i,a){this._$handlers||(this._$handlers={});var n=this._$handlers;if(typeof e=="function"&&(a=i,i=e,e=null),!i||!t)return this;var o=this._$eventProcessor;e!=null&&o&&o.normalizeQuery&&(e=o.normalizeQuery(e)),n[t]||(n[t]=[]);for(var s=0;s>1)%2;s.cssText=["position: absolute","visibility: hidden","padding: 0","margin: 0","border-width: 0","user-select: none","width:0","height:0",i[l]+":0",a[u]+":0",i[1-l]+":auto",a[1-u]+":auto",""].join("!important;"),r.appendChild(o),e.push(o)}return e}function aM(r,t,e){for(var i=e?"invTrans":"trans",a=t[i],n=t.srcCoords,o=[],s=[],l=!0,u=0;u<4;u++){var f=r[u].getBoundingClientRect(),h=2*u,p=f.left,c=f.top;o.push(p,c),l=l&&n&&p===n[h]&&c===n[h+1],s.push(r[u].offsetLeft,r[u].offsetTop)}return l&&a?a:(t.srcCoords=o,t[i]=e?Lh(s,o):Lh(o,s))}function Ph(r){return r.nodeName.toUpperCase()==="CANVAS"}var nM=/([&<>"'])/g,oM={"&":"&","<":"<",">":">",'"':""","'":"'"};function ee(r){return r==null?"":(r+"").replace(nM,function(t,e){return oM[e]})}var sM=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Rh=[],lM=j.browser.firefox&&+j.browser.version.split(".")[0]<39;function wl(r,t,e,i){return e=e||{},i?Um(r,t,e):lM&&t.layerX!=null&&t.layerX!==t.offsetX?(e.zrX=t.layerX,e.zrY=t.layerY):t.offsetX!=null?(e.zrX=t.offsetX,e.zrY=t.offsetY):Um(r,t,e),e}function Um(r,t,e){if(j.domSupported&&r.getBoundingClientRect){var i=t.clientX,a=t.clientY;if(Ph(r)){var n=r.getBoundingClientRect();e.zrX=i-n.left,e.zrY=a-n.top;return}else if(bl(Rh,r,i,a)){e.zrX=Rh[0],e.zrY=Rh[1];return}}e.zrX=e.zrY=0}function Tl(r){return r||window.event}function Me(r,t,e){if(t=Tl(t),t.zrX!=null)return t;var i=t.type,a=i&&i.indexOf("touch")>=0;if(a){var o=i!=="touchend"?t.targetTouches[0]:t.changedTouches[0];o&&wl(r,o,t,e)}else{wl(r,t,t,e);var n=uM(t);t.zrDelta=n?n/120:-(t.detail||0)/3}var s=t.button;return t.which==null&&s!==void 0&&sM.test(t.type)&&(t.which=s&1?1:s&2?3:s&4?2:0),t}function uM(r){var t=r.wheelDelta;if(t)return t;var e=r.deltaX,i=r.deltaY;if(e==null||i==null)return t;var a=Math.abs(i!==0?i:e),n=i>0?-1:i<0?1:e>0?-1:1;return 3*a*n}function Vm(r,t,e,i){r.addEventListener(t,e,i)}function Bm(r,t,e,i){r.removeEventListener(t,e,i)}var Ce=function(r){r.preventDefault(),r.stopPropagation(),r.cancelBubble=!0};function Oh(r){return r.which===2||r.which===3}var Hm=(function(){function r(){this._track=[]}return r.prototype.recognize=function(t,e,i){return this._doTrack(t,e,i),this._recognize(t)},r.prototype.clear=function(){return this._track.length=0,this},r.prototype._doTrack=function(t,e,i){var a=t.touches;if(a){for(var n={points:[],touches:[],target:e,event:t},o=0,s=a.length;o1&&i&&i.length>1){var n=Fm(i)/Fm(a);!isFinite(n)&&(n=1),t.pinchScale=n;var o=fM(i);return t.pinchX=o[0],t.pinchY=o[1],{type:"pinch",target:r[0].target,event:t}}}}};var Qr={};ze(Qr,{clone:()=>hM,copy:()=>Ml,create:()=>dr,identity:()=>Kr,invert:()=>jr,mul:()=>Ke,rotate:()=>ea,scale:()=>zh,translate:()=>yn});function dr(){return[1,0,0,1,0,0]}function Kr(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=1,r[4]=0,r[5]=0,r}function Ml(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r}function Ke(r,t,e){var i=t[0]*e[0]+t[2]*e[1],a=t[1]*e[0]+t[3]*e[1],n=t[0]*e[2]+t[2]*e[3],o=t[1]*e[2]+t[3]*e[3],s=t[0]*e[4]+t[2]*e[5]+t[4],l=t[1]*e[4]+t[3]*e[5]+t[5];return r[0]=i,r[1]=a,r[2]=n,r[3]=o,r[4]=s,r[5]=l,r}function yn(r,t,e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4]+e[0],r[5]=t[5]+e[1],r}function ea(r,t,e,i){i===void 0&&(i=[0,0]);var a=t[0],n=t[2],o=t[4],s=t[1],l=t[3],u=t[5],f=Math.sin(e),h=Math.cos(e);return r[0]=a*h+s*f,r[1]=-a*f+s*h,r[2]=n*h+l*f,r[3]=-n*f+h*l,r[4]=h*(o-i[0])+f*(u-i[1])+i[0],r[5]=h*(u-i[1])-f*(o-i[0])+i[1],r}function zh(r,t,e){var i=e[0],a=e[1];return r[0]=t[0]*i,r[1]=t[1]*a,r[2]=t[2]*i,r[3]=t[3]*a,r[4]=t[4]*i,r[5]=t[5]*a,r}function jr(r,t){var e=t[0],i=t[2],a=t[4],n=t[1],o=t[3],s=t[5],l=e*o-n*i;return l?(l=1/l,r[0]=o*l,r[1]=-n*l,r[2]=-i*l,r[3]=e*l,r[4]=(i*s-o*a)*l,r[5]=(n*a-e*s)*l,r):null}function hM(r){var t=dr();return Ml(t,r),t}var cM=(function(){function r(t,e){this.x=t||0,this.y=e||0}return r.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.set=function(t,e){return this.x=t,this.y=e,this},r.prototype.equal=function(t){return t.x===this.x&&t.y===this.y},r.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},r.prototype.scale=function(t){this.x*=t,this.y*=t},r.prototype.scaleAndAdd=function(t,e){this.x+=t.x*e,this.y+=t.y*e},r.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},r.prototype.dot=function(t){return this.x*t.x+this.y*t.y},r.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},r.prototype.normalize=function(){var t=this.len();return this.x/=t,this.y/=t,this},r.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},r.prototype.distanceSquare=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.transform=function(t){if(t){var e=this.x,i=this.y;return this.x=t[0]*e+t[2]*i+t[4],this.y=t[1]*e+t[3]*i+t[5],this}},r.prototype.toArray=function(t){return t[0]=this.x,t[1]=this.y,t},r.prototype.fromArray=function(t){this.x=t[0],this.y=t[1]},r.set=function(t,e,i){t.x=e,t.y=i},r.copy=function(t,e){t.x=e.x,t.y=e.y},r.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},r.lenSquare=function(t){return t.x*t.x+t.y*t.y},r.dot=function(t,e){return t.x*e.x+t.y*e.y},r.add=function(t,e,i){t.x=e.x+i.x,t.y=e.y+i.y},r.sub=function(t,e,i){t.x=e.x-i.x,t.y=e.y-i.y},r.scale=function(t,e,i){t.x=e.x*i,t.y=e.y*i},r.scaleAndAdd=function(t,e,i,a){t.x=e.x+i.x*a,t.y=e.y+i.y*a},r.lerp=function(t,e,i,a){var n=1-a;t.x=n*e.x+a*i.x,t.y=n*e.y+a*i.y},r})(),rt=cM;var Cl=Math.min,Dl=Math.max,ra=new rt,ia=new rt,aa=new rt,na=new rt,Io=new rt,Po=new rt,pM=(function(){function r(t,e,i,a){i<0&&(t=t+i,i=-i),a<0&&(e=e+a,a=-a),this.x=t,this.y=e,this.width=i,this.height=a}return r.prototype.union=function(t){var e=Cl(t.x,this.x),i=Cl(t.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=Dl(t.x+t.width,this.x+this.width)-e:this.width=t.width,isFinite(this.y)&&isFinite(this.height)?this.height=Dl(t.y+t.height,this.y+this.height)-i:this.height=t.height,this.x=e,this.y=i},r.prototype.applyTransform=function(t){r.applyTransform(this,this,t)},r.prototype.calculateTransform=function(t){var e=this,i=t.width/e.width,a=t.height/e.height,n=dr();return yn(n,n,[-e.x,-e.y]),zh(n,n,[i,a]),yn(n,n,[t.x,t.y]),n},r.prototype.intersect=function(t,e){if(!t)return!1;t instanceof r||(t=r.create(t));var i=this,a=i.x,n=i.x+i.width,o=i.y,s=i.y+i.height,l=t.x,u=t.x+t.width,f=t.y,h=t.y+t.height,p=!(nv&&(v=_,mv&&(v=x,g=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.copy=function(t){r.copy(this,t)},r.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},r.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},r.prototype.isZero=function(){return this.width===0||this.height===0},r.create=function(t){return new r(t.x,t.y,t.width,t.height)},r.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},r.applyTransform=function(t,e,i){if(!i){t!==e&&r.copy(t,e);return}if(i[1]<1e-5&&i[1]>-1e-5&&i[2]<1e-5&&i[2]>-1e-5){var a=i[0],n=i[3],o=i[4],s=i[5];t.x=e.x*a+o,t.y=e.y*n+s,t.width=e.width*a,t.height=e.height*n,t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height);return}ra.x=aa.x=e.x,ra.y=na.y=e.y,ia.x=na.x=e.x+e.width,ia.y=aa.y=e.y+e.height,ra.transform(i),na.transform(i),ia.transform(i),aa.transform(i),t.x=Cl(ra.x,ia.x,aa.x,na.x),t.y=Cl(ra.y,ia.y,aa.y,na.y);var l=Dl(ra.x,ia.x,aa.x,na.x),u=Dl(ra.y,ia.y,aa.y,na.y);t.width=l-t.x,t.height=u-t.y},r})(),J=pM;var Wm="silent";function vM(r,t,e){return{type:r,event:e,target:t.target,topTarget:t.topTarget,cancelBubble:!1,offsetX:e.zrX,offsetY:e.zrY,gestureEvent:e.gestureEvent,pinchX:e.pinchX,pinchY:e.pinchY,pinchScale:e.pinchScale,wheelDelta:e.zrDelta,zrByTouch:e.zrByTouch,which:e.which,stop:dM}}function dM(){Ce(this.event)}var mM=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.handler=null,e}return t.prototype.dispose=function(){},t.prototype.setCursor=function(){},t})(Wt),Ro=(function(){function r(t,e){this.x=t,this.y=e}return r})(),gM=["click","dblclick","mousewheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],kh=new J(0,0,0,0),Ym=(function(r){I(t,r);function t(e,i,a,n,o){var s=r.call(this)||this;return s._hovered=new Ro(0,0),s.storage=e,s.painter=i,s.painterRoot=n,s._pointerSize=o,a=a||new mM,s.proxy=null,s.setHandlerProxy(a),s._draggingMgr=new Nm(s),s}return t.prototype.setHandlerProxy=function(e){this.proxy&&this.proxy.dispose(),e&&(b(gM,function(i){e.on&&e.on(i,this[i],this)},this),e.handler=this),this.proxy=e},t.prototype.mousemove=function(e){var i=e.zrX,a=e.zrY,n=Zm(this,i,a),o=this._hovered,s=o.target;s&&!s.__zr&&(o=this.findHover(o.x,o.y),s=o.target);var l=this._hovered=n?new Ro(i,a):this.findHover(i,a),u=l.target,f=this.proxy;f.setCursor&&f.setCursor(u?u.cursor:"default"),s&&u!==s&&this.dispatchToElement(o,"mouseout",e),this.dispatchToElement(l,"mousemove",e),u&&u!==s&&this.dispatchToElement(l,"mouseover",e)},t.prototype.mouseout=function(e){var i=e.zrEventControl;i!=="only_globalout"&&this.dispatchToElement(this._hovered,"mouseout",e),i!=="no_globalout"&&this.trigger("globalout",{type:"globalout",event:e})},t.prototype.resize=function(){this._hovered=new Ro(0,0)},t.prototype.dispatch=function(e,i){var a=this[e];a&&a.call(this,i)},t.prototype.dispose=function(){this.proxy.dispose(),this.storage=null,this.proxy=null,this.painter=null},t.prototype.setCursorStyle=function(e){var i=this.proxy;i.setCursor&&i.setCursor(e)},t.prototype.dispatchToElement=function(e,i,a){e=e||{};var n=e.target;if(!(n&&n.silent)){for(var o="on"+i,s=vM(i,e,a);n&&(n[o]&&(s.cancelBubble=!!n[o].call(n,s)),n.trigger(i,s),n=n.__hostTarget?n.__hostTarget:n.parent,!s.cancelBubble););s.cancelBubble||(this.trigger(i,s),this.painter&&this.painter.eachOtherLayer&&this.painter.eachOtherLayer(function(l){typeof l[o]=="function"&&l[o].call(l,s),l.trigger&&l.trigger(i,s)}))}},t.prototype.findHover=function(e,i,a){var n=this.storage.getDisplayList(),o=new Ro(e,i);if(Gm(n,o,e,i,a),this._pointerSize&&!o.target){for(var s=[],l=this._pointerSize,u=l/2,f=new J(e-u,i-u,l,l),h=n.length-1;h>=0;h--){var p=n[h];p!==a&&!p.ignore&&!p.ignoreCoarsePointer&&(!p.parent||!p.parent.ignoreCoarsePointer)&&(kh.copy(p.getBoundingRect()),p.transform&&kh.applyTransform(p.transform),kh.intersect(f)&&s.push(p))}if(s.length)for(var c=4,v=Math.PI/12,m=Math.PI*2,d=0;d4)return;this._downPoint=null}this.dispatchToElement(n,r,t)}});function yM(r,t,e){if(r[r.rectHover?"rectContain":"contain"](t,e)){for(var i=r,a=void 0,n=!1;i;){if(i.ignoreClip&&(n=!0),!n){var o=i.getClipPath();if(o&&!o.contain(t,e))return!1}i.silent&&(a=!0);var s=i.__hostTarget;i=s||i.parent}return a?Wm:!0}return!1}function Gm(r,t,e,i,a){for(var n=r.length-1;n>=0;n--){var o=r[n],s=void 0;if(o!==a&&!o.ignore&&(s=yM(o,e,i))&&(!t.topTarget&&(t.topTarget=o),s!==Wm)){t.target=o;break}}}function Zm(r,t,e){var i=r.painter;return t<0||t>i.getWidth()||e<0||e>i.getHeight()}var Xm=Ym;var jm=32,Oo=7;function _M(r){for(var t=0;r>=jm;)t|=r&1,r>>=1;return r+t}function qm(r,t,e,i){var a=t+1;if(a===e)return 1;if(i(r[a++],r[t])<0){for(;a=0;)a++;return a-t}function xM(r,t,e){for(e--;t>>1,a(n,r[l])<0?s=l:o=l+1;var u=i-o;switch(u){case 3:r[o+3]=r[o+2];case 2:r[o+2]=r[o+1];case 1:r[o+1]=r[o];break;default:for(;u>0;)r[o+u]=r[o+u-1],u--}r[o]=n}}function Uh(r,t,e,i,a,n){var o=0,s=0,l=1;if(n(r,t[e+a])>0){for(s=i-a;l0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=a,l+=a}else{for(s=a+1;ls&&(l=s);var u=o;o=a-l,l=a-u}for(o++;o>>1);n(r,t[e+f])>0?o=f+1:l=f}return l}function Vh(r,t,e,i,a,n){var o=0,s=0,l=1;if(n(r,t[e+a])<0){for(s=a+1;ls&&(l=s);var u=o;o=a-l,l=a-u}else{for(s=i-a;l=0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=a,l+=a}for(o++;o>>1);n(r,t[e+f])<0?l=f:o=f+1}return l}function SM(r,t){var e=Oo,i,a,n=0,o=[];i=[],a=[];function s(c,v){i[n]=c,a[n]=v,n+=1}function l(){for(;n>1;){var c=n-2;if(c>=1&&a[c-1]<=a[c]+a[c+1]||c>=2&&a[c-2]<=a[c]+a[c-1])a[c-1]a[c+1])break;f(c)}}function u(){for(;n>1;){var c=n-2;c>0&&a[c-1]=Oo||T>=Oo);if(M)break;w<0&&(w=0),w+=2}if(e=w,e<1&&(e=1),v===1){for(g=0;g=0;g--)r[S+g]=r[w+g];r[x]=o[_];return}for(var T=e;;){var M=0,D=0,A=!1;do if(t(o[_],r[y])<0){if(r[x--]=r[y--],M++,D=0,--v===0){A=!0;break}}else if(r[x--]=o[_--],D++,M=0,--d===1){A=!0;break}while((M|D)=0;g--)r[S+g]=r[w+g];if(v===0){A=!0;break}}if(r[x--]=o[_--],--d===1){A=!0;break}if(D=d-Uh(r[y],o,0,d,d-1,t),D!==0){for(x-=D,_-=D,d-=D,S=x+1,w=_+1,g=0;g=Oo||D>=Oo);if(A)break;T<0&&(T=0),T+=2}if(e=T,e<1&&(e=1),d===1){for(x-=v,y-=v,S=x+1,w=y+1,g=v-1;g>=0;g--)r[S+g]=r[w+g];r[x]=o[_]}else{if(d===0)throw new Error;for(w=x-(d-1),g=0;gs&&(l=s),Km(r,e,e+l,e+n,t),n=l}o.pushRun(e,n),o.mergeRuns(),a-=n,e+=n}while(a!==0);o.forceMergeRuns()}}var Ht=1,sa=2,gi=4;var Qm=!1;function Bh(){Qm||(Qm=!0,console.warn("z / z2 / zlevel of displayable is invalid, which may cause unexpected errors"))}function $m(r,t){return r.zlevel===t.zlevel?r.z===t.z?r.z2-t.z2:r.z-t.z:r.zlevel-t.zlevel}var bM=(function(){function r(){this._roots=[],this._displayList=[],this._displayListLen=0,this.displayableSortFunc=$m}return r.prototype.traverse=function(t,e){for(var i=0;i0&&(f.__clipPaths=[]),isNaN(f.z)&&(Bh(),f.z=0),isNaN(f.z2)&&(Bh(),f.z2=0),isNaN(f.zlevel)&&(Bh(),f.zlevel=0),this._displayList[this._displayListLen++]=f}var h=t.getDecalElement&&t.getDecalElement();h&&this._updateAndAddDisplayable(h,e,i);var p=t.getTextGuideLine();p&&this._updateAndAddDisplayable(p,e,i);var c=t.getTextContent();c&&this._updateAndAddDisplayable(c,e,i)}},r.prototype.addRoot=function(t){t.__zr&&t.__zr.storage===this||this._roots.push(t)},r.prototype.delRoot=function(t){if(t instanceof Array){for(var e=0,i=t.length;e=0&&this._roots.splice(a,1)},r.prototype.delAllRoots=function(){this._roots=[],this._displayList=[],this._displayListLen=0},r.prototype.getRoots=function(){return this._roots},r.prototype.dispose=function(){this._displayList=null,this._roots=null},r})(),Jm=bM;var tg;tg=j.hasGlobalWindow&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(r){return setTimeout(r,16)};var No=tg;var Al={linear:function(r){return r},quadraticIn:function(r){return r*r},quadraticOut:function(r){return r*(2-r)},quadraticInOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},cubicIn:function(r){return r*r*r},cubicOut:function(r){return--r*r*r+1},cubicInOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},quarticIn:function(r){return r*r*r*r},quarticOut:function(r){return 1- --r*r*r*r},quarticInOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)},quinticIn:function(r){return r*r*r*r*r},quinticOut:function(r){return--r*r*r*r*r+1},quinticInOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)},sinusoidalIn:function(r){return 1-Math.cos(r*Math.PI/2)},sinusoidalOut:function(r){return Math.sin(r*Math.PI/2)},sinusoidalInOut:function(r){return .5*(1-Math.cos(Math.PI*r))},exponentialIn:function(r){return r===0?0:Math.pow(1024,r-1)},exponentialOut:function(r){return r===1?1:1-Math.pow(2,-10*r)},exponentialInOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)},circularIn:function(r){return 1-Math.sqrt(1-r*r)},circularOut:function(r){return Math.sqrt(1- --r*r)},circularInOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)},elasticIn:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),-(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)))},elasticOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*r)*Math.sin((r-t)*(2*Math.PI)/i)+1)},elasticInOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),(r*=2)<1?-.5*(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)):e*Math.pow(2,-10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)*.5+1)},backIn:function(r){var t=1.70158;return r*r*((t+1)*r-t)},backOut:function(r){var t=1.70158;return--r*r*((t+1)*r+t)+1},backInOut:function(r){var t=2.5949095;return(r*=2)<1?.5*(r*r*((t+1)*r-t)):.5*((r-=2)*r*((t+1)*r+t)+2)},bounceIn:function(r){return 1-Al.bounceOut(1-r)},bounceOut:function(r){return r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-=.5454545454545454)*r+.75:r<.9090909090909091?7.5625*(r-=.8181818181818182)*r+.9375:7.5625*(r-=.9545454545454546)*r+.984375},bounceInOut:function(r){return r<.5?Al.bounceIn(r*2)*.5:Al.bounceOut(r*2-1)*.5+.5}},El=Al;var Ll=Math.pow,_i=Math.sqrt,Pl=1e-8,rg=1e-4,eg=_i(3),Il=1/3,Er=qr(),je=qr(),_n=qr();function yi(r){return r>-Pl&&rPl||r<-Pl}function At(r,t,e,i,a){var n=1-a;return n*n*(n*r+3*a*t)+a*a*(a*i+3*n*e)}function Fh(r,t,e,i,a){var n=1-a;return 3*(((t-r)*n+2*(e-t)*a)*n+(i-e)*a*a)}function la(r,t,e,i,a,n){var o=i+3*(t-e)-r,s=3*(e-t*2+r),l=3*(t-r),u=r-a,f=s*s-3*o*l,h=s*l-9*o*u,p=l*l-3*s*u,c=0;if(yi(f)&&yi(h))if(yi(s))n[0]=0;else{var v=-l/s;v>=0&&v<=1&&(n[c++]=v)}else{var m=h*h-4*f*p;if(yi(m)){var d=h/f,v=-s/o+d,g=-d/2;v>=0&&v<=1&&(n[c++]=v),g>=0&&g<=1&&(n[c++]=g)}else if(m>0){var y=_i(m),_=f*s+1.5*o*(-h+y),x=f*s+1.5*o*(-h-y);_<0?_=-Ll(-_,Il):_=Ll(_,Il),x<0?x=-Ll(-x,Il):x=Ll(x,Il);var v=(-s-(_+x))/(3*o);v>=0&&v<=1&&(n[c++]=v)}else{var w=(2*f*s-3*o*h)/(2*_i(f*f*f)),S=Math.acos(w)/3,T=_i(f),M=Math.cos(S),v=(-s-2*T*M)/(3*o),g=(-s+T*(M+eg*Math.sin(S)))/(3*o),D=(-s+T*(M-eg*Math.sin(S)))/(3*o);v>=0&&v<=1&&(n[c++]=v),g>=0&&g<=1&&(n[c++]=g),D>=0&&D<=1&&(n[c++]=D)}}return c}function Rl(r,t,e,i,a){var n=6*e-12*t+6*r,o=9*t+3*i-3*r-9*e,s=3*t-3*r,l=0;if(yi(o)){if(ig(n)){var u=-s/n;u>=0&&u<=1&&(a[l++]=u)}}else{var f=n*n-4*o*s;if(yi(f))a[0]=-n/(2*o);else if(f>0){var h=_i(f),u=(-n+h)/(2*o),p=(-n-h)/(2*o);u>=0&&u<=1&&(a[l++]=u),p>=0&&p<=1&&(a[l++]=p)}}return l}function xn(r,t,e,i,a,n){var o=(t-r)*a+r,s=(e-t)*a+t,l=(i-e)*a+e,u=(s-o)*a+o,f=(l-s)*a+s,h=(f-u)*a+u;n[0]=r,n[1]=o,n[2]=u,n[3]=h,n[4]=h,n[5]=f,n[6]=l,n[7]=i}function ag(r,t,e,i,a,n,o,s,l,u,f){var h,p=.005,c=1/0,v,m,d,g;Er[0]=l,Er[1]=u;for(var y=0;y<1;y+=.05)je[0]=At(r,e,a,o,y),je[1]=At(t,i,n,s,y),d=mi(Er,je),d=0&&d=0&&u<=1&&(a[l++]=u)}}else{var f=o*o-4*n*s;if(yi(f)){var u=-o/(2*n);u>=0&&u<=1&&(a[l++]=u)}else if(f>0){var h=_i(f),u=(-o+h)/(2*n),p=(-o-h)/(2*n);u>=0&&u<=1&&(a[l++]=u),p>=0&&p<=1&&(a[l++]=p)}}return l}function Ol(r,t,e){var i=r+e-2*t;return i===0?.5:(r-t)/i}function Sn(r,t,e,i,a){var n=(t-r)*i+r,o=(e-t)*i+t,s=(o-n)*i+n;a[0]=r,a[1]=n,a[2]=s,a[3]=s,a[4]=o,a[5]=e}function sg(r,t,e,i,a,n,o,s,l){var u,f=.005,h=1/0;Er[0]=o,Er[1]=s;for(var p=0;p<1;p+=.05){je[0]=Yt(r,e,a,p),je[1]=Yt(t,i,n,p);var c=mi(Er,je);c=0&&c=1?1:la(0,i,n,1,l,s)&&At(0,a,o,1,s[0])}}}var TM=(function(){function r(t){this._inited=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=t.life||1e3,this._delay=t.delay||0,this.loop=t.loop||!1,this.onframe=t.onframe||Dt,this.ondestroy=t.ondestroy||Dt,this.onrestart=t.onrestart||Dt,t.easing&&this.setEasing(t.easing)}return r.prototype.step=function(t,e){if(this._inited||(this._startTime=t+this._delay,this._inited=!0),this._paused){this._pausedTime+=e;return}var i=this._life,a=t-this._startTime-this._pausedTime,n=a/i;n<0&&(n=0),n=Math.min(n,1);var o=this.easingFunc,s=o?o(n):n;if(this.onframe(s),n===1)if(this.loop){var l=a%i;this._startTime=t-l,this._pausedTime=0,this.onrestart()}else return!0;return!1},r.prototype.pause=function(){this._paused=!0},r.prototype.resume=function(){this._paused=!1},r.prototype.setEasing=function(t){this.easing=t,this.easingFunc=G(t)?t:El[t]||Nl(t)},r})(),ug=TM;var Uo={};ze(Uo,{fastLerp:()=>wn,fastMapToColor:()=>LM,lerp:()=>kl,lift:()=>qh,liftColor:()=>Ul,lum:()=>fa,mapToColor:()=>IM,modifyAlpha:()=>Kh,modifyHSL:()=>ko,parse:()=>re,random:()=>PM,stringify:()=>De,toHex:()=>EM});var fg=(function(){function r(t){this.value=t}return r})();var MM=(function(){function r(){this._len=0}return r.prototype.insert=function(t){var e=new fg(t);return this.insertEntry(e),e},r.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t):this.head=this.tail=t,this._len++},r.prototype.remove=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},r.prototype.len=function(){return this._len},r.prototype.clear=function(){this.head=this.tail=null,this._len=0},r})();var CM=(function(){function r(t){this._list=new MM,this._maxSize=10,this._map={},this._maxSize=t}return r.prototype.put=function(t,e){var i=this._list,a=this._map,n=null;if(a[t]==null){var o=i.len(),s=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var l=i.head;i.remove(l),delete a[l.key],n=l.value,this._lastRemovedEntry=l}s?s.value=e:s=new fg(e),s.key=t,i.insertEntry(s),a[t]=s}return n},r.prototype.get=function(t){var e=this._map[t],i=this._list;if(e!=null)return e!==i.tail&&(i.remove(e),i.insertEntry(e)),e.value},r.prototype.clear=function(){this._list.clear(),this._map={}},r.prototype.len=function(){return this._list.len()},r})(),$r=CM;var hg={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function mr(r){return r=Math.round(r),r<0?0:r>255?255:r}function DM(r){return r=Math.round(r),r<0?0:r>360?360:r}function zo(r){return r<0?0:r>1?1:r}function Wh(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?mr(parseFloat(t)/100*255):mr(parseInt(t,10))}function ua(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?zo(parseFloat(t)/100):zo(parseFloat(t))}function Yh(r,t,e){return e<0?e+=1:e>1&&(e-=1),e*6<1?r+(t-r)*e*6:e*2<1?t:e*3<2?r+(t-r)*(2/3-e)*6:r}function xi(r,t,e){return r+(t-r)*e}function Qe(r,t,e,i,a){return r[0]=t,r[1]=e,r[2]=i,r[3]=a,r}function Zh(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r}var pg=new $r(20),zl=null;function bn(r,t){zl&&Zh(zl,t),zl=pg.put(r,zl||t.slice())}function re(r,t){if(r){t=t||[];var e=pg.get(r);if(e)return Zh(t,e);r=r+"";var i=r.replace(/ /g,"").toLowerCase();if(i in hg)return Zh(t,hg[i]),bn(r,t),t;var a=i.length;if(i.charAt(0)==="#"){if(a===4||a===5){var n=parseInt(i.slice(1,4),16);if(!(n>=0&&n<=4095)){Qe(t,0,0,0,1);return}return Qe(t,(n&3840)>>4|(n&3840)>>8,n&240|(n&240)>>4,n&15|(n&15)<<4,a===5?parseInt(i.slice(4),16)/15:1),bn(r,t),t}else if(a===7||a===9){var n=parseInt(i.slice(1,7),16);if(!(n>=0&&n<=16777215)){Qe(t,0,0,0,1);return}return Qe(t,(n&16711680)>>16,(n&65280)>>8,n&255,a===9?parseInt(i.slice(7),16)/255:1),bn(r,t),t}return}var o=i.indexOf("("),s=i.indexOf(")");if(o!==-1&&s+1===a){var l=i.substr(0,o),u=i.substr(o+1,s-(o+1)).split(","),f=1;switch(l){case"rgba":if(u.length!==4)return u.length===3?Qe(t,+u[0],+u[1],+u[2],1):Qe(t,0,0,0,1);f=ua(u.pop());case"rgb":if(u.length>=3)return Qe(t,Wh(u[0]),Wh(u[1]),Wh(u[2]),u.length===3?f:ua(u[3])),bn(r,t),t;Qe(t,0,0,0,1);return;case"hsla":if(u.length!==4){Qe(t,0,0,0,1);return}return u[3]=ua(u[3]),Xh(u,t),bn(r,t),t;case"hsl":if(u.length!==3){Qe(t,0,0,0,1);return}return Xh(u,t),bn(r,t),t;default:return}}Qe(t,0,0,0,1)}}function Xh(r,t){var e=(parseFloat(r[0])%360+360)%360/360,i=ua(r[1]),a=ua(r[2]),n=a<=.5?a*(i+1):a+i-a*i,o=a*2-n;return t=t||[],Qe(t,mr(Yh(o,n,e+1/3)*255),mr(Yh(o,n,e)*255),mr(Yh(o,n,e-1/3)*255),1),r.length===4&&(t[3]=r[3]),t}function AM(r){if(r){var t=r[0]/255,e=r[1]/255,i=r[2]/255,a=Math.min(t,e,i),n=Math.max(t,e,i),o=n-a,s=(n+a)/2,l,u;if(o===0)l=0,u=0;else{s<.5?u=o/(n+a):u=o/(2-n-a);var f=((n-t)/6+o/2)/o,h=((n-e)/6+o/2)/o,p=((n-i)/6+o/2)/o;t===n?l=p-h:e===n?l=1/3+f-p:i===n&&(l=2/3+h-f),l<0&&(l+=1),l>1&&(l-=1)}var c=[l*360,u,s];return r[3]!=null&&c.push(r[3]),c}}function qh(r,t){var e=re(r);if(e){for(var i=0;i<3;i++)t<0?e[i]=e[i]*(1-t)|0:e[i]=(255-e[i])*t+e[i]|0,e[i]>255?e[i]=255:e[i]<0&&(e[i]=0);return De(e,e.length===4?"rgba":"rgb")}}function EM(r){var t=re(r);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)}function wn(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){e=e||[];var i=r*(t.length-1),a=Math.floor(i),n=Math.ceil(i),o=t[a],s=t[n],l=i-a;return e[0]=mr(xi(o[0],s[0],l)),e[1]=mr(xi(o[1],s[1],l)),e[2]=mr(xi(o[2],s[2],l)),e[3]=zo(xi(o[3],s[3],l)),e}}var LM=wn;function kl(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){var i=r*(t.length-1),a=Math.floor(i),n=Math.ceil(i),o=re(t[a]),s=re(t[n]),l=i-a,u=De([mr(xi(o[0],s[0],l)),mr(xi(o[1],s[1],l)),mr(xi(o[2],s[2],l)),zo(xi(o[3],s[3],l))],"rgba");return e?{color:u,leftIndex:a,rightIndex:n,value:i}:u}}var IM=kl;function ko(r,t,e,i){var a=re(r);if(r)return a=AM(a),t!=null&&(a[0]=DM(t)),e!=null&&(a[1]=ua(e)),i!=null&&(a[2]=ua(i)),De(Xh(a),"rgba")}function Kh(r,t){var e=re(r);if(e&&t!=null)return e[3]=zo(t),De(e,"rgba")}function De(r,t){if(!(!r||!r.length)){var e=r[0]+","+r[1]+","+r[2];return(t==="rgba"||t==="hsva"||t==="hsla")&&(e+=","+r[3]),t+"("+e+")"}}function fa(r,t){var e=re(r);return e?(.299*e[0]+.587*e[1]+.114*e[2])*e[3]/255+(1-e[3])*t:0}function PM(){return De([Math.round(Math.random()*255),Math.round(Math.random()*255),Math.round(Math.random()*255)],"rgb")}var cg=new $r(100);function Ul(r){if(U(r)){var t=cg.get(r);return t||(t=qh(r,-.1),cg.put(r,t)),t}else if(Zr(r)){var e=N({},r);return e.colorStops=k(r.colorStops,function(i){return{offset:i.offset,color:qh(i.color,-.1)}}),e}return r}function vg(r){return r.type==="linear"}function dg(r){return r.type==="radial"}var H2=(function(){return j.hasGlobalWindow&&G(window.btoa)?function(r){return window.btoa(unescape(encodeURIComponent(r)))}:typeof Buffer<"u"?function(r){return Buffer.from(r).toString("base64")}:function(r){return null}})();var Qh=Array.prototype.slice;function Jr(r,t,e){return(t-r)*e+r}function jh(r,t,e,i){for(var a=t.length,n=0;ni?t:r,n=Math.min(e,i),o=a[n-1]||{color:[0,0,0,0],offset:0},s=n;so;if(s)i.length=o;else for(var l=n;l=1},r.prototype.getAdditiveTrack=function(){return this._additiveTrack},r.prototype.addKeyframe=function(t,e,i){this._needsSort=!0;var a=this.keyframes,n=a.length,o=!1,s=gg,l=e;if(Ot(e)){var u=zM(e);s=u,(u===1&&!nt(e[0])||u===2&&!nt(e[0][0]))&&(o=!0)}else if(nt(e)&&!Ji(e))s=Bl;else if(U(e))if(!isNaN(+e))s=Bl;else{var f=re(e);f&&(l=f,s=Bo)}else if(Zr(e)){var h=N({},l);h.colorStops=k(e.colorStops,function(c){return{offset:c.offset,color:re(c.color)}}),vg(e)?s=$h:dg(e)&&(s=Jh),l=h}n===0?this.valType=s:(s!==this.valType||s===gg)&&(o=!0),this.discrete=this.discrete||o;var p={time:t,value:l,rawValue:e,percent:0};return i&&(p.easing=i,p.easingFunc=G(i)?i:El[i]||Nl(i)),a.push(p),p},r.prototype.prepare=function(t,e){var i=this.keyframes;this._needsSort&&i.sort(function(m,d){return m.time-d.time});for(var a=this.valType,n=i.length,o=i[n-1],s=this.discrete,l=Fl(a),u=yg(a),f=0;f=0&&!(o[f].percent<=e);f--);f=p(f,s-2)}else{for(f=h;fe);f++);f=p(f-1,s-2)}v=o[f+1],c=o[f]}if(c&&v){this._lastFr=f,this._lastFrP=e;var d=v.percent-c.percent,g=d===0?1:p((e-c.percent)/d,1);v.easingFunc&&(g=v.easingFunc(g));var y=i?this._additiveValue:u?Vo:t[l];if((Fl(n)||u)&&!y&&(y=this._additiveValue=[]),this.discrete)t[l]=g<1?c.rawValue:v.rawValue;else if(Fl(n))n===Gl?jh(y,c[a],v[a],g):RM(y,c[a],v[a],g);else if(yg(n)){var _=c[a],x=v[a],w=n===$h;t[l]={type:w?"linear":"radial",x:Jr(_.x,x.x,g),y:Jr(_.y,x.y,g),colorStops:k(_.colorStops,function(T,M){var D=x.colorStops[M];return{offset:Jr(T.offset,D.offset,g),color:Hl(jh([],T.color,D.color,g))}}),global:x.global},w?(t[l].x2=Jr(_.x2,x.x2,g),t[l].y2=Jr(_.y2,x.y2,g)):t[l].r=Jr(_.r,x.r,g)}else if(u)jh(y,c[a],v[a],g),i||(t[l]=Hl(y));else{var S=Jr(c[a],v[a],g);i?this._additiveValue=S:t[l]=S}i&&this._addToTarget(t)}}},r.prototype._addToTarget=function(t){var e=this.valType,i=this.propName,a=this._additiveValue;e===Bl?t[i]=t[i]+a:e===Bo?(re(t[i],Vo),Vl(Vo,Vo,a,1),t[i]=Hl(Vo)):e===Gl?Vl(t[i],t[i],a,1):e===_g&&mg(t[i],t[i],a,1)},r})(),UM=(function(){function r(t,e,i,a){if(this._tracks={},this._trackKeys=[],this._maxTime=0,this._started=0,this._clip=null,this._target=t,this._loop=e,e&&a){$i("Can' use additive animation on looped animation.");return}this._additiveAnimators=a,this._allowDiscrete=i}return r.prototype.getMaxTime=function(){return this._maxTime},r.prototype.getDelay=function(){return this._delay},r.prototype.getLoop=function(){return this._loop},r.prototype.getTarget=function(){return this._target},r.prototype.changeTarget=function(t){this._target=t},r.prototype.when=function(t,e,i){return this.whenWithKeys(t,e,lt(e),i)},r.prototype.whenWithKeys=function(t,e,i,a){for(var n=this._tracks,o=0;o0&&l.addKeyframe(0,Fo(u),a),this._trackKeys.push(s)}l.addKeyframe(t,Fo(e[s]),a)}return this._maxTime=Math.max(this._maxTime,t),this},r.prototype.pause=function(){this._clip.pause(),this._paused=!0},r.prototype.resume=function(){this._clip.resume(),this._paused=!1},r.prototype.isPaused=function(){return!!this._paused},r.prototype.duration=function(t){return this._maxTime=t,this._force=!0,this},r.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var t=this._doneCbs;if(t)for(var e=t.length,i=0;i0)){this._started=1;for(var e=this,i=[],a=this._maxTime||0,n=0;n1){var s=o.pop();n.addKeyframe(s.time,t[a]),n.prepare(this._maxTime,n.getAdditiveTrack())}}}},r})(),Ho=UM;function ha(){return new Date().getTime()}var VM=(function(r){I(t,r);function t(e){var i=r.call(this)||this;return i._running=!1,i._time=0,i._pausedTime=0,i._pauseStart=0,i._paused=!1,e=e||{},i.stage=e.stage||{},i}return t.prototype.addClip=function(e){e.animation&&this.removeClip(e),this._head?(this._tail.next=e,e.prev=this._tail,e.next=null,this._tail=e):this._head=this._tail=e,e.animation=this},t.prototype.addAnimator=function(e){e.animation=this;var i=e.getClip();i&&this.addClip(i)},t.prototype.removeClip=function(e){if(e.animation){var i=e.prev,a=e.next;i?i.next=a:this._head=a,a?a.prev=i:this._tail=i,e.next=e.prev=e.animation=null}},t.prototype.removeAnimator=function(e){var i=e.getClip();i&&this.removeClip(i),e.animation=null},t.prototype.update=function(e){for(var i=ha()-this._pausedTime,a=i-this._time,n=this._head;n;){var o=n.next,s=n.step(i,a);s&&(n.ondestroy(),this.removeClip(n)),n=o}this._time=i,e||(this.trigger("frame",a),this.stage.update&&this.stage.update())},t.prototype._startLoop=function(){var e=this;this._running=!0;function i(){e._running&&(No(i),!e._paused&&e.update())}No(i)},t.prototype.start=function(){this._running||(this._time=ha(),this._pausedTime=0,this._startLoop())},t.prototype.stop=function(){this._running=!1},t.prototype.pause=function(){this._paused||(this._pauseStart=ha(),this._paused=!0)},t.prototype.resume=function(){this._paused&&(this._pausedTime+=ha()-this._pauseStart,this._paused=!1)},t.prototype.clear=function(){for(var e=this._head;e;){var i=e.next;e.prev=e.next=e.animation=null,e=i}this._head=this._tail=null},t.prototype.isFinished=function(){return this._head==null},t.prototype.animate=function(e,i){i=i||{},this.start();var a=new Ho(e,i.loop);return this.addAnimator(a),a},t})(Wt),xg=VM;var BM=300,tc=j.domSupported,ec=(function(){var r=["click","dblclick","mousewheel","wheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],t=["touchstart","touchend","touchmove"],e={pointerdown:1,pointerup:1,pointermove:1,pointerout:1},i=k(r,function(a){var n=a.replace("mouse","pointer");return e.hasOwnProperty(n)?n:a});return{mouse:r,touch:t,pointer:i}})(),Sg={mouse:["mousemove","mouseup"],pointer:["pointermove","pointerup"]},bg=!1;function ac(r){var t=r.pointerType;return t==="pen"||t==="touch"}function FM(r){r.touching=!0,r.touchTimer!=null&&(clearTimeout(r.touchTimer),r.touchTimer=null),r.touchTimer=setTimeout(function(){r.touching=!1,r.touchTimer=null},700)}function rc(r){r&&(r.zrByTouch=!0)}function HM(r,t){return Me(r.dom,new GM(r,t),!0)}function Tg(r,t){for(var e=t,i=!1;e&&e.nodeType!==9&&!(i=e.domBelongToZr||e!==t&&e===r.painterRoot);)e=e.parentNode;return i}var GM=(function(){function r(t,e){this.stopPropagation=Dt,this.stopImmediatePropagation=Dt,this.preventDefault=Dt,this.type=e.type,this.target=this.currentTarget=t.dom,this.pointerType=e.pointerType,this.clientX=e.clientX,this.clientY=e.clientY}return r})(),gr={mousedown:function(r){r=Me(this.dom,r),this.__mayPointerCapture=[r.zrX,r.zrY],this.trigger("mousedown",r)},mousemove:function(r){r=Me(this.dom,r);var t=this.__mayPointerCapture;t&&(r.zrX!==t[0]||r.zrY!==t[1])&&this.__togglePointerCapture(!0),this.trigger("mousemove",r)},mouseup:function(r){r=Me(this.dom,r),this.__togglePointerCapture(!1),this.trigger("mouseup",r)},mouseout:function(r){r=Me(this.dom,r);var t=r.toElement||r.relatedTarget;Tg(this,t)||(this.__pointerCapturing&&(r.zrEventControl="no_globalout"),this.trigger("mouseout",r))},wheel:function(r){bg=!0,r=Me(this.dom,r),this.trigger("mousewheel",r)},mousewheel:function(r){bg||(r=Me(this.dom,r),this.trigger("mousewheel",r))},touchstart:function(r){r=Me(this.dom,r),rc(r),this.__lastTouchMoment=new Date,this.handler.processGesture(r,"start"),gr.mousemove.call(this,r),gr.mousedown.call(this,r)},touchmove:function(r){r=Me(this.dom,r),rc(r),this.handler.processGesture(r,"change"),gr.mousemove.call(this,r)},touchend:function(r){r=Me(this.dom,r),rc(r),this.handler.processGesture(r,"end"),gr.mouseup.call(this,r),+new Date-+this.__lastTouchMomentEg||r<-Eg}var va=[],Tn=[],oc=dr(),sc=Math.abs,XM=(function(){function r(){}return r.prototype.getLocalTransform=function(t){return r.getLocalTransform(this,t)},r.prototype.setPosition=function(t){this.x=t[0],this.y=t[1]},r.prototype.setScale=function(t){this.scaleX=t[0],this.scaleY=t[1]},r.prototype.setSkew=function(t){this.skewX=t[0],this.skewY=t[1]},r.prototype.setOrigin=function(t){this.originX=t[0],this.originY=t[1]},r.prototype.needLocalTransform=function(){return pa(this.rotation)||pa(this.x)||pa(this.y)||pa(this.scaleX-1)||pa(this.scaleY-1)||pa(this.skewX)||pa(this.skewY)},r.prototype.updateTransform=function(){var t=this.parent&&this.parent.transform,e=this.needLocalTransform(),i=this.transform;if(!(e||t)){i&&(Ag(i),this.invTransform=null);return}i=i||dr(),e?this.getLocalTransform(i):Ag(i),t&&(e?Ke(i,t,i):Ml(i,t)),this.transform=i,this._resolveGlobalScaleRatio(i)},r.prototype._resolveGlobalScaleRatio=function(t){var e=this.globalScaleRatio;if(e!=null&&e!==1){this.getGlobalScale(va);var i=va[0]<0?-1:1,a=va[1]<0?-1:1,n=((va[0]-i)*e+i)/va[0]||0,o=((va[1]-a)*e+a)/va[1]||0;t[0]*=n,t[1]*=n,t[2]*=o,t[3]*=o}this.invTransform=this.invTransform||dr(),jr(this.invTransform,t)},r.prototype.getComputedTransform=function(){for(var t=this,e=[];t;)e.push(t),t=t.parent;for(;t=e.pop();)t.updateTransform();return this.transform},r.prototype.setLocalTransform=function(t){if(t){var e=t[0]*t[0]+t[1]*t[1],i=t[2]*t[2]+t[3]*t[3],a=Math.atan2(t[1],t[0]),n=Math.PI/2+a-Math.atan2(t[3],t[2]);i=Math.sqrt(i)*Math.cos(n),e=Math.sqrt(e),this.skewX=n,this.skewY=0,this.rotation=-a,this.x=+t[4],this.y=+t[5],this.scaleX=e,this.scaleY=i,this.originX=0,this.originY=0}},r.prototype.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(t.invTransform=t.invTransform||dr(),Ke(Tn,t.invTransform,e),e=Tn);var i=this.originX,a=this.originY;(i||a)&&(oc[4]=i,oc[5]=a,Ke(Tn,e,oc),Tn[4]-=i,Tn[5]-=a,e=Tn),this.setLocalTransform(e)}},r.prototype.getGlobalScale=function(t){var e=this.transform;return t=t||[],e?(t[0]=Math.sqrt(e[0]*e[0]+e[1]*e[1]),t[1]=Math.sqrt(e[2]*e[2]+e[3]*e[3]),e[0]<0&&(t[0]=-t[0]),e[3]<0&&(t[1]=-t[1]),t):(t[0]=1,t[1]=1,t)},r.prototype.transformCoordToLocal=function(t,e){var i=[t,e],a=this.invTransform;return a&&Nt(i,i,a),i},r.prototype.transformCoordToGlobal=function(t,e){var i=[t,e],a=this.transform;return a&&Nt(i,i,a),i},r.prototype.getLineScale=function(){var t=this.transform;return t&&sc(t[0]-1)>1e-10&&sc(t[3]-1)>1e-10?Math.sqrt(sc(t[0]*t[3]-t[2]*t[1])):1},r.prototype.copyTransform=function(t){qM(this,t)},r.getLocalTransform=function(t,e){e=e||[];var i=t.originX||0,a=t.originY||0,n=t.scaleX,o=t.scaleY,s=t.anchorX,l=t.anchorY,u=t.rotation||0,f=t.x,h=t.y,p=t.skewX?Math.tan(t.skewX):0,c=t.skewY?Math.tan(-t.skewY):0;if(i||a||s||l){var v=i+s,m=a+l;e[4]=-v*n-p*m*o,e[5]=-m*o-c*v*n}else e[4]=e[5]=0;return e[0]=n,e[3]=o,e[1]=c*n,e[2]=p*o,u&&ea(e,e,u),e[4]+=i+f,e[5]+=a+h,e},r.initDefaultProps=(function(){var t=r.prototype;t.scaleX=t.scaleY=t.globalScaleRatio=1,t.x=t.y=t.originX=t.originY=t.skewX=t.skewY=t.rotation=t.anchorX=t.anchorY=0})(),r})(),da=["x","y","originX","originY","anchorX","anchorY","rotation","scaleX","scaleY","skewX","skewY"];function qM(r,t){for(var e=0;e=0?parseFloat(r)/100*t:parseFloat(r):r}function ga(r,t,e){var i=t.position||"inside",a=t.distance!=null?t.distance:5,n=e.height,o=e.width,s=n/2,l=e.x,u=e.y,f="left",h="top";if(i instanceof Array)l+=me(i[0],e.width),u+=me(i[1],e.height),f=null,h=null;else switch(i){case"left":l-=a,u+=s,f="right",h="middle";break;case"right":l+=a+o,u+=s,h="middle";break;case"top":l+=o/2,u-=a,f="center",h="bottom";break;case"bottom":l+=o/2,u+=n+a,f="center";break;case"inside":l+=o/2,u+=s,f="center",h="middle";break;case"insideLeft":l+=a,u+=s,h="middle";break;case"insideRight":l+=o-a,u+=s,f="right",h="middle";break;case"insideTop":l+=o/2,u+=a,f="center";break;case"insideBottom":l+=o/2,u+=n-a,f="center",h="bottom";break;case"insideTopLeft":l+=a,u+=a;break;case"insideTopRight":l+=o-a,u+=a,f="right";break;case"insideBottomLeft":l+=a,u+=n-a,h="bottom";break;case"insideBottomRight":l+=o-a,u+=n-a,f="right",h="bottom";break}return r=r||{},r.x=l,r.y=u,r.align=f,r.verticalAlign=h,r}var lc="__zr_normal__",uc=da.concat(["ignore"]),KM=fe(da,function(r,t){return r[t]=!0,r},{ignore:!1}),Dn={},jM=new J(0,0,0,0),cc=(function(){function r(t){this.id=wo(),this.animators=[],this.currentStates=[],this.states={},this._init(t)}return r.prototype._init=function(t){this.attr(t)},r.prototype.drift=function(t,e,i){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0;break}var a=this.transform;a||(a=this.transform=[1,0,0,1,0,0]),a[4]+=t,a[5]+=e,this.decomposeTransform(),this.markRedraw()},r.prototype.beforeUpdate=function(){},r.prototype.afterUpdate=function(){},r.prototype.update=function(){this.updateTransform(),this.__dirty&&this.updateInnerText()},r.prototype.updateInnerText=function(t){var e=this._textContent;if(e&&(!e.ignore||t)){this.textConfig||(this.textConfig={});var i=this.textConfig,a=i.local,n=e.innerTransformable,o=void 0,s=void 0,l=!1;n.parent=a?this:null;var u=!1;if(n.copyTransform(e),i.position!=null){var f=jM;i.layoutRect?f.copy(i.layoutRect):f.copy(this.getBoundingRect()),a||f.applyTransform(this.transform),this.calculateTextPosition?this.calculateTextPosition(Dn,i,f):ga(Dn,i,f),n.x=Dn.x,n.y=Dn.y,o=Dn.align,s=Dn.verticalAlign;var h=i.origin;if(h&&i.rotation!=null){var p=void 0,c=void 0;h==="center"?(p=f.width*.5,c=f.height*.5):(p=me(h[0],f.width),c=me(h[1],f.height)),u=!0,n.originX=-n.x+p+(a?0:f.x),n.originY=-n.y+c+(a?0:f.y)}}i.rotation!=null&&(n.rotation=i.rotation);var v=i.offset;v&&(n.x+=v[0],n.y+=v[1],u||(n.originX=-v[0],n.originY=-v[1]));var m=i.inside==null?typeof i.position=="string"&&i.position.indexOf("inside")>=0:i.inside,d=this._innerTextDefaultStyle||(this._innerTextDefaultStyle={}),g=void 0,y=void 0,_=void 0;m&&this.canBeInsideText()?(g=i.insideFill,y=i.insideStroke,(g==null||g==="auto")&&(g=this.getInsideTextFill()),(y==null||y==="auto")&&(y=this.getInsideTextStroke(g),_=!0)):(g=i.outsideFill,y=i.outsideStroke,(g==null||g==="auto")&&(g=this.getOutsideFill()),(y==null||y==="auto")&&(y=this.getOutsideStroke(g),_=!0)),g=g||"#000",(g!==d.fill||y!==d.stroke||_!==d.autoStroke||o!==d.align||s!==d.verticalAlign)&&(l=!0,d.fill=g,d.stroke=y,d.autoStroke=_,d.align=o,d.verticalAlign=s,e.setDefaultTextStyle(d)),e.__dirty|=Ht,l&&e.dirtyStyle(!0)}},r.prototype.canBeInsideText=function(){return!0},r.prototype.getInsideTextFill=function(){return"#fff"},r.prototype.getInsideTextStroke=function(t){return"#000"},r.prototype.getOutsideFill=function(){return this.__zr&&this.__zr.isDarkMode()?Yo:Wo},r.prototype.getOutsideStroke=function(t){var e=this.__zr&&this.__zr.getBackgroundColor(),i=typeof e=="string"&&re(e);i||(i=[255,255,255,1]);for(var a=i[3],n=this.__zr.isDarkMode(),o=0;o<3;o++)i[o]=i[o]*a+(n?0:255)*(1-a);return i[3]=1,De(i,"rgba")},r.prototype.traverse=function(t,e){},r.prototype.attrKV=function(t,e){t==="textConfig"?this.setTextConfig(e):t==="textContent"?this.setTextContent(e):t==="clipPath"?this.setClipPath(e):t==="extra"?(this.extra=this.extra||{},N(this.extra,e)):this[t]=e},r.prototype.hide=function(){this.ignore=!0,this.markRedraw()},r.prototype.show=function(){this.ignore=!1,this.markRedraw()},r.prototype.attr=function(t,e){if(typeof t=="string")this.attrKV(t,e);else if(F(t))for(var i=t,a=lt(i),n=0;n0},r.prototype.getState=function(t){return this.states[t]},r.prototype.ensureState=function(t){var e=this.states;return e[t]||(e[t]={}),e[t]},r.prototype.clearStates=function(t){this.useState(lc,!1,t)},r.prototype.useState=function(t,e,i,a){var n=t===lc,o=this.hasState();if(!(!o&&n)){var s=this.currentStates,l=this.stateTransition;if(!(it(s,t)>=0&&(e||s.length===1))){var u;if(this.stateProxy&&!n&&(u=this.stateProxy(t)),u||(u=this.states&&this.states[t]),!u&&!n){$i("State "+t+" not exists.");return}n||this.saveCurrentToNormalState(u);var f=!!(u&&u.hoverLayer||a);f&&this._toggleHoverLayerFlag(!0),this._applyStateObj(t,u,this._normalState,e,!i&&!this.__inHover&&l&&l.duration>0,l);var h=this._textContent,p=this._textGuide;return h&&h.useState(t,e,i,f),p&&p.useState(t,e,i,f),n?(this.currentStates=[],this._normalState={}):e?this.currentStates.push(t):this.currentStates=[t],this._updateAnimationTargets(),this.markRedraw(),!f&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~Ht),u}}},r.prototype.useStates=function(t,e,i){if(!t.length)this.clearStates();else{var a=[],n=this.currentStates,o=t.length,s=o===n.length;if(s){for(var l=0;l0,v);var m=this._textContent,d=this._textGuide;m&&m.useStates(t,e,p),d&&d.useStates(t,e,p),this._updateAnimationTargets(),this.currentStates=t.slice(),this.markRedraw(),!p&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~Ht)}},r.prototype.isSilent=function(){for(var t=this.silent,e=this.parent;!t&&e;){if(e.silent){t=!0;break}e=e.parent}return t},r.prototype._updateAnimationTargets=function(){for(var t=0;t=0){var i=this.currentStates.slice();i.splice(e,1),this.useStates(i)}},r.prototype.replaceState=function(t,e,i){var a=this.currentStates.slice(),n=it(a,t),o=it(a,e)>=0;n>=0?o?a.splice(n,1):a[n]=e:i&&!o&&a.push(e),this.useStates(a)},r.prototype.toggleState=function(t,e){e?this.useState(t,!0):this.removeState(t)},r.prototype._mergeStates=function(t){for(var e={},i,a=0;a=0&&n.splice(o,1)}),this.animators.push(t),i&&i.animation.addAnimator(t),i&&i.wakeUp()},r.prototype.updateDuringAnimation=function(t){this.markRedraw()},r.prototype.stopAnimation=function(t,e){for(var i=this.animators,a=i.length,n=[],o=0;o0&&e.during&&n[0].during(function(v,m){e.during(m)});for(var p=0;p0||a.force&&!o.length){var M=void 0,D=void 0,A=void 0;if(s){D={},p&&(M={});for(var x=0;x<_;x++){var g=m[x];D[g]=e[g],p?M[g]=i[g]:e[g]=i[g]}}else if(p){A={};for(var x=0;x<_;x++){var g=m[x];A[g]=Fo(e[g]),$M(e,i,g)}}var w=new Ho(e,!1,!1,h?Mt(v,function(E){return E.targetName===t}):null);w.targetName=t,a.scope&&(w.scope=a.scope),p&&M&&w.whenWithKeys(0,M,m),A&&w.whenWithKeys(0,A,m),w.whenWithKeys(u??500,s?D:i,m).delay(f||0),r.addAnimator(w,t),o.push(w)}}var Zl=cc;var Og=(function(r){I(t,r);function t(e){var i=r.call(this)||this;return i.isGroup=!0,i._children=[],i.attr(e),i}return t.prototype.childrenRef=function(){return this._children},t.prototype.children=function(){return this._children.slice()},t.prototype.childAt=function(e){return this._children[e]},t.prototype.childOfName=function(e){for(var i=this._children,a=0;a=0&&(a.splice(n,0,e),this._doAdd(e))}return this},t.prototype.replace=function(e,i){var a=it(this._children,e);return a>=0&&this.replaceAt(i,a),this},t.prototype.replaceAt=function(e,i){var a=this._children,n=a[i];if(e&&e!==this&&e.parent!==this&&e!==n){a[i]=e,n.parent=null;var o=this.__zr;o&&n.removeSelfFromZr(o),this._doAdd(e)}return this},t.prototype._doAdd=function(e){e.parent&&e.parent.remove(e),e.parent=this;var i=this.__zr;i&&i!==e.__zr&&e.addSelfToZr(i),i&&i.refresh()},t.prototype.remove=function(e){var i=this.__zr,a=this._children,n=it(a,e);return n<0?this:(a.splice(n,1),e.parent=null,i&&e.removeSelfFromZr(i),i&&i.refresh(),this)},t.prototype.removeAll=function(){for(var e=this._children,i=this.__zr,a=0;a0&&(this._stillFrameAccum++,this._stillFrameAccum>this._sleepAfterStill&&this.animation.stop())},r.prototype.setSleepAfterStill=function(t){this._sleepAfterStill=t},r.prototype.wakeUp=function(){this._disposed||(this.animation.start(),this._stillFrameAccum=0)},r.prototype.refreshHover=function(){this._needsRefreshHover=!0},r.prototype.refreshHoverImmediately=function(){this._disposed||(this._needsRefreshHover=!1,this.painter.refreshHover&&this.painter.getType()==="canvas"&&this.painter.refreshHover())},r.prototype.resize=function(t){this._disposed||(t=t||{},this.painter.resize(t.width,t.height),this.handler.resize())},r.prototype.clearAnimation=function(){this._disposed||this.animation.clear()},r.prototype.getWidth=function(){if(!this._disposed)return this.painter.getWidth()},r.prototype.getHeight=function(){if(!this._disposed)return this.painter.getHeight()},r.prototype.setCursorStyle=function(t){this._disposed||this.handler.setCursorStyle(t)},r.prototype.findHover=function(t,e){if(!this._disposed)return this.handler.findHover(t,e)},r.prototype.on=function(t,e,i){return this._disposed||this.handler.on(t,e,i),this},r.prototype.off=function(t,e){this._disposed||this.handler.off(t,e)},r.prototype.trigger=function(t,e){this._disposed||this.handler.trigger(t,e)},r.prototype.clear=function(){if(!this._disposed){for(var t=this.storage.getRoots(),e=0;e0){if(r<=a)return o;if(r>=n)return s}else{if(r>=a)return o;if(r<=n)return s}else{if(r===a)return o;if(r===n)return s}return(r-a)/l*u+o}function yt(r,t){switch(r){case"center":case"middle":r="50%";break;case"left":case"top":r="0%";break;case"right":case"bottom":r="100%";break}return U(r)?uC(r).match(/%$/)?parseFloat(r)/100*t:parseFloat(r):r==null?NaN:+r}function bt(r,t,e){return t==null&&(t=10),t=Math.min(Math.max(0,t),zg),r=(+r).toFixed(t),e?r:+r}function ke(r){return r.sort(function(t,e){return t-e}),r}function ge(r){if(r=+r,isNaN(r))return 0;if(r>1e-14){for(var t=1,e=0;e<15;e++,t*=10)if(Math.round(r*t)/t===r)return e}return mc(r)}function mc(r){var t=r.toString().toLowerCase(),e=t.indexOf("e"),i=e>0?+t.slice(e+1):0,a=e>0?e:t.length,n=t.indexOf("."),o=n<0?0:a-1-n;return Math.max(0,o-i)}function An(r,t){var e=Math.log,i=Math.LN10,a=Math.floor(e(r[1]-r[0])/i),n=Math.round(e(Math.abs(t[1]-t[0]))/i),o=Math.min(Math.max(-a+n,0),20);return isFinite(o)?o:20}function kg(r,t,e){if(!r[t])return 0;var i=gc(r,e);return i[t]||0}function gc(r,t){var e=fe(r,function(c,v){return c+(isNaN(v)?0:v)},0);if(e===0)return[];for(var i=Math.pow(10,t),a=k(r,function(c){return(isNaN(c)?0:c)/e*i*100}),n=i*100,o=k(a,function(c){return Math.floor(c)}),s=fe(o,function(c,v){return c+v},0),l=k(a,function(c,v){return c-o[v]});su&&(u=l[h],f=h);++o[f],l[f]=0,++s}return k(o,function(c){return c/i})}function Ug(r,t){var e=Math.max(ge(r),ge(t)),i=r+t;return e>zg?i:bt(i,e)}var Vg=9007199254740991;function Xo(r){var t=Math.PI*2;return(r%t+t)%t}function _a(r){return r>-Ng&&r=10&&t++,t}function Ln(r,t){var e=En(r),i=Math.pow(10,e),a=r/i,n;return t?a<1.5?n=1:a<2.5?n=2:a<4?n=3:a<7?n=5:n=10:a<1?n=1:a<2?n=2:a<3?n=3:a<5?n=5:n=10,r=n*i,e>=-20?+r.toFixed(e<0?-e:0):r}function Bg(r,t){var e=(r.length-1)*t+1,i=Math.floor(e),a=+r[i-1],n=e-i;return n?a+n*(r[i]-a):a}function qo(r){r.sort(function(l,u){return s(l,u,0)?-1:1});for(var t=-1/0,e=1,i=0;i=0||n&&it(n,l)<0)){var u=i.getShallow(l,t);u!=null&&(o[r[s][0]]=u)}}return o}}var CC=[["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]],DC=Ir(CC),ey=(function(){function r(){}return r.prototype.getAreaStyle=function(t,e){return DC(this,t,e)},r})();var wc=new $r(50);function iy(r){if(typeof r=="string"){var t=wc.get(r);return t&&t.image}else return r}function Tc(r,t,e,i,a){if(r)if(typeof r=="string"){if(t&&t.__zrImageSrc===r||!e)return t;var n=wc.get(r),o={hostEl:e,cb:i,cbPayload:a};return n?(t=n.image,!On(t)&&n.pending.push(o)):(t=$t.loadImage(r,ry,ry),t.__zrImageSrc=r,wc.put(r,t.__cachedImgObj={image:t,pending:[o]})),t}else return r;else return t}function ry(){var r=this.__cachedImgObj;this.onload=this.onerror=this.__cachedImgObj=null;for(var t=0;t=o;l++)s-=o;var u=Ae(e,t);return u>s&&(e="",u=0),s=r-u,a.ellipsis=e,a.ellipsisWidth=u,a.contentWidth=s,a.containerWidth=r,a}function oy(r,t){var e=t.containerWidth,i=t.font,a=t.contentWidth;if(!e)return"";var n=Ae(r,i);if(n<=e)return r;for(var o=0;;o++){if(n<=a||o>=t.maxIterations){r+=t.ellipsis;break}var s=o===0?EC(r,a,t.ascCharWidth,t.cnCharWidth):n>0?Math.floor(r.length*a/n):0;r=r.substr(0,s),n=Ae(r,i)}return r===""&&(r=t.placeholder),r}function EC(r,t,e,i){for(var a=0,n=0,o=r.length;nc&&u){var v=Math.floor(c/s);h=h.slice(0,v)}if(r&&n&&f!=null)for(var m=ny(f,a,t.ellipsis,{minChar:t.truncateMinChar,placeholder:t.placeholder}),d=0;ds&&Cc(e,r.substring(s,u),t,o),Cc(e,l[2],t,o,l[1]),s=Mc.lastIndex}sa){w>0?(y.tokens=y.tokens.slice(0,w),d(y,x,_),e.lines=e.lines.slice(0,g+1)):e.lines=e.lines.slice(0,g);break t}var E=T.width,L=E==null||E==="auto";if(typeof E=="string"&&E.charAt(E.length-1)==="%")S.percentWidth=E,f.push(S),S.contentWidth=Ae(S.text,A);else{if(L){var P=T.backgroundColor,R=P&&P.image;R&&(R=iy(R),On(R)&&(S.width=Math.max(S.width,R.width*C/R.height)))}var z=v&&i!=null?i-x:null;z!=null&&z0&&v+i.accumWidth>i.width&&(f=t.split(` +`),u=!0),i.accumWidth=v}else{var m=uy(t,l,i.width,i.breakAll,i.accumWidth);i.accumWidth=m.accumWidth+c,h=m.linesWidths,f=m.lines}}else f=t.split(` +`);for(var d=0;d=32&&t<=591||t>=880&&t<=4351||t>=4608&&t<=5119||t>=7680&&t<=8303}var RC=fe(",&?/;] ".split(""),function(r,t){return r[t]=!0,r},{});function OC(r){return PC(r)?!!RC[r]:!0}function uy(r,t,e,i,a){for(var n=[],o=[],s="",l="",u=0,f=0,h=0;he:a+f+c>e){f?(s||l)&&(v?(s||(s=l,l="",u=0,f=u),n.push(s),o.push(f-u),l+=p,u+=c,s="",f=u):(l&&(s+=l,l="",u=0),n.push(s),o.push(f),s=p,f=c)):v?(n.push(l),o.push(u),l=p,u=c):(n.push(p),o.push(c));continue}f+=c,v?(l+=p,u+=c):(l&&(s+=l,l="",u=0),s+=p)}return!n.length&&!s&&(s=r,l="",u=0),l&&(s+=l),s&&(n.push(s),o.push(f)),n.length===1&&(f+=a),{accumWidth:f,lines:n,linesWidths:o}}var Ec="__zr_style_"+Math.round(Math.random()*10),Pr={shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",opacity:1,blend:"source-over"},Sa={style:{shadowBlur:!0,shadowOffsetX:!0,shadowOffsetY:!0,shadowColor:!0,opacity:!0}};Pr[Ec]=!0;var fy=["z","z2","invisible"],NC=["invisible"],zC=(function(r){I(t,r);function t(e){return r.call(this,e)||this}return t.prototype._init=function(e){for(var i=lt(e),a=0;a1e-4){s[0]=r-e,s[1]=t-i,l[0]=r+e,l[1]=t+i;return}if(eu[0]=Ic(a)*e+r,eu[1]=Lc(a)*i+t,ru[0]=Ic(n)*e+r,ru[1]=Lc(n)*i+t,u(s,eu,ru),f(l,eu,ru),a=a%ba,a<0&&(a=a+ba),n=n%ba,n<0&&(n=n+ba),a>n&&!o?n+=ba:aa&&(iu[0]=Ic(c)*e+r,iu[1]=Lc(c)*i+t,u(s,iu,s),f(l,iu,l))}var St={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},wa=[],Ta=[],Or=[],Ti=[],Nr=[],zr=[],Rc=Math.min,Oc=Math.max,Ma=Math.cos,Ca=Math.sin,ei=Math.abs,kc=Math.PI,Mi=kc*2,Nc=typeof Float32Array<"u",Jo=[];function zc(r){var t=Math.round(r/kc*1e8)/1e8;return t%2*kc}function Uc(r,t){var e=zc(r[0]);e<0&&(e+=Mi);var i=e-r[0],a=r[1];a+=i,!t&&a-e>=Mi?a=e+Mi:t&&e-a>=Mi?a=e-Mi:!t&&e>a?a=e+(Mi-zc(e-a)):t&&e0&&(this._ux=ei(i/ca/t)||0,this._uy=ei(i/ca/e)||0)},r.prototype.setDPR=function(t){this.dpr=t},r.prototype.setContext=function(t){this._ctx=t},r.prototype.getContext=function(){return this._ctx},r.prototype.beginPath=function(){return this._ctx&&this._ctx.beginPath(),this.reset(),this},r.prototype.reset=function(){this._saveData&&(this._len=0),this._pathSegLen&&(this._pathSegLen=null,this._pathLen=0),this._version++},r.prototype.moveTo=function(t,e){return this._drawPendingPt(),this.addData(St.M,t,e),this._ctx&&this._ctx.moveTo(t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},r.prototype.lineTo=function(t,e){var i=ei(t-this._xi),a=ei(e-this._yi),n=i>this._ux||a>this._uy;if(this.addData(St.L,t,e),this._ctx&&n&&this._ctx.lineTo(t,e),n)this._xi=t,this._yi=e,this._pendingPtDist=0;else{var o=i*i+a*a;o>this._pendingPtDist&&(this._pendingPtX=t,this._pendingPtY=e,this._pendingPtDist=o)}return this},r.prototype.bezierCurveTo=function(t,e,i,a,n,o){return this._drawPendingPt(),this.addData(St.C,t,e,i,a,n,o),this._ctx&&this._ctx.bezierCurveTo(t,e,i,a,n,o),this._xi=n,this._yi=o,this},r.prototype.quadraticCurveTo=function(t,e,i,a){return this._drawPendingPt(),this.addData(St.Q,t,e,i,a),this._ctx&&this._ctx.quadraticCurveTo(t,e,i,a),this._xi=i,this._yi=a,this},r.prototype.arc=function(t,e,i,a,n,o){this._drawPendingPt(),Jo[0]=a,Jo[1]=n,Uc(Jo,o),a=Jo[0],n=Jo[1];var s=n-a;return this.addData(St.A,t,e,i,i,a,s,0,o?0:1),this._ctx&&this._ctx.arc(t,e,i,a,n,o),this._xi=Ma(n)*i+t,this._yi=Ca(n)*i+e,this},r.prototype.arcTo=function(t,e,i,a,n){return this._drawPendingPt(),this._ctx&&this._ctx.arcTo(t,e,i,a,n),this},r.prototype.rect=function(t,e,i,a){return this._drawPendingPt(),this._ctx&&this._ctx.rect(t,e,i,a),this.addData(St.R,t,e,i,a),this},r.prototype.closePath=function(){this._drawPendingPt(),this.addData(St.Z);var t=this._ctx,e=this._x0,i=this._y0;return t&&t.closePath(),this._xi=e,this._yi=i,this},r.prototype.fill=function(t){t&&t.fill(),this.toStatic()},r.prototype.stroke=function(t){t&&t.stroke(),this.toStatic()},r.prototype.len=function(){return this._len},r.prototype.setData=function(t){var e=t.length;!(this.data&&this.data.length===e)&&Nc&&(this.data=new Float32Array(e));for(var i=0;if.length&&(this._expandData(),f=this.data);for(var h=0;h0&&(this._ctx&&this._ctx.lineTo(this._pendingPtX,this._pendingPtY),this._pendingPtDist=0)},r.prototype._expandData=function(){if(!(this.data instanceof Array)){for(var t=[],e=0;e11&&(this.data=new Float32Array(t)))}},r.prototype.getBoundingRect=function(){Or[0]=Or[1]=Nr[0]=Nr[1]=Number.MAX_VALUE,Ti[0]=Ti[1]=zr[0]=zr[1]=-Number.MAX_VALUE;var t=this.data,e=0,i=0,a=0,n=0,o;for(o=0;oi||ei(_)>a||p===e-1)&&(m=Math.sqrt(y*y+_*_),n=d,o=g);break}case St.C:{var x=t[p++],w=t[p++],d=t[p++],g=t[p++],S=t[p++],T=t[p++];m=ng(n,o,x,w,d,g,S,T,10),n=S,o=T;break}case St.Q:{var x=t[p++],w=t[p++],d=t[p++],g=t[p++];m=lg(n,o,x,w,d,g,10),n=d,o=g;break}case St.A:var M=t[p++],D=t[p++],A=t[p++],C=t[p++],E=t[p++],L=t[p++],P=L+E;p+=1,v&&(s=Ma(E)*A+M,l=Ca(E)*C+D),m=Oc(A,C)*Rc(Mi,Math.abs(L)),n=Ma(P)*A+M,o=Ca(P)*C+D;break;case St.R:{s=n=t[p++],l=o=t[p++];var R=t[p++],z=t[p++];m=R*2+z*2;break}case St.Z:{var y=s-n,_=l-o;m=Math.sqrt(y*y+_*_),n=s,o=l;break}}m>=0&&(u[h++]=m,f+=m)}return this._pathLen=f,f},r.prototype.rebuildPath=function(t,e){var i=this.data,a=this._ux,n=this._uy,o=this._len,s,l,u,f,h,p,c=e<1,v,m,d=0,g=0,y,_=0,x,w;if(!(c&&(this._pathSegLen||this._calculateLength(),v=this._pathSegLen,m=this._pathLen,y=e*m,!y)))t:for(var S=0;S0&&(t.lineTo(x,w),_=0),T){case St.M:s=u=i[S++],l=f=i[S++],t.moveTo(u,f);break;case St.L:{h=i[S++],p=i[S++];var D=ei(h-u),A=ei(p-f);if(D>a||A>n){if(c){var C=v[g++];if(d+C>y){var E=(y-d)/C;t.lineTo(u*(1-E)+h*E,f*(1-E)+p*E);break t}d+=C}t.lineTo(h,p),u=h,f=p,_=0}else{var L=D*D+A*A;L>_&&(x=h,w=p,_=L)}break}case St.C:{var P=i[S++],R=i[S++],z=i[S++],Z=i[S++],V=i[S++],B=i[S++];if(c){var C=v[g++];if(d+C>y){var E=(y-d)/C;xn(u,P,z,V,E,wa),xn(f,R,Z,B,E,Ta),t.bezierCurveTo(wa[1],Ta[1],wa[2],Ta[2],wa[3],Ta[3]);break t}d+=C}t.bezierCurveTo(P,R,z,Z,V,B),u=V,f=B;break}case St.Q:{var P=i[S++],R=i[S++],z=i[S++],Z=i[S++];if(c){var C=v[g++];if(d+C>y){var E=(y-d)/C;Sn(u,P,z,E,wa),Sn(f,R,Z,E,Ta),t.quadraticCurveTo(wa[1],Ta[1],wa[2],Ta[2]);break t}d+=C}t.quadraticCurveTo(P,R,z,Z),u=z,f=Z;break}case St.A:var X=i[S++],Q=i[S++],$=i[S++],mt=i[S++],xt=i[S++],jt=i[S++],Tt=i[S++],Te=!i[S++],Ne=$>mt?$:mt,le=ei($-mt)>.001,Rt=xt+jt,ot=!1;if(c){var C=v[g++];d+C>y&&(Rt=xt+jt*(y-d)/C,ot=!0),d+=C}if(le&&t.ellipse?t.ellipse(X,Q,$,mt,Tt,xt,Rt,Te):t.arc(X,Q,Ne,xt,Rt,Te),ot)break t;M&&(s=Ma(xt)*$+X,l=Ca(xt)*mt+Q),u=Ma(Rt)*$+X,f=Ca(Rt)*mt+Q;break;case St.R:s=u=i[S],l=f=i[S+1],h=i[S++],p=i[S++];var dt=i[S++],Cr=i[S++];if(c){var C=v[g++];if(d+C>y){var Qt=y-d;t.moveTo(h,p),t.lineTo(h+Rc(Qt,dt),p),Qt-=dt,Qt>0&&t.lineTo(h+dt,p+Rc(Qt,Cr)),Qt-=Cr,Qt>0&&t.lineTo(h+Oc(dt-Qt,0),p+Cr),Qt-=dt,Qt>0&&t.lineTo(h,p+Oc(Cr-Qt,0));break t}d+=C}t.rect(h,p,dt,Cr);break;case St.Z:if(c){var C=v[g++];if(d+C>y){var E=(y-d)/C;t.lineTo(u*(1-E)+s*E,f*(1-E)+l*E);break t}d+=C}t.closePath(),u=s,f=l}}},r.prototype.clone=function(){var t=new r,e=this.data;return t.data=e.slice?e.slice():Array.prototype.slice.call(e),t._len=this._len,t},r.CMD=St,r.initDefaultProps=(function(){var t=r.prototype;t._saveData=!0,t._ux=0,t._uy=0,t._pendingPtDist=0,t._version=0})(),r})(),ye=UC;function Da(r,t,e,i,a,n,o){if(a===0)return!1;var s=a,l=0,u=r;if(o>t+s&&o>i+s||or+s&&n>e+s||nt+h&&f>i+h&&f>n+h&&f>s+h||fr+h&&u>e+h&&u>a+h&&u>o+h||ut+u&&l>i+u&&l>n+u||lr+u&&s>e+u&&s>a+u||se||f+ua&&(a+=es);var p=Math.atan2(l,s);return p<0&&(p+=es),p>=i&&p<=a||p+es>=i&&p+es<=a}function rr(r,t,e,i,a,n){if(n>t&&n>i||na?s:0}var Ci=ye.CMD,Aa=Math.PI*2,GC=1e-4;function WC(r,t){return Math.abs(r-t)t&&u>i&&u>n&&u>s||u1&&YC(),c=At(t,i,n,s,ir[0]),p>1&&(v=At(t,i,n,s,ir[1]))),p===2?dt&&s>i&&s>n||s=0&&u<=1){for(var f=0,h=Yt(t,i,n,u),p=0;pe||s<-e)return 0;var l=Math.sqrt(e*e-s*s);_e[0]=-l,_e[1]=l;var u=Math.abs(i-a);if(u<1e-4)return 0;if(u>=Aa-1e-4){i=0,a=Aa;var f=n?1:-1;return o>=_e[0]+r&&o<=_e[1]+r?f:0}if(i>a){var h=i;i=a,a=h}i<0&&(i+=Aa,a+=Aa);for(var p=0,c=0;c<2;c++){var v=_e[c];if(v+r>o){var m=Math.atan2(s,v),f=n?1:-1;m<0&&(m=Aa+m),(m>=i&&m<=a||m+Aa>=i&&m+Aa<=a)&&(m>Math.PI/2&&m1&&(e||(s+=rr(l,u,f,h,i,a))),d&&(l=n[v],u=n[v+1],f=l,h=u),m){case Ci.M:f=n[v++],h=n[v++],l=f,u=h;break;case Ci.L:if(e){if(Da(l,u,n[v],n[v+1],t,i,a))return!0}else s+=rr(l,u,n[v],n[v+1],i,a)||0;l=n[v++],u=n[v++];break;case Ci.C:if(e){if(my(l,u,n[v++],n[v++],n[v++],n[v++],n[v],n[v+1],t,i,a))return!0}else s+=ZC(l,u,n[v++],n[v++],n[v++],n[v++],n[v],n[v+1],i,a)||0;l=n[v++],u=n[v++];break;case Ci.Q:if(e){if(gy(l,u,n[v++],n[v++],n[v],n[v+1],t,i,a))return!0}else s+=XC(l,u,n[v++],n[v++],n[v],n[v+1],i,a)||0;l=n[v++],u=n[v++];break;case Ci.A:var g=n[v++],y=n[v++],_=n[v++],x=n[v++],w=n[v++],S=n[v++];v+=1;var T=!!(1-n[v++]);p=Math.cos(w)*_+g,c=Math.sin(w)*x+y,d?(f=p,h=c):s+=rr(l,u,p,c,i,a);var M=(i-g)*x/_+g;if(e){if(_y(g,y,x,w,w+S,T,t,M,a))return!0}else s+=qC(g,y,x,w,w+S,T,M,a);l=Math.cos(w+S)*_+g,u=Math.sin(w+S)*x+y;break;case Ci.R:f=l=n[v++],h=u=n[v++];var D=n[v++],A=n[v++];if(p=f+D,c=h+A,e){if(Da(f,h,p,h,t,i,a)||Da(p,h,p,c,t,i,a)||Da(p,c,f,c,t,i,a)||Da(f,c,f,h,t,i,a))return!0}else s+=rr(p,h,p,c,i,a),s+=rr(f,c,f,h,i,a);break;case Ci.Z:if(e){if(Da(l,u,f,h,t,i,a))return!0}else s+=rr(l,u,f,h,i,a);l=f,u=h;break}}return!e&&!WC(u,h)&&(s+=rr(l,u,f,h,i,a)||0),s!==0}function Sy(r,t,e){return xy(r,0,!1,t,e)}function by(r,t,e,i){return xy(r,t,!0,e,i)}var Bc=K({fill:"#000",stroke:null,strokePercent:1,fillOpacity:1,strokeOpacity:1,lineDashOffset:0,lineWidth:1,lineCap:"butt",miterLimit:10,strokeNoScale:!1,strokeFirst:!1},Pr),jC={style:K({fill:!0,stroke:!0,strokePercent:!0,fillOpacity:!0,strokeOpacity:!0,lineDashOffset:!0,lineWidth:!0,miterLimit:!0},Sa.style)},Vc=da.concat(["invisible","culling","z","z2","zlevel","parent"]),QC=(function(r){I(t,r);function t(e){return r.call(this,e)||this}return t.prototype.update=function(){var e=this;r.prototype.update.call(this);var i=this.style;if(i.decal){var a=this._decalEl=this._decalEl||new t;a.buildPath===t.prototype.buildPath&&(a.buildPath=function(l){e.buildPath(l,e.shape)}),a.silent=!0;var n=a.style;for(var o in i)n[o]!==i[o]&&(n[o]=i[o]);n.fill=i.fill?i.decal:null,n.decal=null,n.shadowColor=null,i.strokeFirst&&(n.stroke=null);for(var s=0;s.5?Wo:i>.2?Dg:Yo}else if(e)return Yo}return Wo},t.prototype.getInsideTextStroke=function(e){var i=this.style.fill;if(U(i)){var a=this.__zr,n=!!(a&&a.isDarkMode()),o=fa(e,0)0))},t.prototype.hasFill=function(){var e=this.style,i=e.fill;return i!=null&&i!=="none"},t.prototype.getBoundingRect=function(){var e=this._rect,i=this.style,a=!e;if(a){var n=!1;this.path||(n=!0,this.createPathProxy());var o=this.path;(n||this.__dirty&gi)&&(o.beginPath(),this.buildPath(o,this.shape,!1),this.pathUpdated()),e=o.getBoundingRect()}if(this._rect=e,this.hasStroke()&&this.path&&this.path.len()>0){var s=this._rectStroke||(this._rectStroke=e.clone());if(this.__dirty||a){s.copy(e);var l=i.strokeNoScale?this.getLineScale():1,u=i.lineWidth;if(!this.hasFill()){var f=this.strokeContainThreshold;u=Math.max(u,f??4)}l>1e-10&&(s.width+=u/l,s.height+=u/l,s.x-=u/l/2,s.y-=u/l/2)}return s}return e},t.prototype.contain=function(e,i){var a=this.transformCoordToLocal(e,i),n=this.getBoundingRect(),o=this.style;if(e=a[0],i=a[1],n.contain(e,i)){var s=this.path;if(this.hasStroke()){var l=o.lineWidth,u=o.strokeNoScale?this.getLineScale():1;if(u>1e-10&&(this.hasFill()||(l=Math.max(l,this.strokeContainThreshold)),by(s,l/u,e,i)))return!0}if(this.hasFill())return Sy(s,e,i)}return!1},t.prototype.dirtyShape=function(){this.__dirty|=gi,this._rect&&(this._rect=null),this._decalEl&&this._decalEl.dirtyShape(),this.markRedraw()},t.prototype.dirty=function(){this.dirtyStyle(),this.dirtyShape()},t.prototype.animateShape=function(e){return this.animate("shape",e)},t.prototype.updateDuringAnimation=function(e){e==="style"?this.dirtyStyle():e==="shape"?this.dirtyShape():this.markRedraw()},t.prototype.attrKV=function(e,i){e==="shape"?this.setShape(i):r.prototype.attrKV.call(this,e,i)},t.prototype.setShape=function(e,i){var a=this.shape;return a||(a=this.shape={}),typeof e=="string"?a[e]=i:N(a,e),this.dirtyShape(),this},t.prototype.shapeChanged=function(){return!!(this.__dirty&gi)},t.prototype.createStyle=function(e){return Xr(Bc,e)},t.prototype._innerSaveToNormal=function(e){r.prototype._innerSaveToNormal.call(this,e);var i=this._normalState;e.shape&&!i.shape&&(i.shape=N({},this.shape))},t.prototype._applyStateObj=function(e,i,a,n,o,s){r.prototype._applyStateObj.call(this,e,i,a,n,o,s);var l=!(i&&n),u;if(i&&i.shape?o?n?u=i.shape:(u=N({},a.shape),N(u,i.shape)):(u=N({},n?this.shape:a.shape),N(u,i.shape)):l&&(u=a.shape),u)if(o){this.shape=N({},this.shape);for(var f={},h=lt(u),p=0;p0},t.prototype.hasFill=function(){var e=this.style,i=e.fill;return i!=null&&i!=="none"},t.prototype.createStyle=function(e){return Xr($C,e)},t.prototype.setBoundingRect=function(e){this._rect=e},t.prototype.getBoundingRect=function(){var e=this.style;if(!this._rect){var i=e.text;i!=null?i+="":i="";var a=Mn(i,e.font,e.textAlign,e.textBaseline);if(a.x+=e.x||0,a.y+=e.y||0,this.hasStroke()){var n=e.lineWidth;a.x-=n/2,a.y-=n/2,a.width+=n,a.height+=n}this._rect=a}return this._rect},t.initDefaultProps=(function(){var e=t.prototype;e.dirtyRectTolerance=10})(),t})(Rr);wy.prototype.type="tspan";var rs=wy;var JC=K({x:0,y:0},Pr),tD={style:K({x:!0,y:!0,width:!0,height:!0,sx:!0,sy:!0,sWidth:!0,sHeight:!0},Sa.style)};function eD(r){return!!(r&&typeof r!="string"&&r.width&&r.height)}var Ty=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.createStyle=function(e){return Xr(JC,e)},t.prototype._getSize=function(e){var i=this.style,a=i[e];if(a!=null)return a;var n=eD(i.image)?i.image:this.__image;if(!n)return 0;var o=e==="width"?"height":"width",s=i[o];return s==null?n[e]:n[e]/n[o]*s},t.prototype.getWidth=function(){return this._getSize("width")},t.prototype.getHeight=function(){return this._getSize("height")},t.prototype.getAnimationStyleProps=function(){return tD},t.prototype.getBoundingRect=function(){var e=this.style;return this._rect||(this._rect=new J(e.x||0,e.y||0,this.getWidth(),this.getHeight())),this._rect},t})(Rr);Ty.prototype.type="image";var ne=Ty;function My(r,t){var e=t.x,i=t.y,a=t.width,n=t.height,o=t.r,s,l,u,f;a<0&&(e=e+a,a=-a),n<0&&(i=i+n,n=-n),typeof o=="number"?s=l=u=f=o:o instanceof Array?o.length===1?s=l=u=f=o[0]:o.length===2?(s=u=o[0],l=f=o[1]):o.length===3?(s=o[0],l=f=o[1],u=o[2]):(s=o[0],l=o[1],u=o[2],f=o[3]):s=l=u=f=0;var h;s+l>a&&(h=s+l,s*=a/h,l*=a/h),u+f>a&&(h=u+f,u*=a/h,f*=a/h),l+u>n&&(h=l+u,l*=n/h,u*=n/h),s+f>n&&(h=s+f,s*=n/h,f*=n/h),r.moveTo(e+s,i),r.lineTo(e+a-l,i),l!==0&&r.arc(e+a-l,i+l,l,-Math.PI/2,0),r.lineTo(e+a,i+n-u),u!==0&&r.arc(e+a-u,i+n-u,u,0,Math.PI/2),r.lineTo(e+f,i+n),f!==0&&r.arc(e+f,i+n-f,f,Math.PI/2,Math.PI),r.lineTo(e,i+s),s!==0&&r.arc(e+s,i+s,s,Math.PI,Math.PI*1.5)}var Nn=Math.round;function au(r,t,e){if(t){var i=t.x1,a=t.x2,n=t.y1,o=t.y2;r.x1=i,r.x2=a,r.y1=n,r.y2=o;var s=e&&e.lineWidth;return s&&(Nn(i*2)===Nn(a*2)&&(r.x1=r.x2=Di(i,s,!0)),Nn(n*2)===Nn(o*2)&&(r.y1=r.y2=Di(n,s,!0))),r}}function nu(r,t,e){if(t){var i=t.x,a=t.y,n=t.width,o=t.height;r.x=i,r.y=a,r.width=n,r.height=o;var s=e&&e.lineWidth;return s&&(r.x=Di(i,s,!0),r.y=Di(a,s,!0),r.width=Math.max(Di(i+n,s,!1)-r.x,n===0?0:1),r.height=Math.max(Di(a+o,s,!1)-r.y,o===0?0:1)),r}}function Di(r,t,e){if(!t)return r;var i=Nn(r*2);return(i+Nn(t))%2===0?i/2:(i+(e?1:-1))/2}var aD=(function(){function r(){this.x=0,this.y=0,this.width=0,this.height=0}return r})();var nD={},Cy=(function(r){I(t,r);function t(e){return r.call(this,e)||this}return t.prototype.getDefaultShape=function(){return new aD},t.prototype.buildPath=function(e,i){var a,n,o,s;if(this.subPixelOptimize){var l=nu(nD,i,this.style);a=l.x,n=l.y,o=l.width,s=l.height,l.r=i.r,i=l}else a=i.x,n=i.y,o=i.width,s=i.height;i.r?My(e,i):e.rect(a,n,o,s)},t.prototype.isZeroArea=function(){return!this.shape.width||!this.shape.height},t})(at);Cy.prototype.type="rect";var st=Cy;var Dy={fill:"#000"},Ay=2,oD={style:K({fill:!0,stroke:!0,fillOpacity:!0,strokeOpacity:!0,lineWidth:!0,fontSize:!0,lineHeight:!0,width:!0,height:!0,textShadowColor:!0,textShadowBlur:!0,textShadowOffsetX:!0,textShadowOffsetY:!0,backgroundColor:!0,padding:!0,borderColor:!0,borderWidth:!0,borderRadius:!0},Sa.style)},zy=(function(r){I(t,r);function t(e){var i=r.call(this)||this;return i.type="text",i._children=[],i._defaultStyle=Dy,i.attr(e),i}return t.prototype.childrenRef=function(){return this._children},t.prototype.update=function(){r.prototype.update.call(this),this.styleChanged()&&this._updateSubTexts();for(var e=0;e0,E=e.width!=null&&(e.overflow==="truncate"||e.overflow==="break"||e.overflow==="breakAll"),L=o.calculatedLineHeight,P=0;P=0&&(P=S[L],P.align==="right");)this._placeToken(P,e,M,g,E,"right",_),D-=P.width,E-=P.width,L--;for(C+=(n-(C-d)-(y-E)-D)/2;A<=L;)P=S[A],this._placeToken(P,e,M,g,C+P.width/2,"center",_),C+=P.width,A++;g+=M}},t.prototype._placeToken=function(e,i,a,n,o,s,l){var u=i.rich[e.styleName]||{};u.text=e.text;var f=e.verticalAlign,h=n+a/2;f==="top"?h=n+e.height/2:f==="bottom"&&(h=n+a-e.height/2);var p=!e.isLineHolder&&Fc(u);p&&this._renderBackground(u,i,s==="right"?o-e.width:s==="center"?o-e.width/2:o,h-e.height/2,e.width,e.height);var c=!!u.backgroundColor,v=e.textPadding;v&&(o=Oy(o,s,v),h-=e.height/2-v[0]-e.innerHeight/2);var m=this._getOrCreateChild(rs),d=m.createStyle();m.useStyle(d);var g=this._defaultStyle,y=!1,_=0,x=Ry("fill"in u?u.fill:"fill"in i?i.fill:(y=!0,g.fill)),w=Py("stroke"in u?u.stroke:"stroke"in i?i.stroke:!c&&!l&&(!g.autoStroke||y)?(_=Ay,g.stroke):null),S=u.textShadowBlur>0||i.textShadowBlur>0;d.text=e.text,d.x=o,d.y=h,S&&(d.shadowBlur=u.textShadowBlur||i.textShadowBlur||0,d.shadowColor=u.textShadowColor||i.textShadowColor||"transparent",d.shadowOffsetX=u.textShadowOffsetX||i.textShadowOffsetX||0,d.shadowOffsetY=u.textShadowOffsetY||i.textShadowOffsetY||0),d.textAlign=s,d.textBaseline="middle",d.font=e.font||pr,d.opacity=Ar(u.opacity,i.opacity,1),Ly(d,u),w&&(d.lineWidth=Ar(u.lineWidth,i.lineWidth,_),d.lineDash=et(u.lineDash,i.lineDash),d.lineDashOffset=i.lineDashOffset||0,d.stroke=w),x&&(d.fill=x);var T=e.contentWidth,M=e.contentHeight;m.setBoundingRect(new J(Cn(d.x,T,d.textAlign),ma(d.y,M,d.textBaseline),T,M))},t.prototype._renderBackground=function(e,i,a,n,o,s){var l=e.backgroundColor,u=e.borderWidth,f=e.borderColor,h=l&&l.image,p=l&&!h,c=e.borderRadius,v=this,m,d;if(p||e.lineHeight||u&&f){m=this._getOrCreateChild(st),m.useStyle(m.createStyle()),m.style.fill=null;var g=m.shape;g.x=a,g.y=n,g.width=o,g.height=s,g.r=c,m.dirtyShape()}if(p){var y=m.style;y.fill=l||null,y.fillOpacity=et(e.fillOpacity,1)}else if(h){d=this._getOrCreateChild(ne),d.onload=function(){v.dirtyStyle()};var _=d.style;_.image=l.image,_.x=a,_.y=n,_.width=o,_.height=s}if(u&&f){var y=m.style;y.lineWidth=u,y.stroke=f,y.strokeOpacity=et(e.strokeOpacity,1),y.lineDash=e.borderDash,y.lineDashOffset=e.borderDashOffset||0,m.strokeContainThreshold=0,m.hasFill()&&m.hasStroke()&&(y.strokeFirst=!0,y.lineWidth*=2)}var x=(m||d).style;x.shadowBlur=e.shadowBlur||0,x.shadowColor=e.shadowColor||"transparent",x.shadowOffsetX=e.shadowOffsetX||0,x.shadowOffsetY=e.shadowOffsetY||0,x.opacity=Ar(e.opacity,i.opacity,1)},t.makeFont=function(e){var i="";return fD(e)&&(i=[e.fontStyle,e.fontWeight,uD(e.fontSize),e.fontFamily||"sans-serif"].join(" ")),i&&te(i)||e.textFont||e.font},t})(Rr),sD={left:!0,right:1,center:1},lD={top:1,bottom:1,middle:1},Ey=["fontStyle","fontWeight","fontSize","fontFamily"];function uD(r){return typeof r=="string"&&(r.indexOf("px")!==-1||r.indexOf("rem")!==-1||r.indexOf("em")!==-1)?r:isNaN(+r)?ml+"px":r+"px"}function Ly(r,t){for(var e=0;e=0,n=!1;if(r instanceof at){var o=Wy(r),s=a&&o.selectFill||o.normalFill,l=a&&o.selectStroke||o.normalStroke;if(zn(s)||zn(l)){i=i||{};var u=i.style||{};u.fill==="inherit"?(n=!0,i=N({},i),u=N({},u),u.fill=s):!zn(u.fill)&&zn(s)?(n=!0,i=N({},i),u=N({},u),u.fill=Ul(s)):!zn(u.stroke)&&zn(l)&&(n||(i=N({},i),u=N({},u)),u.stroke=Ul(l)),i.style=u}}if(i&&i.z2==null){n||(i=N({},i));var f=r.z2EmphasisLift;i.z2=r.z2+(f??cD)}return i}function yD(r,t,e){if(e&&e.z2==null){e=N({},e);var i=r.z2SelectLift;e.z2=r.z2+(i??pD)}return e}function _D(r,t,e){var i=it(r.currentStates,t)>=0,a=r.style.opacity,n=i?null:mD(r,["opacity"],t,{opacity:1});e=e||{};var o=e.style||{};return o.opacity==null&&(e=N({},e),o=N({opacity:i?a:n.opacity*.1},o),e.style=o),e}function Hc(r,t){var e=this.states[r];if(this.style){if(r==="emphasis")return gD(this,r,t,e);if(r==="blur")return _D(this,r,e);if(r==="select")return yD(this,r,e)}return e}function xD(r){r.stateProxy=Hc;var t=r.getTextContent(),e=r.getTextGuideLine();t&&(t.stateProxy=Hc),e&&(e.stateProxy=Hc)}function Fy(r,t){!Ky(r,t)&&!r.__highByOuter&&ri(r,Yy)}function Hy(r,t){!Ky(r,t)&&!r.__highByOuter&&ri(r,Zy)}function Ea(r,t){r.__highByOuter|=1<<(t||0),ri(r,Yy)}function La(r,t){!(r.__highByOuter&=~(1<<(t||0)))&&ri(r,Zy)}function qy(r){ri(r,Zc)}function qc(r){ri(r,Xy)}function Kc(r){ri(r,vD)}function jc(r){ri(r,dD)}function Ky(r,t){return r.__highDownSilentOnTouch&&t.zrByTouch}function Qc(r){var t=r.getModel(),e=[],i=[];t.eachComponent(function(a,n){var o=Wc(n),s=a==="series",l=s?r.getViewOfSeriesModel(n):r.getViewOfComponentModel(n);!s&&i.push(l),o.isBlured&&(l.group.traverse(function(u){Xy(u)}),s&&e.push(n)),o.isBlured=!1}),b(i,function(a){a&&a.toggleBlurSeries&&a.toggleBlurSeries(e,!1,t)})}function Gc(r,t,e,i){var a=i.getModel();e=e||"coordinateSystem";function n(u,f){for(var h=0;h0){var l={dataIndex:s,seriesIndex:e.seriesIndex};o!=null&&(l.dataType=o),t.push(l)}})}),t}function Ei(r,t,e){uu(r,!0),ri(r,xD),bD(r,t,e)}function SD(r){uu(r,!1)}function yr(r,t,e,i){i?SD(r):Ei(r,t,e)}function bD(r,t,e){var i=ut(r);t!=null?(i.focus=t,i.blurScope=e):i.focus&&(i.focus=null)}var Gy=["emphasis","blur","select"],wD={itemStyle:"getItemStyle",lineStyle:"getLineStyle",areaStyle:"getAreaStyle"};function Ia(r,t,e,i){e=e||"itemStyle";for(var a=0;aOa,BezierCurve:()=>ps,BoundingRect:()=>J,Circle:()=>Pa,CompoundPath:()=>du,Ellipse:()=>us,Group:()=>ft,Image:()=>ne,IncrementalDisplayable:()=>xu,Line:()=>Ve,LinearGradient:()=>Li,OrientedBoundingRect:()=>Hn,Path:()=>at,Point:()=>rt,Polygon:()=>ii,Polyline:()=>xr,RadialGradient:()=>gu,Rect:()=>st,Ring:()=>cs,Sector:()=>Ue,Text:()=>vt,applyTransform:()=>Sr,clipPointsByRect:()=>pp,clipRectByRect:()=>vp,createIcon:()=>Ba,extendPath:()=>up,extendShape:()=>lp,getShapeClass:()=>fp,getTransform:()=>ai,groupTransition:()=>cp,initProps:()=>Gt,isElementRemoved:()=>ka,lineLineIntersect:()=>I0,linePolygonIntersect:()=>iA,makeImage:()=>vs,makePath:()=>Yn,mergePath:()=>hp,registerShape:()=>Be,removeElement:()=>Gn,removeElementWithFadeOut:()=>Ua,resizePath:()=>wu,setTooltipConfig:()=>ms,subPixelOptimize:()=>eA,subPixelOptimizeLine:()=>Va,subPixelOptimizeRect:()=>tA,transformDirection:()=>ds,traverseElements:()=>ni,updateProps:()=>Ct});var Bn=ye.CMD,TD=[[],[],[]],i0=Math.sqrt,MD=Math.atan2;function tp(r,t){if(t){var e=r.data,i=r.len(),a,n,o,s,l,u,f=Bn.M,h=Bn.C,p=Bn.L,c=Bn.R,v=Bn.A,m=Bn.Q;for(o=0,s=0;o1&&(o*=ep(v),s*=ep(v));var m=(a===n?-1:1)*ep((o*o*(s*s)-o*o*(c*c)-s*s*(p*p))/(o*o*(c*c)+s*s*(p*p)))||0,d=m*o*c/s,g=m*-s*p/o,y=(r+e)/2+cu(h)*d-hu(h)*g,_=(t+i)/2+hu(h)*d+cu(h)*g,x=n0([1,0],[(p-d)/o,(c-g)/s]),w=[(p-d)/o,(c-g)/s],S=[(-1*p-d)/o,(-1*c-g)/s],T=n0(w,S);if(rp(w,S)<=-1&&(T=ls),rp(w,S)>=1&&(T=0),T<0){var M=Math.round(T/ls*1e6)/1e6;T=ls*2+M%2*ls}f.addData(u,y,_,o,s,x,T,h,n)}var CD=/([mlvhzcqtsa])([^mlvhzcqtsa]*)/ig,DD=/-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;function AD(r){var t=new ye;if(!r)return t;var e=0,i=0,a=e,n=i,o,s=ye.CMD,l=r.match(CD);if(!l)return t;for(var u=0;uP*P+R*R&&(M=A,D=C),{cx:M,cy:D,x0:-f,y0:-h,x1:M*(a/w-1),y1:D*(a/w-1)}}function OD(r){var t;if(O(r)){var e=r.length;if(!e)return r;e===1?t=[r[0],r[0],0,0]:e===2?t=[r[0],r[0],r[1],r[1]]:e===3?t=r.concat(r[2]):t=r}else t=[r,r,r,r];return t}function g0(r,t){var e,i=fs(t.r,0),a=fs(t.r0||0,0),n=i>0,o=a>0;if(!(!n&&!o)){if(n||(i=a,a=0),a>i){var s=i;i=a,a=s}var l=t.startAngle,u=t.endAngle;if(!(isNaN(l)||isNaN(u))){var f=t.cx,h=t.cy,p=!!t.clockwise,c=d0(u-l),v=c>ip&&c%ip;if(v>_r&&(c=v),!(i>_r))r.moveTo(f,h);else if(c>ip-_r)r.moveTo(f+i*Fn(l),h+i*Ra(l)),r.arc(f,h,i,l,u,!p),a>_r&&(r.moveTo(f+a*Fn(u),h+a*Ra(u)),r.arc(f,h,a,u,l,p));else{var m=void 0,d=void 0,g=void 0,y=void 0,_=void 0,x=void 0,w=void 0,S=void 0,T=void 0,M=void 0,D=void 0,A=void 0,C=void 0,E=void 0,L=void 0,P=void 0,R=i*Fn(l),z=i*Ra(l),Z=a*Fn(u),V=a*Ra(u),B=c>_r;if(B){var X=t.cornerRadius;X&&(e=OD(X),m=e[0],d=e[1],g=e[2],y=e[3]);var Q=d0(i-a)/2;if(_=kr(Q,g),x=kr(Q,y),w=kr(Q,m),S=kr(Q,d),D=T=fs(_,x),A=M=fs(w,S),(T>_r||M>_r)&&(C=i*Fn(u),E=i*Ra(u),L=a*Fn(l),P=a*Ra(l),c_r){var le=kr(g,D),Rt=kr(y,D),ot=pu(L,P,R,z,i,le,p),dt=pu(C,E,Z,V,i,Rt,p);r.moveTo(f+ot.cx+ot.x0,h+ot.cy+ot.y0),D0&&r.arc(f+ot.cx,h+ot.cy,le,he(ot.y0,ot.x0),he(ot.y1,ot.x1),!p),r.arc(f,h,i,he(ot.cy+ot.y1,ot.cx+ot.x1),he(dt.cy+dt.y1,dt.cx+dt.x1),!p),Rt>0&&r.arc(f+dt.cx,h+dt.cy,Rt,he(dt.y1,dt.x1),he(dt.y0,dt.x0),!p))}else r.moveTo(f+R,h+z),r.arc(f,h,i,l,u,!p);if(!(a>_r)||!B)r.lineTo(f+Z,h+V);else if(A>_r){var le=kr(m,A),Rt=kr(d,A),ot=pu(Z,V,C,E,a,-Rt,p),dt=pu(R,z,L,P,a,-le,p);r.lineTo(f+ot.cx+ot.x0,h+ot.cy+ot.y0),A0&&r.arc(f+ot.cx,h+ot.cy,Rt,he(ot.y0,ot.x0),he(ot.y1,ot.x1),!p),r.arc(f,h,a,he(ot.cy+ot.y1,ot.cx+ot.x1),he(dt.cy+dt.y1,dt.cx+dt.x1),p),le>0&&r.arc(f+dt.cx,h+dt.cy,le,he(dt.y1,dt.x1),he(dt.y0,dt.x0),!p))}else r.lineTo(f+Z,h+V),r.arc(f,h,a,u,l,p)}r.closePath()}}}var zD=(function(){function r(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0,this.cornerRadius=0}return r})();var y0=(function(r){I(t,r);function t(e){return r.call(this,e)||this}return t.prototype.getDefaultShape=function(){return new zD},t.prototype.buildPath=function(e,i){g0(e,i)},t.prototype.isZeroArea=function(){return this.shape.startAngle===this.shape.endAngle||this.shape.r===this.shape.r0},t})(at);y0.prototype.type="sector";var Ue=y0;var kD=(function(){function r(){this.cx=0,this.cy=0,this.r=0,this.r0=0}return r})();var _0=(function(r){I(t,r);function t(e){return r.call(this,e)||this}return t.prototype.getDefaultShape=function(){return new kD},t.prototype.buildPath=function(e,i){var a=i.cx,n=i.cy,o=Math.PI*2;e.moveTo(a+i.r,n),e.arc(a,n,i.r,0,o,!1),e.moveTo(a+i.r0,n),e.arc(a,n,i.r0,0,o,!0)},t})(at);_0.prototype.type="ring";var cs=_0;function ap(r,t,e,i){var a=[],n=[],o=[],s=[],l,u,f,h;if(i){f=[1/0,1/0],h=[-1/0,-1/0];for(var p=0,c=r.length;p=2){if(i){var n=ap(a,i,e,t.smoothConstraint);r.moveTo(a[0][0],a[0][1]);for(var o=a.length,s=0;s<(e?o:o-1);s++){var l=n[s*2],u=n[s*2+1],f=a[(s+1)%o];r.bezierCurveTo(l[0],l[1],u[0],u[1],f[0],f[1])}}else{r.moveTo(a[0][0],a[0][1]);for(var s=1,h=a.length;sza[1]){if(s=!1,n)return s;var f=Math.abs(za[0]-Na[1]),h=Math.abs(Na[0]-za[1]);Math.min(f,h)>a.len()&&(f0){var h=f.duration,p=f.delay,c=f.easing,v={duration:h,delay:p||0,easing:c,done:n,force:!!n||!!o,setToFinal:!u,scope:r,during:o};s?t.animateFrom(e,v):t.animateTo(e,v)}else t.stopAnimation(),!s&&t.attr(e),o&&o(1),n&&n()}function Ct(r,t,e,i,a,n){np("update",r,t,e,i,a,n)}function Gt(r,t,e,i,a,n){np("enter",r,t,e,i,a,n)}function ka(r){if(!r.__zr)return!0;for(var t=0;tMath.abs(n[1])?n[0]>0?"right":"left":n[1]>0?"bottom":"top"}function A0(r){return!r.isGroup}function rA(r){return r.shape!=null}function cp(r,t,e){if(!r||!t)return;function i(o){var s={};return o.traverse(function(l){A0(l)&&l.anid&&(s[l.anid]=l)}),s}function a(o){var s={x:o.x,y:o.y,rotation:o.rotation};return rA(o)&&(s.shape=N({},o.shape)),s}var n=i(r);t.traverse(function(o){if(A0(o)&&o.anid){var s=n[o.anid];if(s){var l=a(o);o.attr(a(s)),Ct(o,l,e,ut(o).dataIndex)}}})}function pp(r,t){return k(r,function(e){var i=e[0];i=Su(i,t.x),i=bu(i,t.x+t.width);var a=e[1];return a=Su(a,t.y),a=bu(a,t.y+t.height),[i,a]})}function vp(r,t){var e=Su(r.x,t.x),i=bu(r.x+r.width,t.x+t.width),a=Su(r.y,t.y),n=bu(r.y+r.height,t.y+t.height);if(i>=e&&n>=a)return{x:e,y:a,width:i-e,height:n-a}}function Ba(r,t,e){var i=N({rectHover:!0},t),a=i.style={strokeNoScale:!0};if(e=e||{x:-1,y:-1,width:2,height:2},r)return r.indexOf("image://")===0?(a.image=r.slice(8),K(a,e),new ne(i)):Yn(r.replace("path://",""),i,e,"center")}function iA(r,t,e,i,a){for(var n=0,o=a[a.length-1];n1)return!1;var d=op(c,v,f,h)/p;return!(d<0||d>1)}function op(r,t,e,i){return r*i-e*t}function aA(r){return r<=1e-6&&r>=-1e-6}function ms(r){var t=r.itemTooltipOption,e=r.componentModel,i=r.itemName,a=U(t)?{formatter:t}:t,n=e.mainType,o=e.componentIndex,s={componentType:n,name:i,$vars:["name"]};s[n+"Index"]=o;var l=r.formatterParamsExtra;l&&b(lt(l),function(f){Ze(s,f)||(s[f]=l[f],s.$vars.push(f))});var u=ut(r.el);u.componentMainType=n,u.componentIndex=o,u.tooltipConfig={name:i,option:K({content:i,encodeHTMLContent:!0,formatterParams:s},a)}}function E0(r,t){var e;r.isGroup&&(e=t(r)),e||r.traverse(t)}function ni(r,t){if(r)if(O(r))for(var e=0;e=0&&s.push(l)}),s}}function nr(r,t){return tt(tt({},r,!0),t,!0)}var Y0={time:{month:["January","February","March","April","May","June","July","August","September","October","November","December"],monthAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayOfWeekAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},legend:{selector:{all:"All",inverse:"Inv"}},toolbox:{brush:{title:{rect:"Box Select",polygon:"Lasso Select",lineX:"Horizontally Select",lineY:"Vertically Select",keep:"Keep Selections",clear:"Clear Selections"}},dataView:{title:"Data View",lang:["Data View","Close","Refresh"]},dataZoom:{title:{zoom:"Zoom",back:"Zoom Reset"}},magicType:{title:{line:"Switch to Line Chart",bar:"Switch to Bar Chart",stack:"Stack",tiled:"Tile"}},restore:{title:"Restore"},saveAsImage:{title:"Save as Image",lang:["Right Click to Save Image"]}},series:{typeNames:{pie:"Pie chart",bar:"Bar chart",line:"Line chart",scatter:"Scatter plot",effectScatter:"Ripple scatter plot",radar:"Radar chart",tree:"Tree",treemap:"Treemap",boxplot:"Boxplot",candlestick:"Candlestick",k:"K line chart",heatmap:"Heat map",map:"Map",parallel:"Parallel coordinate map",lines:"Line graph",graph:"Relationship graph",sankey:"Sankey diagram",funnel:"Funnel chart",gauge:"Gauge",pictorialBar:"Pictorial bar",themeRiver:"Theme River Map",sunburst:"Sunburst",custom:"Custom chart",chart:"Chart"}},aria:{general:{withTitle:'This is a chart about "{title}"',withoutTitle:"This is a chart"},series:{single:{prefix:"",withName:" with type {seriesType} named {seriesName}.",withoutName:" with type {seriesType}."},multiple:{prefix:". It consists of {seriesCount} series count.",withName:" The {seriesId} series is a {seriesType} representing {seriesName}.",withoutName:" The {seriesId} series is a {seriesType}.",separator:{middle:"",end:""}}},data:{allData:"The data is as follows: ",partialData:"The first {displayCnt} items are: ",withName:"the data for {name} is {value}",withoutName:"{value}",separator:{middle:", ",end:". "}}}};var Z0={time:{month:["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],monthAbbr:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],dayOfWeek:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],dayOfWeekAbbr:["\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"]},legend:{selector:{all:"\u5168\u9009",inverse:"\u53CD\u9009"}},toolbox:{brush:{title:{rect:"\u77E9\u5F62\u9009\u62E9",polygon:"\u5708\u9009",lineX:"\u6A2A\u5411\u9009\u62E9",lineY:"\u7EB5\u5411\u9009\u62E9",keep:"\u4FDD\u6301\u9009\u62E9",clear:"\u6E05\u9664\u9009\u62E9"}},dataView:{title:"\u6570\u636E\u89C6\u56FE",lang:["\u6570\u636E\u89C6\u56FE","\u5173\u95ED","\u5237\u65B0"]},dataZoom:{title:{zoom:"\u533A\u57DF\u7F29\u653E",back:"\u533A\u57DF\u7F29\u653E\u8FD8\u539F"}},magicType:{title:{line:"\u5207\u6362\u4E3A\u6298\u7EBF\u56FE",bar:"\u5207\u6362\u4E3A\u67F1\u72B6\u56FE",stack:"\u5207\u6362\u4E3A\u5806\u53E0",tiled:"\u5207\u6362\u4E3A\u5E73\u94FA"}},restore:{title:"\u8FD8\u539F"},saveAsImage:{title:"\u4FDD\u5B58\u4E3A\u56FE\u7247",lang:["\u53F3\u952E\u53E6\u5B58\u4E3A\u56FE\u7247"]}},series:{typeNames:{pie:"\u997C\u56FE",bar:"\u67F1\u72B6\u56FE",line:"\u6298\u7EBF\u56FE",scatter:"\u6563\u70B9\u56FE",effectScatter:"\u6D9F\u6F2A\u6563\u70B9\u56FE",radar:"\u96F7\u8FBE\u56FE",tree:"\u6811\u56FE",treemap:"\u77E9\u5F62\u6811\u56FE",boxplot:"\u7BB1\u578B\u56FE",candlestick:"K\u7EBF\u56FE",k:"K\u7EBF\u56FE",heatmap:"\u70ED\u529B\u56FE",map:"\u5730\u56FE",parallel:"\u5E73\u884C\u5750\u6807\u56FE",lines:"\u7EBF\u56FE",graph:"\u5173\u7CFB\u56FE",sankey:"\u6851\u57FA\u56FE",funnel:"\u6F0F\u6597\u56FE",gauge:"\u4EEA\u8868\u76D8\u56FE",pictorialBar:"\u8C61\u5F62\u67F1\u56FE",themeRiver:"\u4E3B\u9898\u6CB3\u6D41\u56FE",sunburst:"\u65ED\u65E5\u56FE",custom:"\u81EA\u5B9A\u4E49\u56FE\u8868",chart:"\u56FE\u8868"}},aria:{general:{withTitle:"\u8FD9\u662F\u4E00\u4E2A\u5173\u4E8E\u201C{title}\u201D\u7684\u56FE\u8868\u3002",withoutTitle:"\u8FD9\u662F\u4E00\u4E2A\u56FE\u8868\uFF0C"},series:{single:{prefix:"",withName:"\u56FE\u8868\u7C7B\u578B\u662F{seriesType}\uFF0C\u8868\u793A{seriesName}\u3002",withoutName:"\u56FE\u8868\u7C7B\u578B\u662F{seriesType}\u3002"},multiple:{prefix:"\u5B83\u7531{seriesCount}\u4E2A\u56FE\u8868\u7CFB\u5217\u7EC4\u6210\u3002",withName:"\u7B2C{seriesId}\u4E2A\u7CFB\u5217\u662F\u4E00\u4E2A\u8868\u793A{seriesName}\u7684{seriesType}\uFF0C",withoutName:"\u7B2C{seriesId}\u4E2A\u7CFB\u5217\u662F\u4E00\u4E2A{seriesType}\uFF0C",separator:{middle:"\uFF1B",end:"\u3002"}}},data:{allData:"\u5176\u6570\u636E\u662F\u2014\u2014",partialData:"\u5176\u4E2D\uFF0C\u524D{displayCnt}\u9879\u662F\u2014\u2014",withName:"{name}\u7684\u6570\u636E\u662F{value}",withoutName:"{value}",separator:{middle:"\uFF0C",end:""}}}};var Cu="ZH",xp="EN",Xn=xp,Mu={},Sp={},Du=j.domSupported?(function(){var r=(document.documentElement.lang||navigator.language||navigator.browserLanguage||Xn).toUpperCase();return r.indexOf(Cu)>-1?Cu:Xn})():Xn;function Au(r,t){r=r.toUpperCase(),Sp[r]=new _t(t),Mu[r]=t}function X0(r){if(U(r)){var t=Mu[r.toUpperCase()]||{};return r===Cu||r===xp?Y(t):tt(Y(t),Y(Mu[Xn]),!1)}else return tt(Y(r),Y(Mu[Xn]),!1)}function q0(r){return Sp[r]}function K0(){return Sp[Xn]}Au(xp,Y0);Au(Cu,Z0);var Lu=1e3,Iu=Lu*60,Kn=Iu*60,He=Kn*24,wp=He*365,gs={year:"{yyyy}",month:"{MMM}",day:"{d}",hour:"{HH}:{mm}",minute:"{HH}:{mm}",second:"{HH}:{mm}:{ss}",millisecond:"{HH}:{mm}:{ss} {SSS}",none:"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss} {SSS}"},Eu="{yyyy}-{MM}-{dd}",Tp={year:"{yyyy}",month:"{yyyy}-{MM}",day:Eu,hour:Eu+" "+gs.hour,minute:Eu+" "+gs.minute,second:Eu+" "+gs.second,millisecond:gs.none},bp=["year","month","day","hour","minute","second","millisecond"],Mp=["year","half-year","quarter","month","week","half-week","day","half-day","quarter-day","hour","minute","second","millisecond"];function ce(r,t){return r+="","0000".substr(0,t-r.length)+r}function Ga(r){switch(r){case"half-year":case"quarter":return"month";case"week":case"half-week":return"day";case"half-day":case"quarter-day":return"hour";default:return r}}function j0(r){return r===Ga(r)}function Q0(r){switch(r){case"year":case"month":return"day";case"millisecond":return"millisecond";default:return"second"}}function oi(r,t,e,i){var a=ie(r),n=a[Pu(e)](),o=a[Ha(e)]()+1,s=Math.floor((o-1)/3)+1,l=a[ys(e)](),u=a["get"+(e?"UTC":"")+"Day"](),f=a[qn(e)](),h=(f-1)%12+1,p=a[_s(e)](),c=a[xs(e)](),v=a[Ss(e)](),m=f>=12?"pm":"am",d=m.toUpperCase(),g=i instanceof _t?i:q0(i||Du)||K0(),y=g.getModel("time"),_=y.get("month"),x=y.get("monthAbbr"),w=y.get("dayOfWeek"),S=y.get("dayOfWeekAbbr");return(t||"").replace(/{a}/g,m+"").replace(/{A}/g,d+"").replace(/{yyyy}/g,n+"").replace(/{yy}/g,ce(n%100+"",2)).replace(/{Q}/g,s+"").replace(/{MMMM}/g,_[o-1]).replace(/{MMM}/g,x[o-1]).replace(/{MM}/g,ce(o,2)).replace(/{M}/g,o+"").replace(/{dd}/g,ce(l,2)).replace(/{d}/g,l+"").replace(/{eeee}/g,w[u]).replace(/{ee}/g,S[u]).replace(/{e}/g,u+"").replace(/{HH}/g,ce(f,2)).replace(/{H}/g,f+"").replace(/{hh}/g,ce(h+"",2)).replace(/{h}/g,h+"").replace(/{mm}/g,ce(p,2)).replace(/{m}/g,p+"").replace(/{ss}/g,ce(c,2)).replace(/{s}/g,c+"").replace(/{SSS}/g,ce(v,3)).replace(/{S}/g,v+"")}function $0(r,t,e,i,a){var n=null;if(U(e))n=e;else if(G(e))n=e(r.value,t,{level:r.level});else{var o=N({},gs);if(r.level>0)for(var s=0;s=0;--s)if(l[u]){n=l[u];break}n=n||o.none}if(O(n)){var h=r.level==null?0:r.level>=0?r.level:n.length+r.level;h=Math.min(h,n.length-1),n=n[h]}}return oi(new Date(r.value),n,a,i)}function J0(r,t){var e=ie(r),i=e[Ha(t)]()+1,a=e[ys(t)](),n=e[qn(t)](),o=e[_s(t)](),s=e[xs(t)](),l=e[Ss(t)](),u=l===0,f=u&&s===0,h=f&&o===0,p=h&&n===0,c=p&&a===1,v=c&&i===1;return v?"year":c?"month":p?"day":h?"hour":f?"minute":u?"second":"millisecond"}function Cp(r,t,e){var i=nt(r)?ie(r):r;switch(t=t||J0(r,e),t){case"year":return i[Pu(e)]();case"half-year":return i[Ha(e)]()>=6?1:0;case"quarter":return Math.floor((i[Ha(e)]()+1)/4);case"month":return i[Ha(e)]();case"day":return i[ys(e)]();case"half-day":return i[qn(e)]()/24;case"hour":return i[qn(e)]();case"minute":return i[_s(e)]();case"second":return i[xs(e)]();case"millisecond":return i[Ss(e)]()}}function Pu(r){return r?"getUTCFullYear":"getFullYear"}function Ha(r){return r?"getUTCMonth":"getMonth"}function ys(r){return r?"getUTCDate":"getDate"}function qn(r){return r?"getUTCHours":"getHours"}function _s(r){return r?"getUTCMinutes":"getMinutes"}function xs(r){return r?"getUTCSeconds":"getSeconds"}function Ss(r){return r?"getUTCMilliseconds":"getMilliseconds"}function t_(r){return r?"setUTCFullYear":"setFullYear"}function Dp(r){return r?"setUTCMonth":"setMonth"}function Ap(r){return r?"setUTCDate":"setDate"}function Ep(r){return r?"setUTCHours":"setHours"}function Lp(r){return r?"setUTCMinutes":"setMinutes"}function Ip(r){return r?"setUTCSeconds":"setSeconds"}function Pp(r){return r?"setUTCMilliseconds":"setMilliseconds"}function Rp(r,t,e,i,a,n,o,s){var l=new vt({style:{text:r,font:t,align:e,verticalAlign:i,padding:a,rich:n,overflow:o?"truncate":null,lineHeight:s}});return l.getBoundingRect()}function bs(r){if(!Ko(r))return U(r)?r:"-";var t=(r+"").split(".");return t[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t.length>1?"."+t[1]:"")}function jn(r,t){return r=(r||"").toLowerCase().replace(/-(.)/g,function(e,i){return i.toUpperCase()}),t&&r&&(r=r.charAt(0).toUpperCase()+r.slice(1)),r}var or=Co;function Ru(r,t,e){var i="{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}";function a(f){return f&&te(f)?f:"-"}function n(f){return!!(f!=null&&!isNaN(f)&&isFinite(f))}var o=t==="time",s=r instanceof Date;if(o||s){var l=o?ie(r):r;if(isNaN(+l)){if(s)return"-"}else return oi(l,i,e)}if(t==="ordinal")return vn(r)?a(r):nt(r)&&n(r)?r+"":"-";var u=$e(r);return n(u)?bs(u):vn(r)?a(r):typeof r=="boolean"?r+"":"-"}var e_=["a","b","c","d","e","f","g"],Op=function(r,t){return"{"+r+(t??"")+"}"};function Qn(r,t,e){O(t)||(t=[t]);var i=t.length;if(!i)return"";for(var a=t[0].$vars||[],n=0;n':'';var o=e.markerId||"markerX";return{renderMode:n,content:"{"+o+"|} ",style:a==="subItem"?{width:4,height:4,borderRadius:2,backgroundColor:i}:{width:10,height:10,borderRadius:5,backgroundColor:i}}}function r_(r,t,e){(r==="week"||r==="month"||r==="quarter"||r==="half-year"||r==="year")&&(r=`MM-dd +yyyy`);var i=ie(t),a=e?"getUTC":"get",n=i[a+"FullYear"](),o=i[a+"Month"]()+1,s=i[a+"Date"](),l=i[a+"Hours"](),u=i[a+"Minutes"](),f=i[a+"Seconds"](),h=i[a+"Milliseconds"]();return r=r.replace("MM",ce(o,2)).replace("M",o).replace("yyyy",n).replace("yy",ce(n%100+"",2)).replace("dd",ce(s,2)).replace("d",s).replace("hh",ce(l,2)).replace("h",l).replace("mm",ce(u,2)).replace("m",u).replace("ss",ce(f,2)).replace("s",f).replace("SSS",ce(h,3)),r}function i_(r){return r&&r.charAt(0).toUpperCase()+r.substr(1)}function br(r,t){return t=t||"transparent",U(r)?r:F(r)&&r.colorStops&&(r.colorStops[0]||{}).color||t}var zu=b,pA=["left","right","top","bottom","width","height"],Nu=[["width","left","right"],["height","top","bottom"]];function Np(r,t,e,i,a){var n=0,o=0;i==null&&(i=1/0),a==null&&(a=1/0);var s=0;t.eachChild(function(l,u){var f=l.getBoundingRect(),h=t.childAt(u+1),p=h&&h.getBoundingRect(),c,v;if(r==="horizontal"){var m=f.width+(p?-p.x+f.x:0);c=n+m,c>i||l.newline?(n=0,c=m,o+=s+e,s=f.height):s=Math.max(s,f.height)}else{var d=f.height+(p?-p.y+f.y:0);v=o+d,v>a||l.newline?(n+=s+e,o=0,v=d,s=f.width):s=Math.max(s,f.width)}l.newline||(l.x=n,l.y=o,l.markRedraw(),r==="horizontal"?n=c+e:o=v+e)})}var si=Np,_V=ct(Np,"vertical"),xV=ct(Np,"horizontal");function pe(r,t,e){e=or(e||0);var i=t.width,a=t.height,n=yt(r.left,i),o=yt(r.top,a),s=yt(r.right,i),l=yt(r.bottom,a),u=yt(r.width,i),f=yt(r.height,a),h=e[2]+e[0],p=e[1]+e[3],c=r.aspect;switch(isNaN(u)&&(u=i-s-p-n),isNaN(f)&&(f=a-l-h-o),c!=null&&(isNaN(u)&&isNaN(f)&&(c>i/a?u=i*.8:f=a*.8),isNaN(u)&&(u=c*f),isNaN(f)&&(f=u/c)),isNaN(n)&&(n=i-s-u-p),isNaN(o)&&(o=a-l-f-h),r.left||r.right){case"center":n=i/2-u/2-e[3];break;case"right":n=i-u-p;break}switch(r.top||r.bottom){case"middle":case"center":o=a/2-f/2-e[0];break;case"bottom":o=a-f-h;break}n=n||0,o=o||0,isNaN(u)&&(u=i-p-n-(s||0)),isNaN(f)&&(f=a-h-o-(l||0));var v=new J(n+e[3],o+e[0],u,f);return v.margin=e,v}function a_(r,t,e,i,a,n){var o=!a||!a.hv||a.hv[0],s=!a||!a.hv||a.hv[1],l=a&&a.boundingMode||"all";if(n=n||r,n.x=r.x,n.y=r.y,!o&&!s)return!1;var u;if(l==="raw")u=r.type==="group"?new J(0,0,+t.width||0,+t.height||0):r.getBoundingRect();else if(u=r.getBoundingRect(),r.needLocalTransform()){var f=r.getLocalTransform();u=u.clone(),u.applyTransform(f)}var h=pe(K({width:u.width,height:u.height},t),e,i),p=o?h.x-u.x:0,c=s?h.y-u.y:0;return l==="raw"?(n.x=p,n.y=c):(n.x+=p,n.y+=c),n===r&&r.markRedraw(),!0}function Pi(r){var t=r.layoutMode||r.constructor.layoutMode;return F(t)?t:t?{type:t}:null}function Ur(r,t,e){var i=e&&e.ignoreSize;!O(i)&&(i=[i,i]);var a=o(Nu[0],0),n=o(Nu[1],1);u(Nu[0],r,a),u(Nu[1],r,n);function o(f,h){var p={},c=0,v={},m=0,d=2;if(zu(f,function(_){v[_]=r[_]}),zu(f,function(_){s(t,_)&&(p[_]=v[_]=t[_]),l(p,_)&&c++,l(v,_)&&m++}),i[h])return l(t,f[1])?v[f[2]]=null:l(t,f[2])&&(v[f[1]]=null),v;if(m===d||!c)return v;if(c>=d)return p;for(var g=0;g=0;l--)s=tt(s,a[l],!0);i.defaultOption=s}return i.defaultOption},t.prototype.getReferringComponents=function(e,i){var a=e+"Index",n=e+"Id";return bi(this.ecModel,e,{index:this.get(a,!0),id:this.get(n,!0)},i)},t.prototype.getBoxLayoutParams=function(){var e=this;return{left:e.get("left"),top:e.get("top"),right:e.get("right"),bottom:e.get("bottom"),width:e.get("width"),height:e.get("height")}},t.prototype.getZLevelKey=function(){return""},t.prototype.setZLevel=function(e){this.option.zlevel=e},t.protoInitialize=(function(){var e=t.prototype;e.type="component",e.id="",e.name="",e.mainType="",e.subType="",e.componentIndex=0})(),t})(_t);Jl($n,_t);wi($n);G0($n);W0($n,mA);function mA(r){var t=[];return b($n.getClassesByMainType(r),function(e){t=t.concat(e.dependencies||e.prototype.dependencies||[])}),t=k(t,function(e){return Le(e).main}),r!=="dataset"&&it(t,"dataset")<=0&&t.unshift("dataset"),t}var pt=$n;var n_="";typeof navigator<"u"&&(n_=navigator.platform||"");var Jn="rgba(0, 0, 0, 0.2)",o_={darkMode:"auto",colorBy:"series",color:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],gradientColor:["#f6efa6","#d88273","#bf444c"],aria:{decal:{decals:[{color:Jn,dashArrayX:[1,0],dashArrayY:[2,5],symbolSize:1,rotation:Math.PI/6},{color:Jn,symbol:"circle",dashArrayX:[[8,8],[0,8,8,0]],dashArrayY:[6,0],symbolSize:.8},{color:Jn,dashArrayX:[1,0],dashArrayY:[4,3],rotation:-Math.PI/4},{color:Jn,dashArrayX:[[6,6],[0,6,6,0]],dashArrayY:[6,0]},{color:Jn,dashArrayX:[[1,0],[1,6]],dashArrayY:[1,0,6,0],rotation:Math.PI/4},{color:Jn,symbol:"triangle",dashArrayX:[[9,9],[0,9,9,0]],dashArrayY:[7,2],symbolSize:.75}]}},textStyle:{fontFamily:n_.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},blendMode:null,stateAnimation:{duration:300,easing:"cubicOut"},animation:"auto",animationDuration:1e3,animationDurationUpdate:500,animationEasing:"cubicInOut",animationEasingUpdate:"cubicInOut",animationThreshold:2e3,progressiveThreshold:3e3,progressive:400,hoverLayerThreshold:3e3,useUTC:!1};var ku=W(["tooltip","label","itemName","itemId","itemGroupId","itemChildGroupId","seriesName"]),oe="original",se="arrayRows",Se="objectRows",Ge="keyedColumns",We="typedArray",zp="unknown",sr="column",li="row";var Xt={Must:1,Might:2,Not:3},s_=ht();function l_(r){s_(r).datasetMap=W()}function u_(r,t,e){var i={},a=Uu(t);if(!a||!r)return i;var n=[],o=[],s=t.ecModel,l=s_(s).datasetMap,u=a.uid+"_"+e.seriesLayoutBy,f,h;r=r.slice(),b(r,function(m,d){var g=F(m)?m:r[d]={name:m};g.type==="ordinal"&&f==null&&(f=d,h=v(g)),i[g.name]=[]});var p=l.get(u)||l.set(u,{categoryWayDim:h,valueWayDim:0});b(r,function(m,d){var g=m.name,y=v(m);if(f==null){var _=p.valueWayDim;c(i[g],_,y),c(o,_,y),p.valueWayDim+=y}else if(f===d)c(i[g],0,y),c(n,0,y);else{var _=p.categoryWayDim;c(i[g],_,y),c(o,_,y),p.categoryWayDim+=y}});function c(m,d,g){for(var y=0;yt)return r[i];return r[e-1]}function _A(r,t,e,i,a,n,o){n=n||r;var s=t(n),l=s.paletteIdx||0,u=s.paletteNameMap=s.paletteNameMap||{};if(u.hasOwnProperty(a))return u[a];var f=o==null||!i?e:yA(i,o);if(f=f||e,!(!f||!f.length)){var h=f[l];return a&&(u[a]=h),s.paletteIdx=(l+1)%f.length,h}}function xA(r,t){t(r).paletteIdx=0,t(r).paletteNameMap={}}var Bu,Ms,d_,m_="\0_ec_inner",SA=1;var x_=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.init=function(e,i,a,n,o,s){n=n||{},this.option=null,this._theme=new _t(n),this._locale=new _t(o),this._optionManager=s},t.prototype.setOption=function(e,i,a){var n=__(i);this._optionManager.setOption(e,a,n),this._resetOption(null,n)},t.prototype.resetOption=function(e,i){return this._resetOption(e,__(i))},t.prototype._resetOption=function(e,i){var a=!1,n=this._optionManager;if(!e||e==="recreate"){var o=n.mountOption(e==="recreate");!this.option||e==="recreate"?d_(this,o):(this.restoreData(),this._mergeOption(o,i)),a=!0}if((e==="timeline"||e==="media")&&this.restoreData(),!e||e==="recreate"||e==="timeline"){var s=n.getTimelineOption(this);s&&(a=!0,this._mergeOption(s,i))}if(!e||e==="recreate"||e==="media"){var l=n.getMediaOption(this);l.length&&b(l,function(u){a=!0,this._mergeOption(u,i)},this)}return a},t.prototype.mergeOption=function(e){this._mergeOption(e,null)},t.prototype._mergeOption=function(e,i){var a=this.option,n=this._componentsMap,o=this._componentsCount,s=[],l=W(),u=i&&i.replaceMergeMainTypeMap;l_(this),b(e,function(h,p){h!=null&&(pt.hasClass(p)?p&&(s.push(p),l.set(p,!0)):a[p]=a[p]==null?Y(h):tt(a[p],h,!0))}),u&&u.each(function(h,p){pt.hasClass(p)&&!l.get(p)&&(s.push(p),l.set(p,!0))}),pt.topologicalTravel(s,pt.getAllClassMainTypes(),f,this);function f(h){var p=p_(this,h,wt(e[h])),c=n.get(h),v=c?u&&u.get(h)?"replaceMerge":"normalMerge":"replaceAll",m=Yg(c,p,v);Xg(m,h,pt),a[h]=null,n.set(h,null),o.set(h,0);var d=[],g=[],y=0,_,x;b(m,function(w,S){var T=w.existing,M=w.newOption;if(!M)T&&(T.mergeOption({},this),T.optionUpdated({},!1));else{var D=h==="series",A=pt.getClass(h,w.keyInfo.subType,!D);if(!A){if(0)var C,E;return}if(h==="tooltip"){if(_)return;_=!0}if(T&&T.constructor===A)T.name=w.keyInfo.name,T.mergeOption(M,this),T.optionUpdated(M,!1);else{var L=N({componentIndex:S},w.keyInfo);T=new A(M,this,this,L),N(T,L),w.brandNew&&(T.__requireNewView=!0),T.init(M,this,this),T.optionUpdated(null,!0)}}T?(d.push(T.option),g.push(T),y++):(d.push(void 0),g.push(void 0))},this),a[h]=d,n.set(h,g),o.set(h,y),h==="series"&&Bu(this)}this._seriesIndices||Bu(this)},t.prototype.getOption=function(){var e=Y(this.option);return b(e,function(i,a){if(pt.hasClass(a)){for(var n=wt(i),o=n.length,s=!1,l=o-1;l>=0;l--)n[l]&&!In(n[l])?s=!0:(n[l]=null,!s&&o--);n.length=o,e[a]=n}}),delete e[m_],e},t.prototype.getTheme=function(){return this._theme},t.prototype.getLocaleModel=function(){return this._locale},t.prototype.setUpdatePayload=function(e){this._payload=e},t.prototype.getUpdatePayload=function(){return this._payload},t.prototype.getComponent=function(e,i){var a=this._componentsMap.get(e);if(a){var n=a[i||0];if(n)return n;if(i==null){for(var o=0;o=t:e==="max"?r<=t:r===t}function PA(r,t){return r.join(",")===t.join(",")}var S_=AA;var wr=b,Ds=F,b_=["areaStyle","lineStyle","nodeStyle","linkStyle","chordStyle","label","labelLine"];function Up(r){var t=r&&r.itemStyle;if(t)for(var e=0,i=b_.length;e=0;d--){var g=r[d];if(s||(v=g.data.rawIndexOf(g.stackedByDimension,c)),v>=0){var y=g.data.getByRawIndex(g.stackResultDimension,v);if(l==="all"||l==="positive"&&y>0||l==="negative"&&y<0||l==="samesign"&&p>=0&&y>0||l==="samesign"&&p<=0&&y<0){p=Ug(p,y),m=y;break}}}return i[0]=p,i[1]=m,i})})}var Wu=(function(){function r(t){this.data=t.data||(t.sourceFormat===Ge?{}:[]),this.sourceFormat=t.sourceFormat||zp,this.seriesLayoutBy=t.seriesLayoutBy||sr,this.startIndex=t.startIndex||0,this.dimensionsDetectedCount=t.dimensionsDetectedCount,this.metaRawOption=t.metaRawOption;var e=this.dimensionsDefine=t.dimensionsDefine;if(e)for(var i=0;im&&(m=_)}c[0]=v,c[1]=m}},a=function(){return this._data?this._data.length/this._dimSize:0};I_=(t={},t[se+"_"+sr]={pure:!0,appendData:n},t[se+"_"+li]={pure:!0,appendData:function(){throw new Error('Do not support appendData when set seriesLayoutBy: "row".')}},t[Se]={pure:!0,appendData:n},t[Ge]={pure:!0,appendData:function(o){var s=this._data;b(o,function(l,u){for(var f=s[u]||(s[u]=[]),h=0;h<(l||[]).length;h++)f.push(l[h])})}},t[oe]={appendData:n},t[We]={persistent:!1,pure:!0,appendData:function(o){this._data=o},clean:function(){this._offset+=this.count(),this._data=null}},t);function n(o){for(var s=0;s=0&&(m=o.interpolatedValue[d])}return m!=null?m+"":""})}},r.prototype.getRawValue=function(t,e){return fi(this.getData(e),t)},r.prototype.formatTooltip=function(t,e,i){},r})();function qp(r){var t,e;return F(r)?r.type&&(e=r):t=r,{text:t,frag:e}}function Oi(r){return new ZA(r)}var ZA=(function(){function r(t){t=t||{},this._reset=t.reset,this._plan=t.plan,this._count=t.count,this._onDirty=t.onDirty,this._dirty=!0}return r.prototype.perform=function(t){var e=this._upstream,i=t&&t.skip;if(this._dirty&&e){var a=this.context;a.data=a.outputData=e.context.outputData}this.__pipeline&&(this.__pipeline.currentTask=this);var n;this._plan&&!i&&(n=this._plan(this.context));var o=f(this._modBy),s=this._modDataCount||0,l=f(t&&t.modBy),u=t&&t.modDataCount||0;(o!==l||s!==u)&&(n="reset");function f(y){return!(y>=1)&&(y=1),y}var h;(this._dirty||n==="reset")&&(this._dirty=!1,h=this._doReset(i)),this._modBy=l,this._modDataCount=u;var p=t&&t.step;if(e?this._dueEnd=e._outputDueEnd:this._dueEnd=this._count?this._count(this.context):1/0,this._progress){var c=this._dueIndex,v=Math.min(p!=null?this._dueIndex+p:1/0,this._dueEnd);if(!i&&(h||c1&&i>0?s:o}};return n;function o(){return t=r?null:lt},gte:function(r,t){return r>=t}},IB=(function(){function r(t,e){if(!nt(e)){var i="";ae(i)}this._opFn=XA[t],this._rvalFloat=$e(e)}return r.prototype.evaluate=function(t){return nt(t)?this._opFn(t,this._rvalFloat):this._opFn($e(t),this._rvalFloat)},r})(),k_=(function(){function r(t,e){var i=t==="desc";this._resultLT=i?1:-1,e==null&&(e=i?"min":"max"),this._incomparable=e==="min"?-1/0:1/0}return r.prototype.evaluate=function(t,e){var i=nt(t)?t:$e(t),a=nt(e)?e:$e(e),n=isNaN(i),o=isNaN(a);if(n&&(i=this._incomparable),o&&(a=this._incomparable),n&&o){var s=U(t),l=U(e);s&&(i=l?t:0),l&&(a=s?e:0)}return ia?-this._resultLT:0},r})();var PB=(function(){function r(t,e){this._rval=e,this._isEQ=t,this._rvalTypeof=typeof e,this._rvalFloat=$e(e)}return r.prototype.evaluate=function(t){var e=t===this._rval;if(!e){var i=typeof t;i!==this._rvalTypeof&&(i==="number"||this._rvalTypeof==="number")&&(e=$e(t)===this._rvalFloat)}return this._isEQ?e:!e},r})();var qA=(function(){function r(){}return r.prototype.getRawData=function(){throw new Error("not supported")},r.prototype.getRawDataItem=function(t){throw new Error("not supported")},r.prototype.cloneRawData=function(){},r.prototype.getDimensionInfo=function(t){},r.prototype.cloneAllDimensionInfo=function(){},r.prototype.count=function(){},r.prototype.retrieveValue=function(t,e){},r.prototype.retrieveValueFromItem=function(t,e){},r.prototype.convertValue=function(t,e){return ro(t,e)},r})();function KA(r,t){var e=new qA,i=r.data,a=e.sourceFormat=r.sourceFormat,n=r.startIndex,o="";r.seriesLayoutBy!==sr&&ae(o);var s=[],l={},u=r.dimensionsDefine;if(u)b(u,function(m,d){var g=m.name,y={index:d,name:g,displayName:m.displayName};if(s.push(y),g!=null){var _="";Ze(l,g)&&ae(_),l[g]=y}});else for(var f=0;f65535?eE:rE}function io(){return[1/0,-1/0]}function iE(r){var t=r.constructor;return t===Array?r.slice():new t(r)}function H_(r,t,e,i,a){var n=G_[e||"float"];if(a){var o=r[t],s=o&&o.length;if(s!==i){for(var l=new n(i),u=0;ud[1]&&(d[1]=m)}return this._rawCount=this._count=l,{start:s,end:l}},r.prototype._initDataFromProvider=function(t,e,i){for(var a=this._provider,n=this._chunks,o=this._dimensions,s=o.length,l=this._rawExtent,u=k(o,function(y){return y.property}),f=0;fg[1]&&(g[1]=d)}}!a.persistent&&a.clean&&a.clean(),this._rawCount=this._count=e,this._extent=[]},r.prototype.count=function(){return this._count},r.prototype.get=function(t,e){if(!(e>=0&&e=0&&e=this._rawCount||t<0)return-1;if(!this._indices)return t;var e=this._indices,i=e[t];if(i!=null&&it)n=o-1;else return o}return-1},r.prototype.indicesOfNearest=function(t,e,i){var a=this._chunks,n=a[t],o=[];if(!n)return o;i==null&&(i=1/0);for(var s=1/0,l=-1,u=0,f=0,h=this.count();f=0&&l<0)&&(s=v,l=c,u=0),c===l&&(o[u++]=f))}return o.length=u,o},r.prototype.getIndices=function(){var t,e=this._indices;if(e){var i=e.constructor,a=this._count;if(i===Array){t=new i(a);for(var n=0;n=h&&y<=p||isNaN(y))&&(l[u++]=m),m++}v=!0}else if(n===2){for(var d=c[a[0]],_=c[a[1]],x=t[a[1]][0],w=t[a[1]][1],g=0;g=h&&y<=p||isNaN(y))&&(S>=x&&S<=w||isNaN(S))&&(l[u++]=m),m++}v=!0}}if(!v)if(n===1)for(var g=0;g=h&&y<=p||isNaN(y))&&(l[u++]=T)}else for(var g=0;gt[A][1])&&(M=!1)}M&&(l[u++]=e.getRawIndex(g))}return ug[1]&&(g[1]=d)}}}},r.prototype.lttbDownSample=function(t,e){var i=this.clone([t],!0),a=i._chunks,n=a[t],o=this.count(),s=0,l=Math.floor(1/e),u=this.getRawIndex(0),f,h,p,c=new(Ls(this._rawCount))(Math.min((Math.ceil(o/l)+2)*2,o));c[s++]=u;for(var v=1;vf&&(f=h,p=x)}C>0&&Cf-v&&(l=f-v,s.length=l);for(var m=0;mh[1]&&(h[1]=g),p[c++]=y}return n._count=c,n._indices=p,n._updateGetRawIdx(),n},r.prototype.each=function(t,e){if(this._count)for(var i=t.length,a=this._chunks,n=0,o=this.count();nl&&(l=h)}return o=[s,l],this._extent[t]=o,o},r.prototype.getRawDataItem=function(t){var e=this.getRawIndex(t);if(this._provider.persistent)return this._provider.getItem(e);for(var i=[],a=this._chunks,n=0;n=0?this._indices[t]:-1},r.prototype._updateGetRawIdx=function(){this.getRawIndex=this._indices?this._getRawIdx:this._getRawIdxIdentity},r.internalField=(function(){function t(e,i,a,n){return ro(e[n],this._dimensions[n])}jp={arrayRows:t,objectRows:function(e,i,a,n){return ro(e[i],this._dimensions[n])},keyedColumns:t,original:function(e,i,a,n){var o=e&&(e.value==null?e:e.value);return ro(o instanceof Array?o[n]:o,this._dimensions[n])},typedArray:function(e,i,a,n){return e[n]}}})(),r})(),Is=aE;var Y_=(function(){function r(t){this._sourceList=[],this._storeList=[],this._upstreamSignList=[],this._versionSignBase=0,this._dirty=!0,this._sourceHost=t}return r.prototype.dirty=function(){this._setLocalSource([],[]),this._storeList=[],this._dirty=!0},r.prototype._setLocalSource=function(t,e){this._sourceList=t,this._upstreamSignList=e,this._versionSignBase++,this._versionSignBase>9e10&&(this._versionSignBase=0)},r.prototype._getVersionSign=function(){return this._sourceHost.uid+"_"+this._versionSignBase},r.prototype.prepareSource=function(){this._isDirty()&&(this._createSource(),this._dirty=!1)},r.prototype._createSource=function(){this._setLocalSource([],[]);var t=this._sourceHost,e=this._getUpstreamSourceManagers(),i=!!e.length,a,n;if(qu(t)){var o=t,s=void 0,l=void 0,u=void 0;if(i){var f=e[0];f.prepareSource(),u=f.getSource(),s=u.data,l=u.sourceFormat,n=[f._getVersionSign()]}else s=o.get("data",!0),l=Et(s)?We:oe,n=[];var h=this._getSourceMetaRawOption()||{},p=u&&u.metaRawOption||{},c=et(h.seriesLayoutBy,p.seriesLayoutBy)||null,v=et(h.sourceHeader,p.sourceHeader),m=et(h.dimensions,p.dimensions),d=c!==p.seriesLayoutBy||!!v!=!!p.sourceHeader||m;a=d?[Es(s,{seriesLayoutBy:c,sourceHeader:v,dimensions:m},l)]:[]}else{var g=t;if(i){var y=this._applyTransform(e);a=y.sourceList,n=y.upstreamSignList}else{var _=g.get("source",!0);a=[Es(_,this._getSourceMetaRawOption(),null)],n=[]}}this._setLocalSource(a,n)},r.prototype._applyTransform=function(t){var e=this._sourceHost,i=e.get("transform",!0),a=e.get("fromTransformResult",!0);if(a!=null){var n="";t.length!==1&&W_(n)}var o,s=[],l=[];return b(t,function(u){u.prepareSource();var f=u.getSource(a||0),h="";a!=null&&!f&&W_(h),s.push(f),l.push(u._getVersionSign())}),i?o=B_(i,s,{datasetIndex:e.componentIndex}):a!=null&&(o=[L_(s[0])]),{sourceList:o,upstreamSignList:l}},r.prototype._isDirty=function(){if(this._dirty)return!0;for(var t=this._getUpstreamSourceManagers(),e=0;e1||e>0&&!r.noHeader;return b(r.blocks,function(a){var n=K_(a);n>=t&&(t=n+ +(i&&(!n||$p(a)&&!a.noHeader)))}),t}return 0}function sE(r,t,e,i){var a=t.noHeader,n=uE(K_(t)),o=[],s=t.blocks||[];Ft(!s||O(s)),s=s||[];var l=r.orderMode;if(t.sortBlocks&&l){s=s.slice();var u={valueAsc:"asc",valueDesc:"desc"};if(Ze(u,l)){var f=new k_(u[l],null);s.sort(function(v,m){return f.evaluate(v.sortParam,m.sortParam)})}else l==="seriesDesc"&&s.reverse()}b(s,function(v,m){var d=t.valueFormatter,g=q_(v)(d?N(N({},r),{valueFormatter:d}):r,v,m>0?n.html:0,i);g!=null&&o.push(g)});var h=r.renderMode==="richText"?o.join(n.richText):Jp(o.join(""),a?e:n.html);if(a)return h;var p=Ru(t.header,"ordinal",r.useUTC),c=X_(i,r.renderMode).nameStyle;return r.renderMode==="richText"?j_(r,p,c)+n.richText+h:Jp('
'+ee(p)+"
"+h,e)}function lE(r,t,e,i){var a=r.renderMode,n=t.noName,o=t.noValue,s=!t.markerType,l=t.name,u=r.useUTC,f=t.valueFormatter||r.valueFormatter||function(x){return x=O(x)?x:[x],k(x,function(w,S){return Ru(w,O(c)?c[S]:c,u)})};if(!(n&&o)){var h=s?"":r.markupStyleCreator.makeTooltipMarker(t.markerType,t.markerColor||"#333",a),p=n?"":Ru(l,"ordinal",u),c=t.valueType,v=o?[]:f(t.value,t.dataIndex),m=!s||!n,d=!s&&n,g=X_(i,a),y=g.nameStyle,_=g.valueStyle;return a==="richText"?(s?"":h)+(n?"":j_(r,p,y))+(o?"":cE(r,v,m,d,_)):Jp((s?"":h)+(n?"":fE(p,!s,y))+(o?"":hE(v,m,d,_)),e)}}function tv(r,t,e,i,a,n){if(r){var o=q_(r),s={useUTC:a,renderMode:e,orderMode:i,markupStyleCreator:t,valueFormatter:r.valueFormatter};return o(s,r,0,n)}}function uE(r){return{html:nE[r],richText:oE[r]}}function Jp(r,t){var e='
',i="margin: "+t+"px 0 0";return'
'+r+e+"
"}function fE(r,t,e){var i=t?"margin-left:2px":"";return''+ee(r)+""}function hE(r,t,e,i){var a=e?"10px":"20px",n=t?"float:right;margin-left:"+a:"";return r=O(r)?r:[r],''+k(r,function(o){return ee(o)}).join("  ")+""}function j_(r,t,e){return r.markupStyleCreator.wrapRichTextStyle(t,e)}function cE(r,t,e,i,a){var n=[a],o=i?10:20;return e&&n.push({padding:[0,0,0,o],align:"right"}),r.markupStyleCreator.wrapRichTextStyle(O(t)?t.join(" "):t,n)}function Q_(r,t){var e=r.getData().getItemVisual(t,"style"),i=e[r.visualDrawType];return br(i)}function Ku(r,t){var e=r.get("padding");return e??(t==="richText"?[8,10]:10)}var ju=(function(){function r(){this.richTextStyles={},this._nextStyleNameId=Ql()}return r.prototype._generateStyleName=function(){return"__EC_aUTo_"+this._nextStyleNameId++},r.prototype.makeTooltipMarker=function(t,e,i){var a=i==="richText"?this._generateStyleName():null,n=Ou({color:e,type:t,renderMode:i,markerId:a});return U(n)?n:(this.richTextStyles[a]=n.style,n.content)},r.prototype.wrapRichTextStyle=function(t,e){var i={};O(e)?b(e,function(n){return N(i,n)}):N(i,e);var a=this._generateStyleName();return this.richTextStyles[a]=i,"{"+a+"|"+t+"}"},r})();function $_(r){var t=r.series,e=r.dataIndex,i=r.multipleSeries,a=t.getData(),n=a.mapDimensionsAll("defaultedTooltip"),o=n.length,s=t.getRawValue(e),l=O(s),u=Q_(t,e),f,h,p,c;if(o>1||l&&!o){var v=pE(s,t,e,n,u);f=v.inlineValues,h=v.inlineValueTypes,p=v.blocks,c=v.inlineValues[0]}else if(o){var m=a.getDimensionInfo(n[0]);c=f=fi(a,e,n[0]),h=m.type}else c=f=l?s[0]:s;var d=Pn(t),g=d&&t.name||"",y=a.getName(e),_=i?g:y;return qa("section",{header:g,noHeader:i||!d,sortParam:c,blocks:[qa("nameValue",{markerType:"item",markerColor:u,name:_,noName:!te(_),value:f,valueType:h,dataIndex:e})].concat(p||[])})}function pE(r,t,e,i,a){var n=t.getData(),o=fe(r,function(h,p,c){var v=n.getDimensionInfo(c);return h=h||v&&v.tooltip!==!1&&v.displayName!=null},!1),s=[],l=[],u=[];i.length?b(i,function(h){f(fi(n,e,h),h)}):b(r,f);function f(h,p){var c=n.getDimensionInfo(p);!c||c.otherDims.tooltip===!1||(o?u.push(qa("nameValue",{markerType:"subItem",markerColor:a,name:c.displayName,value:h,valueType:c.type})):(s.push(h),l.push(c.type)))}return{inlineValues:s,inlineValueTypes:l,blocks:u}}var Ni=ht();function Qu(r,t){return r.getName(t)||r.getId(t)}var vE="__universalTransitionEnabled",$u=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._selectedDataIndicesMap={},e}return t.prototype.init=function(e,i,a){this.seriesIndex=this.componentIndex,this.dataTask=Oi({count:mE,reset:gE}),this.dataTask.context={model:this},this.mergeDefaultAndTheme(e,a);var n=Ni(this).sourceManager=new Y_(this);n.prepareSource();var o=this.getInitialData(e,a);tx(o,this),this.dataTask.context.data=o,Ni(this).dataBeforeProcessed=o,J_(this),this._initSelectedMapFromData(o)},t.prototype.mergeDefaultAndTheme=function(e,i){var a=Pi(this),n=a?Vr(e):{},o=this.subType;pt.hasClass(o)&&(o+="Series"),tt(e,i.getTheme().get(this.subType)),tt(e,this.getDefaultOption()),Qo(e,"label",["show"]),this.fillDataTextStyle(e.data),a&&Ur(e,n,a)},t.prototype.mergeOption=function(e,i){e=tt(this.option,e,!0),this.fillDataTextStyle(e.data);var a=Pi(this);a&&Ur(this.option,e,a);var n=Ni(this).sourceManager;n.dirty(),n.prepareSource();var o=this.getInitialData(e,i);tx(o,this),this.dataTask.dirty(),this.dataTask.context.data=o,Ni(this).dataBeforeProcessed=o,J_(this),this._initSelectedMapFromData(o)},t.prototype.fillDataTextStyle=function(e){if(e&&!Et(e))for(var i=["show"],a=0;athis.getShallow("animationThreshold")&&(i=!1),!!i},t.prototype.restoreData=function(){this.dataTask.dirty()},t.prototype.getColorFromPalette=function(e,i,a){var n=this.ecModel,o=Ts.prototype.getColorFromPalette.call(this,e,i,a);return o||(o=n.getColorFromPalette(e,i,a)),o},t.prototype.coordDimToDataDim=function(e){return this.getRawData().mapDimensionsAll(e)},t.prototype.getProgressive=function(){return this.get("progressive")},t.prototype.getProgressiveThreshold=function(){return this.get("progressiveThreshold")},t.prototype.select=function(e,i){this._innerSelect(this.getData(i),e)},t.prototype.unselect=function(e,i){var a=this.option.selectedMap;if(a){var n=this.option.selectedMode,o=this.getData(i);if(n==="series"||a==="all"){this.option.selectedMap={},this._selectedDataIndicesMap={};return}for(var s=0;s=0&&a.push(o)}return a},t.prototype.isSelected=function(e,i){var a=this.option.selectedMap;if(!a)return!1;var n=this.getData(i);return(a==="all"||a[Qu(n,e)])&&!n.getItemModel(e).get(["select","disabled"])},t.prototype.isUniversalTransitionEnabled=function(){if(this[vE])return!0;var e=this.option.universalTransition;return e?e===!0?!0:e&&e.enabled:!1},t.prototype._innerSelect=function(e,i){var a,n,o=this.option,s=o.selectedMode,l=i.length;if(!(!s||!l)){if(s==="series")o.selectedMap="all";else if(s==="multiple"){F(o.selectedMap)||(o.selectedMap={});for(var u=o.selectedMap,f=0;f0&&this._innerSelect(e,i)}},t.registerClass=function(e){return pt.registerClass(e)},t.protoInitialize=(function(){var e=t.prototype;e.type="series.__base__",e.seriesIndex=0,e.ignoreStyleOnData=!1,e.hasSymbolVisual=!1,e.defaultSymbol="circle",e.visualStyleAccessPath="itemStyle",e.visualDrawType="fill"})(),t})(pt);Jt($u,N_);Jt($u,Ts);Jl($u,pt);function J_(r){var t=r.name;Pn(r)||(r.name=dE(r)||t)}function dE(r){var t=r.getRawData(),e=t.mapDimensionsAll("seriesName"),i=[];return b(e,function(a){var n=t.getDimensionInfo(a);n.displayName&&i.push(n.displayName)}),i.join(" ")}function mE(r){return r.model.getRawData().count()}function gE(r){var t=r.model;return t.setData(t.getRawData().cloneShallow()),yE}function yE(r,t){t.outputData&&r.end>t.outputData.count()&&t.model.getRawData().cloneShallow(t.outputData)}function tx(r,t){b(wh(r.CHANGABLE_METHODS,r.DOWNSAMPLE_METHODS),function(e){r.wrapMethod(e,ct(_E,t))})}function _E(r,t){var e=ev(r);return e&&e.setOutputEnd((t||this).count()),t}function ev(r){var t=(r.ecModel||{}).scheduler,e=t&&t.getPipeline(r.uid);if(e){var i=e.currentTask;if(i){var a=i.agentStubMap;a&&(i=a.get(r.uid))}return i}}var qt=$u;var rv=(function(){function r(){this.group=new ft,this.uid=Ii("viewComponent")}return r.prototype.init=function(t,e){},r.prototype.render=function(t,e,i,a){},r.prototype.dispose=function(t,e){},r.prototype.updateView=function(t,e,i,a){},r.prototype.updateLayout=function(t,e,i,a){},r.prototype.updateVisual=function(t,e,i,a){},r.prototype.toggleBlurSeries=function(t,e,i){},r.prototype.eachRendered=function(t){var e=this.group;e&&e.traverse(t)},r})();Rn(rv);wi(rv);var Lt=rv;function Ka(){var r=ht();return function(t){var e=r(t),i=t.pipelineContext,a=!!e.large,n=!!e.progressiveRender,o=e.large=!!(i&&i.large),s=e.progressiveRender=!!(i&&i.progressiveRender);return(a!==o||n!==s)&&"reset"}}var ix=ht(),xE=Ka(),iv=(function(){function r(){this.group=new ft,this.uid=Ii("viewChart"),this.renderTask=Oi({plan:SE,reset:bE}),this.renderTask.context={view:this}}return r.prototype.init=function(t,e){},r.prototype.render=function(t,e,i,a){},r.prototype.highlight=function(t,e,i,a){var n=t.getData(a&&a.dataType);n&&rx(n,a,"emphasis")},r.prototype.downplay=function(t,e,i,a){var n=t.getData(a&&a.dataType);n&&rx(n,a,"normal")},r.prototype.remove=function(t,e){this.group.removeAll()},r.prototype.dispose=function(t,e){},r.prototype.updateView=function(t,e,i,a){this.render(t,e,i,a)},r.prototype.updateLayout=function(t,e,i,a){this.render(t,e,i,a)},r.prototype.updateVisual=function(t,e,i,a){this.render(t,e,i,a)},r.prototype.eachRendered=function(t){ni(this.group,t)},r.markUpdateMethod=function(t,e){ix(t).updateMethod=e},r.protoInitialize=(function(){var t=r.prototype;t.type="chart"})(),r})();function ex(r,t,e){r&&ss(r)&&(t==="emphasis"?Ea:La)(r,e)}function rx(r,t,e){var i=Je(r,t),a=t&&t.highlightKey!=null?e0(t.highlightKey):null;i!=null?b(wt(i),function(n){ex(r.getItemGraphicEl(n),e,a)}):r.eachItemGraphicEl(function(n){ex(n,e,a)})}Rn(iv,["dispose"]);wi(iv);function SE(r){return xE(r.model)}function bE(r){var t=r.model,e=r.ecModel,i=r.api,a=r.payload,n=t.pipelineContext.progressiveRender,o=r.view,s=a&&ix(a).updateMethod,l=n?"incrementalPrepareRender":s&&o[s]?s:"render";return l!=="render"&&o[l](t,e,i,a),wE[l]}var wE={incrementalPrepareRender:{progress:function(r,t){t.view.incrementalRender(r,t.model,t.ecModel,t.api,t.payload)}},render:{forceFirstProgress:!0,progress:function(r,t){t.view.render(t.model,t.ecModel,t.api,t.payload)}}},Ut=iv;var Ju="\0__throttleOriginMethod",ax="\0__throttleRate",nx="\0__throttleType";function ja(r,t,e){var i,a=0,n=0,o=null,s,l,u,f;t=t||0;function h(){n=new Date().getTime(),o=null,r.apply(l,u||[])}var p=function(){for(var c=[],v=0;v=0?h():o=setTimeout(h,-s),a=i};return p.clear=function(){o&&(clearTimeout(o),o=null)},p.debounceNextCall=function(c){f=c},p}function zi(r,t,e,i){var a=r[t];if(a){var n=a[Ju]||a,o=a[nx],s=a[ax];if(s!==e||o!==i){if(e==null||!i)return r[t]=n;a=r[t]=ja(n,e,i==="debounce"),a[Ju]=n,a[nx]=i,a[ax]=e}return a}}function Qa(r,t){var e=r[t];e&&e[Ju]&&(e.clear&&e.clear(),r[t]=e[Ju])}var ox=ht(),sx={itemStyle:Ir(yp,!0),lineStyle:Ir(gp,!0)},TE={lineStyle:"stroke",itemStyle:"fill"};function lx(r,t){var e=r.visualStyleMapper||sx[t];return e||(console.warn("Unknown style type '"+t+"'."),sx.itemStyle)}function ux(r,t){var e=r.visualDrawType||TE[t];return e||(console.warn("Unknown style type '"+t+"'."),"fill")}var fx={createOnAllSeries:!0,performRawSeries:!0,reset:function(r,t){var e=r.getData(),i=r.visualStyleAccessPath||"itemStyle",a=r.getModel(i),n=lx(r,i),o=n(a),s=a.getShallow("decal");s&&(e.setVisual("decal",s),s.dirty=!0);var l=ux(r,i),u=o[l],f=G(u)?u:null,h=o.fill==="auto"||o.stroke==="auto";if(!o[l]||f||h){var p=r.getColorFromPalette(r.name,null,t.getSeriesCount());o[l]||(o[l]=p,e.setVisual("colorFromPalette",!0)),o.fill=o.fill==="auto"||G(o.fill)?p:o.fill,o.stroke=o.stroke==="auto"||G(o.stroke)?p:o.stroke}if(e.setVisual("style",o),e.setVisual("drawType",l),!t.isSeriesFiltered(r)&&f)return e.setVisual("colorFromPalette",!1),{dataEach:function(c,v){var m=r.getDataParams(v),d=N({},o);d[l]=f(m),c.setItemVisual(v,"style",d)}}}},Ps=new _t,hx={createOnAllSeries:!0,performRawSeries:!0,reset:function(r,t){if(!(r.ignoreStyleOnData||t.isSeriesFiltered(r))){var e=r.getData(),i=r.visualStyleAccessPath||"itemStyle",a=lx(r,i),n=e.getVisual("drawType");return{dataEach:e.hasItemOption?function(o,s){var l=o.getRawDataItem(s);if(l&&l[i]){Ps.option=l[i];var u=a(Ps),f=o.ensureUniqueItemVisual(s,"style");N(f,u),Ps.option.decal&&(o.setItemVisual(s,"decal",Ps.option.decal),Ps.option.decal.dirty=!0),n in u&&o.setItemVisual(s,"colorFromPalette",!1)}}:null}}}},cx={performRawSeries:!0,overallReset:function(r){var t=W();r.eachSeries(function(e){var i=e.getColorBy();if(!e.isColorBySeries()){var a=e.type+"-"+i,n=t.get(a);n||(n={},t.set(a,n)),ox(e).scope=n}}),r.eachSeries(function(e){if(!(e.isColorBySeries()||r.isSeriesFiltered(e))){var i=e.getRawData(),a={},n=e.getData(),o=ox(e).scope,s=e.visualStyleAccessPath||"itemStyle",l=ux(e,s);n.each(function(u){var f=n.getRawIndex(u);a[f]=u}),i.each(function(u){var f=a[u],h=n.getItemVisual(f,"colorFromPalette");if(h){var p=n.ensureUniqueItemVisual(f,"style"),c=i.getName(u)||u+"",v=i.count();p[l]=e.getColorFromPalette(c,o,v)}})}})}};var tf=Math.PI;function nv(r,t){t=t||{},K(t,{text:"loading",textColor:"#000",fontSize:12,fontWeight:"normal",fontStyle:"normal",fontFamily:"sans-serif",maskColor:"rgba(255, 255, 255, 0.8)",showSpinner:!0,color:"#5470c6",spinnerRadius:10,lineWidth:5,zlevel:0});var e=new ft,i=new st({style:{fill:t.maskColor},zlevel:t.zlevel,z:1e4});e.add(i);var a=new vt({style:{text:t.text,fill:t.textColor,fontSize:t.fontSize,fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:t.fontFamily},zlevel:t.zlevel,z:10001}),n=new st({style:{fill:"none"},textContent:a,textConfig:{position:"right",distance:10},zlevel:t.zlevel,z:10001});e.add(n);var o;return t.showSpinner&&(o=new Oa({shape:{startAngle:-tf/2,endAngle:-tf/2+.1,r:t.spinnerRadius},style:{stroke:t.color,lineCap:"round",lineWidth:t.lineWidth},zlevel:t.zlevel,z:10001}),o.animateShape(!0).when(1e3,{endAngle:tf*3/2}).start("circularInOut"),o.animateShape(!0).when(1e3,{startAngle:tf*3/2}).delay(300).start("circularInOut"),e.add(o)),e.resize=function(){var s=a.getBoundingRect().width,l=t.showSpinner?t.spinnerRadius:0,u=(r.getWidth()-l*2-(t.showSpinner&&s?10:0)-s)/2-(t.showSpinner&&s?0:5+s/2)+(t.showSpinner?0:s/2)+(s?0:l),f=r.getHeight()/2;t.showSpinner&&o.setShape({cx:u,cy:f}),n.setShape({x:u-l,y:f-l,width:l*2,height:l*2}),i.setShape({x:0,y:0,width:r.getWidth(),height:r.getHeight()})},e.resize(),e}var ME=(function(){function r(t,e,i,a){this._stageTaskMap=W(),this.ecInstance=t,this.api=e,i=this._dataProcessorHandlers=i.slice(),a=this._visualHandlers=a.slice(),this._allHandlers=i.concat(a)}return r.prototype.restoreData=function(t,e){t.restoreData(e),this._stageTaskMap.each(function(i){var a=i.overallTask;a&&a.dirty()})},r.prototype.getPerformArgs=function(t,e){if(t.__pipeline){var i=this._pipelineMap.get(t.__pipeline.id),a=i.context,n=!e&&i.progressiveEnabled&&(!a||a.progressiveRender)&&t.__idxInPipeline>i.blockIndex,o=n?i.step:null,s=a&&a.modDataCount,l=s!=null?Math.ceil(s/o):null;return{step:o,modBy:l,modDataCount:s}}},r.prototype.getPipeline=function(t){return this._pipelineMap.get(t)},r.prototype.updateStreamModes=function(t,e){var i=this._pipelineMap.get(t.uid),a=t.getData(),n=a.count(),o=i.progressiveEnabled&&e.incrementalPrepareRender&&n>=i.threshold,s=t.get("large")&&n>=t.get("largeThreshold"),l=t.get("progressiveChunkMode")==="mod"?n:null;t.pipelineContext=i.context={progressiveRender:o,modDataCount:l,large:s}},r.prototype.restorePipelines=function(t){var e=this,i=e._pipelineMap=W();t.eachSeries(function(a){var n=a.getProgressive(),o=a.uid;i.set(o,{id:o,head:null,tail:null,threshold:a.getProgressiveThreshold(),progressiveEnabled:n&&!(a.preventIncremental&&a.preventIncremental()),blockIndex:-1,step:Math.round(n||700),count:0}),e._pipe(a,a.dataTask)})},r.prototype.prepareStageTasks=function(){var t=this._stageTaskMap,e=this.api.getModel(),i=this.api;b(this._allHandlers,function(a){var n=t.get(a.uid)||t.set(a.uid,{}),o="";Ft(!(a.reset&&a.overallReset),o),a.reset&&this._createSeriesStageTask(a,n,e,i),a.overallReset&&this._createOverallStageTask(a,n,e,i)},this)},r.prototype.prepareView=function(t,e,i,a){var n=t.renderTask,o=n.context;o.model=e,o.ecModel=i,o.api=a,n.__block=!t.incrementalPrepareRender,this._pipe(e,n)},r.prototype.performDataProcessorTasks=function(t,e){this._performStageTasks(this._dataProcessorHandlers,t,e,{block:!0})},r.prototype.performVisualTasks=function(t,e,i){this._performStageTasks(this._visualHandlers,t,e,i)},r.prototype._performStageTasks=function(t,e,i,a){a=a||{};var n=!1,o=this;b(t,function(l,u){if(!(a.visualType&&a.visualType!==l.visualType)){var f=o._stageTaskMap.get(l.uid),h=f.seriesTaskMap,p=f.overallTask;if(p){var c,v=p.agentStubMap;v.each(function(d){s(a,d)&&(d.dirty(),c=!0)}),c&&p.dirty(),o.updatePayload(p,i);var m=o.getPerformArgs(p,a.block);v.each(function(d){d.perform(m)}),p.perform(m)&&(n=!0)}else h&&h.each(function(d,g){s(a,d)&&d.dirty();var y=o.getPerformArgs(d,a.block);y.skip=!l.performRawSeries&&e.isSeriesFiltered(d.context.model),o.updatePayload(d,i),d.perform(y)&&(n=!0)})}});function s(l,u){return l.setDirty&&(!l.dirtyMap||l.dirtyMap.get(u.__pipeline.id))}this.unfinished=n||this.unfinished},r.prototype.performSeriesTasks=function(t){var e;t.eachSeries(function(i){e=i.dataTask.perform()||e}),this.unfinished=e||this.unfinished},r.prototype.plan=function(){this._pipelineMap.each(function(t){var e=t.tail;do{if(e.__block){t.blockIndex=e.__idxInPipeline;break}e=e.getUpstream()}while(e)})},r.prototype.updatePayload=function(t,e){e!=="remain"&&(t.context.payload=e)},r.prototype._createSeriesStageTask=function(t,e,i,a){var n=this,o=e.seriesTaskMap,s=e.seriesTaskMap=W(),l=t.seriesType,u=t.getTargetSeries;t.createOnAllSeries?i.eachRawSeries(f):l?i.eachRawSeriesByType(l,f):u&&u(i,a).each(f);function f(h){var p=h.uid,c=s.set(p,o&&o.get(p)||Oi({plan:LE,reset:IE,count:RE}));c.context={model:h,ecModel:i,api:a,useClearVisual:t.isVisual&&!t.isLayout,plan:t.plan,reset:t.reset,scheduler:n},n._pipe(h,c)}},r.prototype._createOverallStageTask=function(t,e,i,a){var n=this,o=e.overallTask=e.overallTask||Oi({reset:CE});o.context={ecModel:i,api:a,overallReset:t.overallReset,scheduler:n};var s=o.agentStubMap,l=o.agentStubMap=W(),u=t.seriesType,f=t.getTargetSeries,h=!0,p=!1,c="";Ft(!t.createOnAllSeries,c),u?i.eachRawSeriesByType(u,v):f?f(i,a).each(v):(h=!1,b(i.getSeries(),v));function v(m){var d=m.uid,g=l.set(d,s&&s.get(d)||(p=!0,Oi({reset:DE,onDirty:EE})));g.context={model:m,overallProgress:h},g.agent=o,g.__block=h,n._pipe(m,g)}p&&o.dirty()},r.prototype._pipe=function(t,e){var i=t.uid,a=this._pipelineMap.get(i);!a.head&&(a.head=e),a.tail&&a.tail.pipe(e),a.tail=e,e.__idxInPipeline=a.count++,e.__pipeline=a},r.wrapStageHandler=function(t,e){return G(t)&&(t={overallReset:t,seriesType:OE(t)}),t.uid=Ii("stageHandler"),e&&(t.visualType=e),t},r})();function CE(r){r.overallReset(r.ecModel,r.api,r.payload)}function DE(r){return r.overallProgress&&AE}function AE(){this.agent.dirty(),this.getDownstream().dirty()}function EE(){this.agent&&this.agent.dirty()}function LE(r){return r.plan?r.plan(r.model,r.ecModel,r.api,r.payload):null}function IE(r){r.useClearVisual&&r.data.clearAllVisual();var t=r.resetDefines=wt(r.reset(r.model,r.ecModel,r.api,r.payload));return t.length>1?k(t,function(e,i){return px(i)}):PE}var PE=px(0);function px(r){return function(t,e){var i=e.data,a=e.resetDefines[r];if(a&&a.dataEach)for(var n=t.start;n0&&c===u.length-p.length){var v=u.slice(0,c);v!=="data"&&(e.mainType=v,e[p.toLowerCase()]=l,f=!0)}}s.hasOwnProperty(u)&&(i[u]=l,f=!0),f||(a[u]=l)})}return{cptQuery:e,dataQuery:i,otherQuery:a}},r.prototype.filter=function(t,e){var i=this.eventInfo;if(!i)return!0;var a=i.targetEl,n=i.packedEvent,o=i.model,s=i.view;if(!o||!s)return!0;var l=e.cptQuery,u=e.dataQuery;return f(l,o,"mainType")&&f(l,o,"subType")&&f(l,o,"index","componentIndex")&&f(l,o,"name")&&f(l,o,"id")&&f(u,n,"name")&&f(u,n,"dataIndex")&&f(u,n,"dataType")&&(!s.filterForExposedEvent||s.filterForExposedEvent(t,e.otherQuery,a,n));function f(h,p,c,v){return h[c]==null||p[v||c]===h[c]}},r.prototype.afterTrigger=function(){this.eventInfo=null},r})();var sv=["symbol","symbolSize","symbolRotate","symbolOffset"],Tx=sv.concat(["symbolKeepAspect"]),Mx={createOnAllSeries:!0,performRawSeries:!0,reset:function(r,t){var e=r.getData();if(r.legendIcon&&e.setVisual("legendIcon",r.legendIcon),!r.hasSymbolVisual)return;for(var i={},a={},n=!1,o=0;o=0&&$a(l)?l:.5;var u=r.createRadialGradient(o,s,0,o,s,l);return u}function Ns(r,t,e){for(var i=t.type==="radial"?XE(r,t,e):ZE(r,t,e),a=t.colorStops,n=0;n0)?null:r==="dashed"?[4*t,2*t]:r==="dotted"?[t]:nt(r)?[r]:O(r)?r:null}function lv(r){var t=r.style,e=t.lineDash&&t.lineWidth>0&&qE(t.lineDash,t.lineWidth),i=t.lineDashOffset;if(e){var a=t.strokeNoScale&&r.getLineScale?r.getLineScale():1;a&&a!==1&&(e=k(e,function(n){return n/a}),i/=a)}return[e,i]}var KE=new ye(!0);function lf(r){var t=r.stroke;return!(t==null||t==="none"||!(r.lineWidth>0))}function Rx(r){return typeof r=="string"&&r!=="none"}function uf(r){var t=r.fill;return t!=null&&t!=="none"}function Ox(r,t){if(t.fillOpacity!=null&&t.fillOpacity!==1){var e=r.globalAlpha;r.globalAlpha=t.fillOpacity*t.opacity,r.fill(),r.globalAlpha=e}else r.fill()}function Nx(r,t){if(t.strokeOpacity!=null&&t.strokeOpacity!==1){var e=r.globalAlpha;r.globalAlpha=t.strokeOpacity*t.opacity,r.stroke(),r.globalAlpha=e}else r.stroke()}function ff(r,t,e){var i=Tc(t.image,t.__image,e);if(On(i)){var a=r.createPattern(i,t.repeat||"repeat");if(typeof DOMMatrix=="function"&&a&&a.setTransform){var n=new DOMMatrix;n.translateSelf(t.x||0,t.y||0),n.rotateSelf(0,0,(t.rotation||0)*xl),n.scaleSelf(t.scaleX||1,t.scaleY||1),a.setTransform(n)}return a}}function jE(r,t,e,i){var a,n=lf(e),o=uf(e),s=e.strokePercent,l=s<1,u=!t.path;(!t.silent||l)&&u&&t.createPathProxy();var f=t.path||KE,h=t.__dirty;if(!i){var p=e.fill,c=e.stroke,v=o&&!!p.colorStops,m=n&&!!c.colorStops,d=o&&!!p.image,g=n&&!!c.image,y=void 0,_=void 0,x=void 0,w=void 0,S=void 0;(v||m)&&(S=t.getBoundingRect()),v&&(y=h?Ns(r,p,S):t.__canvasFillGradient,t.__canvasFillGradient=y),m&&(_=h?Ns(r,c,S):t.__canvasStrokeGradient,t.__canvasStrokeGradient=_),d&&(x=h||!t.__canvasFillPattern?ff(r,p,t):t.__canvasFillPattern,t.__canvasFillPattern=x),g&&(w=h||!t.__canvasStrokePattern?ff(r,c,t):t.__canvasStrokePattern,t.__canvasStrokePattern=x),v?r.fillStyle=y:d&&(x?r.fillStyle=x:o=!1),m?r.strokeStyle=_:g&&(w?r.strokeStyle=w:n=!1)}var T=t.getGlobalScale();f.setScale(T[0],T[1],t.segmentIgnoreThreshold);var M,D;r.setLineDash&&e.lineDash&&(a=lv(t),M=a[0],D=a[1]);var A=!0;(u||h&gi)&&(f.setDPR(r.dpr),l?f.setContext(null):(f.setContext(r),A=!1),f.reset(),t.buildPath(f,t.shape,i),f.toStatic(),t.pathUpdated()),A&&f.rebuildPath(r,l?s:1),M&&(r.setLineDash(M),r.lineDashOffset=D),i||(e.strokeFirst?(n&&Nx(r,e),o&&Ox(r,e)):(o&&Ox(r,e),n&&Nx(r,e))),M&&r.setLineDash([])}function QE(r,t,e){var i=t.__image=Tc(e.image,t.__image,t,t.onload);if(!(!i||!On(i))){var a=e.x||0,n=e.y||0,o=t.getWidth(),s=t.getHeight(),l=i.width/i.height;if(o==null&&s!=null?o=s*l:s==null&&o!=null?s=o/l:o==null&&s==null&&(o=i.width,s=i.height),e.sWidth&&e.sHeight){var u=e.sx||0,f=e.sy||0;r.drawImage(i,u,f,e.sWidth,e.sHeight,a,n,o,s)}else if(e.sx&&e.sy){var u=e.sx,f=e.sy,h=o-u,p=s-f;r.drawImage(i,u,f,h,p,a,n,o,s)}else r.drawImage(i,a,n,o,s)}}function $E(r,t,e){var i,a=e.text;if(a!=null&&(a+=""),a){r.font=e.font||pr,r.textAlign=e.textAlign,r.textBaseline=e.textBaseline;var n=void 0,o=void 0;r.setLineDash&&e.lineDash&&(i=lv(t),n=i[0],o=i[1]),n&&(r.setLineDash(n),r.lineDashOffset=o),e.strokeFirst?(lf(e)&&r.strokeText(a,e.x,e.y),uf(e)&&r.fillText(a,e.x,e.y)):(uf(e)&&r.fillText(a,e.x,e.y),lf(e)&&r.strokeText(a,e.x,e.y)),n&&r.setLineDash([])}}var zx=["shadowBlur","shadowOffsetX","shadowOffsetY"],kx=[["lineCap","butt"],["lineJoin","miter"],["miterLimit",10]];function Gx(r,t,e,i,a){var n=!1;if(!i&&(e=e||{},t===e))return!1;if(i||t.opacity!==e.opacity){Pe(r,a),n=!0;var o=Math.max(Math.min(t.opacity,1),0);r.globalAlpha=isNaN(o)?Pr.opacity:o}(i||t.blend!==e.blend)&&(n||(Pe(r,a),n=!0),r.globalCompositeOperation=t.blend||Pr.blend);for(var s=0;s0&&e.unfinished);e.unfinished||this._zr.flush()}}},t.prototype.getDom=function(){return this._dom},t.prototype.getId=function(){return this.id},t.prototype.getZr=function(){return this._zr},t.prototype.isSSR=function(){return this._ssr},t.prototype.setOption=function(e,i,a){if(!this[de]){if(this._disposed){this.id;return}var n,o,s;if(F(i)&&(a=i.lazyUpdate,n=i.silent,o=i.replaceMerge,s=i.transition,i=i.notMerge),this[de]=!0,!this._model||i){var l=new S_(this._api),u=this._theme,f=this._model=new Fu;f.scheduler=this._scheduler,f.ssr=this._ssr,f.init(null,null,null,u,this._locale,l)}this._model.setOption(e,{replaceMerge:o},xv);var h={seriesTransition:s,optionChanged:!0};if(a)this[Re]={silent:n,updateParams:h},this[de]=!1,this.getZr().wakeUp();else{try{oo(this),Ui.update.call(this,null,h)}catch(p){throw this[Re]=null,this[de]=!1,p}this._ssr||this._zr.flush(),this[Re]=null,this[de]=!1,Vs.call(this,n),Bs.call(this,n)}}},t.prototype.setTheme=function(){},t.prototype.getModel=function(){return this._model},t.prototype.getOption=function(){return this._model&&this._model.getOption()},t.prototype.getWidth=function(){return this._zr.getWidth()},t.prototype.getHeight=function(){return this._zr.getHeight()},t.prototype.getDevicePixelRatio=function(){return this._zr.painter.dpr||j.hasGlobalWindow&&window.devicePixelRatio||1},t.prototype.getRenderedCanvas=function(e){return this.renderToCanvas(e)},t.prototype.renderToCanvas=function(e){e=e||{};var i=this._zr.painter;return i.getRenderedCanvas({backgroundColor:e.backgroundColor||this._model.get("backgroundColor"),pixelRatio:e.pixelRatio||this.getDevicePixelRatio()})},t.prototype.renderToSVGString=function(e){e=e||{};var i=this._zr.painter;return i.renderToString({useViewBox:e.useViewBox})},t.prototype.getSvgDataURL=function(){if(j.svgSupported){var e=this._zr,i=e.storage.getDisplayList();return b(i,function(a){a.stopAnimation(null,!0)}),e.painter.toDataURL()}},t.prototype.getDataURL=function(e){if(this._disposed){this.id;return}e=e||{};var i=e.excludeComponents,a=this._model,n=[],o=this;b(i,function(l){a.eachComponent({mainType:l},function(u){var f=o._componentsMap[u.__viewId];f.group.ignore||(n.push(f),f.group.ignore=!0)})});var s=this._zr.painter.getType()==="svg"?this.getSvgDataURL():this.renderToCanvas(e).toDataURL("image/"+(e&&e.type||"png"));return b(n,function(l){l.group.ignore=!1}),s},t.prototype.getConnectedDataURL=function(e){if(this._disposed){this.id;return}var i=e.type==="svg",a=this.group,n=Math.min,o=Math.max,s=1/0;if(mf[a]){var l=s,u=s,f=-s,h=-s,p=[],c=e&&e.pixelRatio||this.getDevicePixelRatio();b(Ja,function(_,x){if(_.group===a){var w=i?_.getZr().painter.getSvgDom().innerHTML:_.renderToCanvas(Y(e)),S=_.getDom().getBoundingClientRect();l=n(S.left,l),u=n(S.top,u),f=o(S.right,f),h=o(S.bottom,h),p.push({dom:w,left:S.left,top:S.top})}}),l*=c,u*=c,f*=c,h*=c;var v=f-l,m=h-u,d=$t.createCanvas(),g=ql(d,{renderer:i?"svg":"canvas"});if(g.resize({width:v,height:m}),i){var y="";return b(p,function(_){var x=_.left-l,w=_.top-u;y+=''+_.dom+""}),g.painter.getSvgRoot().innerHTML=y,e.connectedBackgroundColor&&g.painter.setBackgroundColor(e.connectedBackgroundColor),g.refreshImmediately(),g.painter.toDataURL()}else return e.connectedBackgroundColor&&g.add(new st({shape:{x:0,y:0,width:v,height:m},style:{fill:e.connectedBackgroundColor}})),b(p,function(_){var x=new ne({style:{x:_.left*c-l,y:_.top*c-u,image:_.dom}});g.add(x)}),g.refreshImmediately(),d.toDataURL("image/"+(e&&e.type||"png"))}else return this.getDataURL(e)},t.prototype.convertToPixel=function(e,i){return dv(this,"convertToPixel",e,i)},t.prototype.convertFromPixel=function(e,i){return dv(this,"convertFromPixel",e,i)},t.prototype.containPixel=function(e,i){if(this._disposed){this.id;return}var a=this._model,n,o=$l(a,e);return b(o,function(s,l){l.indexOf("Models")>=0&&b(s,function(u){var f=u.coordinateSystem;if(f&&f.containPoint)n=n||!!f.containPoint(i);else if(l==="seriesModels"){var h=this._chartsMap[u.__viewId];h&&h.containPoint&&(n=n||h.containPoint(i,u))}},this)},this),!!n},t.prototype.getVisual=function(e,i){var a=this._model,n=$l(a,e,{defaultMainType:"series"}),o=n.seriesModel,s=o.getData(),l=n.hasOwnProperty("dataIndexInside")?n.dataIndexInside:n.hasOwnProperty("dataIndex")?s.indexOfRawIndex(n.dataIndex):null;return l!=null?af(s,l,i):nf(s,i)},t.prototype.getViewOfComponentModel=function(e){return this._componentsMap[e.__viewId]},t.prototype.getViewOfSeriesModel=function(e){return this._chartsMap[e.__viewId]},t.prototype._initEvents=function(){var e=this;b(bL,function(i){var a=function(n){var o=e.getModel(),s=n.target,l,u=i==="globalout";if(u?l={}:s&&hi(s,function(v){var m=ut(v);if(m&&m.dataIndex!=null){var d=m.dataModel||o.getSeriesByIndex(m.seriesIndex);return l=d&&d.getDataParams(m.dataIndex,m.dataType,s)||{},!0}else if(m.eventData)return l=N({},m.eventData),!0},!0),l){var f=l.componentType,h=l.componentIndex;(f==="markLine"||f==="markPoint"||f==="markArea")&&(f="series",h=l.seriesIndex);var p=f&&h!=null&&o.getComponent(f,h),c=p&&e[p.mainType==="series"?"_chartsMap":"_componentsMap"][p.__viewId];l.event=n,l.type=i,e._$eventProcessor.eventInfo={targetEl:s,packedEvent:l,model:p,view:c},e.trigger(i,l)}};a.zrEventfulCallAtLast=!0,e._zr.on(i,a,e)}),b(Fs,function(i,a){e._messageCenter.on(a,function(n){this.trigger(a,n)},e)}),b(["selectchanged"],function(i){e._messageCenter.on(i,function(a){this.trigger(i,a)},e)}),Ex(this._messageCenter,this,this._api)},t.prototype.isDisposed=function(){return this._disposed},t.prototype.clear=function(){if(this._disposed){this.id;return}this.setOption({series:[]},!0)},t.prototype.dispose=function(){if(this._disposed){this.id;return}this._disposed=!0;var e=this.getDom();e&&xc(this.getDom(),Mv,"");var i=this,a=i._api,n=i._model;b(i._componentsViews,function(o){o.dispose(n,a)}),b(i._chartsViews,function(o){o.dispose(n,a)}),i._zr.dispose(),i._dom=i._model=i._chartsMap=i._componentsMap=i._chartsViews=i._componentsViews=i._scheduler=i._api=i._zr=i._throttledZrFlush=i._theme=i._coordSysMgr=i._messageCenter=null,delete Ja[i.id]},t.prototype.resize=function(e){if(!this[de]){if(this._disposed){this.id;return}this._zr.resize(e);var i=this._model;if(this._loadingFX&&this._loadingFX.resize(),!!i){var a=i.resetOption("media"),n=e&&e.silent;this[Re]&&(n==null&&(n=this[Re].silent),a=!0,this[Re]=null),this[de]=!0;try{a&&oo(this),Ui.update.call(this,{type:"resize",animation:N({duration:0},e&&e.animation)})}catch(o){throw this[de]=!1,o}this[de]=!1,Vs.call(this,n),Bs.call(this,n)}}},t.prototype.showLoading=function(e,i){if(this._disposed){this.id;return}if(F(e)&&(i=e,e=""),e=e||"default",this.hideLoading(),!!Sv[e]){var a=Sv[e](this._api,i),n=this._zr;this._loadingFX=a,n.add(a)}},t.prototype.hideLoading=function(){if(this._disposed){this.id;return}this._loadingFX&&this._zr.remove(this._loadingFX),this._loadingFX=null},t.prototype.makeActionFromEvent=function(e){var i=N({},e);return i.type=Fs[e.type],i},t.prototype.dispatchAction=function(e,i){if(this._disposed){this.id;return}if(F(i)||(i={silent:!!i}),!!vf[e.type]&&this._model){if(this[de]){this._pendingActions.push(e);return}var a=i.silent;gv.call(this,e,a);var n=i.flush;n?this._zr.flush():n!==!1&&j.browser.weChat&&this._throttledZrFlush(),Vs.call(this,a),Bs.call(this,a)}},t.prototype.updateLabelLayout=function(){ur.trigger("series:layoutlabels",this._model,this._api,{updatedSeries:[]})},t.prototype.appendData=function(e){if(this._disposed){this.id;return}var i=e.seriesIndex,a=this.getModel(),n=a.getSeriesByIndex(i);n.appendData(e),this._scheduler.unfinished=!0,this.getZr().wakeUp()},t.internalField=(function(){oo=function(h){var p=h._scheduler;p.restorePipelines(h._model),p.prepareStageTasks(),vv(h,!0),vv(h,!1),p.plan()},vv=function(h,p){for(var c=h._model,v=h._scheduler,m=p?h._componentsViews:h._chartsViews,d=p?h._componentsMap:h._chartsMap,g=h._zr,y=h._api,_=0;_p.get("hoverLayerThreshold")&&!j.node&&!j.worker&&p.eachSeries(function(d){if(!d.preventUsingHoverLayer){var g=h._chartsMap[d.__viewId];g.__alive&&g.eachRendered(function(y){y.states.emphasis&&(y.states.emphasis.hoverLayer=!0)})}})}function o(h,p){var c=h.get("blendMode")||null;p.eachRendered(function(v){v.isGroup||(v.style.blend=c)})}function s(h,p){if(!h.preventAutoZ){var c=h.get("z")||0,v=h.get("zlevel")||0;p.eachRendered(function(m){return l(m,c,v,-1/0),!0})}}function l(h,p,c,v){var m=h.getTextContent(),d=h.getTextGuideLine(),g=h.isGroup;if(g)for(var y=h.childrenRef(),_=0;_0?{duration:m,delay:c.get("delay"),easing:c.get("easing")}:null;p.eachRendered(function(g){if(g.states&&g.states.emphasis){if(ka(g))return;if(g instanceof at&&r0(g),g.__dirty){var y=g.prevStates;y&&g.useStates(y)}if(v){g.stateTransition=d;var _=g.getTextContent(),x=g.getTextGuideLine();_&&(_.stateTransition=d),x&&(x.stateTransition=d)}g.__dirty&&a(g)}})}iS=function(h){return new((function(p){I(c,p);function c(){return p!==null&&p.apply(this,arguments)||this}return c.prototype.getCoordinateSystems=function(){return h._coordSysMgr.getCoordinateSystems()},c.prototype.getComponentByElement=function(v){for(;v;){var m=v.__ecComponentInfo;if(m!=null)return h._model.getComponent(m.mainType,m.index);v=v.parent}},c.prototype.enterEmphasis=function(v,m){Ea(v,m),fr(h)},c.prototype.leaveEmphasis=function(v,m){La(v,m),fr(h)},c.prototype.enterBlur=function(v){qy(v),fr(h)},c.prototype.leaveBlur=function(v){qc(v),fr(h)},c.prototype.enterSelect=function(v){Kc(v),fr(h)},c.prototype.leaveSelect=function(v){jc(v),fr(h)},c.prototype.getModel=function(){return h.getModel()},c.prototype.getViewOfComponentModel=function(v){return h.getViewOfComponentModel(v)},c.prototype.getViewOfSeriesModel=function(v){return h.getViewOfSeriesModel(v)},c})(Hu))(h)},vS=function(h){function p(c,v){for(var m=0;m=0)){nS.push(e);var n=ov.wrapStageHandler(e,a);n.__prio=t,n.__raw=e,r.push(n)}}function xf(r,t){Sv[r]=t}function IL(r){gl({createCanvas:r})}function Rv(r,t,e){var i=hv("registerMap");i&&i(r,t,e)}function PL(r){var t=hv("getMap");return t&&t(r)}var Ov=V_;ci(bv,fx);ci(gf,hx);ci(gf,cx);ci(bv,Mx);ci(gf,Cx);ci(lS,fv);yf(Gu);_f(hL,Fp);xf("default",nv);Br({type:Ai,event:Ai,update:Ai},Dt);Br({type:ns,event:ns,update:ns},Dt);Br({type:Un,event:Un,update:Un},Dt);Br({type:os,event:os,update:os},Dt);Br({type:Vn,event:Vn,update:Vn},Dt);Dv("light",gx);Dv("dark",Sx);var RL={};function Gs(r){return r==null?0:r.length||1}function gS(r){return r}var NL=(function(){function r(t,e,i,a,n,o){this._old=t,this._new=e,this._oldKeyGetter=i||gS,this._newKeyGetter=a||gS,this.context=n,this._diffModeMultiple=o==="multiple"}return r.prototype.add=function(t){return this._add=t,this},r.prototype.update=function(t){return this._update=t,this},r.prototype.updateManyToOne=function(t){return this._updateManyToOne=t,this},r.prototype.updateOneToMany=function(t){return this._updateOneToMany=t,this},r.prototype.updateManyToMany=function(t){return this._updateManyToMany=t,this},r.prototype.remove=function(t){return this._remove=t,this},r.prototype.execute=function(){this[this._diffModeMultiple?"_executeMultiple":"_executeOneToOne"]()},r.prototype._executeOneToOne=function(){var t=this._old,e=this._new,i={},a=new Array(t.length),n=new Array(e.length);this._initIndexMap(t,null,a,"_oldKeyGetter"),this._initIndexMap(e,i,n,"_newKeyGetter");for(var o=0;o1){var f=l.shift();l.length===1&&(i[s]=l[0]),this._update&&this._update(f,o)}else u===1?(i[s]=null,this._update&&this._update(l,o)):this._remove&&this._remove(o)}this._performRestAdd(n,i)},r.prototype._executeMultiple=function(){var t=this._old,e=this._new,i={},a={},n=[],o=[];this._initIndexMap(t,i,n,"_oldKeyGetter"),this._initIndexMap(e,a,o,"_newKeyGetter");for(var s=0;s1&&p===1)this._updateManyToOne&&this._updateManyToOne(f,u),a[l]=null;else if(h===1&&p>1)this._updateOneToMany&&this._updateOneToMany(f,u),a[l]=null;else if(h===1&&p===1)this._update&&this._update(f,u),a[l]=null;else if(h>1&&p>1)this._updateManyToMany&&this._updateManyToMany(f,u),a[l]=null;else if(h>1)for(var c=0;c1)for(var s=0;s30}var Ws=F,Vi=k,FL=typeof Int32Array>"u"?Array:Int32Array,HL="e\0\0",SS=-1,GL=["hasItemOption","_nameList","_idList","_invertedIndicesMap","_dimSummary","userOutput","_rawData","_dimValueGetter","_nameDimIdx","_idDimIdx","_nameRepeatCount"],WL=["_approximateExtent"],bS,bf,Ys,Zs,Bv,wf,Fv,YL=(function(){function r(t,e){this.type="list",this._dimOmitted=!1,this._nameList=[],this._idList=[],this._visual={},this._layout={},this._itemVisuals=[],this._itemLayouts=[],this._graphicEls=[],this._approximateExtent={},this._calculationInfo={},this.hasItemOption=!1,this.TRANSFERABLE_METHODS=["cloneShallow","downSample","lttbDownSample","map"],this.CHANGABLE_METHODS=["filterSelf","selectRange"],this.DOWNSAMPLE_METHODS=["downSample","lttbDownSample"];var i,a=!1;Sf(t)?(i=t.dimensions,this._dimOmitted=t.isDimensionOmitted(),this._schema=t):(a=!0,i=t),i=i||["x","y"];for(var n={},o=[],s={},l=!1,u={},f=0;f=e)){var i=this._store,a=i.getProvider();this._updateOrdinalMeta();var n=this._nameList,o=this._idList,s=a.getSource().sourceFormat,l=s===oe;if(l&&!a.pure)for(var u=[],f=t;f0},r.prototype.ensureUniqueItemVisual=function(t,e){var i=this._itemVisuals,a=i[t];a||(a=i[t]={});var n=a[e];return n==null&&(n=this.getVisual(e),O(n)?n=n.slice():Ws(n)&&(n=N({},n)),a[e]=n),n},r.prototype.setItemVisual=function(t,e,i){var a=this._itemVisuals[t]||{};this._itemVisuals[t]=a,Ws(e)?N(a,e):a[e]=i},r.prototype.clearAllVisual=function(){this._visual={},this._itemVisuals=[]},r.prototype.setLayout=function(t,e){Ws(t)?N(this._layout,t):this._layout[t]=e},r.prototype.getLayout=function(t){return this._layout[t]},r.prototype.getItemLayout=function(t){return this._itemLayouts[t]},r.prototype.setItemLayout=function(t,e,i){this._itemLayouts[t]=i?N(this._itemLayouts[t]||{},e):e},r.prototype.clearItemLayouts=function(){this._itemLayouts.length=0},r.prototype.setItemGraphicEl=function(t,e){var i=this.hostModel&&this.hostModel.seriesIndex;ky(i,this.dataType,t,e),this._graphicEls[t]=e},r.prototype.getItemGraphicEl=function(t){return this._graphicEls[t]},r.prototype.eachItemGraphicEl=function(t,e){b(this._graphicEls,function(i,a){i&&t&&t.call(e,i,a)})},r.prototype.cloneShallow=function(t){return t||(t=new r(this._schema?this._schema:Vi(this.dimensions,this._getDimInfo,this),this.hostModel)),Bv(t,this),t._store=this._store,t},r.prototype.wrapMethod=function(t,e){var i=this[t];G(i)&&(this.__wrappedMethods=this.__wrappedMethods||[],this.__wrappedMethods.push(t),this[t]=function(){var a=i.apply(this,arguments);return e.apply(this,[a].concat(Mo(arguments)))})},r.internalField=(function(){bS=function(t){var e=t._invertedIndicesMap;b(e,function(i,a){var n=t._dimInfos[a],o=n.ordinalMeta,s=t._store;if(o){i=e[a]=new FL(o.categories.length);for(var l=0;l1&&(l+="__ec__"+f),a[e]=l}}})(),r})(),lo=YL;var $v={};ze($v,{createDimensions:()=>wS,createList:()=>AI,createScale:()=>LI,createSymbol:()=>Vt,createTextStyle:()=>PI,dataStack:()=>EI,enableHoverEmphasis:()=>Ei,getECData:()=>ut,getLayoutRect:()=>pe,mixinAxisModelCommonMethods:()=>II});function wS(r,t){return uo(r,t).dimensions}function uo(r,t){to(r)||(r=eo(r)),t=t||{};var e=t.coordDimensions||[],i=t.dimensionsDefine||r.dimensionsDefine||[],a=W(),n=[],o=XL(r,e,i,t.dimensionsCount),s=t.canOmitUnusedDimensions&&Vv(o),l=i===r.dimensionsDefine,u=l?Uv(r):kv(i),f=t.encodeDefine;!f&&t.encodeDefaulter&&(f=t.encodeDefaulter(r,o));for(var h=W(f),p=new Qp(o),c=0;c0&&(i.name=a+(n-1)),n++,t.set(a,n)}}function XL(r,t,e,i){var a=Math.max(r.dimensionsDetectedCount||1,t.length,e.length,i||0);return b(t,function(n){var o;F(n)&&(o=n.dimsDef)&&(a=Math.max(a,o.length))}),a}function qL(r,t,e){if(e||t.hasKey(r)){for(var i=0;t.hasKey(r+i);)i++;r+=i}return t.set(r,!0),r}var KL=(function(){function r(t){this.coordSysDims=[],this.axisMap=W(),this.categoryAxisMap=W(),this.coordSysName=t}return r})();function TS(r){var t=r.get("coordinateSystem"),e=new KL(t),i=jL[t];if(i)return i(r,e,e.axisMap,e.categoryAxisMap),e}var jL={cartesian2d:function(r,t,e,i){var a=r.getReferringComponents("xAxis",zt).models[0],n=r.getReferringComponents("yAxis",zt).models[0];t.coordSysDims=["x","y"],e.set("x",a),e.set("y",n),fo(a)&&(i.set("x",a),t.firstCategoryDimIndex=0),fo(n)&&(i.set("y",n),t.firstCategoryDimIndex==null&&(t.firstCategoryDimIndex=1))},singleAxis:function(r,t,e,i){var a=r.getReferringComponents("singleAxis",zt).models[0];t.coordSysDims=["single"],e.set("single",a),fo(a)&&(i.set("single",a),t.firstCategoryDimIndex=0)},polar:function(r,t,e,i){var a=r.getReferringComponents("polar",zt).models[0],n=a.findAxisModel("radiusAxis"),o=a.findAxisModel("angleAxis");t.coordSysDims=["radius","angle"],e.set("radius",n),e.set("angle",o),fo(n)&&(i.set("radius",n),t.firstCategoryDimIndex=0),fo(o)&&(i.set("angle",o),t.firstCategoryDimIndex==null&&(t.firstCategoryDimIndex=1))},geo:function(r,t,e,i){t.coordSysDims=["lng","lat"]},parallel:function(r,t,e,i){var a=r.ecModel,n=a.getComponent("parallel",r.get("parallelIndex")),o=t.coordSysDims=n.dimensions.slice();b(n.parallelAxisIndex,function(s,l){var u=a.getComponent("parallelAxis",s),f=o[l];e.set(f,u),fo(u)&&(i.set(f,u),t.firstCategoryDimIndex==null&&(t.firstCategoryDimIndex=l))})}};function fo(r){return r.get("type")==="category"}function Tf(r,t,e){e=e||{};var i=e.byIndex,a=e.stackedCoordDimension,n,o,s;QL(t)?n=t:(o=t.schema,n=o.dimensions,s=t.store);var l=!!(r&&r.get("stack")),u,f,h,p;if(b(n,function(y,_){U(y)&&(n[_]=y={name:y}),l&&!y.isExtraCoord&&(!i&&!u&&y.ordinalMeta&&(u=y),!f&&y.type!=="ordinal"&&y.type!=="time"&&(!a||a===y.coordDim)&&(f=y))}),f&&!i&&!u&&(i=!0),f){h="__\0ecstackresult_"+r.id,p="__\0ecstackedover_"+r.id,u&&(u.createInvertedIndices=!0);var c=f.coordDim,v=f.type,m=0;b(n,function(y){y.coordDim===c&&m++});var d={name:h,coordDim:c,coordDimIndex:m,type:v,isExtraCoord:!0,isCalculationCoord:!0,storeDimIndex:n.length},g={name:p,coordDim:p,coordDimIndex:m+1,type:v,isExtraCoord:!0,isCalculationCoord:!0,storeDimIndex:n.length+1};o?(s&&(d.storeDimIndex=s.ensureCalculationDimension(p,v),g.storeDimIndex=s.ensureCalculationDimension(h,v)),o.appendCalculationDimension(d),o.appendCalculationDimension(g)):(n.push(d),n.push(g))}return{stackedDimension:f&&f.name,stackedByDimension:u&&u.name,isStackedByIndex:i,stackedOverDimension:p,stackResultDimension:h}}function QL(r){return!Sf(r.schema)}function Tr(r,t){return!!t&&t===r.getCalculationInfo("stackedDimension")}function Mf(r,t){return Tr(r,t)?r.getCalculationInfo("stackResultDimension"):t}function $L(r,t){var e=r.get("coordinateSystem"),i=Ri.get(e),a;return t&&t.coordSysDims&&(a=k(t.coordSysDims,function(n){var o={name:n},s=t.axisMap.get(n);if(s){var l=s.get("type");o.type=xS(l)}return o})),a||(a=i&&(i.getDimensionsInfo?i.getDimensionsInfo():i.dimensions.slice())||["x","y"]),a}function JL(r,t,e){var i,a;return e&&b(r,function(n,o){var s=n.coordDim,l=e.categoryAxisMap.get(s);l&&(i==null&&(i=o),n.ordinalMeta=l.getOrdinalMeta(),t&&(n.createInvertedIndices=!0)),n.otherDims.itemName!=null&&(a=!0)}),!a&&i!=null&&(r[i].otherDims.itemName=0),i}function tI(r,t,e){e=e||{};var i=t.getSourceManager(),a,n=!1;r?(n=!0,a=eo(r)):(a=i.getSource(),n=a.sourceFormat===oe);var o=TS(t),s=$L(t,o),l=e.useEncodeDefaulter,u=G(l)?l:l?ct(u_,s,t):null,f={coordDimensions:s,generateCoord:e.generateCoord,encodeDefine:t.getEncode(),encodeDefaulter:u,canOmitUnusedDimensions:!n},h=uo(a,f),p=JL(h.dimensions,e.createInvertedIndices,o),c=n?null:i.getSharedDataStore(h),v=Tf(t,{schema:h,store:c}),m=new lo(h,t);m.setCalculationInfo(v);var d=p!=null&&eI(a)?function(g,y,_,x){return x===p?_:this.defaultDimValueGetter(g,y,_,x)}:null;return m.hasItemOption=!1,m.initData(n?a:c,null,d),m}function eI(r){if(r.sourceFormat===oe){var t=rI(r.data||[]);return!O(ti(t))}}function rI(r){for(var t=0;te[1]&&(e[1]=t[1])},r.prototype.unionExtentFromData=function(t,e){this.unionExtent(t.getApproximateExtent(e))},r.prototype.getExtent=function(){return this._extent.slice()},r.prototype.setExtent=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},r.prototype.isInExtentRange=function(t){return this._extent[0]<=t&&this._extent[1]>=t},r.prototype.isBlank=function(){return this._isBlank},r.prototype.setBlank=function(t){this._isBlank=t},r})();wi(MS);var Oe=MS;var iI=0,aI=(function(){function r(t){this.categories=t.categories||[],this._needCollect=t.needCollect,this._deduplication=t.deduplication,this.uid=++iI}return r.createByAxisModel=function(t){var e=t.option,i=e.data,a=i&&k(i,nI);return new r({categories:a,needCollect:!a,deduplication:e.dedplication!==!1})},r.prototype.getOrdinal=function(t){return this._getOrCreateMap().get(t)},r.prototype.parseAndCollect=function(t){var e,i=this._needCollect;if(!U(t)&&!i)return t;if(i&&!this._deduplication)return e=this.categories.length,this.categories[e]=t,e;var a=this._getOrCreateMap();return e=a.get(t),e==null&&(i?(e=this.categories.length,this.categories[e]=t,a.set(t,e)):e=NaN),e},r.prototype._getOrCreateMap=function(){return this._map||(this._map=W(this.categories))},r})();function nI(r){return F(r)&&r.value!=null?r.value:r+""}var Xs=aI;function qs(r){return r.type==="interval"||r.type==="log"}function DS(r,t,e,i){var a={},n=r[1]-r[0],o=a.interval=Ln(n/t,!0);e!=null&&oi&&(o=a.interval=i);var s=a.intervalPrecision=Hv(o),l=a.niceTickExtent=[bt(Math.ceil(r[0]/o)*o,s),bt(Math.floor(r[1]/o)*o,s)];return oI(l,r),a}function Cf(r){var t=Math.pow(10,En(r)),e=r/t;return e?e===2?e=3:e===3?e=5:e*=2:e=1,bt(e*t)}function Hv(r){return ge(r)+2}function CS(r,t,e){r[t]=Math.max(Math.min(r[t],e[1]),e[0])}function oI(r,t){!isFinite(r[0])&&(r[0]=t[0]),!isFinite(r[1])&&(r[1]=t[1]),CS(r,0,t),CS(r,1,t),r[0]>r[1]&&(r[0]=r[1])}function Bi(r,t){return r>=t[0]&&r<=t[1]}function Fi(r,t){return t[1]===t[0]?.5:(r-t[0])/(t[1]-t[0])}function Hi(r,t){return r*(t[1]-t[0])+t[0]}var AS=(function(r){I(t,r);function t(e){var i=r.call(this,e)||this;i.type="ordinal";var a=i.getSetting("ordinalMeta");return a||(a=new Xs({})),O(a)&&(a=new Xs({categories:k(a,function(n){return F(n)?n.value:n})})),i._ordinalMeta=a,i._extent=i.getSetting("extent")||[0,a.categories.length-1],i}return t.prototype.parse=function(e){return e==null?NaN:U(e)?this._ordinalMeta.getOrdinal(e):Math.round(e)},t.prototype.contain=function(e){return e=this.parse(e),Bi(e,this._extent)&&this._ordinalMeta.categories[e]!=null},t.prototype.normalize=function(e){return e=this._getTickNumber(this.parse(e)),Fi(e,this._extent)},t.prototype.scale=function(e){return e=Math.round(Hi(e,this._extent)),this.getRawOrdinalNumber(e)},t.prototype.getTicks=function(){for(var e=[],i=this._extent,a=i[0];a<=i[1];)e.push({value:a}),a++;return e},t.prototype.getMinorTicks=function(e){},t.prototype.setSortInfo=function(e){if(e==null){this._ordinalNumbersByTick=this._ticksByOrdinalNumber=null;return}for(var i=e.ordinalNumbers,a=this._ordinalNumbersByTick=[],n=this._ticksByOrdinalNumber=[],o=0,s=this._ordinalMeta.categories.length,l=Math.min(s,i.length);o=0&&e=0&&e=e},t.prototype.getOrdinalMeta=function(){return this._ordinalMeta},t.prototype.calcNiceTicks=function(){},t.prototype.calcNiceExtent=function(){},t.type="ordinal",t})(Oe);Oe.registerClass(AS);var Gv=AS;var tn=bt,ES=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type="interval",e._interval=0,e._intervalPrecision=2,e}return t.prototype.parse=function(e){return e},t.prototype.contain=function(e){return Bi(e,this._extent)},t.prototype.normalize=function(e){return Fi(e,this._extent)},t.prototype.scale=function(e){return Hi(e,this._extent)},t.prototype.setExtent=function(e,i){var a=this._extent;isNaN(e)||(a[0]=parseFloat(e)),isNaN(i)||(a[1]=parseFloat(i))},t.prototype.unionExtent=function(e){var i=this._extent;e[0]i[1]&&(i[1]=e[1]),this.setExtent(i[0],i[1])},t.prototype.getInterval=function(){return this._interval},t.prototype.setInterval=function(e){this._interval=e,this._niceExtent=this._extent.slice(),this._intervalPrecision=Hv(e)},t.prototype.getTicks=function(e){var i=this._interval,a=this._extent,n=this._niceExtent,o=this._intervalPrecision,s=[];if(!i)return s;var l=1e4;a[0]l)return[];var f=s.length?s[s.length-1].value:n[1];return a[1]>f&&(e?s.push({value:tn(f+i,o)}):s.push({value:a[1]})),s},t.prototype.getMinorTicks=function(e){for(var i=this.getTicks(!0),a=[],n=this.getExtent(),o=1;on[0]&&c0&&(n=n===null?s:Math.min(n,s))}e[i]=n}}return e}function Xv(r){var t=uI(r),e=[];return b(r,function(i){var a=i.coordinateSystem,n=a.getBaseAxis(),o=n.getExtent(),s;if(n.type==="category")s=n.getBandWidth();else if(n.type==="value"||n.type==="time"){var l=n.dim+"_"+n.index,u=t[l],f=Math.abs(o[1]-o[0]),h=n.scale.getExtent(),p=Math.abs(h[1]-h[0]);s=u?f/p*u:f}else{var c=i.getData();s=Math.abs(o[1]-o[0])/c.count()}var v=yt(i.get("barWidth"),s),m=yt(i.get("barMaxWidth"),s),d=yt(i.get("barMinWidth")||(NS(i)?.5:1),s),g=i.get("barGap"),y=i.get("barCategoryGap");e.push({bandWidth:s,barWidth:v,barMaxWidth:m,barMinWidth:d,barGap:g,barCategoryGap:y,axisKey:Yv(n),stackId:Wv(i)})}),fI(e)}function fI(r){var t={};b(r,function(i,a){var n=i.axisKey,o=i.bandWidth,s=t[n]||{bandWidth:o,remainedWidth:o,autoWidthCount:0,categoryGap:null,gap:"20%",stacks:{}},l=s.stacks;t[n]=s;var u=i.stackId;l[u]||s.autoWidthCount++,l[u]=l[u]||{width:0,maxWidth:0};var f=i.barWidth;f&&!l[u].width&&(l[u].width=f,f=Math.min(s.remainedWidth,f),s.remainedWidth-=f);var h=i.barMaxWidth;h&&(l[u].maxWidth=h);var p=i.barMinWidth;p&&(l[u].minWidth=p);var c=i.barGap;c!=null&&(s.gap=c);var v=i.barCategoryGap;v!=null&&(s.categoryGap=v)});var e={};return b(t,function(i,a){e[a]={};var n=i.stacks,o=i.bandWidth,s=i.categoryGap;if(s==null){var l=lt(n).length;s=Math.max(35-l*4,15)+"%"}var u=yt(s,o),f=yt(i.gap,1),h=i.remainedWidth,p=i.autoWidthCount,c=(h-u)/(p+(p-1)*f);c=Math.max(c,0),b(n,function(g){var y=g.maxWidth,_=g.minWidth;if(g.width){var x=g.width;y&&(x=Math.min(x,y)),_&&(x=Math.max(x,_)),g.width=x,h-=x+f*x,p--}else{var x=c;y&&yx&&(x=_),x!==c&&(g.width=x,h-=x+f*x,p--)}}),c=(h-u)/(p+(p-1)*f),c=Math.max(c,0);var v=0,m;b(n,function(g,y){g.width||(g.width=c),m=g,v+=g.width*(1+f)}),m&&(v-=m.width*f);var d=-v/2;b(n,function(g,y){e[a][y]=e[a][y]||{bandWidth:o,offset:d,width:g.width},d+=g.width*(1+f)})}),e}function IS(r,t,e){if(r&&t){var i=r[Yv(t)];return i!=null&&e!=null?i[Wv(e)]:i}}function PS(r,t){var e=Zv(r,t),i=Xv(e);b(e,function(a){var n=a.getData(),o=a.coordinateSystem,s=o.getBaseAxis(),l=Wv(a),u=i[Yv(s)][l],f=u.offset,h=u.width;n.setLayout({bandWidth:u.bandWidth,offset:f,size:h})})}function RS(r){return{seriesType:r,plan:Ka(),reset:function(t){if(OS(t)){var e=t.getData(),i=t.coordinateSystem,a=i.getBaseAxis(),n=i.getOtherAxis(a),o=e.getDimensionIndex(e.mapDimension(n.dim)),s=e.getDimensionIndex(e.mapDimension(a.dim)),l=t.get("showBackground",!0),u=e.mapDimension(n.dim),f=e.getCalculationInfo("stackResultDimension"),h=Tr(e,u)&&!!e.getCalculationInfo("stackedOnSeries"),p=n.isHorizontal(),c=hI(a,n),v=NS(t),m=t.get("barMinHeight")||0,d=f&&e.getDimensionIndex(f),g=e.getLayout("size"),y=e.getLayout("offset");return{progress:function(_,x){for(var w=_.count,S=v&&Ye(w*3),T=v&&l&&Ye(w*3),M=v&&Ye(w),D=i.master.getRect(),A=p?D.width:D.height,C,E=x.getStore(),L=0;(C=_.next())!=null;){var P=E.get(h?d:o,C),R=E.get(s,C),z=c,Z=void 0;h&&(Z=+P-E.get(o,C));var V=void 0,B=void 0,X=void 0,Q=void 0;if(p){var $=i.dataToPoint([P,R]);if(h){var mt=i.dataToPoint([Z,R]);z=mt[0]}V=z,B=$[1]+y,X=$[0]-z,Q=g,Math.abs(X)0?e:1:e))}var cI=function(r,t,e,i){for(;e>>1;r[a][1]a&&(this._approxInterval=a);var s=Af.length,l=Math.min(cI(Af,this._approxInterval,0,s),s-1);this._interval=Af[l][1],this._minLevelUnit=Af[Math.max(l-1,0)][0]},t.prototype.parse=function(e){return nt(e)?e:+ie(e)},t.prototype.contain=function(e){return Bi(this.parse(e),this._extent)},t.prototype.normalize=function(e){return Fi(this.parse(e),this._extent)},t.prototype.scale=function(e){return Hi(e,this._extent)},t.type="time",t})(pi),Af=[["second",Lu],["minute",Iu],["hour",Kn],["quarter-day",Kn*6],["half-day",Kn*12],["day",He*1.2],["half-week",He*3.5],["week",He*7],["month",He*31],["quarter",He*95],["half-year",wp/2],["year",wp]];function pI(r,t,e,i){var a=ie(t),n=ie(e),o=function(v){return Cp(a,v,i)===Cp(n,v,i)},s=function(){return o("year")},l=function(){return s()&&o("month")},u=function(){return l()&&o("day")},f=function(){return u()&&o("hour")},h=function(){return f()&&o("minute")},p=function(){return h()&&o("second")},c=function(){return p()&&o("millisecond")};switch(r){case"year":return s();case"month":return l();case"day":return u();case"hour":return f();case"minute":return h();case"second":return p();case"millisecond":return c()}}function vI(r,t){return r/=He,r>16?16:r>7.5?7:r>3.5?4:r>1.5?2:1}function dI(r){var t=30*He;return r/=t,r>6?6:r>3?3:r>2?2:1}function mI(r){return r/=Kn,r>12?12:r>6?6:r>3.5?4:r>2?2:1}function zS(r,t){return r/=t?Iu:Lu,r>30?30:r>20?20:r>15?15:r>10?10:r>5?5:r>2?2:1}function gI(r){return Ln(r,!0)}function yI(r,t,e){var i=new Date(r);switch(Ga(t)){case"year":case"month":i[Dp(e)](0);case"day":i[Ap(e)](1);case"hour":i[Ep(e)](0);case"minute":i[Lp(e)](0);case"second":i[Ip(e)](0),i[Pp(e)](0)}return i.getTime()}function _I(r,t,e,i){var a=1e4,n=Mp,o=0;function s(A,C,E,L,P,R,z){for(var Z=new Date(C),V=C,B=Z[L]();V1&&R===0&&E.unshift({value:E[0].value-V})}}for(var R=0;R=i[0]&&y<=i[1]&&h++)}var _=(i[1]-i[0])/t;if(h>_*1.5&&p>_/1.5||(u.push(d),h>_||r===n[c]))break}f=[]}}}for(var x=Mt(k(u,function(A){return Mt(A,function(C){return C.value>=i[0]&&C.value<=i[1]&&!C.notAdd})}),function(A){return A.length>0}),w=[],S=x.length-1,c=0;c0;)n*=10;var s=[bt(bI(i[0]/n)*n),bt(SI(i[1]/n)*n)];this._interval=n,this._niceExtent=s}},t.prototype.calcNiceExtent=function(e){Ks.calcNiceExtent.call(this,e),this._fixMin=e.fixMin,this._fixMax=e.fixMax},t.prototype.parse=function(e){return e},t.prototype.contain=function(e){return e=Mr(e)/Mr(this.base),Bi(e,this._extent)},t.prototype.normalize=function(e){return e=Mr(e)/Mr(this.base),Fi(e,this._extent)},t.prototype.scale=function(e){return e=Hi(e,this._extent),Ef(this.base,e)},t.type="log",t})(Oe),BS=qv.prototype;BS.getMinorTicks=Ks.getMinorTicks;BS.getLabel=Ks.getLabel;function Lf(r,t){return xI(r,ge(t))}Oe.registerClass(qv);var FS=qv;var wI=(function(){function r(t,e,i){this._prepareParams(t,e,i)}return r.prototype._prepareParams=function(t,e,i){i[1]0&&l>0&&!u&&(s=0),s<0&&l<0&&!f&&(l=0));var p=this._determinedMin,c=this._determinedMax;return p!=null&&(s=p,u=!0),c!=null&&(l=c,f=!0),{min:s,max:l,minFixed:u,maxFixed:f,isBlank:h}},r.prototype.modifyDataMinMax=function(t,e){this[MI[t]]=e},r.prototype.setDeterminedMinMax=function(t,e){var i=TI[t];this[i]=e},r.prototype.freeze=function(){this.frozen=!0},r})();var TI={min:"_determinedMin",max:"_determinedMax"},MI={min:"_dataMin",max:"_dataMax"};function Pf(r,t,e){var i=r.rawExtentInfo;return i||(i=new wI(r,t,e),r.rawExtentInfo=i,i)}function If(r,t){return t==null?null:Ji(t)?NaN:r.parse(t)}function Kv(r,t){var e=r.type,i=Pf(r,t,r.getExtent()).calculate();r.setBlank(i.isBlank);var a=i.min,n=i.max,o=t.ecModel;if(o&&e==="time"){var s=Zv("bar",o),l=!1;if(b(s,function(h){l=l||h.getBaseAxis()===t.axis}),l){var u=Xv(s),f=CI(a,n,t,u);a=f.min,n=f.max}}return{extent:[a,n],fixMin:i.minFixed,fixMax:i.maxFixed}}function CI(r,t,e,i){var a=e.axis.getExtent(),n=a[1]-a[0],o=IS(i,e.axis);if(o===void 0)return{min:r,max:t};var s=1/0;b(o,function(c){s=Math.min(c.offset,s)});var l=-1/0;b(o,function(c){l=Math.max(c.offset+c.width,l)}),s=Math.abs(s),l=Math.abs(l);var u=s+l,f=t-r,h=1-(s+l)/n,p=f/h-f;return t+=p*(l/u),r-=p*(s/u),{min:r,max:t}}function js(r,t){var e=t,i=Kv(r,e),a=i.extent,n=e.get("splitNumber");r instanceof FS&&(r.base=e.get("logBase"));var o=r.type,s=e.get("interval"),l=o==="interval"||o==="time";r.setExtent(a[0],a[1]),r.calcNiceExtent({splitNumber:n,fixMin:i.fixMin,fixMax:i.fixMax,minInterval:l?e.get("minInterval"):null,maxInterval:l?e.get("maxInterval"):null}),s!=null&&r.setInterval&&r.setInterval(s)}function Rf(r,t){if(t=t||r.get("type"),t)switch(t){case"category":return new Gv({ordinalMeta:r.getOrdinalMeta?r.getOrdinalMeta():r.getCategories(),extent:[1/0,-1/0]});case"time":return new US({locale:r.ecModel.getLocaleModel(),useUTC:r.ecModel.get("useUTC")});default:return new(Oe.getClass(t)||pi)}}function HS(r){var t=r.scale.getExtent(),e=t[0],i=t[1];return!(e>0&&i>0||e<0&&i<0)}function en(r){var t=r.getLabelModel().get("formatter"),e=r.type==="category"?r.scale.getExtent()[0]:null;return r.scale.type==="time"?(function(i){return function(a,n){return r.scale.getFormattedLabel(a,n,i)}})(t):U(t)?(function(i){return function(a){var n=r.scale.getLabel(a),o=i.replace("{value}",n??"");return o}})(t):G(t)?(function(i){return function(a,n){return e!=null&&(n=a.value-e),i(Qs(r,a),n,a.level!=null?{level:a.level}:null)}})(t):function(i){return r.scale.getLabel(i)}}function Qs(r,t){return r.type==="category"?r.scale.getLabel(t):t.value}function GS(r){var t=r.model,e=r.scale;if(!(!t.get(["axisLabel","show"])||e.isBlank())){var i,a,n=e.getExtent();e instanceof Gv?a=e.count():(i=e.getTicks(),a=i.length);var o=r.getLabelModel(),s=en(r),l,u=1;a>40&&(u=Math.ceil(a/40));for(var f=0;fr[1]&&(r[1]=a[1])})}var zf=(function(){function r(){}return r.prototype.getNeedCrossZero=function(){var t=this.option;return!t.scale},r.prototype.getCoordSysModel=function(){},r})();function AI(r){return Fr(null,r)}var EI={isDimensionStacked:Tr,enableDataStack:Tf,getStackedDimension:Mf};function LI(r,t){var e=t;t instanceof _t||(e=new _t(t));var i=Rf(e);return i.setExtent(r[0],r[1]),js(i,e),i}function II(r){Jt(r,zf)}function PI(r,t){return t=t||{},Zt(r,null,null,t.state!=="normal")}var YS=[],RI={registerPreprocessor:yf,registerProcessor:_f,registerPostInit:Av,registerPostUpdate:Ev,registerUpdateLifecycle:Hs,registerAction:Br,registerCoordinateSystem:Lv,registerLayout:Iv,registerVisual:ci,registerTransform:Ov,registerLoading:xf,registerMap:Rv,registerImpl:Qx,PRIORITY:wv,ComponentModel:pt,ComponentView:Lt,SeriesModel:qt,ChartView:Ut,registerComponentModel:function(r){pt.registerClass(r)},registerComponentView:function(r){Lt.registerClass(r)},registerSeriesModel:function(r){qt.registerClass(r)},registerChartView:function(r){Ut.registerClass(r)},registerSubTypeDefaulter:function(r,t){pt.registerSubTypeDefaulter(r,t)},registerPainter:function(r,t){vc(r,t)}};function Bt(r){if(O(r)){b(r,function(t){Bt(t)});return}it(YS,r)>=0||(YS.push(r),G(r)&&(r={install:r}),r.install(RI))}var OI=1e-8;function ZS(r,t){return Math.abs(r-t)a&&(i=o,a=l)}if(i)return kI(i.exterior);var u=this.getBoundingRect();return[u.x+u.width/2,u.y+u.height/2]},t.prototype.getBoundingRect=function(e){var i=this._rect;if(i&&!e)return i;var a=[1/0,1/0],n=[-1/0,-1/0],o=this.geometries;return b(o,function(s){s.type==="polygon"?XS(s.exterior,a,n,e):b(s.points,function(l){XS(l,a,n,e)})}),isFinite(a[0])&&isFinite(a[1])&&isFinite(n[0])&&isFinite(n[1])||(a[0]=a[1]=n[0]=n[1]=0),i=new J(a[0],a[1],n[0]-a[0],n[1]-a[1]),e||(this._rect=i),i},t.prototype.contain=function(e){var i=this.getBoundingRect(),a=this.geometries;if(!i.contain(e[0],e[1]))return!1;t:for(var n=0,o=a.length;n>1^-(s&1),l=l>>1^-(l&1),s+=a,l+=n,a=s,n=l,i.push([s/e,l/e])}return i}function kf(r,t){return r=UI(r),k(Mt(r.features,function(e){return e.geometry&&e.properties&&e.geometry.coordinates.length>0}),function(e){var i=e.properties,a=e.geometry,n=[];switch(a.type){case"Polygon":var o=a.coordinates;n.push(new ed(o[0],o.slice(1)));break;case"MultiPolygon":b(a.coordinates,function(l){l[0]&&n.push(new ed(l[0],l.slice(1)))});break;case"LineString":n.push(new rd([a.coordinates]));break;case"MultiLineString":n.push(new rd(a.coordinates))}var s=new KS(i[t||"name"],n,i.cp);return s.properties=i,s})}var ad={};ze(ad,{MAX_SAFE_INTEGER:()=>Vg,asc:()=>ke,getPercentWithPrecision:()=>kg,getPixelPrecision:()=>An,getPrecision:()=>ge,getPrecisionSafe:()=>mc,isNumeric:()=>Ko,isRadianAroundZero:()=>_a,linearMap:()=>gt,nice:()=>Ln,numericToNumber:()=>$e,parseDate:()=>ie,quantile:()=>Bg,quantity:()=>jl,quantityExponent:()=>En,reformIntervals:()=>qo,remRadian:()=>Xo,round:()=>bt});var nd={};ze(nd,{format:()=>oi,parse:()=>ie});var od={};ze(od,{Arc:()=>Oa,BezierCurve:()=>ps,BoundingRect:()=>J,Circle:()=>Pa,CompoundPath:()=>du,Ellipse:()=>us,Group:()=>ft,Image:()=>ne,IncrementalDisplayable:()=>xu,Line:()=>Ve,LinearGradient:()=>Li,Polygon:()=>ii,Polyline:()=>xr,RadialGradient:()=>gu,Rect:()=>st,Ring:()=>cs,Sector:()=>Ue,Text:()=>vt,clipPointsByRect:()=>pp,clipRectByRect:()=>vp,createIcon:()=>Ba,extendPath:()=>up,extendShape:()=>lp,getShapeClass:()=>fp,getTransform:()=>ai,initProps:()=>Gt,makeImage:()=>vs,makePath:()=>Yn,mergePath:()=>hp,registerShape:()=>Be,resizePath:()=>wu,updateProps:()=>Ct});var sd={};ze(sd,{addCommas:()=>bs,capitalFirst:()=>i_,encodeHTML:()=>ee,formatTime:()=>r_,formatTpl:()=>Qn,getTextRect:()=>Rp,getTooltipMarker:()=>Ou,normalizeCssArray:()=>or,toCamelCase:()=>jn,truncateText:()=>tu});var ld={};ze(ld,{bind:()=>H,clone:()=>Y,curry:()=>ct,defaults:()=>K,each:()=>b,extend:()=>N,filter:()=>Mt,indexOf:()=>it,inherits:()=>To,isArray:()=>O,isFunction:()=>G,isObject:()=>F,isString:()=>U,map:()=>k,merge:()=>tt,reduce:()=>fe});var $s=ht();function QS(r,t){var e=k(t,function(i){return r.scale.parse(i)});return r.type==="time"&&e.length>0&&(e.sort(),e.unshift(e[0]),e.push(e[e.length-1])),e}function $S(r){var t=r.getLabelModel().get("customValues");if(t){var e=en(r);return{labels:QS(r,t).map(function(i){var a={value:i};return{formattedLabel:e(a),rawLabel:r.scale.getLabel(a),tickValue:i}})}}return r.type==="category"?VI(r):FI(r)}function JS(r,t){var e=r.getTickModel().get("customValues");return e?{ticks:QS(r,e)}:r.type==="category"?BI(r,t):{ticks:k(r.scale.getTicks(),function(i){return i.value})}}function VI(r){var t=r.getLabelModel(),e=t1(r,t);return!t.get("show")||r.scale.isBlank()?{labels:[],labelCategoryInterval:e.labelCategoryInterval}:e}function t1(r,t){var e=e1(r,"labels"),i=Of(t),a=r1(e,i);if(a)return a;var n,o;return G(i)?n=o1(r,i):(o=i==="auto"?HI(r):i,n=n1(r,o)),i1(e,i,{labels:n,labelCategoryInterval:o})}function BI(r,t){var e=e1(r,"ticks"),i=Of(t),a=r1(e,i);if(a)return a;var n,o;if((!t.get("show")||r.scale.isBlank())&&(n=[]),G(i))n=o1(r,i,!0);else if(i==="auto"){var s=t1(r,r.getLabelModel());o=s.labelCategoryInterval,n=k(s.labels,function(l){return l.tickValue})}else o=i,n=n1(r,o,!0);return i1(e,i,{ticks:n,tickCategoryInterval:o})}function FI(r){var t=r.scale.getTicks(),e=en(r);return{labels:k(t,function(i,a){return{level:i.level,formattedLabel:e(i,a),rawLabel:r.scale.getLabel(i),tickValue:i.value}})}}function e1(r,t){return $s(r)[t]||($s(r)[t]=[])}function r1(r,t){for(var e=0;e40&&(s=Math.max(1,Math.floor(o/40)));for(var l=n[0],u=r.dataToCoord(l+1)-r.dataToCoord(l),f=Math.abs(u*Math.cos(i)),h=Math.abs(u*Math.sin(i)),p=0,c=0;l<=n[1];l+=s){var v=0,m=0,d=Mn(e({value:l}),t.font,"center","top");v=d.width*1.3,m=d.height*1.3,p=Math.max(p,v,7),c=Math.max(c,m,7)}var g=p/f,y=c/h;isNaN(g)&&(g=1/0),isNaN(y)&&(y=1/0);var _=Math.max(0,Math.floor(Math.min(g,y))),x=$s(r.model),w=r.getExtent(),S=x.lastAutoInterval,T=x.lastTickCount;return S!=null&&T!=null&&Math.abs(S-_)<=1&&Math.abs(T-o)<=1&&S>_&&x.axisExtent0===w[0]&&x.axisExtent1===w[1]?_=S:(x.lastTickCount=o,x.lastAutoInterval=_,x.axisExtent0=w[0],x.axisExtent1=w[1]),_}function GI(r){var t=r.getLabelModel();return{axisRotate:r.getRotate?r.getRotate():r.isHorizontal&&!r.isHorizontal()?90:0,labelRotate:t.get("rotate")||0,font:t.getFont()}}function n1(r,t,e){var i=en(r),a=r.scale,n=a.getExtent(),o=r.getLabelModel(),s=[],l=Math.max((t||0)+1,1),u=n[0],f=a.count();u!==0&&l>1&&f/l>2&&(u=Math.round(Math.ceil(u/l)*l));var h=Nf(r),p=o.get("showMinLabel")||h,c=o.get("showMaxLabel")||h;p&&u!==n[0]&&m(n[0]);for(var v=u;v<=n[1];v+=l)m(v);c&&v-l!==n[1]&&m(n[1]);function m(d){var g={value:d};s.push(e?d:{formattedLabel:i(g),rawLabel:a.getLabel(g),tickValue:d})}return s}function o1(r,t,e){var i=r.scale,a=en(r),n=[];return b(i.getTicks(),function(o){var s=i.getLabel(o),l=o.value;t(o.value,s)&&n.push(e?l:{formattedLabel:a(o),rawLabel:s,tickValue:l})}),n}var s1=[0,1],WI=(function(){function r(t,e,i){this.onBand=!1,this.inverse=!1,this.dim=t,this.scale=e,this._extent=i||[0,0]}return r.prototype.contain=function(t){var e=this._extent,i=Math.min(e[0],e[1]),a=Math.max(e[0],e[1]);return t>=i&&t<=a},r.prototype.containData=function(t){return this.scale.contain(t)},r.prototype.getExtent=function(){return this._extent.slice()},r.prototype.getPixelPrecision=function(t){return An(t||this.scale.getExtent(),this._extent)},r.prototype.setExtent=function(t,e){var i=this._extent;i[0]=t,i[1]=e},r.prototype.dataToCoord=function(t,e){var i=this._extent,a=this.scale;return t=a.normalize(t),this.onBand&&a.type==="ordinal"&&(i=i.slice(),l1(i,a.count())),gt(t,s1,i,e)},r.prototype.coordToData=function(t,e){var i=this._extent,a=this.scale;this.onBand&&a.type==="ordinal"&&(i=i.slice(),l1(i,a.count()));var n=gt(t,i,s1,e);return this.scale.scale(n)},r.prototype.pointToData=function(t,e){},r.prototype.getTicksCoords=function(t){t=t||{};var e=t.tickModel||this.getTickModel(),i=JS(this,e),a=i.ticks,n=k(a,function(s){return{coord:this.dataToCoord(this.scale.type==="ordinal"?this.scale.getRawOrdinalNumber(s):s),tickValue:s}},this),o=e.get("alignWithLabel");return YI(this,n,o,t.clamp),n},r.prototype.getMinorTicksCoords=function(){if(this.scale.type==="ordinal")return[];var t=this.model.getModel("minorTick"),e=t.get("splitNumber");e>0&&e<100||(e=5);var i=this.scale.getMinorTicks(e),a=k(i,function(n){return k(n,function(o){return{coord:this.dataToCoord(o),tickValue:o}},this)},this);return a},r.prototype.getViewLabels=function(){return $S(this).labels},r.prototype.getLabelModel=function(){return this.model.getModel("axisLabel")},r.prototype.getTickModel=function(){return this.model.getModel("axisTick")},r.prototype.getBandWidth=function(){var t=this._extent,e=this.scale.getExtent(),i=e[1]-e[0]+(this.onBand?1:0);i===0&&(i=1);var a=Math.abs(t[1]-t[0]);return Math.abs(a)/i},r.prototype.calculateCategoryInterval=function(){return a1(this)},r})();function l1(r,t){var e=r[1]-r[0],i=t,a=e/i/2;r[0]+=a,r[1]-=a}function YI(r,t,e,i){var a=t.length;if(!r.onBand||e||!a)return;var n=r.getExtent(),o,s;if(a===1)t[0].coord=n[0],o=t[1]={coord:n[1]};else{var l=t[a-1].tickValue-t[0].tickValue,u=(t[a-1].coord-t[0].coord)/l;b(t,function(c){c.coord-=u/2});var f=r.scale.getExtent();s=1+f[1]-t[a-1].tickValue,o={coord:t[a-1].coord+u*s},t.push(o)}var h=n[0]>n[1];p(t[0].coord,n[0])&&(i?t[0].coord=n[0]:t.shift()),i&&p(n[0],t[0].coord)&&t.unshift({coord:n[0]}),p(n[1],o.coord)&&(i?o.coord=n[1]:t.pop()),i&&p(o.coord,n[1])&&t.push({coord:n[1]});function p(c,v){return c=bt(c),v=bt(v),h?c>v:c0){t=t/180*Math.PI,Gi.fromArray(r[0]),Pt.fromArray(r[1]),ue.fromArray(r[2]),rt.sub(Wi,Gi,Pt),rt.sub(Hr,ue,Pt);var e=Wi.len(),i=Hr.len();if(!(e<.001||i<.001)){Wi.scale(1/e),Hr.scale(1/i);var a=Wi.dot(Hr),n=Math.cos(t);if(n1&&rt.copy(we,ue),we.toArray(r[1])}}}}function h1(r,t,e){if(e<=180&&e>0){e=e/180*Math.PI,Gi.fromArray(r[0]),Pt.fromArray(r[1]),ue.fromArray(r[2]),rt.sub(Wi,Pt,Gi),rt.sub(Hr,ue,Pt);var i=Wi.len(),a=Hr.len();if(!(i<.001||a<.001)){Wi.scale(1/i),Hr.scale(1/a);var n=Wi.dot(t),o=Math.cos(e);if(n=l)rt.copy(we,ue);else{we.scaleAndAdd(Hr,s/Math.tan(Math.PI/2-f));var h=ue.x!==Pt.x?(we.x-Pt.x)/(ue.x-Pt.x):(we.y-Pt.y)/(ue.y-Pt.y);if(isNaN(h))return;h<0?rt.copy(we,Pt):h>1&&rt.copy(we,ue)}we.toArray(r[1])}}}}function ud(r,t,e,i){var a=e==="normal",n=a?r:r.ensureState(e);n.ignore=t;var o=i.get("smooth");o&&o===!0&&(o=.3),n.shape=n.shape||{},o>0&&(n.shape.smooth=o);var s=i.getModel("lineStyle").getLineStyle();a?r.useStyle(s):n.style=s}function jI(r,t){var e=t.smooth,i=t.points;if(i)if(r.moveTo(i[0][0],i[0][1]),e>0&&i.length>=3){var a=dn(i[0],i[1]),n=dn(i[1],i[2]);if(!a||!n){r.lineTo(i[1][0],i[1][1]),r.lineTo(i[2][0],i[2][1]);return}var o=Math.min(a,n)*e,s=Lo([],i[1],i[0],o/a),l=Lo([],i[1],i[2],o/n),u=Lo([],s,l,.5);r.bezierCurveTo(s[0],s[1],s[0],s[1],u[0],u[1]),r.bezierCurveTo(l[0],l[1],l[0],l[1],i[2][0],i[2][1])}else for(var f=1;f0&&n&&S(-h/o,0,o);var d=r[0],g=r[o-1],y,_;x(),y<0&&T(-y,.8),_<0&&T(_,.8),x(),w(y,_,1),w(_,y,-1),x(),y<0&&M(-y),_<0&&M(_);function x(){y=d.rect[t]-i,_=a-g.rect[t]-g.rect[e]}function w(D,A,C){if(D<0){var E=Math.min(A,-D);if(E>0){S(E*C,0,o);var L=E+D;L<0&&T(-L*C,1)}else T(-D*C,1)}}function S(D,A,C){D!==0&&(u=!0);for(var E=A;E0)for(var L=0;L0;L--){var Z=C[L-1]*z;S(-Z,L,o)}}}function M(D){var A=D<0?-1:1;D=Math.abs(D);for(var C=Math.ceil(D/(o-1)),E=0;E0?S(C,0,E+1):S(-C,o-E-1,o),D-=C,D<=0)return}return u}function d1(r,t,e,i){return QI(r,"y","height",t,e,i)}function m1(r){var t=[];r.sort(function(m,d){return d.priority-m.priority});var e=new J(0,0,0,0);function i(m){if(!m.ignore){var d=m.ensureState("emphasis");d.ignore==null&&(d.ignore=!1)}m.ignore=!0}for(var a=0;a-1&&(u.style.stroke=u.style.fill,u.style.fill="#fff",u.style.lineWidth=2),i},t.type="series.line",t.dependencies=["grid","polar"],t.defaultOption={z:3,coordinateSystem:"cartesian2d",legendHoverLink:!0,clip:!0,label:{position:"top"},endLabel:{show:!1,valueAnimation:!0,distance:8},lineStyle:{width:2,type:"solid"},emphasis:{scale:!0},step:!1,smooth:!1,smoothMonotone:null,symbol:"emptyCircle",symbolSize:4,symbolRotate:null,showSymbol:!0,showAllSymbol:"auto",connectNulls:!1,sampling:"none",animationEasing:"linear",progressive:0,hoverLayerThreshold:1/0,universalTransition:{divideShape:"clone"},triggerLineEvent:!1},t})(qt),g1=$I;function ho(r,t){var e=r.mapDimensionsAll("defaultedLabel"),i=e.length;if(i===1){var a=fi(r,t,e[0]);return a!=null?a+"":null}else if(i){for(var n=[],o=0;o=0&&i.push(t[n])}return i.join(" ")}var JI=(function(r){I(t,r);function t(e,i,a,n){var o=r.call(this)||this;return o.updateData(e,i,a,n),o}return t.prototype._createSymbol=function(e,i,a,n,o){this.removeAll();var s=Vt(e,-1,-1,2,2,null,o);s.attr({z2:100,culling:!0,scaleX:n[0]/2,scaleY:n[1]/2}),s.drift=tP,this._symbolType=e,this.add(s)},t.prototype.stopSymbolAnimation=function(e){this.childAt(0).stopAnimation(null,e)},t.prototype.getSymbolType=function(){return this._symbolType},t.prototype.getSymbolPath=function(){return this.childAt(0)},t.prototype.highlight=function(){Ea(this.childAt(0))},t.prototype.downplay=function(){La(this.childAt(0))},t.prototype.setZ=function(e,i){var a=this.childAt(0);a.zlevel=e,a.z=i},t.prototype.setDraggable=function(e,i){var a=this.childAt(0);a.draggable=e,a.cursor=!i&&e?"move":a.cursor},t.prototype.updateData=function(e,i,a,n){this.silent=!1;var o=e.getItemVisual(i,"symbol")||"circle",s=e.hostModel,l=t.getSymbolSize(e,i),u=o!==this._symbolType,f=n&&n.disableAnimation;if(u){var h=e.getItemVisual(i,"symbolKeepAspect");this._createSymbol(o,e,i,l,h)}else{var p=this.childAt(0);p.silent=!1;var c={scaleX:l[0]/2,scaleY:l[1]/2};f?p.attr(c):Ct(p,c,s,i),Wn(p)}if(this._updateCommon(e,i,l,a,n),u){var p=this.childAt(0);if(!f){var c={scaleX:this._sizeX,scaleY:this._sizeY,style:{opacity:p.style.opacity}};p.scaleX=p.scaleY=0,p.style.opacity=0,Gt(p,c,s,i)}}f&&this.childAt(0).stopAnimation("leave")},t.prototype._updateCommon=function(e,i,a,n,o){var s=this.childAt(0),l=e.hostModel,u,f,h,p,c,v,m,d,g;if(n&&(u=n.emphasisItemStyle,f=n.blurItemStyle,h=n.selectItemStyle,p=n.focus,c=n.blurScope,m=n.labelStatesModels,d=n.hoverScale,g=n.cursorStyle,v=n.emphasisDisabled),!n||e.hasItemOption){var y=n&&n.itemModel?n.itemModel:e.getItemModel(i),_=y.getModel("emphasis");u=_.getModel("itemStyle").getItemStyle(),h=y.getModel(["select","itemStyle"]).getItemStyle(),f=y.getModel(["blur","itemStyle"]).getItemStyle(),p=_.get("focus"),c=_.get("blurScope"),v=_.get("disabled"),m=Fe(y),d=_.getShallow("scale"),g=y.getShallow("cursor")}var x=e.getItemVisual(i,"symbolRotate");s.attr("rotation",(x||0)*Math.PI/180||0);var w=of(e.getItemVisual(i,"symbolOffset"),a);w&&(s.x=w[0],s.y=w[1]),g&&s.attr("cursor",g);var S=e.getItemVisual(i,"style"),T=S.fill;if(s instanceof ne){var M=s.style;s.useStyle(N({image:M.image,x:M.x,y:M.y,width:M.width,height:M.height},S))}else s.__isEmptyBrush?s.useStyle(N({},S)):s.useStyle(S),s.style.decal=null,s.setColor(T,o&&o.symbolInnerColor),s.style.strokeNoScale=!0;var D=e.getItemVisual(i,"liftZ"),A=this._z2;D!=null?A==null&&(this._z2=s.z2,s.z2+=D):A!=null&&(s.z2=A,this._z2=null);var C=o&&o.useNameLabel;ar(s,m,{labelFetcher:l,labelDataIndex:i,defaultText:E,inheritColor:T,defaultOpacity:S.opacity});function E(R){return C?e.getName(R):ho(e,R)}this._sizeX=a[0]/2,this._sizeY=a[1]/2;var L=s.ensureState("emphasis");L.style=u,s.ensureState("select").style=h,s.ensureState("blur").style=f;var P=d==null||d===!0?Math.max(1.1,3/this._sizeY):isFinite(d)&&d>0?+d:1;L.scaleX=this._sizeX*P,L.scaleY=this._sizeY*P,this.setSymbolScale(1),yr(this,p,c,v)},t.prototype.setSymbolScale=function(e){this.scaleX=this.scaleY=e},t.prototype.fadeOut=function(e,i,a){var n=this.childAt(0),o=ut(this).dataIndex,s=a&&a.animation;if(this.silent=n.silent=!0,a&&a.fadeLabel){var l=n.getTextContent();l&&Gn(l,{style:{opacity:0}},i,{dataIndex:o,removeOpt:s,cb:function(){n.removeTextContent()}})}else n.removeTextContent();Gn(n,{style:{opacity:0},scaleX:0,scaleY:0},i,{dataIndex:o,cb:e,removeOpt:s})},t.getSymbolSize=function(e,i){return Ix(e.getItemVisual(i,"symbolSize"))},t})(ft);function tP(r,t){this.parent.drift(r,t)}var Js=JI;function fd(r,t,e,i){return t&&!isNaN(t[0])&&!isNaN(t[1])&&!(i.isIgnore&&i.isIgnore(e))&&!(i.clipShape&&!i.clipShape.contain(t[0],t[1]))&&r.getItemVisual(e,"symbol")!=="none"}function y1(r){return r!=null&&!F(r)&&(r={isIgnore:r}),r||{}}function _1(r){var t=r.hostModel,e=t.getModel("emphasis");return{emphasisItemStyle:e.getModel("itemStyle").getItemStyle(),blurItemStyle:t.getModel(["blur","itemStyle"]).getItemStyle(),selectItemStyle:t.getModel(["select","itemStyle"]).getItemStyle(),focus:e.get("focus"),blurScope:e.get("blurScope"),emphasisDisabled:e.get("disabled"),hoverScale:e.get("scale"),labelStatesModels:Fe(t),cursorStyle:t.get("cursor")}}var eP=(function(){function r(t){this.group=new ft,this._SymbolCtor=t||Js}return r.prototype.updateData=function(t,e){this._progressiveEls=null,e=y1(e);var i=this.group,a=t.hostModel,n=this._data,o=this._SymbolCtor,s=e.disableAnimation,l=_1(t),u={disableAnimation:s},f=e.getSymbolPoint||function(h){return t.getItemLayout(h)};n||i.removeAll(),t.diff(n).add(function(h){var p=f(h);if(fd(t,p,h,e)){var c=new o(t,h,l,u);c.setPosition(p),t.setItemGraphicEl(h,c),i.add(c)}}).update(function(h,p){var c=n.getItemGraphicEl(p),v=f(h);if(!fd(t,v,h,e)){i.remove(c);return}var m=t.getItemVisual(h,"symbol")||"circle",d=c&&c.getSymbolType&&c.getSymbolType();if(!c||d&&d!==m)i.remove(c),c=new o(t,h,l,u),c.setPosition(v);else{c.updateData(t,h,l,u);var g={x:v[0],y:v[1]};s?c.attr(g):Ct(c,g,a)}i.add(c),t.setItemGraphicEl(h,c)}).remove(function(h){var p=n.getItemGraphicEl(h);p&&p.fadeOut(function(){i.remove(p)},a)}).execute(),this._getSymbolPoint=f,this._data=t},r.prototype.updateLayout=function(){var t=this,e=this._data;e&&e.eachItemGraphicEl(function(i,a){var n=t._getSymbolPoint(a);i.setPosition(n),i.markRedraw()})},r.prototype.incrementalPrepareUpdate=function(t){this._seriesScope=_1(t),this._data=null,this.group.removeAll()},r.prototype.incrementalUpdate=function(t,e,i){this._progressiveEls=[],i=y1(i);function a(l){l.isGroup||(l.incremental=!0,l.ensureState("emphasis").hoverLayer=!0)}for(var n=t.start;n0?e=i[0]:i[1]<0&&(e=i[1]),e}function Gf(r,t,e,i){var a=NaN;r.stacked&&(a=e.get(e.getCalculationInfo("stackedOverDimension"),i)),isNaN(a)&&(a=r.valueStart);var n=r.baseDataOffset,o=[];return o[n]=e.get(r.baseDim,i),o[1-n]=a,t.dataToPoint(o)}function iP(r,t){var e=[];return t.diff(r).add(function(i){e.push({cmd:"+",idx:i})}).update(function(i,a){e.push({cmd:"=",idx:a,idx1:i})}).remove(function(i){e.push({cmd:"-",idx:i})}).execute(),e}function hd(r,t,e,i,a,n,o,s){for(var l=iP(r,t),u=[],f=[],h=[],p=[],c=[],v=[],m=[],d=Hf(a,t,o),g=r.getLayout("points")||[],y=t.getLayout("points")||[],_=0;_=a||m<0)break;if(rn(g,y)){if(l){m+=n;continue}break}if(m===e)r[n>0?"moveTo":"lineTo"](g,y),h=g,p=y;else{var _=g-u,x=y-f;if(_*_+x*x<.5){m+=n;continue}if(o>0){for(var w=m+n,S=t[w*2],T=t[w*2+1];S===g&&T===y&&d=i||rn(S,T))c=g,v=y;else{A=S-u,C=T-f;var P=g-u,R=S-g,z=y-f,Z=T-y,V=void 0,B=void 0;if(s==="x"){V=Math.abs(P),B=Math.abs(R);var X=A>0?1:-1;c=g-X*V*o,v=y,E=g+X*B*o,L=y}else if(s==="y"){V=Math.abs(z),B=Math.abs(Z);var Q=C>0?1:-1;c=g,v=y-Q*V*o,E=g,L=y+Q*B*o}else V=Math.sqrt(P*P+z*z),B=Math.sqrt(R*R+Z*Z),D=B/(B+V),c=g-A*o*(1-D),v=y-C*o*(1-D),E=g+A*o*D,L=y+C*o*D,E=Yi(E,Zi(S,g)),L=Yi(L,Zi(T,y)),E=Zi(E,Yi(S,g)),L=Zi(L,Yi(T,y)),A=E-g,C=L-y,c=g-A*V/B,v=y-C*V/B,c=Yi(c,Zi(u,g)),v=Yi(v,Zi(f,y)),c=Zi(c,Yi(u,g)),v=Zi(v,Yi(f,y)),A=g-c,C=y-v,E=g+A*B/V,L=y+C*B/V}r.bezierCurveTo(h,p,c,v,g,y),h=E,p=L}else r.lineTo(g,y)}u=g,f=y,m+=n}return d}var S1=(function(){function r(){this.smooth=0,this.smoothConstraint=!0}return r})(),b1=(function(r){I(t,r);function t(e){var i=r.call(this,e)||this;return i.type="ec-polyline",i}return t.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},t.prototype.getDefaultShape=function(){return new S1},t.prototype.buildPath=function(e,i){var a=i.points,n=0,o=a.length/2;if(i.connectNulls){for(;o>0&&rn(a[o*2-2],a[o*2-1]);o--);for(;n=0){var x=u?(v-l)*_+l:(c-s)*_+s;return u?[e,x]:[x,e]}s=c,l=v;break;case o.C:c=n[h++],v=n[h++],m=n[h++],d=n[h++],g=n[h++],y=n[h++];var w=u?la(s,c,m,g,e,f):la(l,v,d,y,e,f);if(w>0)for(var S=0;S=0){var x=u?At(l,v,d,y,T):At(s,c,m,g,T);return u?[e,x]:[x,e]}}s=g,l=y;break}}},t})(at);var aP=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(S1),w1=(function(r){I(t,r);function t(e){var i=r.call(this,e)||this;return i.type="ec-polygon",i}return t.prototype.getDefaultShape=function(){return new aP},t.prototype.buildPath=function(e,i){var a=i.points,n=i.stackedOnPoints,o=0,s=a.length/2,l=i.smoothMonotone;if(i.connectNulls){for(;s>0&&rn(a[s*2-2],a[s*2-1]);s--);for(;ot){n?e.push(o(n,l,t)):a&&e.push(o(a,l,0),o(a,l,t));break}else a&&(e.push(o(a,l,0)),a=null),e.push(l),n=l}return e}function sP(r,t,e){var i=r.getVisual("visualMeta");if(!(!i||!i.length||!r.count())&&t.type==="cartesian2d"){for(var a,n,o=i.length-1;o>=0;o--){var s=r.getDimensionInfo(i[o].dimension);if(a=s&&s.coordDim,a==="x"||a==="y"){n=i[o];break}}if(n){var l=t.getAxis(a),u=k(n.stops,function(_){return{coord:l.toGlobalCoord(l.dataToCoord(_.value)),color:_.color}}),f=u.length,h=n.outerColors.slice();f&&u[0].coord>u[f-1].coord&&(u.reverse(),h.reverse());var p=oP(u,a==="x"?e.getWidth():e.getHeight()),c=p.length;if(!c&&f)return u[0].coord<0?h[1]?h[1]:u[f-1].color:h[0]?h[0]:u[0].color;var v=10,m=p[0].coord-v,d=p[c-1].coord+v,g=d-m;if(g<.001)return"transparent";b(p,function(_){_.offset=(_.coord-m)/g}),p.push({offset:c?p[c-1].offset:.5,color:h[1]||"transparent"}),p.unshift({offset:c?p[0].offset:.5,color:h[0]||"transparent"});var y=new Li(0,0,0,0,p,!0);return y[a]=m,y[a+"2"]=d,y}}}function lP(r,t,e){var i=r.get("showAllSymbol"),a=i==="auto";if(!(i&&!a)){var n=e.getAxesByScale("ordinal")[0];if(n&&!(a&&uP(n,t))){var o=t.mapDimension(n.dim),s={};return b(n.getViewLabels(),function(l){var u=n.scale.getRawOrdinalNumber(l.tickValue);s[u]=1}),function(l){return!s.hasOwnProperty(t.get(o,l))}}}}function uP(r,t){var e=r.getExtent(),i=Math.abs(e[1]-e[0])/r.scale.count();isNaN(i)&&(i=0);for(var a=t.count(),n=Math.max(1,Math.round(a/5)),o=0;oi)return!1;return!0}function fP(r,t){return isNaN(r)||isNaN(t)}function hP(r){for(var t=r.length/2;t>0&&fP(r[t*2-2],r[t*2-1]);t--);return t-1}function E1(r,t){return[r[t*2],r[t*2+1]]}function cP(r,t,e){for(var i=r.length/2,a=e==="x"?0:1,n,o,s=0,l=-1,u=0;u=t||n>=t&&o<=t){l=u;break}s=u,n=o}return{range:[s,l],t:(t-n)/(o-n)}}function L1(r){if(r.get(["endLabel","show"]))return!0;for(var t=0;t0&&e.get(["emphasis","lineStyle","width"])==="bolder"){var X=m.getState("emphasis").style;X.lineWidth=+m.style.lineWidth+1}ut(m).seriesIndex=e.seriesIndex,yr(m,Z,V,B);var Q=A1(e.get("smooth")),$=e.get("smoothMonotone");if(m.setShape({smooth:Q,smoothMonotone:$,connectNulls:M}),d){var mt=l.getCalculationInfo("stackedOnSeries"),xt=0;d.useStyle(K(f.getAreaStyle(),{fill:L,opacity:.7,lineJoin:"bevel",decal:l.getVisual("style").decal})),mt&&(xt=A1(mt.get("smooth"))),d.setShape({smooth:Q,stackedOnSmooth:xt,smoothMonotone:$,connectNulls:M}),Ia(d,e,"areaStyle"),ut(d).seriesIndex=e.seriesIndex,yr(d,Z,V,B)}var jt=function(Tt){n._changePolyState(Tt)};l.eachItemGraphicEl(function(Tt){Tt&&(Tt.onHoverStateChange=jt)}),this._polyline.onHoverStateChange=jt,this._data=l,this._coordSys=o,this._stackedOnPoints=S,this._points=h,this._step=C,this._valueOrigin=x,e.get("triggerLineEvent")&&(this.packEventData(e,m),d&&this.packEventData(e,d))},t.prototype.packEventData=function(e,i){ut(i).eventData={componentType:"series",componentSubType:"line",componentIndex:e.componentIndex,seriesIndex:e.seriesIndex,seriesName:e.name,seriesType:"line"}},t.prototype.highlight=function(e,i,a,n){var o=e.getData(),s=Je(o,n);if(this._changePolyState("emphasis"),!(s instanceof Array)&&s!=null&&s>=0){var l=o.getLayout("points"),u=o.getItemGraphicEl(s);if(!u){var f=l[s*2],h=l[s*2+1];if(isNaN(f)||isNaN(h)||this._clipShapeForSymbol&&!this._clipShapeForSymbol.contain(f,h))return;var p=e.get("zlevel")||0,c=e.get("z")||0;u=new Js(o,s),u.x=f,u.y=h,u.setZ(p,c);var v=u.getSymbolPath().getTextContent();v&&(v.zlevel=p,v.z=c,v.z2=this._polyline.z2+1),u.__temp=!0,o.setItemGraphicEl(s,u),u.stopSymbolAnimation(!0),this.group.add(u)}u.highlight()}else Ut.prototype.highlight.call(this,e,i,a,n)},t.prototype.downplay=function(e,i,a,n){var o=e.getData(),s=Je(o,n);if(this._changePolyState("normal"),s!=null&&s>=0){var l=o.getItemGraphicEl(s);l&&(l.__temp?(o.setItemGraphicEl(s,null),this.group.remove(l)):l.downplay())}else Ut.prototype.downplay.call(this,e,i,a,n)},t.prototype._changePolyState=function(e){var i=this._polygon;Xc(this._polyline,e),i&&Xc(i,e)},t.prototype._newPolyline=function(e){var i=this._polyline;return i&&this._lineGroup.remove(i),i=new b1({shape:{points:e},segmentIgnoreThreshold:2,z2:10}),this._lineGroup.add(i),this._polyline=i,i},t.prototype._newPolygon=function(e,i){var a=this._polygon;return a&&this._lineGroup.remove(a),a=new w1({shape:{points:e,stackedOnPoints:i},segmentIgnoreThreshold:2}),this._lineGroup.add(a),this._polygon=a,a},t.prototype._initSymbolLabelAnimation=function(e,i,a){var n,o,s=i.getBaseAxis(),l=s.inverse;i.type==="cartesian2d"?(n=s.isHorizontal(),o=!1):i.type==="polar"&&(n=s.dim==="angle",o=!0);var u=e.hostModel,f=u.get("animationDuration");G(f)&&(f=f(null));var h=u.get("animationDelay")||0,p=G(h)?h(null):h;e.eachItemGraphicEl(function(c,v){var m=c;if(m){var d=[c.x,c.y],g=void 0,y=void 0,_=void 0;if(a)if(o){var x=a,w=i.pointToCoord(d);n?(g=x.startAngle,y=x.endAngle,_=-w[1]/180*Math.PI):(g=x.r0,y=x.r,_=w[0])}else{var S=a;n?(g=S.x,y=S.x+S.width,_=c.x):(g=S.y+S.height,y=S.y,_=c.y)}var T=y===g?0:(_-g)/(y-g);l&&(T=1-T);var M=G(h)?h(v):f*T+p,D=m.getSymbolPath(),A=D.getTextContent();m.attr({scaleX:0,scaleY:0}),m.animateTo({scaleX:1,scaleY:1},{duration:200,setToFinal:!0,delay:M}),A&&A.animateFrom({style:{opacity:0}},{duration:300,delay:M}),D.disableLabelAnimation=!0}})},t.prototype._initOrUpdateEndLabel=function(e,i,a){var n=e.getModel("endLabel");if(L1(e)){var o=e.getData(),s=this._polyline,l=o.getLayout("points");if(!l){s.removeTextContent(),this._endLabel=null;return}var u=this._endLabel;u||(u=this._endLabel=new vt({z2:200}),u.ignoreClip=!0,s.setTextContent(this._endLabel),s.disableLabelAnimation=!0);var f=hP(l);f>=0&&(ar(s,Fe(e,"endLabel"),{inheritColor:a,labelFetcher:e,labelDataIndex:f,defaultText:function(h,p,c){return c!=null?Ff(o,c):ho(o,h)},enableTextSetter:!0},pP(n,i)),s.textConfig.position=null)}else this._endLabel&&(this._polyline.removeTextContent(),this._endLabel=null)},t.prototype._endLabelOnDuring=function(e,i,a,n,o,s,l){var u=this._endLabel,f=this._polyline;if(u){e<1&&n.originalX==null&&(n.originalX=u.x,n.originalY=u.y);var h=a.getLayout("points"),p=a.hostModel,c=p.get("connectNulls"),v=s.get("precision"),m=s.get("distance")||0,d=l.getBaseAxis(),g=d.isHorizontal(),y=d.inverse,_=i.shape,x=y?g?_.x:_.y+_.height:g?_.x+_.width:_.y,w=(g?m:0)*(y?-1:1),S=(g?0:-m)*(y?-1:1),T=g?"x":"y",M=cP(h,x,T),D=M.range,A=D[1]-D[0],C=void 0;if(A>=1){if(A>1&&!c){var E=E1(h,D[0]);u.attr({x:E[0]+w,y:E[1]+S}),o&&(C=p.getRawValue(D[0]))}else{var E=f.getPointOn(x,T);E&&u.attr({x:E[0]+w,y:E[1]+S});var L=p.getRawValue(D[0]),P=p.getRawValue(D[1]);o&&(C=Sc(a,v,L,P,M.t))}n.lastFrameIndex=D[0]}else{var R=e===1||n.lastFrameIndex>0?D[0]:0,E=E1(h,R);o&&(C=p.getRawValue(R)),u.attr({x:E[0]+w,y:E[1]+S})}if(o){var z=Zn(u);typeof z.setLabelText=="function"&&z.setLabelText(C)}}},t.prototype._doUpdateAnimation=function(e,i,a,n,o,s,l){var u=this._polyline,f=this._polygon,h=e.hostModel,p=hd(this._data,e,this._stackedOnPoints,i,this._coordSys,a,this._valueOrigin,s),c=p.current,v=p.stackedOnCurrent,m=p.next,d=p.stackedOnNext;if(o&&(c=Xi(p.current,a,o,l),v=Xi(p.stackedOnCurrent,a,o,l),m=Xi(p.next,a,o,l),d=Xi(p.stackedOnNext,a,o,l)),D1(c,m)>3e3||f&&D1(v,d)>3e3){u.stopAnimation(),u.setShape({points:m}),f&&(f.stopAnimation(),f.setShape({points:m,stackedOnPoints:d}));return}u.shape.__points=p.current,u.shape.points=c;var g={shape:{points:m}};p.current!==c&&(g.shape.__points=p.next),u.stopAnimation(),Ct(u,g,h),f&&(f.setShape({points:c,stackedOnPoints:v}),f.stopAnimation(),Ct(f,{shape:{stackedOnPoints:d}},h),u.shape.points!==f.shape.points&&(f.shape.points=u.shape.points));for(var y=[],_=p.status,x=0;x<_.length;x++){var w=_[x].cmd;if(w==="="){var S=e.getItemGraphicEl(_[x].idx1);S&&y.push({el:S,ptIdx:x})}}u.animators&&u.animators.length&&u.animators[0].during(function(){f&&f.dirtyShape();for(var T=u.shape.__points,M=0;Mt&&(t=r[e]);return isFinite(t)?t:NaN},min:function(r){for(var t=1/0,e=0;et&&(t=n,e=a)}return isFinite(e)?e:NaN},nearest:function(r){return r[0]}},mP=function(r){return Math.round(r.length/2)};function tl(r){return{seriesType:r,reset:function(t,e,i){var a=t.getData(),n=t.get("sampling"),o=t.coordinateSystem,s=a.count();if(s>10&&o.type==="cartesian2d"&&n){var l=o.getBaseAxis(),u=o.getOtherAxis(l),f=l.getExtent(),h=i.getDevicePixelRatio(),p=Math.abs(f[1]-f[0])*(h||1),c=Math.round(s/p);if(isFinite(c)&&c>1){n==="lttb"&&t.setData(a.lttbDownSample(a.mapDimension(u.dim),1/c));var v=void 0;U(n)?v=dP[n]:G(n)&&(v=n),v&&t.setData(a.downSample(a.mapDimension(u.dim),1/c,v,mP))}}}}}function gd(r){r.registerChartView(I1),r.registerSeriesModel(g1),r.registerLayout(md("line",!0)),r.registerVisual({seriesType:"line",reset:function(t){var e=t.getData(),i=t.getModel("lineStyle").getLineStyle();i&&!i.stroke&&(i.stroke=e.getVisual("style").fill),e.setVisual("legendLineStyle",i)}}),r.registerProcessor(r.PRIORITY.PROCESSOR.STATISTIC,tl("line"))}var P1=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(e,i){return Fr(null,this,{useEncodeDefaulter:!0})},t.prototype.getMarkerPosition=function(e,i,a){var n=this.coordinateSystem;if(n&&n.clampData){var o=n.clampData(e),s=n.dataToPoint(o);if(a)b(n.getAxes(),function(p,c){if(p.type==="category"&&i!=null){var v=p.getTicksCoords(),m=p.getTickModel().get("alignWithLabel"),d=o[c],g=i[c]==="x1"||i[c]==="y1";if(g&&!m&&(d+=1),v.length<2)return;if(v.length===2){s[c]=p.toGlobalCoord(p.getExtent()[g?1:0]);return}for(var y=void 0,_=void 0,x=1,w=0;wd){_=(S+y)/2;break}w===1&&(x=T-v[0].tickValue)}_==null&&(y?y&&(_=v[v.length-1].coord):_=v[0].coord),s[c]=p.toGlobalCoord(_)}});else{var l=this.getData(),u=l.getLayout("offset"),f=l.getLayout("size"),h=n.getBaseAxis().isHorizontal()?0:1;s[h]+=u+f/2}return s}return[NaN,NaN]},t.type="series.__base_bar__",t.defaultOption={z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,barMinHeight:0,barMinAngle:0,large:!1,largeThreshold:400,progressive:3e3,progressiveChunkMode:"mod"},t})(qt);qt.registerClass(P1);var yd=P1;var gP=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(){return Fr(null,this,{useEncodeDefaulter:!0,createInvertedIndices:!!this.get("realtimeSort",!0)||null})},t.prototype.getProgressive=function(){return this.get("large")?this.get("progressive"):!1},t.prototype.getProgressiveThreshold=function(){var e=this.get("progressiveThreshold"),i=this.get("largeThreshold");return i>e&&(e=i),e},t.prototype.brushSelector=function(e,i,a){return a.rect(i.getItemLayout(e))},t.type="series.bar",t.dependencies=["grid","polar"],t.defaultOption=nr(yd.defaultOption,{clip:!0,roundCap:!1,showBackground:!1,backgroundStyle:{color:"rgba(180, 180, 180, 0.2)",borderColor:null,borderWidth:0,borderType:"solid",borderRadius:0,shadowBlur:0,shadowColor:null,shadowOffsetX:0,shadowOffsetY:0,opacity:1},select:{itemStyle:{borderColor:"#212121"}},realtimeSort:!1}),t})(yd),R1=gP;var yP=(function(){function r(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0}return r})(),_P=(function(r){I(t,r);function t(e){var i=r.call(this,e)||this;return i.type="sausage",i}return t.prototype.getDefaultShape=function(){return new yP},t.prototype.buildPath=function(e,i){var a=i.cx,n=i.cy,o=Math.max(i.r0||0,0),s=Math.max(i.r,0),l=(s-o)*.5,u=o+l,f=i.startAngle,h=i.endAngle,p=i.clockwise,c=Math.PI*2,v=p?h-fMath.PI/2&&fs)return!0;s=h}return!1},t.prototype._isOrderDifferentInView=function(e,i){for(var a=i.scale,n=a.getExtent(),o=Math.max(0,n[0]),s=Math.min(n[1],a.getOrdinalMeta().categories.length-1);o<=s;++o)if(e.ordinalNumbers[o]!==a.getRawOrdinalNumber(o))return!0},t.prototype._updateSortWithinSameData=function(e,i,a,n){if(this._isOrderChangedWithinSameData(e,i,a)){var o=this._dataSort(e,a,i);this._isOrderDifferentInView(o,a)&&(this._removeOnRenderedListener(n),n.dispatchAction({type:"changeAxisOrder",componentType:a.dim+"Axis",axisId:a.index,sortInfo:o}))}},t.prototype._dispatchInitSort=function(e,i,a){var n=i.baseAxis,o=this._dataSort(e,n,function(s){return e.get(e.mapDimension(i.otherAxis.dim),s)});a.dispatchAction({type:"changeAxisOrder",componentType:n.dim+"Axis",isInitSort:!0,axisId:n.index,sortInfo:o})},t.prototype.remove=function(e,i){this._clear(this._model),this._removeOnRenderedListener(i)},t.prototype.dispose=function(e,i){this._removeOnRenderedListener(i)},t.prototype._removeOnRenderedListener=function(e){this._onRendered&&(e.getZr().off("rendered",this._onRendered),this._onRendered=null)},t.prototype._clear=function(e){var i=this.group,a=this._data;e&&e.isAnimationEnabled()&&a&&!this._isLargeDraw?(this._removeBackground(),this._backgroundEls=[],a.eachItemGraphicEl(function(n){Ua(n,e,ut(n).dataIndex)})):i.removeAll(),this._data=null,this._isFirstFrame=!0},t.prototype._removeBackground=function(){this.group.remove(this._backgroundGroup),this._backgroundGroup=null},t.type="bar",t})(Ut),z1={cartesian2d:function(r,t){var e=t.width<0?-1:1,i=t.height<0?-1:1;e<0&&(t.x+=t.width,t.width=-t.width),i<0&&(t.y+=t.height,t.height=-t.height);var a=r.x+r.width,n=r.y+r.height,o=xd(t.x,r.x),s=Sd(t.x+t.width,a),l=xd(t.y,r.y),u=Sd(t.y+t.height,n),f=sa?s:o,t.y=h&&l>n?u:l,t.width=f?0:s-o,t.height=h?0:u-l,e<0&&(t.x+=t.width,t.width=-t.width),i<0&&(t.y+=t.height,t.height=-t.height),f||h},polar:function(r,t){var e=t.r0<=t.r?1:-1;if(e<0){var i=t.r;t.r=t.r0,t.r0=i}var a=Sd(t.r,r.r),n=xd(t.r0,r.r0);t.r=a,t.r0=n;var o=a-n<0;if(e<0){var i=t.r;t.r=t.r0,t.r0=i}return o}},k1={cartesian2d:function(r,t,e,i,a,n,o,s,l){var u=new st({shape:N({},i),z2:1});if(u.__dataIndex=e,u.name="item",n){var f=u.shape,h=a?"height":"width";f[h]=0}return u},polar:function(r,t,e,i,a,n,o,s,l){var u=!a&&l?_d:Ue,f=new u({shape:i,z2:1});f.name="item";var h=Y1(a);if(f.calculateTextPosition=O1(h,{isRoundCap:u===_d}),n){var p=f.shape,c=a?"r":"endAngle",v={};p[c]=a?i.r0:i.startAngle,v[c]=i[c],(s?Ct:Gt)(f,{shape:v},n)}return f}};function bP(r,t){var e=r.get("realtimeSort",!0),i=t.getBaseAxis();if(e&&i.type==="category"&&t.type==="cartesian2d")return{baseAxis:i,otherAxis:t.getOtherAxis(i)}}function U1(r,t,e,i,a,n,o,s){var l,u;n?(u={x:i.x,width:i.width},l={y:i.y,height:i.height}):(u={y:i.y,height:i.height},l={x:i.x,width:i.width}),s||(o?Ct:Gt)(e,{shape:l},t,a,null);var f=t?r.baseAxis.model:null;(o?Ct:Gt)(e,{shape:u},f,a)}function V1(r,t){for(var e=0;e0?1:-1,o=i.height>0?1:-1;return{x:i.x+n*a/2,y:i.y+o*a/2,width:i.width-n*a,height:i.height-o*a}},polar:function(r,t,e){var i=r.getItemLayout(t);return{cx:i.cx,cy:i.cy,r0:i.r0,r:i.r,startAngle:i.startAngle,endAngle:i.endAngle,clockwise:i.clockwise}}};function MP(r){return r.startAngle!=null&&r.endAngle!=null&&r.startAngle===r.endAngle}function Y1(r){return(function(t){var e=t?"Arc":"Angle";return function(i){switch(i){case"start":case"insideStart":case"end":case"insideEnd":return i+e;default:return i}}})(r)}function F1(r,t,e,i,a,n,o,s){var l=t.getItemVisual(e,"style");if(s){if(!n.get("roundCap")){var f=r.shape,h=nn(i.getModel("itemStyle"),f,!0);N(f,h),r.setShape(f)}}else{var u=i.get(["itemStyle","borderRadius"])||0;r.setShape("r",u)}r.useStyle(l);var p=i.getShallow("cursor");p&&r.attr("cursor",p);var c=s?o?a.r>=a.r0?"endArc":"startArc":a.endAngle>=a.startAngle?"endAngle":"startAngle":o?a.height>=0?"bottom":"top":a.width>=0?"right":"left",v=Fe(i);ar(r,v,{labelFetcher:n,labelDataIndex:e,defaultText:ho(n.getData(),e),inheritColor:l.fill,defaultOpacity:l.opacity,defaultOutsidePosition:c});var m=r.getTextContent();if(s&&m){var d=i.get(["label","position"]);r.textConfig.inside=d==="middle"?!0:null,N1(r,d==="outside"?c:d,Y1(o),i.get(["label","rotate"]))}V0(m,v,n.getRawValue(e),function(y){return Ff(t,y)});var g=i.getModel(["emphasis"]);yr(r,g.get("focus"),g.get("blurScope"),g.get("disabled")),Ia(r,i),MP(a)&&(r.style.fill="none",r.style.stroke="none",b(r.states,function(y){y.style&&(y.style.fill=y.style.stroke="none")}))}function CP(r,t){var e=r.get(["itemStyle","borderColor"]);if(!e||e==="none")return 0;var i=r.get(["itemStyle","borderWidth"])||0,a=isNaN(t.width)?Number.MAX_VALUE:Math.abs(t.width),n=isNaN(t.height)?Number.MAX_VALUE:Math.abs(t.height);return Math.min(i,a,n)}var DP=(function(){function r(){}return r})(),H1=(function(r){I(t,r);function t(e){var i=r.call(this,e)||this;return i.type="largeBar",i}return t.prototype.getDefaultShape=function(){return new DP},t.prototype.buildPath=function(e,i){for(var a=i.points,n=this.baseDimIdx,o=1-this.baseDimIdx,s=[],l=[],u=this.barWidth,f=0;f=0?e:null},30,!1);function AP(r,t,e){for(var i=r.baseDimIdx,a=1-i,n=r.shape.points,o=r.largeDataIndices,s=[],l=[],u=r.barWidth,f=0,h=n.length/3;f=s[0]&&t<=s[0]+l[0]&&e>=s[1]&&e<=s[1]+l[1])return o[f]}return-1}function Z1(r,t,e){if(an(e,"cartesian2d")){var i=t,a=e.getArea();return{x:r?i.x:a.x,y:r?a.y:i.y,width:r?i.width:a.width,height:r?a.height:i.height}}else{var a=e.getArea(),n=t;return{cx:a.cx,cy:a.cy,r0:r?a.r0:n.r0,r:r?a.r:n.r,startAngle:r?n.startAngle:0,endAngle:r?n.endAngle:Math.PI*2}}}function EP(r,t,e){var i=r.type==="polar"?Ue:st;return new i({shape:Z1(t,e,r),silent:!0,z2:0})}var X1=SP;function bd(r){r.registerChartView(X1),r.registerSeriesModel(R1),r.registerLayout(r.PRIORITY.VISUAL.LAYOUT,ct(PS,"bar")),r.registerLayout(r.PRIORITY.VISUAL.PROGRESSIVE_LAYOUT,RS("bar")),r.registerProcessor(r.PRIORITY.PROCESSOR.STATISTIC,tl("bar")),r.registerAction({type:"changeAxisOrder",event:"changeAxisOrder",update:"update"},function(t,e){var i=t.componentType||"series";e.eachComponent({mainType:i,query:t},function(a){t.sortInfo&&a.axis.setCategorySortInfo(t.sortInfo)})})}var q1=Math.PI*2,Xf=Math.PI/180;function K1(r,t){return pe(r.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()})}function wd(r,t){var e=K1(r,t),i=r.get("center"),a=r.get("radius");O(a)||(a=[0,a]);var n=yt(e.width,t.getWidth()),o=yt(e.height,t.getHeight()),s=Math.min(n,o),l=yt(a[0],s/2),u=yt(a[1],s/2),f,h,p=r.coordinateSystem;if(p){var c=p.dataToPoint(i);f=c[0]||0,h=c[1]||0}else O(i)||(i=[i,i]),f=yt(i[0],n)+e.x,h=yt(i[1],o)+e.y;return{cx:f,cy:h,r0:l,r:u}}function Td(r,t,e){t.eachSeriesByType(r,function(i){var a=i.getData(),n=a.mapDimension("value"),o=K1(i,e),s=wd(i,e),l=s.cx,u=s.cy,f=s.r,h=s.r0,p=-i.get("startAngle")*Xf,c=i.get("endAngle"),v=i.get("padAngle")*Xf;c=c==="auto"?p-q1:-c*Xf;var m=i.get("minAngle")*Xf,d=m+v,g=0;a.each(n,function(Z){!isNaN(Z)&&g++});var y=a.getSum(n),_=Math.PI/(y||g)*2,x=i.get("clockwise"),w=i.get("roseType"),S=i.get("stillShowZeroSum"),T=a.getDataExtent(n);T[0]=0;var M=x?1:-1,D=[p,c],A=M*v/2;Uc(D,!x),p=D[0],c=D[1];var C=Md(i);C.startAngle=p,C.endAngle=c,C.clockwise=x;var E=Math.abs(c-p),L=E,P=0,R=p;if(a.setLayout({viewRect:o,r:f}),a.each(n,function(Z,V){var B;if(isNaN(Z)){a.setItemLayout(V,{angle:NaN,startAngle:NaN,endAngle:NaN,clockwise:x,cx:l,cy:u,r0:h,r:w?NaN:f});return}w!=="area"?B=y===0&&S?_:Z*_:B=E/g,BB?(Q=R+M*B/2,$=Q):(Q=R+A,$=X-A),a.setItemLayout(V,{angle:B,startAngle:Q,endAngle:$,clockwise:x,cx:l,cy:u,r0:h,r:w?gt(Z,T,[h,f]):f}),R=X}),Le?g:d,w=Math.abs(_.label.y-e);if(w>=x.maxY){var S=_.label.x-t-_.len2*a,T=i+_.len,M=Math.abs(S)r.unconstrainedWidth?null:c:null;i.setStyle("width",v)}var m=i.getBoundingRect();n.width=m.width;var d=(i.style.margin||0)+2.1;n.height=m.height+d,n.y-=(n.height-h)/2}}}function Dd(r){return r.position==="center"}function Ad(r){var t=r.getData(),e=[],i,a,n=!1,o=(r.get("minShowLabelAngle")||0)*LP,s=t.getLayout("viewRect"),l=t.getLayout("r"),u=s.width,f=s.x,h=s.y,p=s.height;function c(S){S.ignore=!0}function v(S){if(!S.ignore)return!0;for(var T in S.states)if(S.states[T].ignore===!1)return!0;return!1}t.each(function(S){var T=t.getItemGraphicEl(S),M=T.shape,D=T.getTextContent(),A=T.getTextGuideLine(),C=t.getItemModel(S),E=C.getModel("label"),L=E.get("position")||C.get(["emphasis","label","position"]),P=E.get("distanceToLabelLine"),R=E.get("alignTo"),z=yt(E.get("edgeDistance"),u),Z=E.get("bleedMargin"),V=C.getModel("labelLine"),B=V.get("length");B=yt(B,u);var X=V.get("length2");if(X=yt(X,u),Math.abs(M.endAngle-M.startAngle)0?"right":"left":$>0?"left":"right"}var di=Math.PI,Yr=0,So=E.get("rotate");if(nt(So))Yr=So*(di/180);else if(L==="center")Yr=0;else if(So==="radial"||So===!0){var bT=$<0?-Q+di:-Q;Yr=bT}else if(So==="tangential"&&L!=="outside"&&L!=="outer"){var hn=Math.atan2($,mt);hn<0&&(hn=di*2+hn);var wT=mt>0;wT&&(hn=di+hn),Yr=hn-di}if(n=!!Yr,D.x=xt,D.y=jt,D.rotation=Yr,D.setStyle({verticalAlign:"middle"}),Ne){D.setStyle({align:Te});var gh=D.states.select;gh&&(gh.x+=D.x,gh.y+=D.y)}else{var bo=D.getBoundingRect().clone();bo.applyTransform(D.getComputedTransform());var Dm=(D.style.margin||0)+2.1;bo.y-=Dm/2,bo.height+=Dm,e.push({label:D,labelLine:A,position:L,len:B,len2:X,minTurnAngle:V.get("minTurnAngle"),maxSurfaceAngle:V.get("maxSurfaceAngle"),surfaceNormal:new rt($,mt),linePoints:Tt,textAlign:Te,labelDistance:P,labelAlignTo:R,edgeDistance:z,bleedMargin:Z,rect:bo,unconstrainedWidth:bo.width,labelStyleWidth:D.style.width})}T.setTextConfig({inside:Ne})}}),!n&&r.get("avoidLabelOverlap")&&IP(e,i,a,l,u,p,f,h);for(var m=0;m0){for(var f=o.getItemLayout(0),h=1;isNaN(f&&f.startAngle)&&h=n.r0}},t.type="pie",t})(Ut),$1=RP;function Ed(r,t,e){t=O(t)&&{coordDimensions:t}||N({encodeDefine:r.getEncode()},t);var i=r.getSource(),a=uo(i,t).dimensions,n=new lo(a,r);return n.initData(i,e),n}var OP=(function(){function r(t,e){this._getDataWithEncodedVisual=t,this._getRawData=e}return r.prototype.getAllNames=function(){var t=this._getRawData();return t.mapArray(t.getName)},r.prototype.containName=function(t){var e=this._getRawData();return e.indexOfName(t)>=0},r.prototype.indexOfName=function(t){var e=this._getDataWithEncodedVisual();return e.indexOfName(t)},r.prototype.getItemVisual=function(t,e){var i=this._getDataWithEncodedVisual();return i.getItemVisual(t,e)},r})(),J1=OP;var NP=ht(),zP=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.init=function(e){r.prototype.init.apply(this,arguments),this.legendVisualProvider=new J1(H(this.getData,this),H(this.getRawData,this)),this._defaultLabelLine(e)},t.prototype.mergeOption=function(){r.prototype.mergeOption.apply(this,arguments)},t.prototype.getInitialData=function(){return Ed(this,{coordDimensions:["value"],encodeDefaulter:ct(f_,this)})},t.prototype.getDataParams=function(e){var i=this.getData(),a=NP(i),n=a.seats;if(!n){var o=[];i.each(i.mapDimension("value"),function(l){o.push(l)}),n=a.seats=gc(o,i.hostModel.get("percentPrecision"))}var s=r.prototype.getDataParams.call(this,e);return s.percent=n[e]||0,s.$vars.push("percent"),s},t.prototype._defaultLabelLine=function(e){Qo(e,"labelLine",["show"]);var i=e.labelLine,a=e.emphasis.labelLine;i.show=i.show&&e.label.show,a.show=a.show&&e.emphasis.label.show},t.type="series.pie",t.defaultOption={z:2,legendHoverLink:!0,colorBy:"data",center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,endAngle:"auto",padAngle:0,minAngle:0,minShowLabelAngle:0,selectedOffset:10,percentPrecision:2,stillShowZeroSum:!0,left:0,top:0,right:0,bottom:0,width:null,height:null,label:{rotate:0,show:!0,overflow:"truncate",position:"outer",alignTo:"none",edgeDistance:"25%",bleedMargin:10,distanceToLabelLine:5},labelLine:{show:!0,length:15,length2:15,smooth:!1,minTurnAngle:90,maxSurfaceAngle:90,lineStyle:{width:1,type:"solid"}},itemStyle:{borderWidth:1,borderJoin:"round"},showEmptyCircle:!0,emptyCircleStyle:{color:"lightgray",opacity:1},labelLayout:{hideOverlap:!0},emphasis:{scale:!0,scaleSize:5},avoidLabelOverlap:!0,animationType:"expansion",animationDuration:1e3,animationTypeUpdate:"transition",animationEasingUpdate:"cubicInOut",animationDurationUpdate:500,animationEasing:"cubicInOut"},t})(qt),tb=zP;function Ld(r){return{seriesType:r,reset:function(t,e){var i=t.getData();i.filterSelf(function(a){var n=i.mapDimension("value"),o=i.get(n,a);return!(nt(o)&&!isNaN(o)&&o<0)})}}}function Id(r){r.registerChartView($1),r.registerSeriesModel(tb),Ax("pie",r.registerAction),r.registerLayout(ct(Td,"pie")),r.registerProcessor(Cd("pie")),r.registerProcessor(Ld("pie"))}var kP=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.type="grid",t.dependencies=["xAxis","yAxis"],t.layoutMode="box",t.defaultOption={show:!1,z:0,left:"10%",top:60,right:"10%",bottom:70,containLabel:!1,backgroundColor:"rgba(0,0,0,0)",borderWidth:1,borderColor:"#ccc"},t})(pt),eb=kP;var qf=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.getCoordSysModel=function(){return this.getReferringComponents("grid",zt).models[0]},t.type="cartesian2dAxis",t})(pt);Jt(qf,zf);var rb={show:!0,z:0,inverse:!1,name:"",nameLocation:"end",nameRotate:null,nameTruncate:{maxWidth:null,ellipsis:"...",placeholder:"."},nameTextStyle:{},nameGap:15,silent:!1,triggerEvent:!1,tooltip:{show:!1},axisPointer:{},axisLine:{show:!0,onZero:!0,onZeroAxisIndex:null,lineStyle:{color:"#6E7079",width:1,type:"solid"},symbol:["none","none"],symbolSize:[10,15]},axisTick:{show:!0,inside:!1,length:5,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,showMinLabel:null,showMaxLabel:null,margin:8,fontSize:12},splitLine:{show:!0,lineStyle:{color:["#E0E6F1"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},UP=tt({boundaryGap:!0,deduplication:null,splitLine:{show:!1},axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"}},rb),Pd=tt({boundaryGap:[0,0],axisLine:{show:"auto"},axisTick:{show:"auto"},splitNumber:5,minorTick:{show:!1,splitNumber:5,length:3,lineStyle:{}},minorSplitLine:{show:!1,lineStyle:{color:"#F4F7FD",width:1}}},rb),VP=tt({splitNumber:6,axisLabel:{showMinLabel:!1,showMaxLabel:!1,rich:{primary:{fontWeight:"bold"}}},splitLine:{show:!1}},Pd),BP=K({logBase:10},Pd),ib={category:UP,value:Pd,time:VP,log:BP};var ab={value:1,category:1,time:1,log:1};function Kf(r,t,e,i){b(ab,function(a,n){var o=tt(tt({},ib[n],!0),i,!0),s=(function(l){I(u,l);function u(){var f=l!==null&&l.apply(this,arguments)||this;return f.type=t+"Axis."+n,f}return u.prototype.mergeDefaultAndTheme=function(f,h){var p=Pi(this),c=p?Vr(f):{},v=h.getTheme();tt(f,v.get(n+"Axis")),tt(f,this.getDefaultOption()),f.type=nb(f),p&&Ur(f,c,p)},u.prototype.optionUpdated=function(){var f=this.option;f.type==="category"&&(this.__ordinalMeta=Xs.createByAxisModel(this))},u.prototype.getCategories=function(f){var h=this.option;if(h.type==="category")return f?h.data:this.__ordinalMeta.categories},u.prototype.getOrdinalMeta=function(){return this.__ordinalMeta},u.type=t+"Axis."+n,u.defaultOption=o,u})(e);r.registerComponentModel(s)}),r.registerSubTypeDefaulter(t+"Axis",nb)}function nb(r){return r.type||(r.data?"category":"value")}var FP=(function(){function r(t){this.type="cartesian",this._dimList=[],this._axes={},this.name=t||""}return r.prototype.getAxis=function(t){return this._axes[t]},r.prototype.getAxes=function(){return k(this._dimList,function(t){return this._axes[t]},this)},r.prototype.getAxesByScale=function(t){return t=t.toLowerCase(),Mt(this.getAxes(),function(e){return e.scale.type===t})},r.prototype.addAxis=function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},r})(),ob=FP;var jf=["x","y"];function sb(r){return r.type==="interval"||r.type==="time"}var HP=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type="cartesian2d",e.dimensions=jf,e}return t.prototype.calcAffineTransform=function(){this._transform=this._invTransform=null;var e=this.getAxis("x").scale,i=this.getAxis("y").scale;if(!(!sb(e)||!sb(i))){var a=e.getExtent(),n=i.getExtent(),o=this.dataToPoint([a[0],n[0]]),s=this.dataToPoint([a[1],n[1]]),l=a[1]-a[0],u=n[1]-n[0];if(!(!l||!u)){var f=(s[0]-o[0])/l,h=(s[1]-o[1])/u,p=o[0]-a[0]*f,c=o[1]-n[0]*h,v=this._transform=[f,0,0,h,p,c];this._invTransform=jr([],v)}}},t.prototype.getBaseAxis=function(){return this.getAxesByScale("ordinal")[0]||this.getAxesByScale("time")[0]||this.getAxis("x")},t.prototype.containPoint=function(e){var i=this.getAxis("x"),a=this.getAxis("y");return i.contain(i.toLocalCoord(e[0]))&&a.contain(a.toLocalCoord(e[1]))},t.prototype.containData=function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])},t.prototype.containZone=function(e,i){var a=this.dataToPoint(e),n=this.dataToPoint(i),o=this.getArea(),s=new J(a[0],a[1],n[0]-a[0],n[1]-a[1]);return o.intersect(s)},t.prototype.dataToPoint=function(e,i,a){a=a||[];var n=e[0],o=e[1];if(this._transform&&n!=null&&isFinite(n)&&o!=null&&isFinite(o))return Nt(a,e,this._transform);var s=this.getAxis("x"),l=this.getAxis("y");return a[0]=s.toGlobalCoord(s.dataToCoord(n,i)),a[1]=l.toGlobalCoord(l.dataToCoord(o,i)),a},t.prototype.clampData=function(e,i){var a=this.getAxis("x").scale,n=this.getAxis("y").scale,o=a.getExtent(),s=n.getExtent(),l=a.parse(e[0]),u=n.parse(e[1]);return i=i||[],i[0]=Math.min(Math.max(Math.min(o[0],o[1]),l),Math.max(o[0],o[1])),i[1]=Math.min(Math.max(Math.min(s[0],s[1]),u),Math.max(s[0],s[1])),i},t.prototype.pointToData=function(e,i){var a=[];if(this._invTransform)return Nt(a,e,this._invTransform);var n=this.getAxis("x"),o=this.getAxis("y");return a[0]=n.coordToData(n.toLocalCoord(e[0]),i),a[1]=o.coordToData(o.toLocalCoord(e[1]),i),a},t.prototype.getOtherAxis=function(e){return this.getAxis(e.dim==="x"?"y":"x")},t.prototype.getArea=function(e){e=e||0;var i=this.getAxis("x").getGlobalExtent(),a=this.getAxis("y").getGlobalExtent(),n=Math.min(i[0],i[1])-e,o=Math.min(a[0],a[1])-e,s=Math.max(i[0],i[1])-n+e,l=Math.max(a[0],a[1])-o+e;return new J(n,o,s,l)},t})(ob),lb=HP;var GP=(function(r){I(t,r);function t(e,i,a,n,o){var s=r.call(this,e,i,a)||this;return s.index=0,s.type=n||"value",s.position=o||"bottom",s}return t.prototype.isHorizontal=function(){var e=this.position;return e==="top"||e==="bottom"},t.prototype.getGlobalExtent=function(e){var i=this.getExtent();return i[0]=this.toGlobalCoord(i[0]),i[1]=this.toGlobalCoord(i[1]),e&&i[0]>i[1]&&i.reverse(),i},t.prototype.pointToData=function(e,i){return this.coordToData(this.toLocalCoord(e[this.dim==="x"?0:1]),i)},t.prototype.setCategorySortInfo=function(e){if(this.type!=="category")return!1;this.model.option.categorySortInfo=e,this.scale.setSortInfo(e)},t})(Uf),ub=GP;function el(r,t,e){e=e||{};var i=r.coordinateSystem,a=t.axis,n={},o=a.getAxesOnZeroOf()[0],s=a.position,l=o?"onZero":s,u=a.dim,f=i.getRect(),h=[f.x,f.x+f.width,f.y,f.y+f.height],p={left:0,right:1,top:0,bottom:1,onZero:2},c=t.get("offset")||0,v=u==="x"?[h[2]-c,h[3]+c]:[h[0]-c,h[1]+c];if(o){var m=o.toGlobalCoord(o.dataToCoord(0));v[p.onZero]=Math.max(Math.min(m,v[1]),v[0])}n.position=[u==="y"?v[p[l]]:h[0],u==="x"?v[p[l]]:h[3]],n.rotation=Math.PI/2*(u==="x"?0:1);var d={top:-1,bottom:1,left:-1,right:1};n.labelDirection=n.tickDirection=n.nameDirection=d[s],n.labelOffset=o?v[p[s]]-v[p.onZero]:0,t.get(["axisTick","inside"])&&(n.tickDirection=-n.tickDirection),Dr(e.labelInside,t.get(["axisLabel","inside"]))&&(n.labelDirection=-n.labelDirection);var g=t.get(["axisLabel","rotate"]);return n.labelRotate=l==="top"?-g:g,n.z2=1,n}function Rd(r){return r.get("coordinateSystem")==="cartesian2d"}function Od(r){var t={xAxisModel:null,yAxisModel:null};return b(t,function(e,i){var a=i.replace(/Model$/,""),n=r.getReferringComponents(a,zt).models[0];t[i]=n}),t}var Nd=Math.log;function hb(r,t,e){var i=pi.prototype,a=i.getTicks.call(e),n=i.getTicks.call(e,!0),o=a.length-1,s=i.getInterval.call(e),l=Kv(r,t),u=l.extent,f=l.fixMin,h=l.fixMax;if(r.type==="log"){var p=Nd(r.base);u=[Nd(u[0])/p,Nd(u[1])/p]}r.setExtent(u[0],u[1]),r.calcNiceExtent({splitNumber:o,fixMin:f,fixMax:h});var c=i.getExtent.call(r);f&&(u[0]=c[0]),h&&(u[1]=c[1]);var v=i.getInterval.call(r),m=u[0],d=u[1];if(f&&h)v=(d-m)/o;else if(f)for(d=u[0]+v*o;du[0]&&isFinite(m)&&isFinite(u[0]);)v=Cf(v),m=u[1]-v*o;else{var g=r.getTicks().length-1;g>o&&(v=Cf(v));var y=v*o;d=Math.ceil(u[1]/v)*v,m=bt(d-y),m<0&&u[0]>=0?(m=0,d=bt(y)):d>0&&u[1]<=0&&(d=0,m=-bt(y))}var _=(a[0].value-n[0].value)/s,x=(a[o].value-n[o].value)/s;if(i.setExtent.call(r,m+v*_,d+v*x),i.setInterval.call(r,v),(_||x)&&i.setNiceExtent.call(r,m+v,d-v),0)var w}var WP=(function(){function r(t,e,i){this.type="grid",this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this.axisPointerEnabled=!0,this.dimensions=jf,this._initCartesian(t,e,i),this.model=t}return r.prototype.getRect=function(){return this._rect},r.prototype.update=function(t,e){var i=this._axesMap;this._updateScale(t,this.model);function a(o){var s,l=lt(o),u=l.length;if(u){for(var f=[],h=u-1;h>=0;h--){var p=+l[h],c=o[p],v=c.model,m=c.scale;qs(m)&&v.get("alignTicks")&&v.get("interval")==null?f.push(c):(js(m,v),qs(m)&&(s=c))}f.length&&(s||(s=f.pop(),js(s.scale,s.model)),b(f,function(d){hb(d.scale,d.model,s.scale)}))}}a(i.x),a(i.y);var n={};b(i.x,function(o){cb(i,"y",o,n)}),b(i.y,function(o){cb(i,"x",o,n)}),this.resize(this.model,e)},r.prototype.resize=function(t,e,i){var a=t.getBoxLayoutParams(),n=!i&&t.get("containLabel"),o=pe(a,{width:e.getWidth(),height:e.getHeight()});this._rect=o;var s=this._axesList;l(),n&&(b(s,function(u){if(!u.model.get(["axisLabel","inside"])){var f=GS(u);if(f){var h=u.isHorizontal()?"height":"width",p=u.model.get(["axisLabel","margin"]);o[h]-=f[h]+p,u.position==="top"?o.y+=f.height+p:u.position==="left"&&(o.x+=f.width+p)}}}),l()),b(this._coordsList,function(u){u.calcAffineTransform()});function l(){b(s,function(u){var f=u.isHorizontal(),h=f?[0,o.width]:[0,o.height],p=u.inverse?1:0;u.setExtent(h[p],h[1-p]),YP(u,f?o.x:o.y)})}},r.prototype.getAxis=function(t,e){var i=this._axesMap[t];if(i!=null)return i[e||0]},r.prototype.getAxes=function(){return this._axesList.slice()},r.prototype.getCartesian=function(t,e){if(t!=null&&e!=null){var i="x"+t+"y"+e;return this._coordsMap[i]}F(t)&&(e=t.yAxisIndex,t=t.xAxisIndex);for(var a=0,n=this._coordsList;a0?"top":"bottom",n="center"):_a(a-qi)?(o=i>0?"bottom":"top",n="center"):(o="middle",a>0&&a0?"right":"left":n=i>0?"left":"right"),{rotation:a,textAlign:n,textVerticalAlign:o}},r.makeAxisEventDataBase=function(t){var e={componentType:t.mainType,componentIndex:t.componentIndex};return e[t.mainType+"Index"]=t.componentIndex,e},r.isLabelSilent=function(t){var e=t.get("tooltip");return t.get("silent")||!(t.get("triggerEvent")||e&&e.show)},r})(),db={axisLine:function(r,t,e,i){var a=t.get(["axisLine","show"]);if(a==="auto"&&r.handleAutoShown&&(a=r.handleAutoShown("axisLine")),!!a){var n=t.axis.getExtent(),o=i.transform,s=[n[0],0],l=[n[1],0],u=s[0]>l[0];o&&(Nt(s,s,o),Nt(l,l,o));var f=N({lineCap:"round"},t.getModel(["axisLine","lineStyle"]).getLineStyle()),h=new Ve({shape:{x1:s[0],y1:s[1],x2:l[0],y2:l[1]},style:f,strokeContainThreshold:r.strokeContainThreshold||5,silent:!0,z2:1});Va(h.shape,h.style.lineWidth),h.anid="line",e.add(h);var p=t.get(["axisLine","symbol"]);if(p!=null){var c=t.get(["axisLine","symbolSize"]);U(p)&&(p=[p,p]),(U(c)||nt(c))&&(c=[c,c]);var v=of(t.get(["axisLine","symbolOffset"])||0,c),m=c[0],d=c[1];b([{rotate:r.rotation+Math.PI/2,offset:v[0],r:0},{rotate:r.rotation-Math.PI/2,offset:v[1],r:Math.sqrt((s[0]-l[0])*(s[0]-l[0])+(s[1]-l[1])*(s[1]-l[1]))}],function(g,y){if(p[y]!=="none"&&p[y]!=null){var _=Vt(p[y],-m/2,-d/2,m,d,f.stroke,!0),x=g.r+g.offset,w=u?l:s;_.attr({rotation:g.rotate,x:w[0]+x*Math.cos(r.rotation),y:w[1]-x*Math.sin(r.rotation),silent:!0,z2:11}),e.add(_)}})}}},axisTickLabel:function(r,t,e,i){var a=qP(e,i,t,r),n=jP(e,i,t,r);if(XP(t,n,a),KP(e,i,t,r.tickDirection),t.get(["axisLabel","hideOverlap"])){var o=v1(k(n,function(s){return{label:s,priority:s.z2,defaultAttr:{ignore:s.ignore}}}));m1(o)}},axisName:function(r,t,e,i){var a=Dr(r.axisName,t.get("name"));if(a){var n=t.get("nameLocation"),o=r.nameDirection,s=t.getModel("nameTextStyle"),l=t.get("nameGap")||0,u=t.axis.getExtent(),f=u[0]>u[1]?-1:1,h=[n==="start"?u[0]-f*l:n==="end"?u[1]+f*l:(u[0]+u[1])/2,gb(n)?r.labelOffset+o*l:0],p,c=t.get("nameRotate");c!=null&&(c=c*qi/180);var v;gb(n)?p=on.innerTextLayout(r.rotation,c??r.rotation,o):(p=ZP(r.rotation,n,c||0,u),v=r.axisNameAvailableWidth,v!=null&&(v=Math.abs(v/Math.sin(p.rotation)),!isFinite(v)&&(v=null)));var m=s.getFont(),d=t.get("nameTruncate",!0)||{},g=d.ellipsis,y=Dr(r.nameTruncateMaxWidth,d.maxWidth,v),_=new vt({x:h[0],y:h[1],rotation:p.rotation,silent:on.isLabelSilent(t),style:Zt(s,{text:a,font:m,overflow:"truncate",width:y,ellipsis:g,fill:s.getTextColor()||t.get(["axisLine","lineStyle","color"]),align:s.get("align")||p.textAlign,verticalAlign:s.get("verticalAlign")||p.textVerticalAlign}),z2:1});if(ms({el:_,componentModel:t,itemName:a}),_.__fullText=a,_.anid="name",t.get("triggerEvent")){var x=on.makeAxisEventDataBase(t);x.targetType="axisName",x.name=a,ut(_).eventData=x}i.add(_),_.updateTransform(),e.add(_),_.decomposeTransform()}}};function ZP(r,t,e,i){var a=Xo(e-r),n,o,s=i[0]>i[1],l=t==="start"&&!s||t!=="start"&&s;return _a(a-qi/2)?(o=l?"bottom":"top",n="center"):_a(a-qi*1.5)?(o=l?"top":"bottom",n="center"):(o="middle",aqi/2?n=l?"left":"right":n=l?"right":"left"),{rotation:a,textAlign:n,textVerticalAlign:o}}function XP(r,t,e){if(!Nf(r.axis)){var i=r.get(["axisLabel","showMinLabel"]),a=r.get(["axisLabel","showMaxLabel"]);t=t||[],e=e||[];var n=t[0],o=t[1],s=t[t.length-1],l=t[t.length-2],u=e[0],f=e[1],h=e[e.length-1],p=e[e.length-2];i===!1?(hr(n),hr(u)):mb(n,o)&&(i?(hr(o),hr(f)):(hr(n),hr(u))),a===!1?(hr(s),hr(h)):mb(l,s)&&(a?(hr(l),hr(p)):(hr(s),hr(h)))}}function hr(r){r&&(r.ignore=!0)}function mb(r,t){var e=r&&r.getBoundingRect().clone(),i=t&&t.getBoundingRect().clone();if(!(!e||!i)){var a=Kr([]);return ea(a,a,-r.rotation),e.applyTransform(Ke([],a,r.getLocalTransform())),i.applyTransform(Ke([],a,t.getLocalTransform())),e.intersect(i)}}function gb(r){return r==="middle"||r==="center"}function yb(r,t,e,i,a){for(var n=[],o=[],s=[],l=0;l=0||r===t}function xb(r){var t=$f(r);if(t){var e=t.axisPointerModel,i=t.axis.scale,a=e.option,n=e.get("status"),o=e.get("value");o!=null&&(o=i.parse(o));var s=Ud(e);n==null&&(a.status=s?"show":"hide");var l=i.getExtent().slice();l[0]>l[1]&&l.reverse(),(o==null||o>l[1])&&(o=l[1]),o3?1.4:o>1?1.2:1.1,f=n>0?u:1/u;Gd(this,"zoom","zoomOnMouseWheel",e,{scale:f,originX:s,originY:l,isAvailableBehavior:null})}if(a){var h=Math.abs(n),p=(n>0?1:-1)*(h>3?.4:h>1?.15:.05);Gd(this,"scrollMove","moveOnMouseWheel",e,{scrollDelta:p,originX:s,originY:l,isAvailableBehavior:null})}}},t.prototype._pinchHandler=function(e){if(!Hd(this._zr,"globalPan")){var i=e.pinchScale>1?1.1:1/1.1;Gd(this,"zoom",null,e,{scale:i,originX:e.pinchX,originY:e.pinchY,isAvailableBehavior:null})}},t})(Wt);function Gd(r,t,e,i,a){r.pointerChecker&&r.pointerChecker(i,a.originX,a.originY)&&(Ce(i.event),Lb(r,t,e,i,a))}function Lb(r,t,e,i,a){a.isAvailableBehavior=H(th,null,e,i),r.trigger(t,a)}function th(r,t,e){var i=e[r];return!r||i&&(!U(i)||t.event[i+"Key"])}var Ib=lR;var al=b,uR=F,ih=-1,Xd=(function(){function r(t){var e=t.mappingMethod,i=t.type,a=this.option=Y(t);this.type=i,this.mappingMethod=e,this._normalizeData=cR[e];var n=r.visualHandlers[i];this.applyVisual=n.applyVisual,this.getColorMapper=n.getColorMapper,this._normalizedToVisual=n._normalizedToVisual[e],e==="piecewise"?(Wd(a),fR(a)):e==="category"?a.categories?hR(a):Wd(a,!0):(Ft(e!=="linear"||a.dataExtent),Wd(a))}return r.prototype.mapValueToVisual=function(t){var e=this._normalizeData(t);return this._normalizedToVisual(e,t)},r.prototype.getNormalizer=function(){return H(this._normalizeData,this)},r.listVisualTypes=function(){return lt(r.visualHandlers)},r.isValidType=function(t){return r.visualHandlers.hasOwnProperty(t)},r.eachVisual=function(t,e,i){F(t)?b(t,e,i):e.call(i,t)},r.mapVisual=function(t,e,i){var a,n=O(t)?[]:F(t)?{}:(a=!0,null);return r.eachVisual(t,function(o,s){var l=e.call(i,o,s);a?n=l:n[s]=l}),n},r.retrieveVisuals=function(t){var e={},i;return t&&al(r.visualHandlers,function(a,n){t.hasOwnProperty(n)&&(e[n]=t[n],i=!0)}),i?e:null},r.prepareVisualTypes=function(t){if(O(t))t=t.slice();else if(uR(t)){var e=[];al(t,function(i,a){e.push(a)}),t=e}else return[];return t.sort(function(i,a){return a==="color"&&i!=="color"&&i.indexOf("color")===0?1:-1}),t},r.dependsOn=function(t,e){return e==="color"?!!(t&&t.indexOf(e)===0):t===e},r.findPieceIndex=function(t,e,i){for(var a,n=1/0,o=0,s=e.length;o=0;n--)i[n]==null&&(delete e[t[n]],t.pop())}function Wd(r,t){var e=r.visual,i=[];F(e)?al(e,function(n){i.push(n)}):e!=null&&i.push(e);var a={color:1,symbol:1};!t&&i.length===1&&!a.hasOwnProperty(r.type)&&(i[1]=i[0]),Rb(r,i)}function eh(r){return{applyVisual:function(t,e,i){var a=this.mapValueToVisual(t);i("color",r(e("color"),a))},_normalizedToVisual:Yd([0,1])}}function Pb(r){var t=this.option.visual;return t[Math.round(gt(r,[0,1],[0,t.length-1],!0))]||{}}function rl(r){return function(t,e,i){i(r,this.mapValueToVisual(t))}}function il(r){var t=this.option.visual;return t[this.option.loop&&r!==ih?r%t.length:r]}function sn(){return this.option.visual[0]}function Yd(r){return{linear:function(t){return gt(t,r,this.option.visual,!0)},category:il,piecewise:function(t,e){var i=Zd.call(this,e);return i==null&&(i=gt(t,r,this.option.visual,!0)),i},fixed:sn}}function Zd(r){var t=this.option,e=t.pieceList;if(t.hasSpecialVisual){var i=Xd.findPieceIndex(r,e),a=e[i];if(a&&a.visual)return a.visual[this.type]}}function Rb(r,t){return r.visual=t,r.type==="color"&&(r.parsedVisual=k(t,function(e){var i=re(e);return i||[0,0,0,1]})),t}var cR={linear:function(r){return gt(r,this.option.dataExtent,[0,1],!0)},piecewise:function(r){var t=this.option.pieceList,e=Xd.findPieceIndex(r,t,!0);if(e!=null)return gt(e,[0,t.length-1],[0,1],!0)},category:function(r){var t=this.option.categories?this.option.categoryMap[r]:r;return t??ih},fixed:Dt};function rh(r,t,e){return r?t<=e:tn&&(t[1-i]=t[i]+h.sign*n),t}function qd(r,t){var e=r[t]-r[1-t];return{span:Math.abs(e),sign:e>0?-1:e<0?1:t?-1:1}}function po(r,t){return Math.min(t[1]!=null?t[1]:1/0,Math.max(t[0]!=null?t[0]:-1/0,r))}var pR=256,vR=(function(){function r(){this.blurSize=30,this.pointSize=20,this.maxOpacity=1,this.minOpacity=0,this._gradientPixels={inRange:null,outOfRange:null};var t=$t.createCanvas();this.canvas=t}return r.prototype.update=function(t,e,i,a,n,o){var s=this._getBrush(),l=this._getGradient(n,"inRange"),u=this._getGradient(n,"outOfRange"),f=this.pointSize+this.blurSize,h=this.canvas,p=h.getContext("2d"),c=t.length;h.width=e,h.height=i;for(var v=0;v0){var E=o(_)?l:u;_>0&&(_=_*A+M),w[S++]=E[C],w[S++]=E[C+1],w[S++]=E[C+2],w[S++]=E[C+3]*_*256}else S+=4}return p.putImageData(x,0,0),h},r.prototype._getBrush=function(){var t=this._brushCanvas||(this._brushCanvas=$t.createCanvas()),e=this.pointSize+this.blurSize,i=e*2;t.width=i,t.height=i;var a=t.getContext("2d");return a.clearRect(0,0,i,i),a.shadowOffsetX=i,a.shadowBlur=this.blurSize,a.shadowColor="#000",a.beginPath(),a.arc(-e,e,this.pointSize,0,Math.PI*2,!0),a.closePath(),a.fill(),t},r.prototype._getGradient=function(t,e){for(var i=this._gradientPixels,a=i[e]||(i[e]=new Uint8ClampedArray(256*4)),n=[0,0,0,0],o=0,s=0;s<256;s++)t[e](s/255,!0,n),a[o++]=n[0],a[o++]=n[1],a[o++]=n[2],a[o++]=n[3];return a},r})(),Ob=vR;function dR(r,t,e){var i=r[1]-r[0];t=k(t,function(o){return{interval:[(o.interval[0]-r[0])/i,(o.interval[1]-r[0])/i]}});var a=t.length,n=0;return function(o){var s;for(s=n;s=0;s--){var l=t[s].interval;if(l[0]<=o&&o<=l[1]){n=s;break}}return s>=0&&s=t[0]&&i<=t[1]}}function Nb(r){var t=r.dimensions;return t[0]==="lng"&&t[1]==="lat"}var gR=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){var n;i.eachComponent("visualMap",function(s){s.eachTargetSeries(function(l){l===e&&(n=s)})}),this._progressiveEls=null,this.group.removeAll();var o=e.coordinateSystem;o.type==="cartesian2d"||o.type==="calendar"?this._renderOnCartesianAndCalendar(e,a,0,e.getData().count()):Nb(o)&&this._renderOnGeo(o,e,n,a)},t.prototype.incrementalPrepareRender=function(e,i,a){this.group.removeAll()},t.prototype.incrementalRender=function(e,i,a,n){var o=i.coordinateSystem;o&&(Nb(o)?this.render(i,a,n):(this._progressiveEls=[],this._renderOnCartesianAndCalendar(i,n,e.start,e.end,!0)))},t.prototype.eachRendered=function(e){ni(this._progressiveEls||this.group,e)},t.prototype._renderOnCartesianAndCalendar=function(e,i,a,n,o){var s=e.coordinateSystem,l=an(s,"cartesian2d"),u,f,h,p;if(l){var c=s.getAxis("x"),v=s.getAxis("y");u=c.getBandWidth()+.5,f=v.getBandWidth()+.5,h=c.scale.getExtent(),p=v.scale.getExtent()}for(var m=this.group,d=e.getData(),g=e.getModel(["emphasis","itemStyle"]).getItemStyle(),y=e.getModel(["blur","itemStyle"]).getItemStyle(),_=e.getModel(["select","itemStyle"]).getItemStyle(),x=e.get(["itemStyle","borderRadius"]),w=Fe(e),S=e.getModel("emphasis"),T=S.get("focus"),M=S.get("blurScope"),D=S.get("disabled"),A=l?[d.mapDimension("x"),d.mapDimension("y"),d.mapDimension("value")]:[d.mapDimension("time"),d.mapDimension("value")],C=a;Ch[1]||Rp[1])continue;var z=s.dataToPoint([P,R]);E=new st({shape:{x:z[0]-u/2,y:z[1]-f/2,width:u,height:f},style:L})}else{if(isNaN(d.get(A[1],C)))continue;E=new st({z2:1,shape:s.dataToRect([d.get(A[0],C)]).contentShape,style:L})}if(d.hasItemOption){var Z=d.getItemModel(C),V=Z.getModel("emphasis");g=V.getModel("itemStyle").getItemStyle(),y=Z.getModel(["blur","itemStyle"]).getItemStyle(),_=Z.getModel(["select","itemStyle"]).getItemStyle(),x=Z.get(["itemStyle","borderRadius"]),T=V.get("focus"),M=V.get("blurScope"),D=V.get("disabled"),w=Fe(Z)}E.shape.r=x;var B=e.getRawValue(C),X="-";B&&B[2]!=null&&(X=B[2]+""),ar(E,w,{labelFetcher:e,labelDataIndex:C,defaultOpacity:L.opacity,defaultText:X}),E.ensureState("emphasis").style=g,E.ensureState("blur").style=y,E.ensureState("select").style=_,yr(E,T,M,D),E.incremental=o,o&&(E.states.emphasis.hoverLayer=!0),m.add(E),d.setItemGraphicEl(C,E),this._progressiveEls&&this._progressiveEls.push(E)}},t.prototype._renderOnGeo=function(e,i,a,n){var o=a.targetVisuals.inRange,s=a.targetVisuals.outOfRange,l=i.getData(),u=this._hmLayer||this._hmLayer||new Ob;u.blurSize=i.get("blurSize"),u.pointSize=i.get("pointSize"),u.minOpacity=i.get("minOpacity"),u.maxOpacity=i.get("maxOpacity");var f=e.getViewRect().clone(),h=e.getRoamTransform();f.applyTransform(h);var p=Math.max(f.x,0),c=Math.max(f.y,0),v=Math.min(f.width+f.x,n.getWidth()),m=Math.min(f.height+f.y,n.getHeight()),d=v-p,g=m-c,y=[l.mapDimension("lng"),l.mapDimension("lat"),l.mapDimension("value")],_=l.mapArray(y,function(T,M,D){var A=e.dataToPoint([T,M]);return A[0]-=p,A[1]-=c,A.push(D),A}),x=a.getExtent(),w=a.type==="visualMap.continuous"?mR(x,a.option.range):dR(x,a.getPieceList(),a.option.selected);u.update(_,d,g,o.color.getNormalizer(),{inRange:o.color.getColorMapper(),outOfRange:s.color.getColorMapper()},w);var S=new ne({style:{width:d,height:g,x:p,y:c,image:u.canvas},silent:!0});this.group.add(S)},t.type="heatmap",t})(Ut),zb=gR;var yR=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(e,i){return Fr(null,this,{generateCoord:"value"})},t.prototype.preventIncremental=function(){var e=Ri.get(this.get("coordinateSystem"));if(e&&e.dimensions)return e.dimensions[0]==="lng"&&e.dimensions[1]==="lat"},t.type="series.heatmap",t.dependencies=["grid","geo","calendar"],t.defaultOption={coordinateSystem:"cartesian2d",z:2,geoIndex:0,blurSize:30,pointSize:20,maxOpacity:1,minOpacity:0,select:{itemStyle:{borderColor:"#212121"}}},t})(qt),kb=yR;function Kd(r){r.registerChartView(zb),r.registerSeriesModel(kb)}var ln=ht(),Ub=Y,jd=H,_R=(function(){function r(){this._dragging=!1,this.animationThreshold=15}return r.prototype.render=function(t,e,i,a){var n=e.get("value"),o=e.get("status");if(this._axisModel=t,this._axisPointerModel=e,this._api=i,!(!a&&this._lastValue===n&&this._lastStatus===o)){this._lastValue=n,this._lastStatus=o;var s=this._group,l=this._handle;if(!o||o==="hide"){s&&s.hide(),l&&l.hide();return}s&&s.show(),l&&l.show();var u={};this.makeElOption(u,n,t,e,i);var f=u.graphicKey;f!==this._lastGraphicKey&&this.clear(i),this._lastGraphicKey=f;var h=this._moveAnimation=this.determineAnimation(t,e);if(!s)s=this._group=new ft,this.createPointerEl(s,u,t,e),this.createLabelEl(s,u,t,e),i.getZr().add(s);else{var p=ct(Vb,e,h);this.updatePointerEl(s,u,p),this.updateLabelEl(s,u,p,e)}Fb(s,e,!0),this._renderHandle(n)}},r.prototype.remove=function(t){this.clear(t)},r.prototype.dispose=function(t){this.clear(t)},r.prototype.determineAnimation=function(t,e){var i=e.get("animation"),a=t.axis,n=a.type==="category",o=e.get("snap");if(!o&&!n)return!1;if(i==="auto"||i==null){var s=this.animationThreshold;if(n&&a.getBandWidth()>s)return!0;if(o){var l=$f(t).seriesDataCount,u=a.getExtent();return Math.abs(u[0]-u[1])/l>s}return!1}return i===!0},r.prototype.makeElOption=function(t,e,i,a,n){},r.prototype.createPointerEl=function(t,e,i,a){var n=e.pointer;if(n){var o=ln(t).pointerEl=new It[n.type](Ub(e.pointer));t.add(o)}},r.prototype.createLabelEl=function(t,e,i,a){if(e.label){var n=ln(t).labelEl=new vt(Ub(e.label));t.add(n),Bb(n,a)}},r.prototype.updatePointerEl=function(t,e,i){var a=ln(t).pointerEl;a&&e.pointer&&(a.setStyle(e.pointer.style),i(a,{shape:e.pointer.shape}))},r.prototype.updateLabelEl=function(t,e,i,a){var n=ln(t).labelEl;n&&(n.setStyle(e.label.style),i(n,{x:e.label.x,y:e.label.y}),Bb(n,a))},r.prototype._renderHandle=function(t){if(!(this._dragging||!this.updateHandleTransform)){var e=this._axisPointerModel,i=this._api.getZr(),a=this._handle,n=e.getModel("handle"),o=e.get("status");if(!n.get("show")||!o||o==="hide"){a&&i.remove(a),this._handle=null;return}var s;this._handle||(s=!0,a=this._handle=Ba(n.get("icon"),{cursor:"move",draggable:!0,onmousemove:function(u){Ce(u.event)},onmousedown:jd(this._onHandleDragMove,this,0,0),drift:jd(this._onHandleDragMove,this),ondragend:jd(this._onHandleDragEnd,this)}),i.add(a)),Fb(a,e,!1),a.setStyle(n.getItemStyle(null,["color","borderColor","borderWidth","opacity","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY"]));var l=n.get("size");O(l)||(l=[l,l]),a.scaleX=l[0]/2,a.scaleY=l[1]/2,zi(this,"_doDispatchAxisPointer",n.get("throttle")||0,"fixRate"),this._moveHandleToValue(t,s)}},r.prototype._moveHandleToValue=function(t,e){Vb(this._axisPointerModel,!e&&this._moveAnimation,this._handle,Qd(this.getHandleTransform(t,this._axisModel,this._axisPointerModel)))},r.prototype._onHandleDragMove=function(t,e){var i=this._handle;if(i){this._dragging=!0;var a=this.updateHandleTransform(Qd(i),[t,e],this._axisModel,this._axisPointerModel);this._payloadInfo=a,i.stopAnimation(),i.attr(Qd(a)),ln(i).lastProp=null,this._doDispatchAxisPointer()}},r.prototype._doDispatchAxisPointer=function(){var t=this._handle;if(t){var e=this._payloadInfo,i=this._axisModel;this._api.dispatchAction({type:"updateAxisPointer",x:e.cursorPoint[0],y:e.cursorPoint[1],tooltipOption:e.tooltipOption,axesInfo:[{axisDim:i.axis.dim,axisIndex:i.componentIndex}]})}},r.prototype._onHandleDragEnd=function(){this._dragging=!1;var t=this._handle;if(t){var e=this._axisPointerModel.get("value");this._moveHandleToValue(e),this._api.dispatchAction({type:"hideTip"})}},r.prototype.clear=function(t){this._lastValue=null,this._lastStatus=null;var e=t.getZr(),i=this._group,a=this._handle;e&&i&&(this._lastGraphicKey=null,i&&e.remove(i),a&&e.remove(a),this._group=null,this._handle=null,this._payloadInfo=null),Qa(this,"_doDispatchAxisPointer")},r.prototype.doClear=function(){},r.prototype.buildLabel=function(t,e,i){return i=i||0,{x:t[i],y:t[1-i],width:e[i],height:e[1-i]}},r})();function Vb(r,t,e,i){Hb(ln(e).lastProp,i)||(ln(e).lastProp=i,t?Ct(e,i,r):(e.stopAnimation(),e.attr(i)))}function Hb(r,t){if(F(r)&&F(t)){var e=!0;return b(t,function(i,a){e=e&&Hb(r[a],i)}),!!e}else return r===t}function Bb(r,t){r[t.get(["label","show"])?"show":"hide"]()}function Qd(r){return{x:r.x||0,y:r.y||0,rotation:r.rotation||0}}function Fb(r,t,e){var i=t.get("z"),a=t.get("zlevel");r&&r.traverse(function(n){n.type!=="group"&&(i!=null&&(n.z=i),a!=null&&(n.zlevel=a),n.silent=e)})}var Gb=_R;function Wb(r){var t=r.get("type"),e=r.getModel(t+"Style"),i;return t==="line"?(i=e.getLineStyle(),i.fill=null):t==="shadow"&&(i=e.getAreaStyle(),i.stroke=null),i}function xR(r,t,e,i,a){var n=e.get("value"),o=$d(n,t.axis,t.ecModel,e.get("seriesDataIndices"),{precision:e.get(["label","precision"]),formatter:e.get(["label","formatter"])}),s=e.getModel("label"),l=or(s.get("padding")||0),u=s.getFont(),f=Mn(o,u),h=a.position,p=f.width+l[1]+l[3],c=f.height+l[0]+l[2],v=a.align;v==="right"&&(h[0]-=p),v==="center"&&(h[0]-=p/2);var m=a.verticalAlign;m==="bottom"&&(h[1]-=c),m==="middle"&&(h[1]-=c/2),SR(h,p,c,i);var d=s.get("backgroundColor");(!d||d==="auto")&&(d=t.get(["axisLine","lineStyle","color"])),r.label={x:h[0],y:h[1],style:Zt(s,{text:o,font:u,fill:s.getTextColor(),padding:l,backgroundColor:d}),z2:10}}function SR(r,t,e,i){var a=i.getWidth(),n=i.getHeight();r[0]=Math.min(r[0]+t,a)-t,r[1]=Math.min(r[1]+e,n)-e,r[0]=Math.max(r[0],0),r[1]=Math.max(r[1],0)}function $d(r,t,e,i,a){r=t.scale.parse(r);var n=t.scale.getLabel({value:r},{precision:a.precision}),o=a.formatter;if(o){var s={value:Qs(t,{value:r}),axisDimension:t.dim,axisIndex:t.index,seriesData:[]};b(i,function(l){var u=e.getSeriesByIndex(l.seriesIndex),f=l.dataIndexInside,h=u&&u.getDataParams(f);h&&s.seriesData.push(h)}),U(o)?n=o.replace("{value}",n):G(o)&&(n=o(s))}return n}function Jd(r,t,e){var i=dr();return ea(i,i,e.rotation),yn(i,i,e.position),Sr([r.dataToCoord(t),(e.labelOffset||0)+(e.labelDirection||1)*(e.labelMargin||0)],i)}function Yb(r,t,e,i,a,n){var o=Qf.innerTextLayout(e.rotation,0,e.labelDirection);e.labelMargin=a.get(["label","margin"]),xR(t,i,a,n,{position:Jd(i.axis,r,e),align:o.textAlign,verticalAlign:o.textVerticalAlign})}function Zb(r,t,e){return e=e||0,{x1:r[e],y1:r[1-e],x2:t[e],y2:t[1-e]}}function Xb(r,t,e){return e=e||0,{x:r[e],y:r[1-e],width:t[e],height:t[1-e]}}var bR=(function(r){I(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.makeElOption=function(e,i,a,n,o){var s=a.axis,l=s.grid,u=n.get("type"),f=Kb(l,s).getOtherAxis(s).getGlobalExtent(),h=s.toGlobalCoord(s.dataToCoord(i,!0));if(u&&u!=="none"){var p=Wb(n),c=wR[u](s,h,f);c.style=p,e.graphicKey=c.type,e.pointer=c}var v=el(l.model,a);Yb(i,e,v,a,n,o)},t.prototype.getHandleTransform=function(e,i,a){var n=el(i.axis.grid.model,i,{labelInside:!1});n.labelMargin=a.get(["handle","margin"]);var o=Jd(i.axis,e,n);return{x:o[0],y:o[1],rotation:n.rotation+(n.labelDirection<0?Math.PI:0)}},t.prototype.updateHandleTransform=function(e,i,a,n){var o=a.axis,s=o.grid,l=o.getGlobalExtent(!0),u=Kb(s,o).getOtherAxis(o).getGlobalExtent(),f=o.dim==="x"?0:1,h=[e.x,e.y];h[f]+=i[f],h[f]=Math.min(l[1],h[f]),h[f]=Math.max(l[0],h[f]);var p=(u[1]+u[0])/2,c=[p,p];c[f]=h[f];var v=[{verticalAlign:"middle"},{align:"center"}];return{x:h[0],y:h[1],rotation:e.rotation,cursorPoint:c,tooltipOption:v[f]}},t})(Gb);function Kb(r,t){var e={};return e[t.dim+"AxisIndex"]=t.index,r.getCartesian(e)}var wR={line:function(r,t,e){var i=Zb([t,e[0]],[t,e[1]],jb(r));return{type:"Line",subPixelOptimize:!0,shape:i}},shadow:function(r,t,e){var i=Math.max(1,r.getBandWidth()),a=e[1]-e[0];return{type:"Rect",shape:Xb([t-i/2,e[0]],[i,a],jb(r))}}};function jb(r){return r.dim==="x"?0:1}var Qb=bR;var TR=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="axisPointer",t.defaultOption={show:"auto",z:50,type:"line",snap:!1,triggerTooltip:!0,triggerEmphasis:!0,value:null,status:null,link:[],animation:null,animationDurationUpdate:200,lineStyle:{color:"#B9BEC9",width:1,type:"dashed"},shadowStyle:{color:"rgba(210,219,238,0.2)"},label:{show:!0,formatter:null,precision:"auto",margin:3,color:"#fff",padding:[5,7,5,7],backgroundColor:"auto",borderColor:null,borderWidth:0,borderRadius:3},handle:{show:!1,icon:"M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z",size:45,margin:50,color:"#333",shadowBlur:3,shadowColor:"#aaa",shadowOffsetX:0,shadowOffsetY:2,throttle:40}},t})(pt),$b=TR;var vi=ht(),MR=b;function ah(r,t,e){if(!j.node){var i=t.getZr();vi(i).records||(vi(i).records={}),CR(i,t);var a=vi(i).records[r]||(vi(i).records[r]={});a.handler=e}}function CR(r,t){if(vi(r).initialized)return;vi(r).initialized=!0,e("click",ct(Jb,"click")),e("mousemove",ct(Jb,"mousemove")),e("globalout",AR);function e(i,a){r.on(i,function(n){var o=ER(t);MR(vi(r).records,function(s){s&&a(s,n,o.dispatchAction)}),DR(o.pendings,t)})}}function DR(r,t){var e=r.showTip.length,i=r.hideTip.length,a;e?a=r.showTip[e-1]:i&&(a=r.hideTip[i-1]),a&&(a.dispatchAction=null,t.dispatchAction(a))}function AR(r,t,e){r.handler("leave",null,e)}function Jb(r,t,e,i){t.handler(r,e,i)}function ER(r){var t={showTip:[],hideTip:[]},e=function(i){var a=t[i.type];a?a.push(i):(i.dispatchAction=e,r.dispatchAction(i))};return{dispatchAction:e,pendings:t}}function nl(r,t){if(!j.node){var e=t.getZr(),i=(vi(e).records||{})[r];i&&(vi(e).records[r]=null)}}var LR=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){var n=i.getComponent("tooltip"),o=e.get("triggerOn")||n&&n.get("triggerOn")||"mousemove|click";ah("axisPointer",a,function(s,l,u){o!=="none"&&(s==="leave"||o.indexOf(s)>=0)&&u({type:"updateAxisPointer",currTrigger:s,x:l&&l.offsetX,y:l&&l.offsetY})})},t.prototype.remove=function(e,i){nl("axisPointer",i)},t.prototype.dispose=function(e,i){nl("axisPointer",i)},t.type="axisPointer",t})(Lt),ew=LR;function ol(r,t){var e=[],i=r.seriesIndex,a;if(i==null||!(a=t.getSeriesByIndex(i)))return{point:[]};var n=a.getData(),o=Je(n,r);if(o==null||o<0||O(o))return{point:[]};var s=n.getItemGraphicEl(o),l=a.coordinateSystem;if(a.getTooltipPosition)e=a.getTooltipPosition(o)||[];else if(l&&l.dataToPoint)if(r.isStacked){var u=l.getBaseAxis(),f=l.getOtherAxis(u),h=f.dim,p=u.dim,c=h==="x"||h==="radius"?1:0,v=n.mapDimension(p),m=[];m[c]=n.get(v,o),m[1-c]=n.get(n.getCalculationInfo("stackResultDimension"),o),e=l.dataToPoint(m)||[]}else e=l.dataToPoint(n.getValues(k(l.dimensions,function(g){return n.mapDimension(g)}),o))||[];else if(s){var d=s.getBoundingRect().clone();d.applyTransform(s.transform),e=[d.x+d.width/2,d.y+d.height/2]}return{point:e,el:s}}var rw=ht();function tm(r,t,e){var i=r.currTrigger,a=[r.x,r.y],n=r,o=r.dispatchAction||H(e.dispatchAction,e),s=t.getComponent("axisPointer").coordSysAxesInfo;if(s){nh(a)&&(a=ol({seriesIndex:n.seriesIndex,dataIndex:n.dataIndex},t).point);var l=nh(a),u=n.axesInfo,f=s.axesInfo,h=i==="leave"||nh(a),p={},c={},v={list:[],map:{}},m={showPointer:ct(PR,c),showTooltip:ct(RR,v)};b(s.coordSysMap,function(g,y){var _=l||g.containPoint(a);b(s.coordSysAxesInfo[y],function(x,w){var S=x.axis,T=kR(u,x);if(!h&&_&&(!u||T)){var M=T&&T.value;M==null&&!l&&(M=S.pointToData(a)),M!=null&&iw(x,M,m,!1,p)}})});var d={};return b(f,function(g,y){var _=g.linkGroup;_&&!c[y]&&b(_.axesInfo,function(x,w){var S=c[w];if(x!==g&&S){var T=S.value;_.mapper&&(T=g.axis.scale.parse(_.mapper(T,aw(x),aw(g)))),d[g.key]=T}})}),b(d,function(g,y){iw(f[y],g,m,!0,p)}),OR(c,f,p),NR(v,a,r,o),zR(f,o,e),p}}function iw(r,t,e,i,a){var n=r.axis;if(!(n.scale.isBlank()||!n.containData(t))){if(!r.involveSeries){e.showPointer(r,t);return}var o=IR(t,r),s=o.payloadBatch,l=o.snapToValue;s[0]&&a.seriesIndex==null&&N(a,s[0]),!i&&r.snap&&n.containData(l)&&l!=null&&(t=l),e.showPointer(r,t,s),e.showTooltip(r,o,l)}}function IR(r,t){var e=t.axis,i=e.dim,a=r,n=[],o=Number.MAX_VALUE,s=-1;return b(t.seriesModels,function(l,u){var f=l.getData().mapDimensionsAll(i),h,p;if(l.getAxisTooltipData){var c=l.getAxisTooltipData(f,r,e);p=c.dataIndices,h=c.nestestValue}else{if(p=l.getData().indicesOfNearest(f[0],r,e.type==="category"?.5:null),!p.length)return;h=l.getData().get(f[0],p[0])}if(!(h==null||!isFinite(h))){var v=r-h,m=Math.abs(v);m<=o&&((m=0&&s<0)&&(o=m,s=v,a=h,n.length=0),b(p,function(d){n.push({seriesIndex:l.seriesIndex,dataIndexInside:d,dataIndex:l.getData().getRawIndex(d)})}))}}),{payloadBatch:n,snapToValue:a}}function PR(r,t,e,i){r[t.key]={value:e,payloadBatch:i}}function RR(r,t,e,i){var a=e.payloadBatch,n=t.axis,o=n.model,s=t.axisPointerModel;if(!(!t.triggerTooltip||!a.length)){var l=t.coordSys.model,u=co(l),f=r.map[u];f||(f=r.map[u]={coordSysId:l.id,coordSysIndex:l.componentIndex,coordSysType:l.type,coordSysMainType:l.mainType,dataByAxis:[]},r.list.push(f)),f.dataByAxis.push({axisDim:n.dim,axisIndex:o.componentIndex,axisType:o.type,axisId:o.id,value:i,valueLabelOpt:{precision:s.get(["label","precision"]),formatter:s.get(["label","formatter"])},seriesDataIndices:a.slice()})}}function OR(r,t,e){var i=e.axesInfo=[];b(t,function(a,n){var o=a.axisPointerModel.option,s=r[n];s?(!a.useHandle&&(o.status="show"),o.value=s.value,o.seriesDataIndices=(s.payloadBatch||[]).slice()):!a.useHandle&&(o.status="hide"),o.status==="show"&&i.push({axisDim:a.axis.dim,axisIndex:a.axis.model.componentIndex,value:o.value})})}function NR(r,t,e,i){if(nh(t)||!r.list.length){i({type:"hideTip"});return}var a=((r.list[0].dataByAxis[0]||{}).seriesDataIndices||[])[0]||{};i({type:"showTip",escapeConnect:!0,x:t[0],y:t[1],tooltipOption:e.tooltipOption,position:e.position,dataIndexInside:a.dataIndexInside,dataIndex:a.dataIndex,seriesIndex:a.seriesIndex,dataByCoordSys:r.list})}function zR(r,t,e){var i=e.getZr(),a="axisPointerLastHighlights",n=rw(i)[a]||{},o=rw(i)[a]={};b(r,function(u,f){var h=u.axisPointerModel.option;h.status==="show"&&u.triggerEmphasis&&b(h.seriesDataIndices,function(p){var c=p.seriesIndex+" | "+p.dataIndex;o[c]=p})});var s=[],l=[];b(n,function(u,f){!o[f]&&l.push(u)}),b(o,function(u,f){!n[f]&&s.push(u)}),l.length&&e.dispatchAction({type:"downplay",escapeConnect:!0,notBlur:!0,batch:l}),s.length&&e.dispatchAction({type:"highlight",escapeConnect:!0,notBlur:!0,batch:s})}function kR(r,t){for(var e=0;e<(r||[]).length;e++){var i=r[e];if(t.axis.dim===i.axisDim&&t.axis.model.componentIndex===i.axisIndex)return i}}function aw(r){var t=r.axis.model,e={},i=e.axisDim=r.axis.dim;return e.axisIndex=e[i+"AxisIndex"]=t.componentIndex,e.axisName=e[i+"AxisName"]=t.name,e.axisId=e[i+"AxisId"]=t.id,e}function nh(r){return!r||r[0]==null||isNaN(r[0])||r[1]==null||isNaN(r[1])}function un(r){Jf.registerAxisPointerClass("CartesianAxisPointer",Qb),r.registerComponentModel($b),r.registerComponentView(ew),r.registerPreprocessor(function(t){if(t){(!t.axisPointer||t.axisPointer.length===0)&&(t.axisPointer={});var e=t.axisPointer.link;e&&!O(e)&&(t.axisPointer.link=[e])}}),r.registerProcessor(r.PRIORITY.PROCESSOR.STATISTIC,function(t,e){t.getComponent("axisPointer").coordSysAxesInfo=_b(t,e)}),r.registerAction({type:"updateAxisPointer",event:"updateAxisPointer",update:":updateAxisPointer"},tm)}function em(r){Bt(Ab),Bt(un)}var rm=["x","y","radius","angle","single"],UR=["cartesian2d","polar","singleAxis"];function nw(r){var t=r.get("coordinateSystem");return it(UR,t)>=0}function cr(r){return r+"Axis"}function ow(r,t){var e=W(),i=[],a=W();r.eachComponent({mainType:"dataZoom",query:t},function(f){a.get(f.uid)||s(f)});var n;do n=!1,r.eachComponent("dataZoom",o);while(n);function o(f){!a.get(f.uid)&&l(f)&&(s(f),n=!0)}function s(f){a.set(f.uid,!0),i.push(f),u(f)}function l(f){var h=!1;return f.eachTargetAxis(function(p,c){var v=e.get(p);v&&v[c]&&(h=!0)}),h}function u(f){f.eachTargetAxis(function(h,p){(e.get(h)||e.set(h,[]))[p]=!0})}return i}function oh(r){var t=r.ecModel,e={infoList:[],infoMap:W()};return r.eachTargetAxis(function(i,a){var n=t.getComponent(cr(i),a);if(n){var o=n.getCoordSysModel();if(o){var s=o.uid,l=e.infoMap.get(s);l||(l={model:o,axisModels:[]},e.infoList.push(l),e.infoMap.set(s,l)),l.axisModels.push(n)}}}),e}var im=(function(){function r(){this.indexList=[],this.indexMap=[]}return r.prototype.add=function(t){this.indexMap[t]||(this.indexList.push(t),this.indexMap[t]=!0)},r})(),VR=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e._autoThrottle=!0,e._noTarget=!0,e._rangePropMode=["percent","percent"],e}return t.prototype.init=function(e,i,a){var n=sw(e);this.settledOption=n,this.mergeDefaultAndTheme(e,a),this._doInit(n)},t.prototype.mergeOption=function(e){var i=sw(e);tt(this.option,e,!0),tt(this.settledOption,i,!0),this._doInit(i)},t.prototype._doInit=function(e){var i=this.option;this._setDefaultThrottle(e),this._updateRangeUse(e);var a=this.settledOption;b([["start","startValue"],["end","endValue"]],function(n,o){this._rangePropMode[o]==="value"&&(i[n[0]]=a[n[0]]=null)},this),this._resetTarget()},t.prototype._resetTarget=function(){var e=this.get("orient",!0),i=this._targetAxisInfoMap=W(),a=this._fillSpecifiedTargetAxis(i);a?this._orient=e||this._makeAutoOrientByTargetAxis():(this._orient=e||"horizontal",this._fillAutoTargetAxisByOrient(i,this._orient)),this._noTarget=!0,i.each(function(n){n.indexList.length&&(this._noTarget=!1)},this)},t.prototype._fillSpecifiedTargetAxis=function(e){var i=!1;return b(rm,function(a){var n=this.getReferringComponents(cr(a),Kg);if(n.specified){i=!0;var o=new im;b(n.models,function(s){o.add(s.componentIndex)}),e.set(a,o)}},this),i},t.prototype._fillAutoTargetAxisByOrient=function(e,i){var a=this.ecModel,n=!0;if(n){var o=i==="vertical"?"y":"x",s=a.findComponents({mainType:o+"Axis"});l(s,o)}if(n){var s=a.findComponents({mainType:"singleAxis",filter:function(f){return f.get("orient",!0)===i}});l(s,"single")}function l(u,f){var h=u[0];if(h){var p=new im;if(p.add(h.componentIndex),e.set(f,p),n=!1,f==="x"||f==="y"){var c=h.getReferringComponents("grid",zt).models[0];c&&b(u,function(v){h.componentIndex!==v.componentIndex&&c===v.getReferringComponents("grid",zt).models[0]&&p.add(v.componentIndex)})}}}n&&b(rm,function(u){if(n){var f=a.findComponents({mainType:cr(u),filter:function(p){return p.get("type",!0)==="category"}});if(f[0]){var h=new im;h.add(f[0].componentIndex),e.set(u,h),n=!1}}},this)},t.prototype._makeAutoOrientByTargetAxis=function(){var e;return this.eachTargetAxis(function(i){!e&&(e=i)},this),e==="y"?"vertical":"horizontal"},t.prototype._setDefaultThrottle=function(e){if(e.hasOwnProperty("throttle")&&(this._autoThrottle=!1),this._autoThrottle){var i=this.ecModel.option;this.option.throttle=i.animation&&i.animationDurationUpdate>0?100:20}},t.prototype._updateRangeUse=function(e){var i=this._rangePropMode,a=this.get("rangeMode");b([["start","startValue"],["end","endValue"]],function(n,o){var s=e[n[0]]!=null,l=e[n[1]]!=null;s&&!l?i[o]="percent":!s&&l?i[o]="value":a?i[o]=a[o]:s&&(i[o]="percent")})},t.prototype.noTarget=function(){return this._noTarget},t.prototype.getFirstTargetAxisModel=function(){var e;return this.eachTargetAxis(function(i,a){e==null&&(e=this.ecModel.getComponent(cr(i),a))},this),e},t.prototype.eachTargetAxis=function(e,i){this._targetAxisInfoMap.each(function(a,n){b(a.indexList,function(o){e.call(i,n,o)})})},t.prototype.getAxisProxy=function(e,i){var a=this.getAxisModel(e,i);if(a)return a.__dzAxisProxy},t.prototype.getAxisModel=function(e,i){var a=this._targetAxisInfoMap.get(e);if(a&&a.indexMap[i])return this.ecModel.getComponent(cr(e),i)},t.prototype.setRawRange=function(e){var i=this.option,a=this.settledOption;b([["start","startValue"],["end","endValue"]],function(n){(e[n[0]]!=null||e[n[1]]!=null)&&(i[n[0]]=a[n[0]]=e[n[0]],i[n[1]]=a[n[1]]=e[n[1]])},this),this._updateRangeUse(e)},t.prototype.setCalculatedRange=function(e){var i=this.option;b(["start","startValue","end","endValue"],function(a){i[a]=e[a]})},t.prototype.getPercentRange=function(){var e=this.findRepresentativeAxisProxy();if(e)return e.getDataPercentWindow()},t.prototype.getValueRange=function(e,i){if(e==null&&i==null){var a=this.findRepresentativeAxisProxy();if(a)return a.getDataValueWindow()}else return this.getAxisProxy(e,i).getDataValueWindow()},t.prototype.findRepresentativeAxisProxy=function(e){if(e)return e.__dzAxisProxy;for(var i,a=this._targetAxisInfoMap.keys(),n=0;no[1];if(_&&!x&&!w)return!0;_&&(d=!0),x&&(v=!0),w&&(m=!0)}return d&&v&&m})}else mo(f,function(c){if(n==="empty")l.setData(u=u.map(c,function(m){return s(m)?m:NaN}));else{var v={};v[c]=o,u.selectRange(v)}});mo(f,function(c){u.setApproximateExtent(o,c)})}});function s(l){return l>=o[0]&&l<=o[1]}},r.prototype._updateMinMaxSpan=function(){var t=this._minMaxSpan={},e=this._dataZoomModel,i=this._dataExtent;mo(["min","max"],function(a){var n=e.get(a+"Span"),o=e.get(a+"ValueSpan");o!=null&&(o=this.getAxisModel().axis.scale.parse(o)),o!=null?n=gt(i[0]+o,i,[0,100],!0):n!=null&&(o=gt(n,[0,100],i,!0)-i[0]),t[a+"Span"]=n,t[a+"ValueSpan"]=o},this)},r.prototype._setAxisModel=function(){var t=this.getAxisModel(),e=this._percentWindow,i=this._valueWindow;if(e){var a=An(i,[0,500]);a=Math.min(a,20);var n=t.axis.scale.rawExtentInfo;e[0]!==0&&n.setDeterminedMinMax("min",+i[0].toFixed(a)),e[1]!==100&&n.setDeterminedMinMax("max",+i[1].toFixed(a)),n.freeze()}},r})();function HR(r,t,e){var i=[1/0,-1/0];mo(e,function(o){WS(i,o.getData(),t)});var a=r.getAxisModel(),n=Pf(a.axis.scale,a,i).calculate();return[n.min,n.max]}var uw=FR;var GR={getTargetSeries:function(r){function t(a){r.eachComponent("dataZoom",function(n){n.eachTargetAxis(function(o,s){var l=r.getComponent(cr(o),s);a(o,s,l,n)})})}t(function(a,n,o,s){o.__dzAxisProxy=null});var e=[];t(function(a,n,o,s){o.__dzAxisProxy||(o.__dzAxisProxy=new uw(a,n,s,r),e.push(o.__dzAxisProxy))});var i=W();return b(e,function(a){b(a.getTargetSeriesModels(),function(n){i.set(n.uid,n)})}),i},overallReset:function(r,t){r.eachComponent("dataZoom",function(e){e.eachTargetAxis(function(i,a){e.getAxisProxy(i,a).reset(e)}),e.eachTargetAxis(function(i,a){e.getAxisProxy(i,a).filterData(e,t)})}),r.eachComponent("dataZoom",function(e){var i=e.findRepresentativeAxisProxy();if(i){var a=i.getDataPercentWindow(),n=i.getDataValueWindow();e.setCalculatedRange({start:a[0],end:a[1],startValue:n[0],endValue:n[1]})}})}},fw=GR;function am(r){r.registerAction("dataZoom",function(t,e){var i=ow(e,t);b(i,function(a){a.setRawRange({start:t.start,end:t.end,startValue:t.startValue,endValue:t.endValue})})})}var hw=!1;function sl(r){hw||(hw=!0,r.registerProcessor(r.PRIORITY.PROCESSOR.FILTER,fw),am(r),r.registerSubTypeDefaulter("dataZoom",function(){return"slider"}))}function cw(r,t){var e=or(t.get("padding")),i=t.getItemStyle(["color","opacity"]);return i.fill=t.get("backgroundColor"),r=new st({shape:{x:r.x-e[3],y:r.y-e[0],width:r.width+e[1]+e[3],height:r.height+e[0]+e[2],r:t.get("borderRadius")},style:i,silent:!0,z2:-1}),r}var WR=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="tooltip",t.dependencies=["axisPointer"],t.defaultOption={z:60,show:!0,showContent:!0,trigger:"item",triggerOn:"mousemove|click",alwaysShowContent:!1,displayMode:"single",renderMode:"auto",confine:null,showDelay:0,hideDelay:100,transitionDuration:.4,enterable:!1,backgroundColor:"#fff",shadowBlur:10,shadowColor:"rgba(0, 0, 0, .2)",shadowOffsetX:1,shadowOffsetY:2,borderRadius:4,borderWidth:1,padding:null,extraCssText:"",axisPointer:{type:"line",axis:"auto",animation:"auto",animationDurationUpdate:200,animationEasingUpdate:"exponentialOut",crossStyle:{color:"#999",width:1,type:"dashed",textStyle:{}}},textStyle:{color:"#666",fontSize:14}},t})(pt),pw=WR;function lh(r){var t=r.get("confine");return t!=null?!!t:r.get("renderMode")==="richText"}function vw(r){if(j.domSupported){for(var t=document.documentElement.style,e=0,i=r.length;e-1?(s+="top:50%",l+="translateY(-50%) rotate("+(u=n==="left"?-225:-45)+"deg)"):(s+="left:50%",l+="translateX(-50%) rotate("+(u=n==="top"?225:45)+"deg)");var f=u*Math.PI/180,h=o+a,p=h*Math.abs(Math.cos(f))+h*Math.abs(Math.sin(f)),c=Math.round(((p-Math.SQRT2*a)/2+Math.SQRT2*a-(p-h)/2)*100)/100;s+=";"+n+":-"+c+"px";var v=t+" solid "+a+"px;",m=["position:absolute;width:"+o+"px;height:"+o+"px;z-index:-1;",s+";"+l+";","border-bottom:"+v,"border-right:"+v,"background-color:"+i+";"];return'
'}function KR(r,t){var e="cubic-bezier(0.23,1,0.32,1)",i=" "+r/2+"s "+e,a="opacity"+i+",visibility"+i;return t||(i=" "+r+"s "+e,a+=j.transformSupported?","+sm+i:",left"+i+",top"+i),YR+":"+a}function gw(r,t,e){var i=r.toFixed(0)+"px",a=t.toFixed(0)+"px";if(!j.transformSupported)return e?"top:"+a+";left:"+i+";":[["top",a],["left",i]];var n=j.transform3dSupported,o="translate"+(n?"3d":"")+"("+i+","+a+(n?",0":"")+")";return e?"top:0;left:0;"+sm+":"+o+";":[["top",0],["left",0],[nm,o]]}function jR(r){var t=[],e=r.get("fontSize"),i=r.getTextColor();i&&t.push("color:"+i),t.push("font:"+r.getFont()),e&&t.push("line-height:"+Math.round(e*3/2)+"px");var a=r.get("textShadowColor"),n=r.get("textShadowBlur")||0,o=r.get("textShadowOffsetX")||0,s=r.get("textShadowOffsetY")||0;return a&&n&&t.push("text-shadow:"+o+"px "+s+"px "+n+"px "+a),b(["decoration","align"],function(l){var u=r.get(l);u&&t.push("text-"+l+":"+u)}),t.join(";")}function QR(r,t,e){var i=[],a=r.get("transitionDuration"),n=r.get("backgroundColor"),o=r.get("shadowBlur"),s=r.get("shadowColor"),l=r.get("shadowOffsetX"),u=r.get("shadowOffsetY"),f=r.getModel("textStyle"),h=Ku(r,"html"),p=l+"px "+u+"px "+o+"px "+s;return i.push("box-shadow:"+p),t&&a&&i.push(KR(a,e)),n&&i.push("background-color:"+n),b(["width","color","radius"],function(c){var v="border-"+c,m=jn(v),d=r.get(m);d!=null&&i.push(v+":"+d+(c==="color"?"":"px"))}),i.push(jR(f)),h!=null&&i.push("padding:"+or(h).join("px ")+"px"),i.join(";")+";"}function yw(r,t,e,i,a){var n=t&&t.painter;if(e){var o=n&&n.getViewportRoot();o&&km(r,o,e,i,a)}else{r[0]=i,r[1]=a;var s=n&&n.getViewportRootOffset();s&&(r[0]+=s.offsetLeft,r[1]+=s.offsetTop)}r[2]=r[0]/t.getWidth(),r[3]=r[1]/t.getHeight()}var $R=(function(){function r(t,e){if(this._show=!1,this._styleCoord=[0,0,0,0],this._enterable=!0,this._alwaysShowContent=!1,this._firstShow=!0,this._longHide=!0,j.wxa)return null;var i=document.createElement("div");i.domBelongToZr=!0,this.el=i;var a=this._zr=t.getZr(),n=e.appendTo,o=n&&(U(n)?document.querySelector(n):Qi(n)?n:G(n)&&n(t.getDom()));yw(this._styleCoord,a,o,t.getWidth()/2,t.getHeight()/2),(o||t.getDom()).appendChild(i),this._api=t,this._container=o;var s=this;i.onmouseenter=function(){s._enterable&&(clearTimeout(s._hideTimeout),s._show=!0),s._inContent=!0},i.onmousemove=function(l){if(l=l||window.event,!s._enterable){var u=a.handler,f=a.painter.getViewportRoot();Me(f,l,!0),u.dispatch("mousemove",l)}},i.onmouseleave=function(){s._inContent=!1,s._enterable&&s._show&&s.hideLater(s._hideDelay)}}return r.prototype.update=function(t){if(!this._container){var e=this._api.getDom(),i=mw(e,"position"),a=e.style;a.position!=="absolute"&&i!=="absolute"&&(a.position="relative")}var n=t.get("alwaysShowContent");n&&this._moveIfResized(),this._alwaysShowContent=n,this.el.className=t.get("className")||""},r.prototype.show=function(t,e){clearTimeout(this._hideTimeout),clearTimeout(this._longHideTimeout);var i=this.el,a=i.style,n=this._styleCoord;i.innerHTML?a.cssText=ZR+QR(t,!this._firstShow,this._longHide)+gw(n[0],n[1],!0)+("border-color:"+br(e)+";")+(t.get("extraCssText")||"")+(";pointer-events:"+(this._enterable?"auto":"none")):a.display="none",this._show=!0,this._firstShow=!1,this._longHide=!1},r.prototype.setContent=function(t,e,i,a,n){var o=this.el;if(t==null){o.innerHTML="";return}var s="";if(U(n)&&i.get("trigger")==="item"&&!lh(i)&&(s=qR(i,a,n)),U(t))o.innerHTML=t+s;else if(t){o.innerHTML="",O(t)||(t=[t]);for(var l=0;l=0?this._tryShow(n,o):a==="leave"&&this._hide(o))},this))},t.prototype._keepShow=function(){var e=this._tooltipModel,i=this._ecModel,a=this._api,n=e.get("triggerOn");if(this._lastX!=null&&this._lastY!=null&&n!=="none"&&n!=="click"){var o=this;clearTimeout(this._refreshUpdateTimeout),this._refreshUpdateTimeout=setTimeout(function(){!a.isDisposed()&&o.manuallyShowTip(e,i,a,{x:o._lastX,y:o._lastY,dataByCoordSys:o._lastDataByCoordSys})})}},t.prototype.manuallyShowTip=function(e,i,a,n){if(!(n.from===this.uid||j.node||!a.getDom())){var o=ww(n,a);this._ticket="";var s=n.dataByCoordSys,l=nO(n,i,a);if(l){var u=l.el.getBoundingRect().clone();u.applyTransform(l.el.transform),this._tryShow({offsetX:u.x+u.width/2,offsetY:u.y+u.height/2,target:l.el,position:n.position,positionDefault:"bottom"},o)}else if(n.tooltip&&n.x!=null&&n.y!=null){var f=tO;f.x=n.x,f.y=n.y,f.update(),ut(f).tooltipConfig={name:null,option:n.tooltip},this._tryShow({offsetX:n.x,offsetY:n.y,target:f},o)}else if(s)this._tryShow({offsetX:n.x,offsetY:n.y,position:n.position,dataByCoordSys:s,tooltipOption:n.tooltipOption},o);else if(n.seriesIndex!=null){if(this._manuallyAxisShowTip(e,i,a,n))return;var h=ol(n,i),p=h.point[0],c=h.point[1];p!=null&&c!=null&&this._tryShow({offsetX:p,offsetY:c,target:h.el,position:n.position,positionDefault:"bottom"},o)}else n.x!=null&&n.y!=null&&(a.dispatchAction({type:"updateAxisPointer",x:n.x,y:n.y}),this._tryShow({offsetX:n.x,offsetY:n.y,position:n.position,target:a.getZr().findHover(n.x,n.y).target},o))}},t.prototype.manuallyHideTip=function(e,i,a,n){var o=this._tooltipContent;this._tooltipModel&&o.hideLater(this._tooltipModel.get("hideDelay")),this._lastX=this._lastY=this._lastDataByCoordSys=null,n.from!==this.uid&&this._hide(ww(n,a))},t.prototype._manuallyAxisShowTip=function(e,i,a,n){var o=n.seriesIndex,s=n.dataIndex,l=i.getComponent("axisPointer").coordSysAxesInfo;if(!(o==null||s==null||l==null)){var u=i.getSeriesByIndex(o);if(u){var f=u.getData(),h=ll([f.getItemModel(s),u,(u.coordinateSystem||{}).model],this._tooltipModel);if(h.get("trigger")==="axis")return a.dispatchAction({type:"updateAxisPointer",seriesIndex:o,dataIndex:s,position:n.position}),!0}}},t.prototype._tryShow=function(e,i){var a=e.target,n=this._tooltipModel;if(n){this._lastX=e.offsetX,this._lastY=e.offsetY;var o=e.dataByCoordSys;if(o&&o.length)this._showAxisTooltip(o,e);else if(a){var s=ut(a);if(s.ssrType==="legend")return;this._lastDataByCoordSys=null;var l,u;hi(a,function(f){if(ut(f).dataIndex!=null)return l=f,!0;if(ut(f).tooltipConfig!=null)return u=f,!0},!0),l?this._showSeriesItemTooltip(e,l,i):u?this._showComponentItemTooltip(e,u,i):this._hide(i)}else this._lastDataByCoordSys=null,this._hide(i)}},t.prototype._showOrMove=function(e,i){var a=e.get("showDelay");i=H(i,this),clearTimeout(this._showTimout),a>0?this._showTimout=setTimeout(i,a):i()},t.prototype._showAxisTooltip=function(e,i){var a=this._ecModel,n=this._tooltipModel,o=[i.offsetX,i.offsetY],s=ll([i.tooltipOption],n),l=this._renderMode,u=[],f=qa("section",{blocks:[],noHeader:!0}),h=[],p=new ju;b(e,function(y){b(y.dataByAxis,function(_){var x=a.getComponent(_.axisDim+"Axis",_.axisIndex),w=_.value;if(!(!x||w==null)){var S=$d(w,x.axis,a,_.seriesDataIndices,_.valueLabelOpt),T=qa("section",{header:S,noHeader:!te(S),sortBlocks:!0,blocks:[]});f.blocks.push(T),b(_.seriesDataIndices,function(M){var D=a.getSeriesByIndex(M.seriesIndex),A=M.dataIndexInside,C=D.getDataParams(A);if(!(C.dataIndex<0)){C.axisDim=_.axisDim,C.axisIndex=_.axisIndex,C.axisType=_.axisType,C.axisId=_.axisId,C.axisValue=Qs(x.axis,{value:w}),C.axisValueLabel=S,C.marker=p.makeTooltipMarker("item",br(C.color),l);var E=qp(D.formatTooltip(A,!0,null)),L=E.frag;if(L){var P=ll([D],n).get("valueFormatter");T.blocks.push(P?N({valueFormatter:P},L):L)}E.text&&h.push(E.text),u.push(C)}})}})}),f.blocks.reverse(),h.reverse();var c=i.position,v=s.get("order"),m=tv(f,p,l,v,a.get("useUTC"),s.get("textStyle"));m&&h.unshift(m);var d=l==="richText"?` + +`:"
",g=h.join(d);this._showOrMove(s,function(){this._updateContentNotChangedOnAxis(e,u)?this._updatePosition(s,c,o[0],o[1],this._tooltipContent,u):this._showTooltipContent(s,g,u,Math.random()+"",o[0],o[1],c,null,p)})},t.prototype._showSeriesItemTooltip=function(e,i,a){var n=this._ecModel,o=ut(i),s=o.seriesIndex,l=n.getSeriesByIndex(s),u=o.dataModel||l,f=o.dataIndex,h=o.dataType,p=u.getData(h),c=this._renderMode,v=e.positionDefault,m=ll([p.getItemModel(f),u,l&&(l.coordinateSystem||{}).model],this._tooltipModel,v?{position:v}:null),d=m.get("trigger");if(!(d!=null&&d!=="item")){var g=u.getDataParams(f,h),y=new ju;g.marker=y.makeTooltipMarker("item",br(g.color),c);var _=qp(u.formatTooltip(f,!1,h)),x=m.get("order"),w=m.get("valueFormatter"),S=_.frag,T=S?tv(w?N({valueFormatter:w},S):S,y,c,x,n.get("useUTC"),m.get("textStyle")):_.text,M="item_"+u.name+"_"+f;this._showOrMove(m,function(){this._showTooltipContent(m,T,g,M,e.offsetX,e.offsetY,e.position,e.target,y)}),a({type:"showTip",dataIndexInside:f,dataIndex:p.getRawIndex(f),seriesIndex:s,from:this.uid})}},t.prototype._showComponentItemTooltip=function(e,i,a){var n=this._renderMode==="html",o=ut(i),s=o.tooltipConfig,l=s.option||{},u=l.encodeHTMLContent;if(U(l)){var f=l;l={content:f,formatter:f},u=!0}u&&n&&l.content&&(l=Y(l),l.content=ee(l.content));var h=[l],p=this._ecModel.getComponent(o.componentMainType,o.componentIndex);p&&h.push(p),h.push({formatter:l.content});var c=e.positionDefault,v=ll(h,this._tooltipModel,c?{position:c}:null),m=v.get("content"),d=Math.random()+"",g=new ju;this._showOrMove(v,function(){var y=Y(v.get("formatterParams")||{});this._showTooltipContent(v,m,y,d,e.offsetX,e.offsetY,e.position,i,g)}),a({type:"showTip",from:this.uid})},t.prototype._showTooltipContent=function(e,i,a,n,o,s,l,u,f){if(this._ticket="",!(!e.get("showContent")||!e.get("show"))){var h=this._tooltipContent;h.setEnterable(e.get("enterable"));var p=e.get("formatter");l=l||e.get("position");var c=i,v=this._getNearestPoint([o,s],a,e.get("trigger"),e.get("borderColor")),m=v.color;if(p)if(U(p)){var d=e.ecModel.get("useUTC"),g=O(a)?a[0]:a,y=g&&g.axisType&&g.axisType.indexOf("time")>=0;c=p,y&&(c=oi(g.axisValue,c,d)),c=Qn(c,a,!0)}else if(G(p)){var _=H(function(x,w){x===this._ticket&&(h.setContent(w,f,e,m,l),this._updatePosition(e,l,o,s,h,a,u))},this);this._ticket=n,c=p(a,n,_)}else c=p;h.setContent(c,f,e,m,l),h.show(e,m),this._updatePosition(e,l,o,s,h,a,u)}},t.prototype._getNearestPoint=function(e,i,a,n){if(a==="axis"||O(i))return{color:n||(this._renderMode==="html"?"#fff":"none")};if(!O(i))return{color:n||i.color||i.borderColor}},t.prototype._updatePosition=function(e,i,a,n,o,s,l){var u=this._api.getWidth(),f=this._api.getHeight();i=i||e.get("position");var h=o.getSize(),p=e.get("align"),c=e.get("verticalAlign"),v=l&&l.getBoundingRect().clone();if(l&&v.applyTransform(l.transform),G(i)&&(i=i([a,n],s,o.el,v,{viewSize:[u,f],contentSize:h.slice()})),O(i))a=yt(i[0],u),n=yt(i[1],f);else if(F(i)){var m=i;m.width=h[0],m.height=h[1];var d=pe(m,{width:u,height:f});a=d.x,n=d.y,p=null,c=null}else if(U(i)&&l){var g=aO(i,v,h,e.get("borderWidth"));a=g[0],n=g[1]}else{var g=rO(a,n,o,u,f,p?null:20,c?null:20);a=g[0],n=g[1]}if(p&&(a-=Tw(p)?h[0]/2:p==="right"?h[0]:0),c&&(n-=Tw(c)?h[1]/2:c==="bottom"?h[1]:0),lh(e)){var g=iO(a,n,o,u,f);a=g[0],n=g[1]}o.moveTo(a,n)},t.prototype._updateContentNotChangedOnAxis=function(e,i){var a=this._lastDataByCoordSys,n=this._cbParamsList,o=!!a&&a.length===e.length;return o&&b(a,function(s,l){var u=s.dataByAxis||[],f=e[l]||{},h=f.dataByAxis||[];o=o&&u.length===h.length,o&&b(u,function(p,c){var v=h[c]||{},m=p.seriesDataIndices||[],d=v.seriesDataIndices||[];o=o&&p.value===v.value&&p.axisType===v.axisType&&p.axisId===v.axisId&&m.length===d.length,o&&b(m,function(g,y){var _=d[y];o=o&&g.seriesIndex===_.seriesIndex&&g.dataIndex===_.dataIndex}),n&&b(p.seriesDataIndices,function(g){var y=g.seriesIndex,_=i[y],x=n[y];_&&x&&x.data!==_.data&&(o=!1)})})}),this._lastDataByCoordSys=e,this._cbParamsList=i,!!o},t.prototype._hide=function(e){this._lastDataByCoordSys=null,e({type:"hideTip",from:this.uid})},t.prototype.dispose=function(e,i){j.node||!i.getDom()||(Qa(this,"_updatePosition"),this._tooltipContent.dispose(),nl("itemTooltip",i))},t.type="tooltip",t})(Lt);function ll(r,t,e){var i=t.ecModel,a;e?(a=new _t(e,i,i),a=new _t(t.option,a,i)):a=t;for(var n=r.length-1;n>=0;n--){var o=r[n];o&&(o instanceof _t&&(o=o.get("tooltip",!0)),U(o)&&(o={formatter:o}),o&&(a=new _t(o,a,i)))}return a}function ww(r,t){return r.dispatchAction||H(t.dispatchAction,t)}function rO(r,t,e,i,a,n,o){var s=e.getSize(),l=s[0],u=s[1];return n!=null&&(r+l+n+2>i?r-=l+n:r+=n),o!=null&&(t+u+o>a?t-=u+o:t+=o),[r,t]}function iO(r,t,e,i,a){var n=e.getSize(),o=n[0],s=n[1];return r=Math.min(r+o,i)-o,t=Math.min(t+s,a)-s,r=Math.max(r,0),t=Math.max(t,0),[r,t]}function aO(r,t,e,i){var a=e[0],n=e[1],o=Math.ceil(Math.SQRT2*i)+8,s=0,l=0,u=t.width,f=t.height;switch(r){case"inside":s=t.x+u/2-a/2,l=t.y+f/2-n/2;break;case"top":s=t.x+u/2-a/2,l=t.y-n-o;break;case"bottom":s=t.x+u/2-a/2,l=t.y+f+o;break;case"left":s=t.x-a-o,l=t.y+f/2-n/2;break;case"right":s=t.x+u+o,l=t.y+f/2-n/2}return[s,l]}function Tw(r){return r==="center"||r==="middle"}function nO(r,t,e){var i=$o(r).queryOptionMap,a=i.keys()[0];if(!(!a||a==="series")){var n=bi(t,a,i.get(a),{useDefault:!1,enableAll:!1,enableNone:!1}),o=n.models[0];if(o){var s=e.getViewOfComponentModel(o),l;if(s.group.traverse(function(u){var f=ut(u).tooltipConfig;if(f&&f.name===r.name)return l=u,!0}),l)return{componentMainType:a,componentIndex:o.componentIndex,el:l}}}}var Mw=eO;function lm(r){Bt(un),r.registerComponentModel(pw),r.registerComponentView(Mw),r.registerAction({type:"showTip",event:"showTip",update:"tooltip:manuallyShowTip"},Dt),r.registerAction({type:"hideTip",event:"hideTip",update:"tooltip:manuallyHideTip"},Dt)}var Cw=b;function Dw(r){if(r){for(var t in r)if(r.hasOwnProperty(t))return!0}}function um(r,t,e){var i={};return Cw(t,function(n){var o=i[n]=a();Cw(r[n],function(s,l){if(Kt.isValidType(l)){var u={type:l,visual:s};e&&e(u,n),o[l]=new Kt(u),l==="opacity"&&(u=Y(u),u.type="colorAlpha",o.__hidden.__alphaForOpacity=new Kt(u))}})}),i;function a(){var n=function(){};n.prototype.__hidden=n.prototype;var o=new n;return o}}function Aw(r,t,e){var i;b(e,function(a){t.hasOwnProperty(a)&&Dw(t[a])&&(i=!0)}),i&&b(e,function(a){t.hasOwnProperty(a)&&Dw(t[a])?r[a]=Y(t[a]):delete r[a]})}function Ew(r,t,e,i){var a={};return b(r,function(n){var o=Kt.prepareVisualTypes(t[n]);a[n]=o}),{progress:function(o,s){var l;i!=null&&(l=s.getDimensionIndex(i));function u(w){return af(s,h,w)}function f(w,S){Dx(s,h,w,S)}for(var h,p=s.getStore();(h=o.next())!=null;){var c=s.getRawDataItem(h);if(!(c&&c.visualMap===!1))for(var v=i!=null?p.get(l,h):h,m=e(v),d=t[m],g=a[m],y=0,_=g.length;y<_;y++){var x=g[y];d[x]&&d[x].applyVisual(v,u,f)}}}}}var oO=function(r,t){if(t==="all")return{type:"all",title:r.getLocaleModel().get(["legend","selector","all"])};if(t==="inverse")return{type:"inverse",title:r.getLocaleModel().get(["legend","selector","inverse"])}},sO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.layoutMode={type:"box",ignoreSize:!0},e}return t.prototype.init=function(e,i,a){this.mergeDefaultAndTheme(e,a),e.selected=e.selected||{},this._updateSelector(e)},t.prototype.mergeOption=function(e,i){r.prototype.mergeOption.call(this,e,i),this._updateSelector(e)},t.prototype._updateSelector=function(e){var i=e.selector,a=this.ecModel;i===!0&&(i=e.selector=["all","inverse"]),O(i)&&b(i,function(n,o){U(n)&&(n={type:n}),i[o]=tt(n,oO(a,n.type))})},t.prototype.optionUpdated=function(){this._updateData(this.ecModel);var e=this._data;if(e[0]&&this.get("selectedMode")==="single"){for(var i=!1,a=0;a=0},t.prototype.getOrient=function(){return this.get("orient")==="vertical"?{index:1,name:"vertical"}:{index:0,name:"horizontal"}},t.type="legend.plain",t.dependencies=["series"],t.defaultOption={z:4,show:!0,orient:"horizontal",left:"center",top:0,align:"auto",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderRadius:0,borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,symbolRotate:"inherit",symbolKeepAspect:!0,inactiveColor:"#ccc",inactiveBorderColor:"#ccc",inactiveBorderWidth:"auto",itemStyle:{color:"inherit",opacity:"inherit",borderColor:"inherit",borderWidth:"auto",borderCap:"inherit",borderJoin:"inherit",borderDashOffset:"inherit",borderMiterLimit:"inherit"},lineStyle:{width:"auto",color:"inherit",inactiveColor:"#ccc",inactiveWidth:2,opacity:"inherit",type:"inherit",cap:"inherit",join:"inherit",dashOffset:"inherit",miterLimit:"inherit"},textStyle:{color:"#333"},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:"sans-serif",color:"#666",borderWidth:1,borderColor:"#666"},emphasis:{selectorLabel:{show:!0,color:"#eee",backgroundColor:"#666"}},selectorPosition:"auto",selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1}},t})(pt),ul=sO;var go=ct,fm=b,uh=ft,lO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.newlineDisabled=!1,e}return t.prototype.init=function(){this.group.add(this._contentGroup=new uh),this.group.add(this._selectorGroup=new uh),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,i,a){var n=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),!!e.get("show",!0)){var o=e.get("align"),s=e.get("orient");(!o||o==="auto")&&(o=e.get("left")==="right"&&s==="vertical"?"right":"left");var l=e.get("selector",!0),u=e.get("selectorPosition",!0);l&&(!u||u==="auto")&&(u=s==="horizontal"?"end":"start"),this.renderInner(o,e,i,a,l,s,u);var f=e.getBoxLayoutParams(),h={width:a.getWidth(),height:a.getHeight()},p=e.get("padding"),c=pe(f,h,p),v=this.layoutInner(e,o,c,n,l,u),m=pe(K({width:v.width,height:v.height},f),h,p);this.group.x=m.x-v.x,this.group.y=m.y-v.y,this.group.markRedraw(),this.group.add(this._backgroundEl=cw(v,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,i,a,n,o,s,l){var u=this.getContentGroup(),f=W(),h=i.get("selectedMode"),p=[];a.eachRawSeries(function(c){!c.get("legendHoverLink")&&p.push(c.id)}),fm(i.getData(),function(c,v){var m=c.get("name");if(!this.newlineDisabled&&(m===""||m===` +`)){var d=new uh;d.newline=!0,u.add(d);return}var g=a.getSeriesByName(m)[0];if(!f.get(m))if(g){var y=g.getData(),_=y.getVisual("legendLineStyle")||{},x=y.getVisual("legendIcon"),w=y.getVisual("style"),S=this._createItem(g,m,v,c,i,e,_,w,x,h,n);S.on("click",go(Iw,m,null,n,p)).on("mouseover",go(hm,g.name,null,n,p)).on("mouseout",go(cm,g.name,null,n,p)),a.ssr&&S.eachChild(function(T){var M=ut(T);M.seriesIndex=g.seriesIndex,M.dataIndex=v,M.ssrType="legend"}),f.set(m,!0)}else a.eachRawSeries(function(T){if(!f.get(m)&&T.legendVisualProvider){var M=T.legendVisualProvider;if(!M.containName(m))return;var D=M.indexOfName(m),A=M.getItemVisual(D,"style"),C=M.getItemVisual(D,"legendIcon"),E=re(A.fill);E&&E[3]===0&&(E[3]=.2,A=N(N({},A),{fill:De(E,"rgba")}));var L=this._createItem(T,m,v,c,i,e,{},A,C,h,n);L.on("click",go(Iw,null,m,n,p)).on("mouseover",go(hm,null,m,n,p)).on("mouseout",go(cm,null,m,n,p)),a.ssr&&L.eachChild(function(P){var R=ut(P);R.seriesIndex=T.seriesIndex,R.dataIndex=v,R.ssrType="legend"}),f.set(m,!0)}},this)},this),o&&this._createSelector(o,i,n,s,l)},t.prototype._createSelector=function(e,i,a,n,o){var s=this.getSelectorGroup();fm(e,function(u){var f=u.type,h=new vt({style:{x:0,y:0,align:"center",verticalAlign:"middle"},onclick:function(){a.dispatchAction({type:f==="all"?"legendAllSelect":"legendInverseSelect"})}});s.add(h);var p=i.getModel("selectorLabel"),c=i.getModel(["emphasis","selectorLabel"]);ar(h,{normal:p,emphasis:c},{defaultText:u.title}),Ei(h)})},t.prototype._createItem=function(e,i,a,n,o,s,l,u,f,h,p){var c=e.visualDrawType,v=o.get("itemWidth"),m=o.get("itemHeight"),d=o.isSelected(i),g=n.get("symbolRotate"),y=n.get("symbolKeepAspect"),_=n.get("icon");f=_||f||"roundRect";var x=uO(f,n,l,u,c,d,p),w=new uh,S=n.getModel("textStyle");if(G(e.getLegendIcon)&&(!_||_==="inherit"))w.add(e.getLegendIcon({itemWidth:v,itemHeight:m,icon:f,iconRotate:g,itemStyle:x.itemStyle,lineStyle:x.lineStyle,symbolKeepAspect:y}));else{var T=_==="inherit"&&e.getData().getVisual("symbol")?g==="inherit"?e.getData().getVisual("symbolRotate"):g:0;w.add(fO({itemWidth:v,itemHeight:m,icon:f,iconRotate:T,itemStyle:x.itemStyle,lineStyle:x.lineStyle,symbolKeepAspect:y}))}var M=s==="left"?v+5:-5,D=s,A=o.get("formatter"),C=i;U(A)&&A?C=A.replace("{name}",i??""):G(A)&&(C=A(i));var E=d?S.getTextColor():n.get("inactiveColor");w.add(new vt({style:Zt(S,{text:C,x:M,y:m/2,fill:E,align:D,verticalAlign:"middle"},{inheritColor:E})}));var L=new st({shape:w.getBoundingRect(),style:{fill:"transparent"}}),P=n.getModel("tooltip");return P.get("show")&&ms({el:L,componentModel:o,itemName:i,itemTooltipOption:P.option}),w.add(L),w.eachChild(function(R){R.silent=!0}),L.silent=!h,this.getContentGroup().add(w),Ei(w),w.__legendDataIndex=a,w},t.prototype.layoutInner=function(e,i,a,n,o,s){var l=this.getContentGroup(),u=this.getSelectorGroup();si(e.get("orient"),l,e.get("itemGap"),a.width,a.height);var f=l.getBoundingRect(),h=[-f.x,-f.y];if(u.markRedraw(),l.markRedraw(),o){si("horizontal",u,e.get("selectorItemGap",!0));var p=u.getBoundingRect(),c=[-p.x,-p.y],v=e.get("selectorButtonGap",!0),m=e.getOrient().index,d=m===0?"width":"height",g=m===0?"height":"width",y=m===0?"y":"x";s==="end"?c[m]+=f[d]+v:h[m]+=p[d]+v,c[1-m]+=f[g]/2-p[g]/2,u.x=c[0],u.y=c[1],l.x=h[0],l.y=h[1];var _={x:0,y:0};return _[d]=f[d]+v+p[d],_[g]=Math.max(f[g],p[g]),_[y]=Math.min(0,p[y]+c[1-m]),_}else return l.x=h[0],l.y=h[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type="legend.plain",t})(Lt);function uO(r,t,e,i,a,n,o){function s(d,g){d.lineWidth==="auto"&&(d.lineWidth=g.lineWidth>0?2:0),fm(d,function(y,_){d[_]==="inherit"&&(d[_]=g[_])})}var l=t.getModel("itemStyle"),u=l.getItemStyle(),f=r.lastIndexOf("empty",0)===0?"fill":"stroke",h=l.getShallow("decal");u.decal=!h||h==="inherit"?i.decal:Us(h,o),u.fill==="inherit"&&(u.fill=i[a]),u.stroke==="inherit"&&(u.stroke=i[f]),u.opacity==="inherit"&&(u.opacity=(a==="fill"?i:e).opacity),s(u,i);var p=t.getModel("lineStyle"),c=p.getLineStyle();if(s(c,e),u.fill==="auto"&&(u.fill=i.fill),u.stroke==="auto"&&(u.stroke=i.fill),c.stroke==="auto"&&(c.stroke=i.fill),!n){var v=t.get("inactiveBorderWidth"),m=u[f];u.lineWidth=v==="auto"?i.lineWidth>0&&m?2:0:u.lineWidth,u.fill=t.get("inactiveColor"),u.stroke=t.get("inactiveBorderColor"),c.stroke=p.get("inactiveColor"),c.lineWidth=p.get("inactiveWidth")}return{itemStyle:u,lineStyle:c}}function fO(r){var t=r.icon||"roundRect",e=Vt(t,0,0,r.itemWidth,r.itemHeight,r.itemStyle.fill,r.symbolKeepAspect);return e.setStyle(r.itemStyle),e.rotation=(r.iconRotate||0)*Math.PI/180,e.setOrigin([r.itemWidth/2,r.itemHeight/2]),t.indexOf("empty")>-1&&(e.style.stroke=e.style.fill,e.style.fill="#fff",e.style.lineWidth=2),e}function Iw(r,t,e,i){cm(r,t,e,i),e.dispatchAction({type:"legendToggleSelect",name:r??t}),hm(r,t,e,i)}function Pw(r){for(var t=r.getZr().storage.getDisplayList(),e,i=0,a=t.length;ia[o],d=[-c.x,-c.y];i||(d[n]=f[u]);var g=[0,0],y=[-v.x,-v.y],_=et(e.get("pageButtonGap",!0),e.get("itemGap",!0));if(m){var x=e.get("pageButtonPosition",!0);x==="end"?y[n]+=a[o]-v[o]:g[n]+=v[o]+_}y[1-n]+=c[s]/2-v[s]/2,f.setPosition(d),h.setPosition(g),p.setPosition(y);var w={x:0,y:0};if(w[o]=m?a[o]:c[o],w[s]=Math.max(c[s],v[s]),w[l]=Math.min(0,v[l]+y[1-n]),h.__rectSize=a[o],m){var S={x:0,y:0};S[o]=Math.max(a[o]-v[o]-_,0),S[s]=w[s],h.setClipPath(new st({shape:S})),h.__rectSize=S[o]}else p.eachChild(function(M){M.attr({invisible:!0,silent:!0})});var T=this._getPageInfo(e);return T.pageIndex!=null&&Ct(f,{x:T.contentPosition[0],y:T.contentPosition[1]},m?e:null),this._updatePageInfoView(e,T),w},t.prototype._pageGo=function(e,i,a){var n=this._getPageInfo(i)[e];n!=null&&a.dispatchAction({type:"legendScroll",scrollDataIndex:n,legendId:i.id})},t.prototype._updatePageInfoView=function(e,i){var a=this._controllerGroup;b(["pagePrev","pageNext"],function(f){var h=f+"DataIndex",p=i[h]!=null,c=a.childOfName(f);c&&(c.setStyle("fill",p?e.get("pageIconColor",!0):e.get("pageIconInactiveColor",!0)),c.cursor=p?"pointer":"default")});var n=a.childOfName("pageText"),o=e.get("pageFormatter"),s=i.pageIndex,l=s!=null?s+1:0,u=i.pageCount;n&&o&&n.setStyle("text",U(o)?o.replace("{current}",l==null?"":l+"").replace("{total}",u==null?"":u+""):o({current:l,total:u}))},t.prototype._getPageInfo=function(e){var i=e.get("scrollDataIndex",!0),a=this.getContentGroup(),n=this._containerGroup.__rectSize,o=e.getOrient().index,s=vm[o],l=dm[o],u=this._findTargetItemIndex(i),f=a.children(),h=f[u],p=f.length,c=p?1:0,v={contentPosition:[a.x,a.y],pageCount:c,pageIndex:c-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!h)return v;var m=x(h);v.contentPosition[o]=-m.s;for(var d=u+1,g=m,y=m,_=null;d<=p;++d)_=x(f[d]),(!_&&y.e>g.s+n||_&&!w(_,g.s))&&(y.i>g.i?g=y:g=_,g&&(v.pageNextDataIndex==null&&(v.pageNextDataIndex=g.i),++v.pageCount)),y=_;for(var d=u-1,g=m,y=m,_=null;d>=-1;--d)_=x(f[d]),(!_||!w(y,_.s))&&g.i=T&&S.s<=T+n}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var i,a=this.getContentGroup(),n;return a.eachChild(function(o,s){var l=o.__legendDataIndex;n==null&&l!=null&&(n=s),l===e&&(i=s)}),i??n},t.type="legend.scroll",t})(fh),kw=cO;function mm(r){r.registerAction("legendScroll","legendscroll",function(t,e){var i=t.scrollDataIndex;i!=null&&e.eachComponent({mainType:"legend",subType:"scroll",query:t},function(a){a.setScrollDataIndex(i)})})}function Uw(r){Bt(hh),r.registerComponentModel(Nw),r.registerComponentView(kw),mm(r)}function gm(r){Bt(hh),Bt(Uw)}var pO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="dataZoom.inside",t.defaultOption=nr(vo.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t})(vo),Vw=pO;var ym=ht();function Bw(r,t,e){ym(r).coordSysRecordMap.each(function(i){var a=i.dataZoomInfoMap.get(t.uid);a&&(a.getRange=e)})}function Fw(r,t){for(var e=ym(r).coordSysRecordMap,i=e.keys(),a=0;ai[e+t]&&(t=s),a=a&&o.get("preventDefaultMouseMove",!0)}),{controlType:t,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!a}}}function Gw(r){r.registerProcessor(r.PRIORITY.PROCESSOR.FILTER,function(t,e){var i=ym(e),a=i.coordSysRecordMap||(i.coordSysRecordMap=W());a.each(function(n){n.dataZoomInfoMap=null}),t.eachComponent({mainType:"dataZoom",subType:"inside"},function(n){var o=oh(n);b(o.infoList,function(s){var l=s.model.uid,u=a.get(l)||a.set(l,vO(e,s.model)),f=u.dataZoomInfoMap||(u.dataZoomInfoMap=W());f.set(n.uid,{dzReferCoordSysInfo:s,model:n,getRange:null})})}),a.each(function(n){var o=n.controller,s,l=n.dataZoomInfoMap;if(l){var u=l.keys()[0];u!=null&&(s=l.get(u))}if(!s){Hw(a,n);return}var f=gO(l);o.enable(f.controlType,f.opt),o.setPointerChecker(n.containsPoint),zi(n,"dispatchAction",s.model.get("throttle",!0),"fixRate")})})}var _O=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type="dataZoom.inside",e}return t.prototype.render=function(e,i,a){if(r.prototype.render.apply(this,arguments),e.noTarget()){this._clear();return}this.range=e.getPercentRange(),Bw(a,e,{pan:H(_m.pan,this),zoom:H(_m.zoom,this),scrollMove:H(_m.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),r.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){Fw(this.api,this.dataZoomModel),this.range=null},t.type="dataZoom.inside",t})(sh),_m={zoom:function(r,t,e,i){var a=this.range,n=a.slice(),o=r.axisModels[0];if(o){var s=xm[t](null,[i.originX,i.originY],o,e,r),l=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(n[1]-n[0])+n[0],u=Math.max(1/i.scale,0);n[0]=(n[0]-l)*u+l,n[1]=(n[1]-l)*u+l;var f=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(Gr(0,n,[0,100],0,f.minSpan,f.maxSpan),this.range=n,a[0]!==n[0]||a[1]!==n[1])return n}},pan:Ww(function(r,t,e,i,a,n){var o=xm[i]([n.oldX,n.oldY],[n.newX,n.newY],t,a,e);return o.signal*(r[1]-r[0])*o.pixel/o.pixelLength}),scrollMove:Ww(function(r,t,e,i,a,n){var o=xm[i]([0,0],[n.scrollDelta,n.scrollDelta],t,a,e);return o.signal*(r[1]-r[0])*n.scrollDelta})};function Ww(r){return function(t,e,i,a){var n=this.range,o=n.slice(),s=t.axisModels[0];if(s){var l=r(o,s,t,e,i,a);if(Gr(l,o,[0,100],"all"),this.range=o,n[0]!==o[0]||n[1]!==o[1])return o}}}var xm={grid:function(r,t,e,i,a){var n=e.axis,o={},s=a.model.coordinateSystem.getRect();return r=r||[0,0],n.dim==="x"?(o.pixel=t[0]-r[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=n.inverse?1:-1):(o.pixel=t[1]-r[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=n.inverse?-1:1),o},polar:function(r,t,e,i,a){var n=e.axis,o={},s=a.model.coordinateSystem,l=s.getRadiusAxis().getExtent(),u=s.getAngleAxis().getExtent();return r=r?s.pointToCoord(r):[0,0],t=s.pointToCoord(t),e.mainType==="radiusAxis"?(o.pixel=t[0]-r[0],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=n.inverse?1:-1):(o.pixel=t[1]-r[1],o.pixelLength=u[1]-u[0],o.pixelStart=u[0],o.signal=n.inverse?-1:1),o},singleAxis:function(r,t,e,i,a){var n=e.axis,o=a.model.coordinateSystem.getRect(),s={};return r=r||[0,0],n.orient==="horizontal"?(s.pixel=t[0]-r[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=n.inverse?1:-1):(s.pixel=t[1]-r[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=n.inverse?-1:1),s}},Yw=_O;function hl(r){sl(r),r.registerComponentModel(Vw),r.registerComponentView(Yw),Gw(r)}var xO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="dataZoom.slider",t.layoutMode="box",t.defaultOption=nr(vo.defaultOption,{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,borderColor:"#d2dbee",borderRadius:3,backgroundColor:"rgba(47,69,84,0)",dataBackground:{lineStyle:{color:"#d2dbee",width:.5},areaStyle:{color:"#d2dbee",opacity:.2}},selectedDataBackground:{lineStyle:{color:"#8fb0f7",width:.5},areaStyle:{color:"#8fb0f7",opacity:.2}},fillerColor:"rgba(135,175,274,0.2)",handleIcon:"path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z",handleSize:"100%",handleStyle:{color:"#fff",borderColor:"#ACB8D1"},moveHandleSize:7,moveHandleIcon:"path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z",moveHandleStyle:{color:"#D2DBEE",opacity:.7},showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:"#6E7079"},brushSelect:!0,brushStyle:{color:"rgba(135,175,274,0.15)"},emphasis:{handleStyle:{borderColor:"#8FB0F7"},moveHandleStyle:{color:"#8FB0F7"}}}),t})(vo),Zw=xO;var cl=st,Xw=7,SO=1,Sm=30,bO=7,pl="horizontal",qw="vertical",wO=5,TO=["line","bar","candlestick","scatter"],MO={easing:"cubicOut",duration:100,delay:0},CO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e._displayables={},e}return t.prototype.init=function(e,i){this.api=i,this._onBrush=H(this._onBrush,this),this._onBrushEnd=H(this._onBrushEnd,this)},t.prototype.render=function(e,i,a,n){if(r.prototype.render.apply(this,arguments),zi(this,"_dispatchZoomAction",e.get("throttle"),"fixRate"),this._orient=e.getOrient(),e.get("show")===!1){this.group.removeAll();return}if(e.noTarget()){this._clear(),this.group.removeAll();return}(!n||n.type!=="dataZoom"||n.from!==this.uid)&&this._buildView(),this._updateView()},t.prototype.dispose=function(){this._clear(),r.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){Qa(this,"_dispatchZoomAction");var e=this.api.getZr();e.off("mousemove",this._onBrush),e.off("mouseup",this._onBrushEnd)},t.prototype._buildView=function(){var e=this.group;e.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var i=this._displayables.sliderGroup=new ft;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),e.add(i),this._positionGroup()},t.prototype._resetLocation=function(){var e=this.dataZoomModel,i=this.api,a=e.get("brushSelect"),n=a?bO:0,o=this._findCoordRect(),s={width:i.getWidth(),height:i.getHeight()},l=this._orient===pl?{right:s.width-o.x-o.width,top:s.height-Sm-Xw-n,width:o.width,height:Sm}:{right:Xw,top:o.y,width:Sm,height:o.height},u=Vr(e.option);b(["right","top","width","height"],function(h){u[h]==="ph"&&(u[h]=l[h])});var f=pe(u,s);this._location={x:f.x,y:f.y},this._size=[f.width,f.height],this._orient===qw&&this._size.reverse()},t.prototype._positionGroup=function(){var e=this.group,i=this._location,a=this._orient,n=this.dataZoomModel.getFirstTargetAxisModel(),o=n&&n.get("inverse"),s=this._displayables.sliderGroup,l=(this._dataShadowInfo||{}).otherAxisInverse;s.attr(a===pl&&!o?{scaleY:l?1:-1,scaleX:1}:a===pl&&o?{scaleY:l?1:-1,scaleX:-1}:a===qw&&!o?{scaleY:l?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:l?-1:1,scaleX:-1,rotation:Math.PI/2});var u=e.getBoundingRect([s]);e.x=i.x-u.x,e.y=i.y-u.y,e.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var e=this.dataZoomModel,i=this._size,a=this._displayables.sliderGroup,n=e.get("brushSelect");a.add(new cl({silent:!0,shape:{x:0,y:0,width:i[0],height:i[1]},style:{fill:e.get("backgroundColor")},z2:-40}));var o=new cl({shape:{x:0,y:0,width:i[0],height:i[1]},style:{fill:"transparent"},z2:0,onclick:H(this._onClickPanel,this)}),s=this.api.getZr();n?(o.on("mousedown",this._onBrushStart,this),o.cursor="crosshair",s.on("mousemove",this._onBrush),s.on("mouseup",this._onBrushEnd)):(s.off("mousemove",this._onBrush),s.off("mouseup",this._onBrushEnd)),a.add(o)},t.prototype._renderDataShadow=function(){var e=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!e)return;var i=this._size,a=this._shadowSize||[],n=e.series,o=n.getRawData(),s=n.getShadowDim&&n.getShadowDim(),l=s&&o.getDimensionInfo(s)?n.getShadowDim():e.otherDim;if(l==null)return;var u=this._shadowPolygonPts,f=this._shadowPolylinePts;if(o!==this._shadowData||l!==this._shadowDim||i[0]!==a[0]||i[1]!==a[1]){var h=o.getDataExtent(l),p=(h[1]-h[0])*.3;h=[h[0]-p,h[1]+p];var c=[0,i[1]],v=[0,i[0]],m=[[i[0],0],[0,0]],d=[],g=v[1]/(o.count()-1),y=0,_=Math.round(o.count()/i[0]),x;o.each([l],function(D,A){if(_>0&&A%_){y+=g;return}var C=D==null||isNaN(D)||D==="",E=C?0:gt(D,h,c,!0);C&&!x&&A?(m.push([m[m.length-1][0],0]),d.push([d[d.length-1][0],0])):!C&&x&&(m.push([y,0]),d.push([y,0])),m.push([y,E]),d.push([y,E]),y+=g,x=C}),u=this._shadowPolygonPts=m,f=this._shadowPolylinePts=d}this._shadowData=o,this._shadowDim=l,this._shadowSize=[i[0],i[1]];var w=this.dataZoomModel;function S(D){var A=w.getModel(D?"selectedDataBackground":"dataBackground"),C=new ft,E=new ii({shape:{points:u},segmentIgnoreThreshold:1,style:A.getModel("areaStyle").getAreaStyle(),silent:!0,z2:-20}),L=new xr({shape:{points:f},segmentIgnoreThreshold:1,style:A.getModel("lineStyle").getLineStyle(),silent:!0,z2:-19});return C.add(E),C.add(L),C}for(var T=0;T<3;T++){var M=S(T===1);this._displayables.sliderGroup.add(M),this._displayables.dataShadowSegs.push(M)}},t.prototype._prepareDataShadowInfo=function(){var e=this.dataZoomModel,i=e.get("showDataShadow");if(i!==!1){var a,n=this.ecModel;return e.eachTargetAxis(function(o,s){var l=e.getAxisProxy(o,s).getTargetSeriesModels();b(l,function(u){if(!a&&!(i!==!0&&it(TO,u.get("type"))<0)){var f=n.getComponent(cr(o),s).axis,h=DO(o),p,c=u.coordinateSystem;h!=null&&c.getOtherAxis&&(p=c.getOtherAxis(f).inverse),h=u.getData().mapDimension(h),a={thisAxis:f,series:u,thisDim:o,otherDim:h,otherAxisInverse:p}}},this)},this),a}},t.prototype._renderHandle=function(){var e=this.group,i=this._displayables,a=i.handles=[null,null],n=i.handleLabels=[null,null],o=this._displayables.sliderGroup,s=this._size,l=this.dataZoomModel,u=this.api,f=l.get("borderRadius")||0,h=l.get("brushSelect"),p=i.filler=new cl({silent:h,style:{fill:l.get("fillerColor")},textConfig:{position:"inside"}});o.add(p),o.add(new cl({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:s[0],height:s[1],r:f},style:{stroke:l.get("dataBackgroundColor")||l.get("borderColor"),lineWidth:SO,fill:"rgba(0,0,0,0)"}})),b([0,1],function(_){var x=l.get("handleIcon");!Os[x]&&x.indexOf("path://")<0&&x.indexOf("image://")<0&&(x="path://"+x);var w=Vt(x,-1,0,2,2,null,!0);w.attr({cursor:Kw(this._orient),draggable:!0,drift:H(this._onDragMove,this,_),ondragend:H(this._onDragEnd,this),onmouseover:H(this._showDataInfo,this,!0),onmouseout:H(this._showDataInfo,this,!1),z2:5});var S=w.getBoundingRect(),T=l.get("handleSize");this._handleHeight=yt(T,this._size[1]),this._handleWidth=S.width/S.height*this._handleHeight,w.setStyle(l.getModel("handleStyle").getItemStyle()),w.style.strokeNoScale=!0,w.rectHover=!0,w.ensureState("emphasis").style=l.getModel(["emphasis","handleStyle"]).getItemStyle(),Ei(w);var M=l.get("handleColor");M!=null&&(w.style.fill=M),o.add(a[_]=w);var D=l.getModel("textStyle");e.add(n[_]=new vt({silent:!0,invisible:!0,style:Zt(D,{x:0,y:0,text:"",verticalAlign:"middle",align:"center",fill:D.getTextColor(),font:D.getFont()}),z2:10}))},this);var c=p;if(h){var v=yt(l.get("moveHandleSize"),s[1]),m=i.moveHandle=new st({style:l.getModel("moveHandleStyle").getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:s[1]-.5,height:v}}),d=v*.8,g=i.moveHandleIcon=Vt(l.get("moveHandleIcon"),-d/2,-d/2,d,d,"#fff",!0);g.silent=!0,g.y=s[1]+v/2-.5,m.ensureState("emphasis").style=l.getModel(["emphasis","moveHandleStyle"]).getItemStyle();var y=Math.min(s[1]/2,Math.max(v,10));c=i.moveZone=new st({invisible:!0,shape:{y:s[1]-y,height:v+y}}),c.on("mouseover",function(){u.enterEmphasis(m)}).on("mouseout",function(){u.leaveEmphasis(m)}),o.add(m),o.add(g),o.add(c)}c.attr({draggable:!0,cursor:Kw(this._orient),drift:H(this._onDragMove,this,"all"),ondragstart:H(this._showDataInfo,this,!0),ondragend:H(this._onDragEnd,this),onmouseover:H(this._showDataInfo,this,!0),onmouseout:H(this._showDataInfo,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),i=this._getViewExtent();this._handleEnds=[gt(e[0],[0,100],i,!0),gt(e[1],[0,100],i,!0)]},t.prototype._updateInterval=function(e,i){var a=this.dataZoomModel,n=this._handleEnds,o=this._getViewExtent(),s=a.findRepresentativeAxisProxy().getMinMaxSpan(),l=[0,100];Gr(i,n,o,a.get("zoomLock")?"all":e,s.minSpan!=null?gt(s.minSpan,l,o,!0):null,s.maxSpan!=null?gt(s.maxSpan,l,o,!0):null);var u=this._range,f=this._range=ke([gt(n[0],o,l,!0),gt(n[1],o,l,!0)]);return!u||u[0]!==f[0]||u[1]!==f[1]},t.prototype._updateView=function(e){var i=this._displayables,a=this._handleEnds,n=ke(a.slice()),o=this._size;b([0,1],function(c){var v=i.handles[c],m=this._handleHeight;v.attr({scaleX:m/2,scaleY:m/2,x:a[c]+(c?-1:1),y:o[1]/2-m/2})},this),i.filler.setShape({x:n[0],y:0,width:n[1]-n[0],height:o[1]});var s={x:n[0],width:n[1]-n[0]};i.moveHandle&&(i.moveHandle.setShape(s),i.moveZone.setShape(s),i.moveZone.getBoundingRect(),i.moveHandleIcon&&i.moveHandleIcon.attr("x",s.x+s.width/2));for(var l=i.dataShadowSegs,u=[0,n[0],n[1],o[0]],f=0;fi[0]||a[1]<0||a[1]>i[1])){var n=this._handleEnds,o=(n[0]+n[1])/2,s=this._updateInterval("all",a[0]-o);this._updateView(),s&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(e){var i=e.offsetX,a=e.offsetY;this._brushStart=new rt(i,a),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(e){if(this._brushing){var i=this._displayables.brushRect;if(this._brushing=!1,!!i){i.attr("ignore",!0);var a=i.shape,n=+new Date;if(!(n-this._brushStartTime<200&&Math.abs(a.width)<5)){var o=this._getViewExtent(),s=[0,100];this._range=ke([gt(a.x,o,s,!0),gt(a.x+a.width,o,s,!0)]),this._handleEnds=[a.x,a.x+a.width],this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(Ce(e.event),this._updateBrushRect(e.offsetX,e.offsetY))},t.prototype._updateBrushRect=function(e,i){var a=this._displayables,n=this.dataZoomModel,o=a.brushRect;o||(o=a.brushRect=new cl({silent:!0,style:n.getModel("brushStyle").getItemStyle()}),a.sliderGroup.add(o)),o.attr("ignore",!1);var s=this._brushStart,l=this._displayables.sliderGroup,u=l.transformCoordToLocal(e,i),f=l.transformCoordToLocal(s.x,s.y),h=this._size;u[0]=Math.max(Math.min(h[0],u[0]),0),o.setShape({x:f[0],y:0,width:u[0]-f[0],height:h[1]})},t.prototype._dispatchZoomAction=function(e){var i=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,animation:e?MO:null,start:i[0],end:i[1]})},t.prototype._findCoordRect=function(){var e,i=oh(this.dataZoomModel).infoList;if(!e&&i.length){var a=i[0].model.coordinateSystem;e=a.getRect&&a.getRect()}if(!e){var n=this.api.getWidth(),o=this.api.getHeight();e={x:n*.2,y:o*.2,width:n*.6,height:o*.6}}return e},t.type="dataZoom.slider",t})(sh);function DO(r){var t={x:"y",y:"x",radius:"angle",angle:"radius"};return t[r]}function Kw(r){return r==="vertical"?"ns-resize":"ew-resize"}var jw=CO;function vl(r){r.registerComponentModel(Zw),r.registerComponentView(jw),sl(r)}function bm(r){Bt(hl),Bt(vl)}var AO={get:function(r,t,e){var i=Y((EO[r]||{})[t]);return e&&O(i)?i[i.length-1]:i}},EO={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},ch=AO;var Qw=Kt.mapVisual,LO=Kt.eachVisual,IO=O,$w=b,PO=ke,RO=gt,OO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.stateList=["inRange","outOfRange"],e.replacableOptionKeys=["inRange","outOfRange","target","controller","color"],e.layoutMode={type:"box",ignoreSize:!0},e.dataBound=[-1/0,1/0],e.targetVisuals={},e.controllerVisuals={},e}return t.prototype.init=function(e,i,a){this.mergeDefaultAndTheme(e,a)},t.prototype.optionUpdated=function(e,i){var a=this.option;!i&&Aw(a,e,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(e){var i=this.stateList;e=H(e,this),this.controllerVisuals=um(this.option.controller,i,e),this.targetVisuals=um(this.option.target,i,e)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var e=this.option.seriesIndex,i=[];return e==null||e==="all"?this.ecModel.eachSeries(function(a,n){i.push(n)}):i=wt(e),i},t.prototype.eachTargetSeries=function(e,i){b(this.getTargetSeriesIndices(),function(a){var n=this.ecModel.getSeriesByIndex(a);n&&e.call(i,n)},this)},t.prototype.isTargetSeries=function(e){var i=!1;return this.eachTargetSeries(function(a){a===e&&(i=!0)}),i},t.prototype.formatValueText=function(e,i,a){var n=this.option,o=n.precision,s=this.dataBound,l=n.formatter,u;a=a||["<",">"],O(e)&&(e=e.slice(),u=!0);var f=i?e:u?[h(e[0]),h(e[1])]:h(e);if(U(l))return l.replace("{value}",u?f[0]:f).replace("{value2}",u?f[1]:f);if(G(l))return u?l(e[0],e[1]):l(e);if(u)return e[0]===s[0]?a[0]+" "+f[1]:e[1]===s[1]?a[1]+" "+f[0]:f[0]+" - "+f[1];return f;function h(p){return p===s[0]?"min":p===s[1]?"max":(+p).toFixed(Math.min(o,20))}},t.prototype.resetExtent=function(){var e=this.option,i=PO([e.min,e.max]);this._dataExtent=i},t.prototype.getDataDimensionIndex=function(e){var i=this.option.dimension;if(i!=null)return e.getDimensionIndex(i);for(var a=e.dimensions,n=a.length-1;n>=0;n--){var o=a[n],s=e.getDimensionInfo(o);if(!s.isCalculationCoord)return s.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var e=this.ecModel,i=this.option,a={inRange:i.inRange,outOfRange:i.outOfRange},n=i.target||(i.target={}),o=i.controller||(i.controller={});tt(n,a),tt(o,a);var s=this.isCategory();l.call(this,n),l.call(this,o),u.call(this,n,"inRange","outOfRange"),f.call(this,o);function l(h){IO(i.color)&&!h.inRange&&(h.inRange={color:i.color.slice().reverse()}),h.inRange=h.inRange||{color:e.get("gradientColor")}}function u(h,p,c){var v=h[p],m=h[c];v&&!m&&(m=h[c]={},$w(v,function(d,g){if(Kt.isValidType(g)){var y=ch.get(g,"inactive",s);y!=null&&(m[g]=y,g==="color"&&!m.hasOwnProperty("opacity")&&!m.hasOwnProperty("colorAlpha")&&(m.opacity=[0,0]))}}))}function f(h){var p=(h.inRange||{}).symbol||(h.outOfRange||{}).symbol,c=(h.inRange||{}).symbolSize||(h.outOfRange||{}).symbolSize,v=this.get("inactiveColor"),m=this.getItemSymbol(),d=m||"roundRect";$w(this.stateList,function(g){var y=this.itemSize,_=h[g];_||(_=h[g]={color:s?v:[v]}),_.symbol==null&&(_.symbol=p&&Y(p)||(s?d:[d])),_.symbolSize==null&&(_.symbolSize=c&&Y(c)||(s?y[0]:[y[0],y[0]])),_.symbol=Qw(_.symbol,function(S){return S==="none"?d:S});var x=_.symbolSize;if(x!=null){var w=-1/0;LO(x,function(S){S>w&&(w=S)}),_.symbolSize=Qw(x,function(S){return RO(S,[0,w],[0,y[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(e){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(e){return null},t.prototype.getVisualMeta=function(e){return null},t.type="visualMap",t.dependencies=["series"],t.defaultOption={show:!0,z:4,seriesIndex:"all",min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",contentColor:"#5793f3",inactiveColor:"#aaa",borderWidth:0,padding:5,textGap:10,precision:0,textStyle:{color:"#333"}},t})(pt),yo=OO;var Jw=[20,140],NO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.optionUpdated=function(e,i){r.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual(function(a){a.mappingMethod="linear",a.dataExtent=this.getExtent()}),this._resetRange()},t.prototype.resetItemSize=function(){r.prototype.resetItemSize.apply(this,arguments);var e=this.itemSize;(e[0]==null||isNaN(e[0]))&&(e[0]=Jw[0]),(e[1]==null||isNaN(e[1]))&&(e[1]=Jw[1])},t.prototype._resetRange=function(){var e=this.getExtent(),i=this.option.range;!i||i.auto?(e.auto=1,this.option.range=e):O(i)&&(i[0]>i[1]&&i.reverse(),i[0]=Math.max(i[0],e[0]),i[1]=Math.min(i[1],e[1]))},t.prototype.completeVisualOption=function(){r.prototype.completeVisualOption.apply(this,arguments),b(this.stateList,function(e){var i=this.option.controller[e].symbolSize;i&&i[0]!==i[1]&&(i[0]=i[1]/3)},this)},t.prototype.setSelected=function(e){this.option.range=e.slice(),this._resetRange()},t.prototype.getSelected=function(){var e=this.getExtent(),i=ke((this.get("range")||[]).slice());return i[0]>e[1]&&(i[0]=e[1]),i[1]>e[1]&&(i[1]=e[1]),i[0]=a[1]||e<=i[1])?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(e){var i=[];return this.eachTargetSeries(function(a){var n=[],o=a.getData();o.each(this.getDataDimensionIndex(o),function(s,l){e[0]<=s&&s<=e[1]&&n.push(l)},this),i.push({seriesId:a.id,dataIndex:n})},this),i},t.prototype.getVisualMeta=function(e){var i=tT(this,"outOfRange",this.getExtent()),a=tT(this,"inRange",this.option.range.slice()),n=[];function o(c,v){n.push({value:c,color:e(c,v)})}for(var s=0,l=0,u=a.length,f=i.length;le[1])break;n.push({color:this.getControllerVisual(l,"color",i),offset:s/a})}return n.push({color:this.getControllerVisual(e[1],"color",i),offset:1}),n},t.prototype._createBarPoints=function(e,i){var a=this.visualMapModel.itemSize;return[[a[0]-i[0],e[0]],[a[0],e[0]],[a[0],e[1]],[a[0]-i[1],e[1]]]},t.prototype._createBarGroup=function(e){var i=this._orient,a=this.visualMapModel.get("inverse");return new ft(i==="horizontal"&&!a?{scaleX:e==="bottom"?1:-1,rotation:Math.PI/2}:i==="horizontal"&&a?{scaleX:e==="bottom"?-1:1,rotation:-Math.PI/2}:i==="vertical"&&!a?{scaleX:e==="left"?1:-1,scaleY:-1}:{scaleX:e==="left"?1:-1})},t.prototype._updateHandle=function(e,i){if(this._useHandle){var a=this._shapes,n=this.visualMapModel,o=a.handleThumbs,s=a.handleLabels,l=n.itemSize,u=n.getExtent();kO([0,1],function(f){var h=o[f];h.setStyle("fill",i.handlesColor[f]),h.y=e[f];var p=Wr(e[f],[0,l[1]],u,!0),c=this.getControllerVisual(p,"symbolSize");h.scaleX=h.scaleY=c/l[0],h.x=l[0]-c/2;var v=Sr(a.handleLabelPoints[f],ai(h,this.group));s[f].setStyle({x:v[0],y:v[1],text:n.formatValueText(this._dataInterval[f]),verticalAlign:"middle",align:this._orient==="vertical"?this._applyTransform("left",a.mainGroup):"center"})},this)}},t.prototype._showIndicator=function(e,i,a,n){var o=this.visualMapModel,s=o.getExtent(),l=o.itemSize,u=[0,l[1]],f=this._shapes,h=f.indicator;if(h){h.attr("invisible",!1);var p={convertOpacityToAlpha:!0},c=this.getControllerVisual(e,"color",p),v=this.getControllerVisual(e,"symbolSize"),m=Wr(e,s,u,!0),d=l[0]-v/2,g={x:h.x,y:h.y};h.y=m,h.x=d;var y=Sr(f.indicatorLabelPoint,ai(h,this.group)),_=f.indicatorLabel;_.attr("invisible",!1);var x=this._applyTransform("left",f.mainGroup),w=this._orient,S=w==="horizontal";_.setStyle({text:(a||"")+o.formatValueText(i),verticalAlign:S?x:"middle",align:S?"center":x});var T={x:d,y:m,style:{fill:c}},M={style:{x:y[0],y:y[1]}};if(o.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var D={duration:100,easing:"cubicInOut",additive:!0};h.x=g.x,h.y=g.y,h.animateTo(T,D),_.animateTo(M,D)}else h.attr(T),_.attr(M);this._firstShowIndicator=!1;var A=this._shapes.handleLabels;if(A)for(var C=0;Co[1]&&(h[1]=1/0),i&&(h[0]===-1/0?this._showIndicator(f,h[1],"< ",l):h[1]===1/0?this._showIndicator(f,h[0],"> ",l):this._showIndicator(f,f,"\u2248 ",l));var p=this._hoverLinkDataIndices,c=[];(i||oT(a))&&(c=this._hoverLinkDataIndices=a.findTargetDataIndices(h));var v=qg(p,c);this._dispatchHighDown("downplay",_o(v[0],a)),this._dispatchHighDown("highlight",_o(v[1],a))}},t.prototype._hoverLinkFromSeriesMouseOver=function(e){var i;if(hi(e.target,function(l){var u=ut(l);if(u.dataIndex!=null)return i=u,!0},!0),!!i){var a=this.ecModel.getSeriesByIndex(i.seriesIndex),n=this.visualMapModel;if(n.isTargetSeries(a)){var o=a.getData(i.dataType),s=o.getStore().get(n.getDataDimensionIndex(o),i.dataIndex);isNaN(s)||this._showIndicator(s,s)}}},t.prototype._hideIndicator=function(){var e=this._shapes;e.indicator&&e.indicator.attr("invisible",!0),e.indicatorLabel&&e.indicatorLabel.attr("invisible",!0);var i=this._shapes.handleLabels;if(i)for(var a=0;a=0&&(n.dimension=o,i.push(n))}}),r.getData().setVisual("visualMeta",i)}}];function HO(r,t,e,i){for(var a=t.targetVisuals[i],n=Kt.prepareVisualTypes(a),o={color:nf(r.getData(),"color")},s=0,l=n.length;s0:t.splitNumber>0)||t.calculable)?"continuous":"piecewise"}),r.registerAction(uT,fT),b(hT,function(t){r.registerVisual(r.PRIORITY.VISUAL.COMPONENT,t)}),r.registerPreprocessor(Tm))}function vT(r){r.registerComponentModel(eT),r.registerComponentView(lT),dl(r)}var GO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e._pieceList=[],e}return t.prototype.optionUpdated=function(e,i){r.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var a=this._mode=this._determineMode();this._pieceList=[],WO[this._mode].call(this,this._pieceList),this._resetSelected(e,i);var n=this.option.categories;this.resetVisual(function(o,s){a==="categories"?(o.mappingMethod="category",o.categories=Y(n)):(o.dataExtent=this.getExtent(),o.mappingMethod="piecewise",o.pieceList=k(this._pieceList,function(l){return l=Y(l),s!=="inRange"&&(l.visual=null),l}))})},t.prototype.completeVisualOption=function(){var e=this.option,i={},a=Kt.listVisualTypes(),n=this.isCategory();b(e.pieces,function(s){b(a,function(l){s.hasOwnProperty(l)&&(i[l]=1)})}),b(i,function(s,l){var u=!1;b(this.stateList,function(f){u=u||o(e,f,l)||o(e.target,f,l)},this),!u&&b(this.stateList,function(f){(e[f]||(e[f]={}))[l]=ch.get(l,f==="inRange"?"active":"inactive",n)})},this);function o(s,l,u){return s&&s[l]&&s[l].hasOwnProperty(u)}r.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(e,i){var a=this.option,n=this._pieceList,o=(i?a:e).selected||{};if(a.selected=o,b(n,function(l,u){var f=this.getSelectedMapKey(l);o.hasOwnProperty(f)||(o[f]=!0)},this),a.selectedMode==="single"){var s=!1;b(n,function(l,u){var f=this.getSelectedMapKey(l);o[f]&&(s?o[f]=!1:s=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get("itemSymbol")},t.prototype.getSelectedMapKey=function(e){return this._mode==="categories"?e.value+"":e.index+""},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var e=this.option;return e.pieces&&e.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},t.prototype.setSelected=function(e){this.option.selected=Y(e)},t.prototype.getValueState=function(e){var i=Kt.findPieceIndex(e,this._pieceList);return i!=null&&this.option.selected[this.getSelectedMapKey(this._pieceList[i])]?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(e){var i=[],a=this._pieceList;return this.eachTargetSeries(function(n){var o=[],s=n.getData();s.each(this.getDataDimensionIndex(s),function(l,u){var f=Kt.findPieceIndex(l,a);f===e&&o.push(u)},this),i.push({seriesId:n.id,dataIndex:o})},this),i},t.prototype.getRepresentValue=function(e){var i;if(this.isCategory())i=e.value;else if(e.value!=null)i=e.value;else{var a=e.interval||[];i=a[0]===-1/0&&a[1]===1/0?0:(a[0]+a[1])/2}return i},t.prototype.getVisualMeta=function(e){if(this.isCategory())return;var i=[],a=["",""],n=this;function o(f,h){var p=n.getRepresentValue({interval:f});h||(h=n.getValueState(p));var c=e(p,h);f[0]===-1/0?a[0]=c:f[1]===1/0?a[1]=c:i.push({value:f[0],color:c},{value:f[1],color:c})}var s=this._pieceList.slice();if(!s.length)s.push({interval:[-1/0,1/0]});else{var l=s[0].interval[0];l!==-1/0&&s.unshift({interval:[-1/0,l]}),l=s[s.length-1].interval[1],l!==1/0&&s.push({interval:[l,1/0]})}var u=-1/0;return b(s,function(f){var h=f.interval;h&&(h[0]>u&&o([u,h[0]],"outOfRange"),o(h.slice()),u=h[1])},this),{stops:i,outerColors:a}},t.type="visualMap.piecewise",t.defaultOption=nr(yo.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0}),t})(yo),WO={splitNumber:function(r){var t=this.option,e=Math.min(t.precision,20),i=this.getExtent(),a=t.splitNumber;a=Math.max(parseInt(a,10),1),t.splitNumber=a;for(var n=(i[1]-i[0])/a;+n.toFixed(e)!==n&&e<5;)e++;t.precision=e,n=+n.toFixed(e),t.minOpen&&r.push({interval:[-1/0,i[0]],close:[0,0]});for(var o=0,s=i[0];o","\u2265"][i[0]]];e.text=e.text||this.formatValueText(e.value!=null?e.value:e.interval,!1,a)},this)}};function dT(r,t){var e=r.inverse;(r.orient==="vertical"?!e:e)&&t.reverse()}var mT=GO;var YO=(function(r){I(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.doRender=function(){var e=this.group;e.removeAll();var i=this.visualMapModel,a=i.get("textGap"),n=i.textStyleModel,o=n.getFont(),s=n.getTextColor(),l=this._getItemAlign(),u=i.itemSize,f=this._getViewData(),h=f.endsText,p=Dr(i.get("showLabel",!0),!h);h&&this._renderEndsText(e,h[0],u,p,l),b(f.viewPieceList,function(c){var v=c.piece,m=new ft;m.onclick=H(this._onItemClick,this,v),this._enableHoverLink(m,c.indexInModelPieceList);var d=i.getRepresentValue(v);if(this._createItemSymbol(m,d,[0,0,u[0],u[1]]),p){var g=this.visualMapModel.getValueState(d);m.add(new vt({style:{x:l==="right"?-a:u[0]+a,y:u[1]/2,text:v.text,verticalAlign:"middle",align:l,font:o,fill:s,opacity:g==="outOfRange"?.5:1}}))}e.add(m)},this),h&&this._renderEndsText(e,h[1],u,p,l),si(i.get("orient"),e,i.get("itemGap")),this.renderBackground(e),this.positionGroup(e)},t.prototype._enableHoverLink=function(e,i){var a=this;e.on("mouseover",function(){return n("highlight")}).on("mouseout",function(){return n("downplay")});var n=function(o){var s=a.visualMapModel;s.option.hoverLink&&a.api.dispatchAction({type:o,batch:_o(s.findTargetDataIndices(i),s)})}},t.prototype._getItemAlign=function(){var e=this.visualMapModel,i=e.option;if(i.orient==="vertical")return vh(e,this.api,e.itemSize);var a=i.align;return(!a||a==="auto")&&(a="left"),a},t.prototype._renderEndsText=function(e,i,a,n,o){if(i){var s=new ft,l=this.visualMapModel.textStyleModel;s.add(new vt({style:Zt(l,{x:n?o==="right"?a[0]:0:a[0]/2,y:a[1]/2,verticalAlign:"middle",align:n?o:"center",text:i})})),e.add(s)}},t.prototype._getViewData=function(){var e=this.visualMapModel,i=k(e.getPieceList(),function(s,l){return{piece:s,indexInModelPieceList:l}}),a=e.get("text"),n=e.get("orient"),o=e.get("inverse");return(n==="horizontal"?o:!o)?i.reverse():a&&(a=a.slice().reverse()),{viewPieceList:i,endsText:a}},t.prototype._createItemSymbol=function(e,i,a){e.add(Vt(this.getControllerVisual(i,"symbol"),a[0],a[1],a[2],a[3],this.getControllerVisual(i,"color")))},t.prototype._onItemClick=function(e){var i=this.visualMapModel,a=i.option,n=a.selectedMode;if(n){var o=Y(a.selected),s=i.getSelectedMapKey(e);n==="single"||n===!0?(o[s]=!0,b(o,function(l,u){o[u]=u===s})):o[s]=!o[s],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:o})}},t.type="visualMap.piecewise",t})(ph),gT=YO;function yT(r){r.registerComponentModel(mT),r.registerComponentView(gT),dl(r)}function Mm(r){Bt(vT),Bt(yT)}function _T(r,t,e){var i=$t.createCanvas(),a=t.getWidth(),n=t.getHeight(),o=i.style;return o&&(o.position="absolute",o.left="0",o.top="0",o.width=a+"px",o.height=n+"px",i.setAttribute("data-zr-dom-id",r)),i.width=a*e,i.height=n*e,i}var ZO=(function(r){I(t,r);function t(e,i,a){var n=r.call(this)||this;n.motionBlur=!1,n.lastFrameAlpha=.7,n.dpr=1,n.virtual=!1,n.config={},n.incremental=!1,n.zlevel=0,n.maxRepaintRectCount=5,n.__dirty=!0,n.__firstTimePaint=!0,n.__used=!1,n.__drawIndex=0,n.__startIndex=0,n.__endIndex=0,n.__prevStartIndex=null,n.__prevEndIndex=null;var o;a=a||ca,typeof e=="string"?o=_T(e,i,a):F(e)&&(o=e,e=o.id),n.id=e,n.dom=o;var s=o.style;return s&&(Do(o),o.onselectstart=function(){return!1},s.padding="0",s.margin="0",s.borderWidth="0"),n.painter=i,n.dpr=a,n}return t.prototype.getElementCount=function(){return this.__endIndex-this.__startIndex},t.prototype.afterBrush=function(){this.__prevStartIndex=this.__startIndex,this.__prevEndIndex=this.__endIndex},t.prototype.initContext=function(){this.ctx=this.dom.getContext("2d"),this.ctx.dpr=this.dpr},t.prototype.setUnpainted=function(){this.__firstTimePaint=!0},t.prototype.createBackBuffer=function(){var e=this.dpr;this.domBack=_T("back-"+this.id,this.painter,e),this.ctxBack=this.domBack.getContext("2d"),e!==1&&this.ctxBack.scale(e,e)},t.prototype.createRepaintRects=function(e,i,a,n){if(this.__firstTimePaint)return this.__firstTimePaint=!1,null;var o=[],s=this.maxRepaintRectCount,l=!1,u=new J(0,0,0,0);function f(y){if(!(!y.isFinite()||y.isZero()))if(o.length===0){var _=new J(0,0,0,0);_.copy(y),o.push(_)}else{for(var x=!1,w=1/0,S=0,T=0;T=s)}}for(var h=this.__startIndex;h15)break}}P.prevElClipPaths&&g.restore()};if(y)if(y.length===0)M=d.__endIndex;else for(var A=c.dpr,C=0;C0&&t>a[0]){for(l=0;lt);l++);s=i[a[l]]}if(a.splice(l+1,0,t),i[t]=e,!e.virtual)if(s){var u=s.dom;u.nextSibling?o.insertBefore(e.dom,u.nextSibling):o.appendChild(e.dom)}else o.firstChild?o.insertBefore(e.dom,o.firstChild):o.appendChild(e.dom);e.painter||(e.painter=this)}},r.prototype.eachLayer=function(t,e){for(var i=this._zlevelList,a=0;a0?mh:0),this._needsManuallyCompositing),f.__builtin__||$i("ZLevel "+u+" has been used by unkown layer "+f.id),f!==n&&(f.__used=!0,f.__startIndex!==l&&(f.__dirty=!0),f.__startIndex=l,f.incremental?f.__drawIndex=-1:f.__drawIndex=l,e(l),n=f),a.__dirty&Ht&&!a.__inHover&&(f.__dirty=!0,f.incremental&&f.__drawIndex<0&&(f.__drawIndex=l))}e(l),this.eachBuiltinLayer(function(h,p){!h.__used&&h.getElementCount()>0&&(h.__dirty=!0,h.__startIndex=h.__endIndex=h.__drawIndex=0),h.__dirty&&h.__drawIndex<0&&(h.__drawIndex=h.__startIndex)})},r.prototype.clear=function(){return this.eachBuiltinLayer(this._clearLayer),this},r.prototype._clearLayer=function(t){t.clear()},r.prototype.setBackgroundColor=function(t){this._backgroundColor=t,b(this._layers,function(e){e.setUnpainted()})},r.prototype.configLayer=function(t,e){if(e){var i=this._layerConfig;i[t]?tt(i[t],e,!0):i[t]=e;for(var a=0;a + + + + + + + + + +
+

+
· · +
+ +

+
+
+

+

+

+ + +

+

+

+ +
+ +

+
+ +

+
+ + + +
agentproviderTTFT
+
+
+ + + + + diff --git a/packages/page-usage-board/test/aggregate.test.mjs b/packages/page-usage-board/test/aggregate.test.mjs new file mode 100644 index 0000000..9b35a57 --- /dev/null +++ b/packages/page-usage-board/test/aggregate.test.mjs @@ -0,0 +1,39 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { aggregateAttribution } from '../server.mjs'; + +const now = new Date(); +const iso = (msAgo) => new Date(now.getTime() - msAgo).toISOString(); + +test('filters attribution by caller but keeps the caller breakdown', async () => { + const rows = [ + { t: iso(0), callerKeyName: 'cloud', provider: 'codearts', providerAccount: 'a', in: 10, out: 5, cache_read: 1, status: 200, ttft_ms: 100, ms: 200 }, + { t: iso(2 * 3600e3), callerKeyName: 'Magpie', provider: 'trae-cn', providerAccount: 'b', in: 20, out: 10, status: 500, ttft_ms: 0, ms: 0 }, + { t: iso(0), callerKeyName: 'hermes', provider: 'nvidia', providerAccount: 'c', in: 1, out: 1, status: 200, ttft_ms: 50, ms: 60 }, + { t: iso(10 * 86400e3), callerKeyName: 'cloud', provider: 'old-provider', providerAccount: 'd', in: 1, out: 1, status: 200, ttft_ms: 10, ms: 10 }, + ]; + const d = await aggregateAttribution(rows, { period: '7d', days: 7, callers: ['cloud', 'Magpie'], source: 'remote' }); + + assert.equal(d.source, 'remote'); + assert.deepEqual(d.callers, ['cloud', 'Magpie']); + assert.equal(d.totals.calls, 2); + assert.equal(d.totals.errors, 1); + assert.equal(d.totals.input, 30); + assert.equal(d.totals.output, 15); + assert.deepEqual(d.providers.map((p) => p.provider).sort(), ['codearts', 'trae-cn']); + assert.deepEqual(d.accounts.map((a) => a.account).sort(), ['a', 'b']); + // hermes is excluded from the device's charts but still shown in the caller breakdown + assert.deepEqual(d.callerBreakdown.map((c) => c.name).sort(), ['Magpie', 'cloud', 'hermes']); + assert.equal(d.callerBreakdown.find((c) => c.name === 'hermes').calls, 1); + // 10 days old is outside a 7-day window + assert.equal(d.providers.some((p) => p.provider === 'old-provider'), false); + // hourly is caller-filtered too (2 calls: cloud + Magpie, not hermes); rows are {hour, r:{...}} + assert.equal(d.hourly.reduce((s, h) => s + h.r.calls, 0), 2); + assert.ok(d.days.length >= 1); +}); + +test('local source is marked so the page can hide remote cards', async () => { + const d = await aggregateAttribution([], { period: '7d', days: 7, callers: [], source: 'local' }); + assert.equal(d.source, 'local'); + assert.equal(d.totals.calls, 0); +}); diff --git a/packages/page-usage-board/test/server.test.mjs b/packages/page-usage-board/test/server.test.mjs new file mode 100644 index 0000000..a2bcce8 --- /dev/null +++ b/packages/page-usage-board/test/server.test.mjs @@ -0,0 +1,630 @@ +import { test, before, after } from 'node:test'; +import assert from 'node:assert/strict'; +import { spawn, spawnSync } from 'node:child_process'; +import net from 'node:net'; +import { mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'; +import http from 'node:http'; +import os from 'node:os'; +import path from 'node:path'; +import { fileURLToPath, pathToFileURL } from 'node:url'; + +// 所有路径都从本测试文件定位(root bun test 从仓库根跑时 cwd 不同也能工作); +// 子进程一律 -e + 绝对 URL 导入;端口一律临时申请,不用固定口。 +// spawn 目标:本测试在 bun test 下也会被跑(社区根仓库 bun test 扫全部包), +// 子进程一律 spawn process.execPath(bun test 下就是 bun——magpie 宿主也正是用 bun 跑 +// server.mjs 的;node --test 下就是 node)。绝不按名字 spawn "node":根仓库 bun test +// 所有包共用一个进程,某些包的测试会清空 process.env.PATH(gcp-ai),按名字找可执行 +// 文件会 "Executable not found"。内联脚本的 -e 子进程改为写临时 .mjs 文件——bun 的 -e +// 兼容性不承诺,文件形式两种运行时行为一致。 +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const RUNTIME = process.execPath; +const SERVER_URL = pathToFileURL(path.join(root, 'server.mjs')).href; +const INDEX_URL = pathToFileURL(path.join(root, 'index.mjs')).href; +const TEST_KEY = 'test-page-key'; +let tmp; +let child; +let port; +let publicChild; +let publicPort; + +const baseEnv = (dir = os.tmpdir()) => ({ + ...process.env, + PAGE_KEY: TEST_KEY, + USAGE_JSONL: path.join(dir, 'usage.jsonl'), + GATEWAY: 'http://127.0.0.1:9', + ATTRIBUTION: 'local', + MAGPIE_PROVIDERS: path.join(dir, 'no-providers.json'), + MAGPIE_PROVIDERS_FILE: path.join(dir, 'no-plugin-providers.json'), +}); + +// 内联脚本子进程:代码写进临时 .mjs 文件再跑(跨 node/bun 一致),结束即清理。 +// 返回 { code, out };killMs 到点强杀防止挂死 runner。 +function spawnChild(code, env, killMs = 25000) { + return new Promise((resolve) => { + const dir = mkdtempSync(path.join(os.tmpdir(), 'usage-board-child-')); + const file = path.join(dir, 'child.mjs'); + writeFileSync(file, code); + const c = spawn(RUNTIME, [file], { env, stdio: ['ignore', 'pipe', 'pipe'] }); + let out = ''; + c.stdout.on('data', (d) => { out += d; }); + c.stderr.on('data', (d) => { out += d; }); + const t = setTimeout(() => c.kill('SIGKILL'), killMs); + c.once('close', (code2) => { + clearTimeout(t); + try { rmSync(dir, { recursive: true, force: true }); } catch {} + resolve({ code: code2, out }); + }); + }); +} + +function start(extra = {}) { + const dir = mkdtempSync(path.join(os.tmpdir(), 'usage-board-')); + writeFileSync(path.join(dir, 'usage.jsonl'), ''); + const c = spawn(RUNTIME, [path.join(root, 'server.mjs')], { + env: { ...baseEnv(dir), HOST: '127.0.0.1', PORT: '0', ...extra }, + stdio: ['ignore', 'pipe', 'pipe'], + }); + const captured = { out: '' }; // 子进程完整 stdout+stderr,供启动日志断言 + const ready = new Promise((resolve, reject) => { + const timer = setTimeout(() => reject(new Error('server did not start')), 10000); + c.stdout.on('data', (d) => { + captured.out += d.toString(); + const m = captured.out.match(/listening on http:\/\/127\.0\.0\.1:(\d+)\//); + if (m) { clearTimeout(timer); resolve(Number(m[1])); } + }); + c.stderr.on('data', (d) => { captured.out += d.toString(); }); + c.once('exit', (code) => { clearTimeout(timer); reject(new Error(`server exited ${code}: ${captured.out}`)); }); + }); + return { c, dir, ready, captured }; +} + +function request(atPort, pathname, { headers = {}, method = 'GET' } = {}) { + return new Promise((resolve, reject) => { + const r = http.request({ + host: '127.0.0.1', + port: atPort, + path: pathname, + method, + headers: { Host: `127.0.0.1:${atPort}`, ...headers }, + }, (res) => { + let body = ''; + res.setEncoding('utf8'); + res.on('data', (d) => { body += d; }); + res.on('end', () => resolve({ status: res.statusCode, headers: res.headers, body })); + }); + r.on('error', reject); + r.end(); + }); +} + +async function waitFor(cond, ms = 3000) { + const end = Date.now() + ms; + while (!cond()) { + if (Date.now() > end) return; + await new Promise((r) => setTimeout(r, 25)); + } +} + +// 申请一个当前空闲的端口:bind 0 → 记下端口 → 立刻关闭(测试进程间传递用) +function freePort() { + return new Promise((resolve, reject) => { + const s = net.createServer(); + s.once('error', reject); + s.listen(0, '127.0.0.1', () => { + const p = s.address().port; + s.close(() => resolve(p)); + }); + }); +} + +let mainLog; +before(async () => { + const s = start(); + child = s.c; + tmp = s.dir; + mainLog = s.captured; + port = await s.ready; +}); + +after(() => { + child?.kill(); + publicChild?.kill(); + try { rmSync(tmp, { recursive: true, force: true }); } catch {} +}); + +test('rejects a foreign Host header (DNS rebinding)', async () => { + const r = await request(port, '/api/ping', { headers: { Host: 'evil.example' } }); + assert.equal(r.status, 403); +}); + +test('accepts a loopback Host with a mapped port (reverse proxy / tunnel)', async () => { + // 回环名不看端口:反代/隧道发布口与服务监听口可以不同,rebinding 威胁在域名 + const r = await request(port, '/api/ping', { headers: { Host: `127.0.0.1:${port + 1}` } }); + assert.equal(r.status, 200); +}); + +test('rejects a non-loopback Host with the wrong port', async () => { + const lan = Object.values(os.networkInterfaces()).flat() + .find((a) => a && !a.internal && a.family === 'IPv4' && a.address); + if (!lan) return; // 无局域网地址的环境(部分 CI 容器)跳过端口分支 + const r = await request(port, '/api/ping', { headers: { Host: `${lan}:${port + 1}` } }); + assert.equal(r.status, 403); +}); + +test('a malformed request target is answered 400 and the process survives', async () => { + // GET // 让 new URL 抛 Invalid URL:必须拿到 4xx,且进程不退出(P0 回归测试) + const r = await request(port, '//'); + assert.equal(r.status, 400); + const h = await request(port, '/api/health'); + assert.equal(h.status, 200); +}); + +test('startup logs never contain the page key and never offer ?key=', async () => { + // 等 finish2 的 open 行写出后再断言(listening 行先到,open 行同 tick 跟随) + await waitFor(() => mainLog.out.includes('[magpie-usage] open ')); + assert.doesNotMatch(mainLog.out, /\?key=/); + assert.ok(!mainLog.out.includes(TEST_KEY), 'startup log leaked the page key'); +}); + +test('instance fingerprint stays anonymous but carries the build id', async () => { + const r = await request(port, '/api/ping'); + assert.equal(r.status, 200); + const j = JSON.parse(r.body); + assert.equal(j.service, 'magpie-usage-board'); + assert.equal(j.ok, true); + assert.match(j.build, /^[0-9a-f]{16}$/); + assert.ok(j.version); +}); + +test('API needs the token', async () => { + const r = await request(port, '/api/overview'); + assert.equal(r.status, 401); +}); + +test('the key never works from a URL (?key= is gone)', async () => { + // key 一旦进 URL 就会落进代理日志/浏览器历史——查询串鉴权必须彻底无效 + const r = await request(port, `/api/overview?key=${TEST_KEY}`); + assert.equal(r.status, 401); +}); + +test('the key never works from a cookie', async () => { + const r = await request(port, '/api/overview', { headers: { Cookie: `dk=${TEST_KEY}` } }); + assert.equal(r.status, 401); +}); + +test('API accepts the token from the x-dash-key header', async () => { + // Gateway is intentionally unreachable: passing auth yields 200 with local data + a + // visible note (the gateway failure must not take the local aggregation down with it). + const r = await request(port, '/api/overview', { headers: { 'x-dash-key': TEST_KEY } }); + assert.equal(r.status, 200); + const d = JSON.parse(r.body); + assert.equal(d.usage, null); + assert.match(d.note, /usage API/); + assert.equal(d.detail.error, undefined); // ENOENT(空日志)= 空态,不是读取失败 +}); + +test('the loopback page serves without a URL token and injects one', async () => { + const r = await request(port, '/'); + assert.equal(r.status, 200); + assert.match(r.body, /window\.__KEY__=/); + assert.match(r.body, new RegExp(`window\\.__KEY__="${TEST_KEY}"`)); + assert.match(r.body, /window\.__DATA__=/); + assert.equal(r.headers.location, undefined); +}); + +test('the page CSP lists the loopback explicitly and no third-party hosts', async () => { + const r = await request(port, '/'); + assert.equal(r.status, 200); + const csp = String(r.headers['content-security-policy']); + assert.match(csp, /default-src 'self'/); + assert.match(csp, new RegExp(`connect-src 'self' http://127\\.0\\.0\\.1:${port}`)); + // frame-ancestors 显式声明(* = 被宿主嵌入是设计意图;宿主 origin 桌面/web 不固定) + assert.match(csp, /frame-ancestors/); + assert.doesNotMatch(csp, /cloudflareinsights/); + assert.equal(r.headers['referrer-policy'], 'no-referrer'); +}); + +test('a sandboxed frame (Origin: null) may fetch the page', async () => { + const r = await request(port, '/', { headers: { Origin: 'null' } }); + assert.equal(r.status, 200); +}); + +test('a cross-origin fetch of the page is refused', async () => { + const r = await request(port, '/', { headers: { Origin: 'https://evil.example' } }); + assert.equal(r.status, 403); +}); + +test('CORS allows only the exact bound port, not any localhost port', async () => { + const r = await request(port, '/api/attribution', { headers: { Origin: `http://127.0.0.1:${port + 1}` } }); + assert.equal(r.status, 403); + const ok = await request(port, '/api/attribution', { headers: { Origin: `http://127.0.0.1:${port}` } }); + assert.equal(ok.status, 401); // CORS 放行、鉴权照拦——链路各管各的 +}); + +test('attribution stays local unless the user opts in', { timeout: 30000 }, async () => { + // 维护者复审点:护栏必须真的能拦住默认值被改坏——这里**不能**继承 baseEnv 的 + // ATTRIBUTION:'local',否则有人把服务端默认改成 remote 时本测试仍绿。 + // extra 里显式设 undefined → Node spawn 会把它从子进程环境里省掉,服务端走默认值; + // REMOTE_BASE/KEY 虽然没配,但默认值若是 remote,remoteSources() 就不再为空,source 会变。 + const s = start({ ATTRIBUTION: undefined, REMOTE_BASE: 'https://remote.example', REMOTE_KEY: 'k' }); + try { + const p = await s.ready; + const r = await request(p, '/api/attribution?period=7d', { headers: { 'x-dash-key': TEST_KEY } }); + assert.equal(r.status, 200); + const j = JSON.parse(r.body); + assert.equal(j.source, 'local'); + assert.equal(j.totals.calls, 0); + } finally { + s.c.kill(); + try { rmSync(s.dir, { recursive: true, force: true }); } catch {} + } +}); + +test('the gateway follows options, env and MAGPIE_ADDR, not a hard-coded port', { timeout: 30000 }, async () => { + // 维护者实测:宿主把 MAGPIE_ADDR 指到(可能被改过端口的)真实网关——看板必须问它, + // 而不是写死的 3425。解析链:options.gateway → GATEWAY → MAGPIE_GATEWAY → + // MAGPIE_ADDR → 3425。fake 网关必须在整个测试的 finally 里关掉:断言一失败就 + // close,否则它的监听 socket 会把 node --test 的进程挂死。 + const fake = http.createServer((req, res) => { + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ calls: 123, tokens: 456, cost: 7.89 })); + }); + await new Promise((resolve) => fake.listen(0, '127.0.0.1', resolve)); + const gwPort = fake.address().port; + try { + // 1) MAGPIE_ADDR 单独生效(宿主场景) + const s1 = start({ + MAGPIE_ADDR: `0.0.0.0:${gwPort}`, // 宿主可能写成通配地址,服务端要归一化成回环 + GATEWAY: undefined, + MAGPIE_GATEWAY: undefined, + }); + try { + const p1 = await s1.ready; + assert.match(s1.captured.out, new RegExp(`gateway=http://127\\.0\\.0\\.1:${gwPort}\\b`)); + const r1 = await request(p1, '/api/overview', { headers: { 'x-dash-key': TEST_KEY } }); + assert.equal(r1.status, 200); + const j1 = JSON.parse(r1.body); + assert.equal(j1.usage.calls, 123); // 请求打到了 MAGPIE_ADDR 指向的网关 + } finally { + s1.c.kill(); + try { rmSync(s1.dir, { recursive: true, force: true }); } catch {} + } + // 2) 显式 GATEWAY 优先于 MAGPIE_ADDR + const s2 = start({ MAGPIE_ADDR: '127.0.0.1:1' }); + try { + await s2.ready; + assert.match(s2.captured.out, /gateway=http:\/\/127\.0\.0\.1:9\b/); // baseEnv 的 GATEWAY 赢了 + assert.doesNotMatch(s2.captured.out, /gateway=http:\/\/127\.0\.0\.1:1\b/); + } finally { + s2.c.kill(); + try { rmSync(s2.dir, { recursive: true, force: true }); } catch {} + } + } finally { + fake.close(() => {}); + } +}); + +test('[::1] in MAGPIE_ADDR stays IPv6 loopback, never 127.0.0.1', { timeout: 30000 }, async () => { + // 只有 unspecified(0.0.0.0/[::])才映射回环;[::1] 是明确的 IPv6 回环,监听在 [::1] + // 的网关通常没有监听 127.0.0.1——改写会把请求打到空处(维护者复审实测)。 + let hits = 0; + const fake6 = http.createServer((req, res) => { + hits++; + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ calls: 7, tokens: 8, cost: 9 })); + }); + const listening = await new Promise((resolve) => { + fake6.once('error', () => resolve(false)); // 无 IPv6 的环境(部分 CI 容器)跳过 + fake6.listen(0, '::1', () => resolve(true)); + }); + if (!listening) return; + const gwPort = fake6.address().port; + // 先探测本机的 IPv6 回环是否真的可连:某些平台(Windows 的 undici)监听 ::1 成功、 + // 但 fetch http://[::1] 会超时——那种环境只验证解析结果,不做端到端请求断言。 + let ipv6Reachable = true; + try { + await fetch(`http://[::1]:${gwPort}/probe`, { signal: AbortSignal.timeout(2000) }); + } catch { + ipv6Reachable = false; + } + hits = 0; // 探测命中了不计入 + const s = start({ MAGPIE_ADDR: `[::1]:${gwPort}`, GATEWAY: undefined, MAGPIE_GATEWAY: undefined }); + try { + const p = await s.ready; + assert.match(s.captured.out, new RegExp(`gateway=http://\\[::1\\]:${gwPort}\\b`)); + assert.doesNotMatch(s.captured.out, new RegExp(`gateway=http://127\\.0\\.0\\.1:${gwPort}\\b`)); + if (ipv6Reachable) { + const r = await request(p, '/api/overview', { headers: { 'x-dash-key': TEST_KEY } }); + assert.equal(r.status, 200); + assert.equal(JSON.parse(r.body).usage.calls, 7); // 真的打到了 ::1 上的网关 + assert.ok(hits > 0, 'fake IPv6 gateway received no requests'); + } + } finally { + s.c.kill(); + try { rmSync(s.dir, { recursive: true, force: true }); } catch {} + fake6.close(() => {}); + } +}); + +test('config dir: the host cwd carrying magpie markers wins (portable installs)', { timeout: 30000 }, async () => { + // magpie 宿主以数据目录为 cwd 启动服务(bunCommand(..., settings.Dir(), ...))—— + // 便携安装因此不需要任何环境变量。不设 USAGE_JSONL,服务应通过 cwd 探测找到它。 + // 路径比较必须用 realpathSync:macOS 的 os.tmpdir() 是 /var/folders/…,而 /var 是指向 + // /private/var 的符号链接——子进程的 process.cwd() 与日志里的路径都是解析后的真实 + // 路径,拿未解析的 dataDir 拼字符串比会假红(维护者复审在 macOS 实测)。 + const dataDir = mkdtempSync(path.join(os.tmpdir(), 'usage-board-cwd-')); + writeFileSync(path.join(dataDir, 'usage.jsonl'), ''); + const realDir = realpathSync(dataDir); + const c = spawn(RUNTIME, [path.join(root, 'server.mjs')], { + cwd: realDir, + env: { + ...process.env, + PAGE_KEY: TEST_KEY, + GATEWAY: 'http://127.0.0.1:9', + ATTRIBUTION: 'local', + MAGPIE_PROVIDERS: path.join(realDir, 'no-providers.json'), + MAGPIE_PROVIDERS_FILE: path.join(realDir, 'no-plugin-providers.json'), + HOST: '127.0.0.1', + PORT: '0', + }, + stdio: ['ignore', 'pipe', 'pipe'], + }); + let out = ''; + c.stdout.on('data', (d) => { out += d; }); + c.stderr.on('data', (d) => { out += d; }); + await new Promise((resolve, reject) => { + const t = setTimeout(() => reject(new Error('server did not start: ' + out)), 10000); + c.stdout.on('data', (d) => { if (/listening/.test(d.toString())) { clearTimeout(t); resolve(); } }); + c.once('exit', (code) => { clearTimeout(t); reject(new Error('exited ' + code + ': ' + out)); }); + }); + try { + assert.ok( + out.includes('jsonl=' + path.join(realDir, 'usage.jsonl') + '(ok)'), + 'usage.jsonl resolved from cwd: ' + out.slice(0, 300), + ); + } finally { + c.kill(); + try { rmSync(dataDir, { recursive: true, force: true }); } catch {} + } +}); + +test('startServer({port: 0}) binds an ephemeral port, not the default', { timeout: 30000 }, async () => { + const r = await spawnChild(` + import(${JSON.stringify(SERVER_URL)}).then(async (m) => { + try { + const bound = await m.startServer({ port: 0 }); + if (bound === 3455 || bound === 0) throw new Error('expected an ephemeral port, got ' + bound); + const r = await fetch('http://127.0.0.1:' + bound + '/api/health'); + if (r.status !== 200) throw new Error('health ' + r.status); + console.log('EPHEMERAL-OK'); + process.exit(0); + } catch (e) { console.error('FAIL ' + (e && e.message || e)); process.exit(1); } + }); + `, { ...baseEnv(), HOST: '127.0.0.1' }); + assert.equal(r.code, 0, `child exit ${r.code}: ${r.out.slice(0, 300)}`); + assert.match(r.out, /EPHEMERAL-OK/); +}); + +test('path traversal stays inside static/', async () => { + for (const p of ['/static/../../server.mjs', '/..%2fserver.mjs', '/%2e%2e/server.mjs']) { + const r = await request(port, p); + assert.equal(r.status, 404, p); + assert.notEqual(r.body, readFileSync(path.join(root, 'server.mjs'), 'utf8')); + } +}); + +test('brand logos come from magpie, with zero network fetches', async () => { + // plugin-providers.json 里的 data URI 注入页面;https 图标一律不抓取(隐私红线) + const dir = mkdtempSync(path.join(os.tmpdir(), 'usage-board-logos-')); + const icon = 'data:image/svg+xml;base64,' + Buffer.from('').toString('base64'); + writeFileSync(path.join(dir, 'plugin-providers.json'), JSON.stringify({ + 0: { id: 'TestProv', icon }, + 1: { id: 'remote-brand', icon: 'https://cdn.example.com/favicon.svg' }, + })); + const s = start({ USAGE_JSONL: path.join(dir, 'usage.jsonl'), MAGPIE_PROVIDERS_FILE: path.join(dir, 'plugin-providers.json') }); + try { + const p = await s.ready; + const page = await request(p, '/'); + assert.equal(page.status, 200); + assert.ok(page.body.includes(icon), 'data-URI logo injected'); + assert.doesNotMatch(page.body, /cdn\.example\.com/); + assert.match(s.captured.out, /logos: 1 brands/); + } finally { + s.c.kill(); + try { rmSync(dir, { recursive: true, force: true }); } catch {} + } +}); + +test('a public bind never serves the board page at all', async () => { + const s = start({ HOST: '0.0.0.0', ALLOWED_HOSTS: 'dash.example' }); + publicChild = s.c; + publicPort = await s.ready; + // The proxy-style Host (with :443) is allowed by the explicit allowlist for APIs... + const ping = await request(publicPort, '/api/ping', { headers: { Host: 'dash.example:443' } }); + assert.equal(ping.status, 200); + // ...but the page is loopback-only: a remote visitor has no auth channel (?key= is gone). + const page = await request(publicPort, '/', { headers: { Host: 'dash.example:443' } }); + assert.equal(page.status, 403); + assert.equal(String(page.body || '').includes('__KEY__'), false); +}); + +test('HOST=:: is a wildcard bind, never treated as loopback (P0 regression)', async () => { + // '::' listens on all interfaces (dual-stack); treating it as loopback handed the + // key-injected page to anonymous visitors. It must behave like 0.0.0.0. + const s = start({ HOST: '::', ALLOWED_HOSTS: 'dash.example' }); + try { + const p = await s.ready; + const page = await request(p, '/', { headers: { Host: 'dash.example:443' } }); + assert.equal(page.status, 403); + assert.equal(String(page.body || '').includes('__KEY__'), false); + } finally { + s.c.kill(); + } +}); + +test('loopback bind with a public ALLOWED_HOSTS still gates the page (P1 regression)', async () => { + // A reverse proxy forwards the public Host name to a loopback-bound service; the + // page must answer loopback hosts only, never the proxied public name. + const s = start({ HOST: '127.0.0.1', ALLOWED_HOSTS: 'dash.example.com' }); + try { + const p = await s.ready; + const viaProxyHost = await request(p, '/', { headers: { Host: 'dash.example.com' } }); + assert.equal(viaProxyHost.status, 403); + assert.equal(String(viaProxyHost.body || '').includes('__KEY__'), false); + } finally { + s.c.kill(); + } +}); + +test('waits for a dying occupier on the target port, then binds it', async () => { + // 宿主重启竞态:上一代濒死实例短暂占着口——新实例必须等它退出后自己绑定, + // 而不是复用一个马上要死的实例(复用会让页面 502)。 + const p = await freePort(); + const occupier = net.createServer(() => {}); + await new Promise((resolve, reject) => { occupier.once('error', reject); occupier.listen(p, '127.0.0.1', resolve); }); + const code = ` + import(${JSON.stringify(SERVER_URL)}).then(async (m) => { + try { + const bound = await m.startServer(); + const r = await fetch('http://127.0.0.1:' + bound + '/api/health'); + if (r.status !== 200) throw new Error('health ' + r.status); + console.log('BOUND-AFTER-WAIT'); + process.exit(0); + } catch (e) { console.error('FAIL ' + (e && e.message || e)); process.exit(1); } + }); + `; + setTimeout(() => occupier.close(() => {}), 1200); // 1.2s 后释放端口(模拟濒死实例退出) + const r = await spawnChild(code, { ...baseEnv(), HOST: '127.0.0.1', PORT: String(p) }, 20000); + assert.equal(r.code, 0, `child exit ${r.code}: ${r.out.slice(0, 400)}`); + assert.match(r.out, /BOUND-AFTER-WAIT/); +}); + +test('reuses a live instance of the same build, never a different one', { timeout: 30000 }, async () => { + // 同构建 → 复用(resolve 端口、不重复绑定);异构建/异种 → 明确报错,绝不把看板 + // 交给一个未知进程。复用判定只认 /api/ping 的 BUILD_ID。子进程必须异步 spawn: + // spawnSync 会阻塞本进程事件循环,同进程里的 fake server 就无法应答探测了。 + // timeout:异构建分支要等服务端 8s deadline 才报错——超过 bun test 默认 5s(维护者复审点)。 + const code = ` + import(${JSON.stringify(SERVER_URL)}).then(async (m) => { + try { + const bound = await m.startServer(); + console.log('RESOLVED-' + bound); + process.exit(0); + } catch (e) { console.error('FAIL ' + (e && e.message || e)); process.exit(1); } + }); + `; + const p = await freePort(); + const first = start({ PORT: String(p) }); + try { + await first.ready; + const r = await spawnChild(code, { ...baseEnv(), HOST: '127.0.0.1', PORT: String(p) }, 20000); + assert.equal(r.code, 0, `child exit ${r.code}: ${r.out.slice(0, 400)}`); + assert.match(r.out, new RegExp(`RESOLVED-${p}`)); + // 异构建:伪装成同款服务但 build 不同 → 必须拒绝启动 + const p2 = await freePort(); + const fake = http.createServer((req, res) => { + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ service: 'magpie-usage-board', ok: true, build: 'deadbeefdeadbeef', version: '9.9.9' })); + }); + await new Promise((resolve) => fake.listen(p2, '127.0.0.1', resolve)); + const r2 = await spawnChild(code, { ...baseEnv(), HOST: '127.0.0.1', PORT: String(p2) }, 20000); + fake.close(() => {}); + assert.notEqual(r2.code, 0, 'a foreign build must not be accepted'); + assert.match(r2.out, /held by another build/); + } finally { + first.c.kill(); + try { rmSync(first.dir, { recursive: true, force: true }); } catch {} + } +}); + +test('index.mjs: importing has no side effects, server() starts and awaits listen', { timeout: 30000 }, async () => { + // The community import-check imports this file for inspection; a module-level + // startServer would grab a port and write config during that check. The child + // picks its own free port, sets PORT, then verifies import ≠ start, server() = start. + const code = ` + (async () => { + const net = await import('node:net'); + const free = await new Promise((res) => { + const s = new net.Server(); + s.listen(0, '127.0.0.1', () => { const p = s.address().port; s.close(() => res(p)); }); + }); + process.env.PORT = String(free); + const m = await import(${JSON.stringify(INDEX_URL)}); + await new Promise((r) => setTimeout(r, 800)); + try { await fetch('http://127.0.0.1:' + free + '/api/health'); console.error('FAIL: import started the service'); process.exit(1); } catch {} + const r0 = await m.default.server(); + if (!r0 || r0.port !== free) { console.error('FAIL: server() did not report the bound port: ' + JSON.stringify(r0)); process.exit(1); } + const r = await fetch('http://127.0.0.1:' + free + '/api/health'); + if (r.status !== 200) { console.error('FAIL: server() did not start the service'); process.exit(1); } + console.log('LIFECYCLE-OK'); + process.exit(0); + })(); + `; + const r = await spawnChild(code, baseEnv(), 20000); + assert.equal(r.code, 0, `child exit ${r.code}: ${r.out.slice(0, 400)}`); + assert.match(r.out, /LIFECYCLE-OK/); +}); + +test('the dashboard asks the local service for attribution', () => { + const html = readFileSync(path.join(root, 'static', 'index.html'), 'utf8'); + assert.match(html, /api\/attribution\?period=/); + assert.doesNotMatch(html, /remote\.js/); + assert.doesNotMatch(html, /cloudflareinsights/); +}); + +test('registry draft summary matches package.json verbatim (three-text rule)', () => { + const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')); + const doc = readFileSync(path.join(root, 'docs', 'community-submission.md'), 'utf8'); + // \r?\n:Windows 检出(core.autocrlf)下这份文件是 CRLF,写死 \n 会假红 + const block = doc.match(/```json\r?\n([\s\S]*?)```/); + assert.ok(block, 'registry json block present in community-submission.md'); + const reg = JSON.parse(block[1]); + assert.equal(reg.package, pkg.name); + assert.equal(reg.name, 'Usage Board'); + assert.equal(reg.summary.en, pkg.magpie.summary.en); + assert.equal(reg.summary.zh, pkg.magpie.summary.zh); +}); + +test('the lead page has no inline scripts and no key', () => { + const html = readFileSync(path.join(root, 'page', 'index.html'), 'utf8') + .replace(//g, ''); + for (const tag of html.match(/]*>/gi) || []) { + assert.match(tag, /src=/i); + } + assert.doesNotMatch(html, /[?&]key=/i); + assert.doesNotMatch(html, /fetch\(/i); // the sandboxed lead page fetches nothing + assert.match(html, /_magpie\/bridge\.js/); + assert.match(html, /boot\.js/); +}); + +test('boot prefers magpie.service, reads the port and theme from the bridge', () => { + const js = readFileSync(path.join(root, 'page', 'boot.js'), 'utf8'); + assert.match(js, /magpie\?\.service/); + assert.match(js, /options\?\.get\?\.\(\)/); + assert.match(js, /current\.dark/); // magpie 自己的深浅色 → ?theme= 传给看板 + assert.match(js, /theme/); + assert.match(js, /3455/); // manifest 声明的默认口(fallback,不再有写死的第二个来源) +}); + +test('the board page ships both languages', () => { + const html = readFileSync(path.join(root, 'static', 'index.html'), 'utf8'); + assert.match(html, /navigator\.language/); + assert.match(html, /\?lang=/); + assert.match(html, /T\s*=\s*\{\s*zh:/); + assert.match(html, /en:/); +}); + +test('package metadata matches the community page spec', () => { + const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')); + assert.equal(pkg.name, '@magpie-community/page-usage-board'); + assert.equal(pkg.license, 'MIT'); + assert.ok(pkg.files.includes('LICENSE')); + assert.ok(pkg.scripts.test); + assert.deepEqual(pkg.magpie.permissions, []); + assert.equal(pkg.magpie.page.file, 'page/index.html'); + assert.equal(pkg.magpie.page.service.port, 3455); + assert.equal(pkg.magpie.page.service.option, 'port'); + assert.equal(pkg.magpie.options.attribution, 'local'); // 远端归因必须 opt-in + assert.ok(pkg.magpie.summary.en && pkg.magpie.summary.zh); + assert.ok(pkg.magpie.page.titles.en && pkg.magpie.page.titles.zh); +}); diff --git a/registry.json b/registry.json index 0be5516..1a4f8b2 100644 --- a/registry.json +++ b/registry.json @@ -273,6 +273,8 @@ { "package": "opencode-teleagent-auth", "name": "TeleAgent 模型", "icon": "https://raw.githubusercontent.com/anbulang/opencode-teleagent-auth/main/assets/icon.svg", "providers": ["teleagent"], "summary": { "en": "Unofficial TeleAgent (天翼 AI 星辰超级智能体) desktop app models in magpie: the app's own sign-in, no API key, macOS and Windows, with points balance and daily check-in.", "zh": "非官方接入 TeleAgent(天翼 AI 星辰超级智能体)桌面端:复用桌面端登录态,不需要 API Key,支持 macOS 和 Windows,带积分余额与每日签到。" } }, { "package": "opencode-xfyun-maas-auth", "name": "讯飞星辰 MaaS", "icon": "https://raw.githubusercontent.com/linjicong/opencode-xfyun-maas-auth/main/icon.svg", "providers": ["xfyun-maas", "xfyun-coding", "xfyun-token"], - "summary": { "en": "iFlytek Xfyun MaaS: Spark, GLM, DeepSeek, Kimi, Qwen and more — pay-as-you-go, Coding Plan and Token Plan.", "zh": "讯飞星辰 MaaS:星火、GLM、DeepSeek、Kimi、Qwen 等模型,按量付费与 Coding/Token 套餐。" } } + "summary": { "en": "iFlytek Xfyun MaaS: Spark, GLM, DeepSeek, Kimi, Qwen and more — pay-as-you-go, Coding Plan and Token Plan.", "zh": "讯飞星辰 MaaS:星火、GLM、DeepSeek、Kimi、Qwen 等模型,按量付费与 Coding/Token 套餐。" } }, + { "package": "@magpie-community/page-usage-board", "name": "Usage Board", "kind": "page", "community": true, + "summary": { "en": "A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.", "zh": "额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。" } } ] }